diff --git a/lib/pages_desktop_specific/home/my_stack_view/desktop_favorite_wallets.dart b/lib/pages_desktop_specific/home/my_stack_view/desktop_favorite_wallets.dart new file mode 100644 index 000000000..0dcbb641a --- /dev/null +++ b/lib/pages_desktop_specific/home/my_stack_view/desktop_favorite_wallets.dart @@ -0,0 +1,133 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; +import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_card.dart'; +import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; + +class DesktopFavoriteWallets extends ConsumerWidget { + const DesktopFavoriteWallets({Key? key}) : super(key: key); + + static const cardWidth = 220.0; + static const cardHeight = 125.0; + static const standardPadding = 16.0; + + @override + Widget build(BuildContext context, WidgetRef ref) { + debugPrint("BUILD: $runtimeType"); + + final favorites = ref.watch(favoritesProvider); + bool hasFavorites = favorites.length > 0; + + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Favorite wallets", + style: STextStyles.desktopTextExtraSmall(context).copyWith( + color: Theme.of(context) + .extension()! + .textFieldActiveSearchIconRight, + ), + ), + BlueTextButton( + text: "Edit", + onTap: () { + Navigator.of(context).pushNamed(ManageFavoritesView.routeName); + }, + ), + ], + ), + const SizedBox( + height: 20, + ), + ConstrainedBox( + constraints: const BoxConstraints( + maxHeight: (cardHeight * 2) + standardPadding, + minHeight: cardHeight, + ), + child: hasFavorites + ? Wrap( + spacing: 16, + children: [ + ...favorites.map((p0) { + final walletId = ref.refresh(p0).walletId; + final managerProvider = ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(walletId); + + return FavoriteCard( + walletId: walletId, + width: cardWidth, + height: cardHeight, + managerProvider: managerProvider, + ); + }) + ], + ) + : Container( + height: cardHeight, + width: cardWidth, + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .textFieldDefaultBG, + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + child: MaterialButton( + splashColor: + Theme.of(context).extension()!.highlight, + key: const Key("favoriteWalletsAddFavoriteButtonKey"), + padding: const EdgeInsets.all(12), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius), + ), + onPressed: () { + Navigator.of(context) + .pushNamed(ManageFavoritesView.routeName); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset( + Assets.svg.plus, + width: 14, + height: 14, + color: Theme.of(context) + .extension()! + .textSubtitle1, + ), + const SizedBox( + width: 4, + ), + Text( + "Add a favorite", + style: STextStyles.itemSubtitle(context).copyWith( + fontSize: 18, + ), + ), + ], + ), + ), + ), + ), + const SizedBox( + height: 40, + ), + ], + ); + } +} diff --git a/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart b/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart index b7860542a..6b60902c4 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stackwallet/pages/wallets_view/sub_widgets/empty_wallets.dart'; import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/my_wallets.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -24,9 +23,6 @@ class _MyStackViewState extends ConsumerState { debugPrint("BUILD: $runtimeType"); final hasWallets = ref.watch(walletsChangeNotifierProvider).hasWallets; - final showFavorites = ref.watch(prefsChangeNotifierProvider - .select((value) => value.showFavoriteWallets)); - return Column( children: [ DesktopAppBar( diff --git a/lib/pages_desktop_specific/home/my_stack_view/my_wallets.dart b/lib/pages_desktop_specific/home/my_stack_view/my_wallets.dart index e41c7643d..08f28c620 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/my_wallets.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/my_wallets.dart @@ -1,46 +1,32 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; +import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/desktop_favorite_wallets.dart'; import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_summary_table.dart'; +import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -class MyWallets extends StatefulWidget { +class MyWallets extends ConsumerStatefulWidget { const MyWallets({Key? key}) : super(key: key); @override - State createState() => _MyWalletsState(); + ConsumerState createState() => _MyWalletsState(); } -class _MyWalletsState extends State { +class _MyWalletsState extends ConsumerState { @override Widget build(BuildContext context) { + final showFavorites = ref.watch(prefsChangeNotifierProvider + .select((value) => value.showFavoriteWallets)); + return Padding( padding: const EdgeInsets.all(24), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - "Favorite wallets", - style: STextStyles.desktopTextExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveSearchIconRight, - ), - ), - const SizedBox( - height: 20, - ), - // TODO favorites grid - Container( - color: Colors.deepPurpleAccent, - height: 210, - ), - - const SizedBox( - height: 40, - ), - + if (showFavorites) const DesktopFavoriteWallets(), Row( children: [ Text( @@ -60,7 +46,6 @@ class _MyWalletsState extends State { ), ], ), - const SizedBox( height: 20, ),