From 9398a095330628fdec48cc5b2c6374c56bbe677b Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 23 May 2024 15:38:37 -0600 Subject: [PATCH] in app logo icon override option added so the stack wallet logo in the standard themes can be replaced specifically for duo but possibly other options as well --- .../stack_duo/stack-duo-icon_dark.svg | 1 + .../stack_duo/stack-duo-icon_light.svg | 1 + .../in_app_logo_icons/stack_wallet/dummy | 1 + lib/app_config.dart | 2 + .../sub_widgets/add_token_list_element.dart | 16 +--- .../subviews/contact_popup.dart | 23 ++---- lib/pages/home_view/home_view.dart | 27 +++---- lib/pages/intro_view.dart | 20 ++--- .../subwidgets/desktop_contact_details.dart | 26 +++---- .../my_stack_view/my_stack_view.dart | 22 ++---- .../delete_password_warning_view.dart | 17 ++--- .../password/desktop_login_view.dart | 21 ++---- .../forgot_password_desktop_view.dart | 21 ++---- lib/themes/theme_providers.dart | 3 +- lib/widgets/address_book_card.dart | 22 ++---- lib/widgets/app_icon.dart | 75 +++++++++++++++++++ lib/widgets/desktop/living_stack_icon.dart | 20 ++--- pubspec.yaml | 1 + scripts/app_config/configure_stack_duo.sh | 5 ++ scripts/app_config/configure_stack_wallet.sh | 2 + scripts/app_config/shared/link_assets.sh | 3 + 21 files changed, 168 insertions(+), 161 deletions(-) create mode 100644 asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg create mode 100644 asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg create mode 100644 asset_sources/in_app_logo_icons/stack_wallet/dummy create mode 100644 lib/widgets/app_icon.dart diff --git a/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg new file mode 100644 index 000000000..eb16522e5 --- /dev/null +++ b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg new file mode 100644 index 000000000..eb16522e5 --- /dev/null +++ b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/asset_sources/in_app_logo_icons/stack_wallet/dummy b/asset_sources/in_app_logo_icons/stack_wallet/dummy new file mode 100644 index 000000000..061d11394 --- /dev/null +++ b/asset_sources/in_app_logo_icons/stack_wallet/dummy @@ -0,0 +1 @@ +Dummy file to ensure dir structure is preserved. Stack app icon is in standard themes. \ No newline at end of file diff --git a/lib/app_config.dart b/lib/app_config.dart index 9374d94bd..3cd5897f5 100644 --- a/lib/app_config.dart +++ b/lib/app_config.dart @@ -11,6 +11,8 @@ abstract class AppConfig { static String get appDefaultDataDirName => _appDataDirName; + static ({String light, String dark})? get appIconAsset => _appIconAsset; + static List get coins => _supportedCoins; static CryptoCurrency? getCryptoCurrencyFor(String coinIdentifier) { diff --git a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart index af132b681..89a818529 100644 --- a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart +++ b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart @@ -8,21 +8,20 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; + import '../../../../models/isar/exchange_cache/currency.dart'; import '../../../../models/isar/models/ethereum/eth_contract.dart'; import '../../../../services/exchange/change_now/change_now_exchange.dart'; import '../../../../services/exchange/exchange_data_loading_service.dart'; import '../../../../themes/stack_colors.dart'; -import '../../../../themes/theme_providers.dart'; import '../../../../utilities/assets.dart'; import '../../../../utilities/text_styles.dart'; import '../../../../utilities/util.dart'; +import '../../../../widgets/app_icon.dart'; import '../../../../widgets/conditional_parent.dart'; import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; import '../../../../widgets/rounded_white_container.dart'; @@ -35,7 +34,7 @@ class AddTokenListElementData { } class AddTokenListElement extends ConsumerStatefulWidget { - const AddTokenListElement({Key? key, required this.data}) : super(key: key); + const AddTokenListElement({super.key, required this.data}); final AddTokenListElementData data; @@ -79,14 +78,7 @@ class _AddTokenListElementState extends ConsumerState { currency.image, width: iconSize, height: iconSize, - placeholderBuilder: (_) => SvgPicture.file( - File( - ref.watch( - themeAssetsProvider.select( - (value) => value.stackIcon, - ), - ), - ), + placeholderBuilder: (_) => AppIcon( width: iconSize, height: iconSize, ), diff --git a/lib/pages/address_book_views/subviews/contact_popup.dart b/lib/pages/address_book_views/subviews/contact_popup.dart index 55c4436e8..5411736e0 100644 --- a/lib/pages/address_book_views/subviews/contact_popup.dart +++ b/lib/pages/address_book_views/subviews/contact_popup.dart @@ -14,25 +14,26 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:tuple/tuple.dart'; + import '../../../models/send_view_auto_fill_data.dart'; import '../../../notifications/show_flush_bar.dart'; -import 'contact_details_view.dart'; -import '../../exchange_view/exchange_step_views/step_2_view.dart'; -import '../../send_view/send_view.dart'; import '../../../providers/global/active_wallet_provider.dart'; import '../../../providers/global/address_book_service_provider.dart'; import '../../../providers/providers.dart'; import '../../../themes/coin_icon_provider.dart'; import '../../../themes/stack_colors.dart'; -import '../../../themes/theme_providers.dart'; import '../../../utilities/assets.dart'; import '../../../utilities/clipboard_interface.dart'; import '../../../utilities/text_styles.dart'; import '../../../utilities/util.dart'; import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/app_icon.dart'; import '../../../widgets/rounded_container.dart'; import '../../../widgets/rounded_white_container.dart'; -import 'package:tuple/tuple.dart'; +import '../../exchange_view/exchange_step_views/step_2_view.dart'; +import '../../send_view/send_view.dart'; +import 'contact_details_view.dart'; final exchangeFromAddressBookAddressStateProvider = StateProvider((ref) => ""); @@ -117,16 +118,8 @@ class ContactPopUp extends ConsumerWidget { borderRadius: BorderRadius.circular(32), ), child: contact.customId == "default" - ? Center( - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value - .assets.stackIcon, - ), - ), - ), + ? const Center( + child: AppIcon( width: 20, ), ) diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index df2966d41..0173064c2 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -14,14 +14,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; + import '../../app_config.dart'; -import '../buy_view/buy_view.dart'; -import '../exchange_view/exchange_view.dart'; -import 'sub_widgets/home_view_button_bar.dart'; -import '../notification_views/notifications_view.dart'; -import '../settings_views/global_settings_view/global_settings_view.dart'; -import '../settings_views/global_settings_view/hidden_settings.dart'; -import '../wallets_view/wallets_view.dart'; import '../../providers/global/notifications_provider.dart'; import '../../providers/ui/home_view_index_provider.dart'; import '../../providers/ui/unread_notifications_provider.dart'; @@ -32,13 +26,21 @@ import '../../utilities/assets.dart'; import '../../utilities/constants.dart'; import '../../utilities/text_styles.dart'; import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/app_icon.dart'; import '../../widgets/background.dart'; import '../../widgets/custom_buttons/app_bar_icon_button.dart'; import '../../widgets/small_tor_icon.dart'; import '../../widgets/stack_dialog.dart'; +import '../buy_view/buy_view.dart'; +import '../exchange_view/exchange_view.dart'; +import '../notification_views/notifications_view.dart'; +import '../settings_views/global_settings_view/global_settings_view.dart'; +import '../settings_views/global_settings_view/hidden_settings.dart'; +import '../wallets_view/wallets_view.dart'; +import 'sub_widgets/home_view_button_bar.dart'; class HomeView extends ConsumerStatefulWidget { - const HomeView({Key? key}) : super(key: key); + const HomeView({super.key}); static const routeName = "/home"; @@ -183,14 +185,7 @@ class _HomeViewState extends ConsumerState { GestureDetector( onTap: _hiddenOptions, child: RotateIcon( - icon: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + icon: const AppIcon( width: 24, height: 24, ), diff --git a/lib/pages/intro_view.dart b/lib/pages/intro_view.dart index 5b6be3d4c..0f99aabae 100644 --- a/lib/pages/intro_view.dart +++ b/lib/pages/intro_view.dart @@ -14,20 +14,22 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:url_launcher/url_launcher.dart'; + import '../app_config.dart'; -import 'stack_privacy_calls.dart'; import '../pages_desktop_specific/password/create_password_view.dart'; import '../themes/stack_colors.dart'; import '../themes/theme_providers.dart'; import '../utilities/prefs.dart'; import '../utilities/text_styles.dart'; import '../utilities/util.dart'; +import '../widgets/app_icon.dart'; import '../widgets/background.dart'; import '../widgets/desktop/secondary_button.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'stack_privacy_calls.dart'; class IntroView extends ConsumerStatefulWidget { - const IntroView({Key? key}) : super(key: key); + const IntroView({super.key}); static const String routeName = "/introView"; @@ -132,18 +134,10 @@ class _IntroViewState extends ConsumerState { const Spacer( flex: 2, ), - SizedBox( + const SizedBox( width: 130, height: 130, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), - ), + child: AppIcon(), ), const Spacer( flex: 42, diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart index 696f71324..d38d171d3 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart @@ -8,24 +8,22 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; +import 'package:tuple/tuple.dart'; + import '../../../models/isar/models/contact_entry.dart'; import '../../../models/isar/models/isar_models.dart'; import '../../../pages/address_book_views/subviews/add_new_contact_address_view.dart'; -import 'desktop_address_card.dart'; -import 'desktop_contact_options_menu_popup.dart'; import '../../../providers/db/main_db_provider.dart'; import '../../../providers/global/address_book_service_provider.dart'; import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; import '../../../themes/stack_colors.dart'; -import '../../../themes/theme_providers.dart'; import '../../../utilities/assets.dart'; import '../../../utilities/text_styles.dart'; +import '../../../widgets/app_icon.dart'; import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; import '../../../widgets/custom_buttons/blue_text_button.dart'; import '../../../widgets/desktop/desktop_dialog.dart'; @@ -33,13 +31,14 @@ import '../../../widgets/desktop/secondary_button.dart'; import '../../../widgets/loading_indicator.dart'; import '../../../widgets/rounded_white_container.dart'; import '../../../widgets/transaction_card.dart'; -import 'package:tuple/tuple.dart'; +import 'desktop_address_card.dart'; +import 'desktop_contact_options_menu_popup.dart'; class DesktopContactDetails extends ConsumerStatefulWidget { const DesktopContactDetails({ - Key? key, + super.key, required this.contactId, - }) : super(key: key); + }); final String contactId; @@ -120,15 +119,8 @@ class _DesktopContactDetailsState extends ConsumerState { borderRadius: BorderRadius.circular(32), ), child: contact.customId == "default" - ? Center( - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + ? const Center( + child: AppIcon( width: 32, ), ) diff --git a/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart b/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart index 9f9bc5226..e981979db 100644 --- a/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart @@ -8,24 +8,22 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; + import '../../app_config.dart'; import '../../pages/settings_views/global_settings_view/hidden_settings.dart'; import '../../pages/wallets_view/sub_widgets/empty_wallets.dart'; -import 'my_wallets.dart'; -import '../../themes/theme_providers.dart'; import '../../utilities/text_styles.dart'; import '../../wallets/isar/providers/all_wallets_info_provider.dart'; import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/app_icon.dart'; import '../../widgets/background.dart'; import '../../widgets/desktop/desktop_app_bar.dart'; +import 'my_wallets.dart'; class MyStackView extends ConsumerStatefulWidget { - const MyStackView({Key? key}) : super(key: key); + const MyStackView({super.key}); static const String routeName = "/myStackDesktop"; @@ -110,18 +108,10 @@ class _DesktopMyStackTitleState extends ConsumerState { GestureDetector( onTap: _hiddenOptions, child: RotateIcon( - icon: SizedBox( + icon: const SizedBox( width: 32, height: 32, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), - ), + child: AppIcon(), ), curve: Curves.easeInOutCubic, rotationPercent: 1.0, diff --git a/lib/pages_desktop_specific/password/delete_password_warning_view.dart b/lib/pages_desktop_specific/password/delete_password_warning_view.dart index cae9ecbba..7708c2230 100644 --- a/lib/pages_desktop_specific/password/delete_password_warning_view.dart +++ b/lib/pages_desktop_specific/password/delete_password_warning_view.dart @@ -13,16 +13,16 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:hive/hive.dart'; import 'package:isar/isar.dart'; + import '../../db/hive/db.dart'; import '../../notifications/show_flush_bar.dart'; import '../../pages/intro_view.dart'; -import '../../themes/theme_providers.dart'; import '../../utilities/logger.dart'; import '../../utilities/stack_file_system.dart'; import '../../utilities/text_styles.dart'; +import '../../widgets/app_icon.dart'; import '../../widgets/custom_buttons/app_bar_icon_button.dart'; import '../../widgets/desktop/desktop_app_bar.dart'; import '../../widgets/desktop/desktop_scaffold.dart'; @@ -31,9 +31,9 @@ import '../../widgets/desktop/secondary_button.dart'; class DeletePasswordWarningView extends ConsumerStatefulWidget { const DeletePasswordWarningView({ - Key? key, + super.key, required this.shouldCreateNew, - }) : super(key: key); + }); static const String routeName = "/deletePasswordWarning"; @@ -119,14 +119,7 @@ class _ForgotPasswordDesktopViewState child: Column( mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + const AppIcon( width: 100, ), const SizedBox( diff --git a/lib/pages_desktop_specific/password/desktop_login_view.dart b/lib/pages_desktop_specific/password/desktop_login_view.dart index 30f13b44b..62e3b70fe 100644 --- a/lib/pages_desktop_specific/password/desktop_login_view.dart +++ b/lib/pages_desktop_specific/password/desktop_login_view.dart @@ -9,40 +9,40 @@ */ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; + import '../../app_config.dart'; import '../../db/db_version_migration.dart'; import '../../db/hive/db.dart'; import '../../notifications/show_flush_bar.dart'; -import '../desktop_home_view.dart'; -import 'forgot_password_desktop_view.dart'; import '../../providers/desktop/storage_crypto_handler_provider.dart'; import '../../providers/global/secure_store_provider.dart'; import '../../themes/stack_colors.dart'; -import '../../themes/theme_providers.dart'; import '../../utilities/assets.dart'; import '../../utilities/constants.dart'; import '../../utilities/flutter_secure_storage_interface.dart'; import '../../utilities/logger.dart'; import '../../utilities/text_styles.dart'; import '../../utilities/util.dart'; +import '../../widgets/app_icon.dart'; import '../../widgets/custom_buttons/blue_text_button.dart'; import '../../widgets/desktop/desktop_scaffold.dart'; import '../../widgets/desktop/primary_button.dart'; import '../../widgets/loading_indicator.dart'; import '../../widgets/rounded_container.dart'; import '../../widgets/stack_text_field.dart'; +import '../desktop_home_view.dart'; +import 'forgot_password_desktop_view.dart'; class DesktopLoginView extends ConsumerStatefulWidget { const DesktopLoginView({ - Key? key, + super.key, this.startupWalletId, this.load, - }) : super(key: key); + }); static const String routeName = "/desktopLogin"; @@ -187,14 +187,7 @@ class _DesktopLoginViewState extends ConsumerState { child: Column( mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + const AppIcon( width: 100, ), const SizedBox( diff --git a/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart b/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart index 56502547a..235f14563 100644 --- a/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart +++ b/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart @@ -8,26 +8,24 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/svg.dart'; + import '../../app_config.dart'; -import 'delete_password_warning_view.dart'; import '../../themes/stack_colors.dart'; -import '../../themes/theme_providers.dart'; import '../../utilities/text_styles.dart'; +import '../../widgets/app_icon.dart'; import '../../widgets/custom_buttons/app_bar_icon_button.dart'; import '../../widgets/desktop/desktop_app_bar.dart'; import '../../widgets/desktop/desktop_scaffold.dart'; import '../../widgets/desktop/primary_button.dart'; import '../../widgets/desktop/secondary_button.dart'; +import 'delete_password_warning_view.dart'; class ForgotPasswordDesktopView extends ConsumerStatefulWidget { const ForgotPasswordDesktopView({ - Key? key, - }) : super(key: key); + super.key, + }); static const String routeName = "/forgotPasswordDesktop"; @@ -60,14 +58,7 @@ class _ForgotPasswordDesktopViewState child: Column( mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + const AppIcon( width: 100, ), const SizedBox( diff --git a/lib/themes/theme_providers.dart b/lib/themes/theme_providers.dart index b09fc2c4e..103ffd217 100644 --- a/lib/themes/theme_providers.dart +++ b/lib/themes/theme_providers.dart @@ -10,10 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; + import '../models/isar/stack_theme.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; import 'stack_colors.dart'; import 'theme_service.dart'; -import '../wallets/crypto_currency/crypto_currency.dart'; final applicationThemesDirectoryPathProvider = StateProvider((ref) => ""); diff --git a/lib/widgets/address_book_card.dart b/lib/widgets/address_book_card.dart index 0fc979b31..51a9fe134 100644 --- a/lib/widgets/address_book_card.dart +++ b/lib/widgets/address_book_card.dart @@ -8,33 +8,32 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; + +import '../app_config.dart'; import '../models/isar/models/contact_entry.dart'; import '../pages/address_book_views/subviews/contact_popup.dart'; import '../providers/global/address_book_service_provider.dart'; -import '../app_config.dart'; import '../themes/stack_colors.dart'; -import '../themes/theme_providers.dart'; import '../utilities/assets.dart'; import '../utilities/constants.dart'; import '../utilities/text_styles.dart'; import '../utilities/util.dart'; import '../wallets/crypto_currency/crypto_currency.dart'; +import 'app_icon.dart'; import 'conditional_parent.dart'; import 'expandable.dart'; import 'rounded_white_container.dart'; class AddressBookCard extends ConsumerStatefulWidget { const AddressBookCard({ - Key? key, + super.key, required this.contactId, this.indicatorDown, this.desktopSendFrom = true, - }) : super(key: key); + }); final String contactId; final ExpandableState? indicatorDown; @@ -104,15 +103,8 @@ class _AddressBookCardState extends ConsumerState { borderRadius: BorderRadius.circular(32), ), child: contact.customId == "default" - ? Center( - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + ? const Center( + child: AppIcon( width: 20, ), ) diff --git a/lib/widgets/app_icon.dart b/lib/widgets/app_icon.dart new file mode 100644 index 000000000..dbdeaaf3d --- /dev/null +++ b/lib/widgets/app_icon.dart @@ -0,0 +1,75 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +import '../app_config.dart'; +import '../themes/theme_providers.dart'; + +enum _SvgType { + file, + asset; +} + +final _pAppIcon = Provider.autoDispose<({_SvgType svgType, String svg})>((ref) { + if (AppConfig.appIconAsset != null) { + final brightness = ref.watch( + themeProvider.select( + (value) => value.brightness, + ), + ); + final String asset; + + switch (brightness) { + case Brightness.dark: + asset = AppConfig.appIconAsset!.dark; + break; + + case Brightness.light: + asset = AppConfig.appIconAsset!.light; + break; + } + + return (svgType: _SvgType.asset, svg: asset); + } else { + final file = ref.watch( + themeAssetsProvider.select( + (value) => value.stackIcon, + ), + ); + return (svgType: _SvgType.file, svg: file); + } +}); + +class AppIcon extends ConsumerWidget { + const AppIcon({ + super.key, + this.width, + this.height, + }); + + final double? width; + final double? height; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final iconInfo = ref.watch(_pAppIcon); + switch (iconInfo.svgType) { + case _SvgType.file: + return SvgPicture.file( + File( + iconInfo.svg, + ), + width: width, + height: height, + ); + case _SvgType.asset: + return SvgPicture.asset( + iconInfo.svg, + width: width, + height: height, + ); + } + } +} diff --git a/lib/widgets/desktop/living_stack_icon.dart b/lib/widgets/desktop/living_stack_icon.dart index bab0a8196..aa1595b1f 100644 --- a/lib/widgets/desktop/living_stack_icon.dart +++ b/lib/widgets/desktop/living_stack_icon.dart @@ -8,18 +8,16 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import '../../themes/theme_providers.dart'; + +import '../app_icon.dart'; class LivingStackIcon extends ConsumerStatefulWidget { const LivingStackIcon({ - Key? key, + super.key, this.onPressed, - }) : super(key: key); + }); final VoidCallback? onPressed; @@ -59,15 +57,7 @@ class _LivingStackIconState extends ConsumerState { child: AnimatedScale( duration: const Duration(milliseconds: 200), scale: _hovering ? 1.2 : 1, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), - ), + child: const AppIcon(), ), ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 99f8bb3e3..d7e07cc1a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -254,6 +254,7 @@ flutter: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg assets: + - assets/in_app_logo_icons/ - assets/images/ - assets/icon/ - google_fonts/ diff --git a/scripts/app_config/configure_stack_duo.sh b/scripts/app_config/configure_stack_duo.sh index d6e0f6919..138c2c432 100755 --- a/scripts/app_config/configure_stack_duo.sh +++ b/scripts/app_config/configure_stack_duo.sh @@ -35,6 +35,11 @@ const _separator = " "; const _suffix = "Duo"; const _appDataDirName = "stackduo"; +const ({String light, String dark})? _appIconAsset = ( + light: "assets/in_app_logo_icons/stack-duo-icon_light.svg", + dark: "assets/in_app_logo_icons/stack-duo-icon_dark.svg", +); + final List _supportedCoins = List.unmodifiable([ Bitcoin(CryptoCurrencyNetwork.main), Monero(CryptoCurrencyNetwork.main), diff --git a/scripts/app_config/configure_stack_wallet.sh b/scripts/app_config/configure_stack_wallet.sh index b6f7d066b..7588b269b 100755 --- a/scripts/app_config/configure_stack_wallet.sh +++ b/scripts/app_config/configure_stack_wallet.sh @@ -37,6 +37,8 @@ const _separator = " "; const _suffix = "Wallet"; const _appDataDirName = "stackwallet"; +const ({String light, String dark})? _appIconAsset = null; + final List _supportedCoins = List.unmodifiable([ Bitcoin(CryptoCurrencyNetwork.main), BitcoinFrost(CryptoCurrencyNetwork.main), diff --git a/scripts/app_config/shared/link_assets.sh b/scripts/app_config/shared/link_assets.sh index e718f0783..c443b1262 100755 --- a/scripts/app_config/shared/link_assets.sh +++ b/scripts/app_config/shared/link_assets.sh @@ -24,3 +24,6 @@ ln -s "${ASSET_SOURCES_DIR}/icon/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/icon" rm -f "${ASSETS_DIR}/lottie" ln -s "${ASSET_SOURCES_DIR}/lottie/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/lottie" + +rm -f "${ASSETS_DIR}/in_app_logo_icons" +ln -s "${ASSET_SOURCES_DIR}/in_app_logo_icons/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/in_app_logo_icons"