fix: added missing assets to theme and updated more references to use theme provided assets

This commit is contained in:
julian 2023-05-09 10:51:30 -06:00
parent e92501c38d
commit 7da7302e63
8 changed files with 109 additions and 79 deletions

View file

@ -1984,6 +1984,7 @@ class StackTheme {
class ThemeAssets {
final String bellNew;
final String buy;
final String exchange;
final String personaIncognito;
final String personaEasy;
final String stack;
@ -2031,12 +2032,14 @@ class ThemeAssets {
final String wowneroImageSecondary;
final String namecoinImageSecondary;
final String particlImageSecondary;
final String? loadingGif;
// todo: add all assets expected in json
ThemeAssets({
required this.bellNew,
required this.buy,
required this.exchange,
required this.personaIncognito,
required this.personaEasy,
required this.stack,
@ -2084,6 +2087,7 @@ class ThemeAssets {
required this.wowneroImageSecondary,
required this.namecoinImageSecondary,
required this.particlImageSecondary,
required this.loadingGif,
});
factory ThemeAssets.fromJson({
@ -2096,6 +2100,8 @@ class ThemeAssets {
"$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["bell_new"] as String}",
buy:
"$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["buy"] as String}",
exchange:
"$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["exchange"] as String}",
personaIncognito:
"$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["persona_incognito"] as String}",
personaEasy:
@ -2190,6 +2196,9 @@ class ThemeAssets {
"$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["namecoinImageSecondary"] as String}",
particlImageSecondary:
"$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["particlImageSecondary"] as String}",
loadingGif: json["assets"]["loadingGif"] is String
? "$applicationThemesDirectoryPath/$internalThemeUuid/${json["assets"]["loadingGif"] as String}"
: null,
);
}
}

View file

@ -5,7 +5,6 @@ import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_title.dart';
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_wallet_button_group.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
@ -82,11 +81,6 @@ class CreateOrRestoreWalletView extends StatelessWidget {
),
);
} else {
final isChans = Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.chan ||
Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.darkChans;
return Background(
child: Scaffold(
backgroundColor:
@ -114,10 +108,9 @@ class CreateOrRestoreWalletView extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (!isChans)
const Spacer(
flex: 2,
),
const Spacer(
flex: 2,
),
CoinImage(
coin: entity.coin,
width: isDesktop

View file

@ -843,7 +843,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
),
ExchangeTextField(
key: Key("exchangeTextFieldKeyFor_"
"${Theme.of(context).extension<StackColors>()!.themeType.name}"
"${Theme.of(context).extension<StackColors>()!.themeId}"
"${ref.watch(efCurrencyPairProvider.select((value) => value.send?.ticker))}"),
controller: _sendController,
focusNode: _sendFocusNode,
@ -925,7 +925,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
),
ExchangeTextField(
key: Key(
"exchangeTextFieldKeyFor1_${Theme.of(context).extension<StackColors>()!.themeType.name}"),
"exchangeTextFieldKeyFor1_${Theme.of(context).extension<StackColors>()!.themeId}"),
focusNode: _receiveFocusNode,
controller: _receiveController,
textStyle: STextStyles.smallMed14(context).copyWith(

View file

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
@ -8,6 +9,7 @@ import 'package:flutter_svg/svg.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart';
import 'package:stackwallet/pages/exchange_view/send_from_view.dart';
@ -21,6 +23,7 @@ import 'package:stackwallet/services/exchange/exchange.dart';
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/clipboard_interface.dart';
@ -110,7 +113,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
super.initState();
}
String _fetchIconAssetForStatus(String statusString) {
String _fetchIconAssetForStatus(String statusString, ThemeAssets assets) {
ChangeNowTransactionStatus? status;
try {
if (statusString.toLowerCase().startsWith("waiting")) {
@ -121,10 +124,10 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
switch (statusString.toLowerCase()) {
case "funds confirming":
case "processing payment":
return Assets.svg.txExchangePending(context);
return assets.txExchangePending;
case "completed":
return Assets.svg.txExchange(context);
return assets.txExchange;
default:
status = ChangeNowTransactionStatus.Failed;
@ -139,11 +142,11 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
case ChangeNowTransactionStatus.Sending:
case ChangeNowTransactionStatus.Refunded:
case ChangeNowTransactionStatus.Verifying:
return Assets.svg.txExchangePending(context);
return assets.txExchangePending;
case ChangeNowTransactionStatus.Finished:
return Assets.svg.txExchange(context);
return assets.txExchange;
case ChangeNowTransactionStatus.Failed:
return Assets.svg.txExchangeFailed(context);
return assets.txExchangeFailed;
}
}
@ -315,8 +318,17 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
if (isDesktop)
Row(
children: [
SvgPicture.asset(
_fetchIconAssetForStatus(trade.status),
SvgPicture.file(
File(
_fetchIconAssetForStatus(
trade.status,
ref.watch(
themeProvider.select(
(value) => value.assets,
),
),
),
),
width: 32,
height: 32,
),
@ -377,8 +389,17 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
borderRadius: BorderRadius.circular(32),
),
child: Center(
child: SvgPicture.asset(
_fetchIconAssetForStatus(trade.status),
child: SvgPicture.file(
File(
_fetchIconAssetForStatus(
trade.status,
ref.watch(
themeProvider.select(
(value) => value.assets,
),
),
),
),
width: 32,
height: 32,
),

View file

@ -1,26 +1,27 @@
import 'dart:io';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lottie/lottie.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/rounded_container.dart';
class LoadingView extends StatelessWidget {
class LoadingView extends ConsumerWidget {
const LoadingView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final size = MediaQuery.of(context).size;
final width = min(size.width, size.height) * 0.5;
final isChan = Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.chan ||
Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.darkChans;
final assetPath = ref.watch(
themeProvider.select((value) => value.assets.loadingGif),
);
return Background(
child: Scaffold(
@ -29,9 +30,8 @@ class LoadingView extends StatelessWidget {
color: Theme.of(context).extension<StackColors>()!.background,
child: Center(
child: ConditionalParent(
condition:
Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.oledBlack,
condition: Theme.of(context).extension<StackColors>()!.themeId ==
"oled_black",
builder: (child) => RoundedContainer(
color: const Color(0xFFDEDEDE),
radiusMultiplier: 100,
@ -41,10 +41,10 @@ class LoadingView extends StatelessWidget {
),
child: SizedBox(
width: width,
child: isChan
? Image(
image: AssetImage(
Assets.gif.stacyPlain,
child: assetPath != null
? Image.file(
File(
assetPath,
),
)
: Lottie.asset(

View file

@ -1,15 +1,17 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/themes/coin_image_provider.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
class BuildingTransactionDialog extends StatefulWidget {
class BuildingTransactionDialog extends ConsumerStatefulWidget {
const BuildingTransactionDialog({
Key? key,
required this.onCancel,
@ -20,10 +22,11 @@ class BuildingTransactionDialog extends StatefulWidget {
final Coin coin;
@override
State<BuildingTransactionDialog> createState() => _RestoringDialogState();
ConsumerState<BuildingTransactionDialog> createState() =>
_RestoringDialogState();
}
class _RestoringDialogState extends State<BuildingTransactionDialog> {
class _RestoringDialogState extends ConsumerState<BuildingTransactionDialog> {
late final VoidCallback onCancel;
@override
@ -35,10 +38,11 @@ class _RestoringDialogState extends State<BuildingTransactionDialog> {
@override
Widget build(BuildContext context) {
final isChans = Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.chan ||
Theme.of(context).extension<StackColors>()!.themeType ==
ThemeType.darkChans;
final assetPath = ref.watch(
coinImageSecondaryProvider(
widget.coin,
),
);
if (Util.isDesktop) {
return Column(
@ -51,17 +55,14 @@ class _RestoringDialogState extends State<BuildingTransactionDialog> {
const SizedBox(
height: 40,
),
if (isChans)
Image(
image: AssetImage(
Assets.gif.kiss(widget.coin),
),
),
if (!isChans)
const RotatingArrows(
width: 40,
height: 40,
),
assetPath.endsWith(".gif")
? Image.file(File(
assetPath,
))
: const RotatingArrows(
width: 40,
height: 40,
),
const SizedBox(
height: 40,
),
@ -79,17 +80,15 @@ class _RestoringDialogState extends State<BuildingTransactionDialog> {
onWillPop: () async {
return false;
},
child: isChans
child: assetPath.endsWith(".gif")
? StackDialogBase(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
Image(
image: AssetImage(
Assets.gif.kiss(widget.coin),
),
),
Image.file(File(
assetPath,
)),
Text(
"Generating transaction",
textAlign: TextAlign.center,

View file

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@ -15,6 +16,7 @@ import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/providers/global/price_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
@ -163,7 +165,7 @@ class TokenSummary extends ConsumerWidget {
}
}
class TokenWalletOptions extends StatelessWidget {
class TokenWalletOptions extends ConsumerWidget {
const TokenWalletOptions({
Key? key,
required this.walletId,
@ -199,7 +201,7 @@ class TokenWalletOptions extends StatelessWidget {
}
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
@ -214,7 +216,7 @@ class TokenWalletOptions extends StatelessWidget {
);
},
subLabel: "Receive",
iconAssetSVG: Assets.svg.arrowDownLeft,
iconAssetPathSVG: Assets.svg.arrowDownLeft,
),
const SizedBox(
width: 16,
@ -231,7 +233,7 @@ class TokenWalletOptions extends StatelessWidget {
);
},
subLabel: "Send",
iconAssetSVG: Assets.svg.arrowUpRight,
iconAssetPathSVG: Assets.svg.arrowUpRight,
),
const SizedBox(
width: 16,
@ -239,7 +241,11 @@ class TokenWalletOptions extends StatelessWidget {
TokenOptionsButton(
onPressed: () => _onExchangePressed(context),
subLabel: "Swap",
iconAssetSVG: Assets.svg.exchange(context),
iconAssetPathSVG: ref.watch(
themeProvider.select(
(value) => value.assets.exchange,
),
),
),
const SizedBox(
width: 16,
@ -247,7 +253,7 @@ class TokenWalletOptions extends StatelessWidget {
TokenOptionsButton(
onPressed: () => _onBuyPressed(context),
subLabel: "Buy",
iconAssetSVG: Assets.svg.creditCard,
iconAssetPathSVG: Assets.svg.creditCard,
),
],
);
@ -259,12 +265,12 @@ class TokenOptionsButton extends StatelessWidget {
Key? key,
required this.onPressed,
required this.subLabel,
required this.iconAssetSVG,
required this.iconAssetPathSVG,
}) : super(key: key);
final VoidCallback onPressed;
final String subLabel;
final String iconAssetSVG;
final String iconAssetPathSVG;
@override
Widget build(BuildContext context) {
@ -302,8 +308,8 @@ class TokenOptionsButton extends StatelessWidget {
child: child,
),
),
child: SvgPicture.asset(
iconAssetSVG,
child: SvgPicture.file(
File(iconAssetPathSVG),
color: Theme.of(context)
.extension<StackColors>()!
.tokenSummaryIcon,

View file

@ -9,11 +9,13 @@ import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart';
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/pages/exchange_view/trade_details_view.dart';
import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart';
import 'package:stackwallet/providers/global/trades_service_provider.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/format.dart';
@ -285,7 +287,7 @@ class DesktopTradeRowCard extends ConsumerStatefulWidget {
class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
late final String tradeId;
String _fetchIconAssetForStatus(String statusString, BuildContext context) {
String _fetchIconAssetForStatus(String statusString, ThemeAssets assets) {
ChangeNowTransactionStatus? status;
try {
if (statusString.toLowerCase().startsWith("waiting")) {
@ -296,10 +298,10 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
switch (statusString.toLowerCase()) {
case "funds confirming":
case "processing payment":
return Assets.svg.txExchangePending(context);
return assets.txExchangePending;
case "completed":
return Assets.svg.txExchange(context);
return assets.txExchange;
default:
status = ChangeNowTransactionStatus.Failed;
@ -314,11 +316,11 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
case ChangeNowTransactionStatus.Sending:
case ChangeNowTransactionStatus.Refunded:
case ChangeNowTransactionStatus.Verifying:
return Assets.svg.txExchangePending(context);
return assets.txExchangePending;
case ChangeNowTransactionStatus.Finished:
return Assets.svg.txExchange(context);
return assets.txExchange;
case ChangeNowTransactionStatus.Failed:
return Assets.svg.txExchangeFailed(context);
return assets.txExchangeFailed;
}
}
@ -523,7 +525,7 @@ class _DesktopTradeRowCardState extends ConsumerState<DesktopTradeRowCard> {
child: SvgPicture.asset(
_fetchIconAssetForStatus(
trade.status,
context,
ref.watch(themeProvider.select((value) => value.assets)),
),
width: 32,
height: 32,