WIP desktop favorites

This commit is contained in:
julian 2022-09-26 12:15:40 -06:00
parent 1cc1a5768e
commit 3ce4519cc7
3 changed files with 143 additions and 29 deletions

View file

@ -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<StackColors>()!
.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<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
child: MaterialButton(
splashColor:
Theme.of(context).extension<StackColors>()!.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<StackColors>()!
.textSubtitle1,
),
const SizedBox(
width: 4,
),
Text(
"Add a favorite",
style: STextStyles.itemSubtitle(context).copyWith(
fontSize: 18,
),
),
],
),
),
),
),
const SizedBox(
height: 40,
),
],
);
}
}

View file

@ -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<MyStackView> {
debugPrint("BUILD: $runtimeType");
final hasWallets = ref.watch(walletsChangeNotifierProvider).hasWallets;
final showFavorites = ref.watch(prefsChangeNotifierProvider
.select((value) => value.showFavoriteWallets));
return Column(
children: [
DesktopAppBar(

View file

@ -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<MyWallets> createState() => _MyWalletsState();
ConsumerState<MyWallets> createState() => _MyWalletsState();
}
class _MyWalletsState extends State<MyWallets> {
class _MyWalletsState extends ConsumerState<MyWallets> {
@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<StackColors>()!
.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<MyWallets> {
),
],
),
const SizedBox(
height: 20,
),