mobile open wallet gui flow changes

This commit is contained in:
julian 2023-04-10 09:12:07 -06:00
parent 510a152b23
commit 7ef2d5f0d7
4 changed files with 42 additions and 141 deletions

View file

@ -1,101 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/wallet_card.dart';
class WalletsSheet extends ConsumerWidget {
const WalletsSheet({
Key? key,
required this.coin,
}) : super(key: key);
final Coin coin;
@override
Widget build(BuildContext context, WidgetRef ref) {
final providers = ref
.watch(walletsChangeNotifierProvider
.select((value) => value.getManagerProvidersByCoin()))
.where((e) => e.item1 == coin)
.map((e) => e.item2)
.expand((e) => e)
.toList();
final maxHeight = MediaQuery.of(context).size.height * 0.60;
return Container(
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.popupBG,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(20),
),
),
child: LimitedBox(
maxHeight: maxHeight,
child: Padding(
padding: const EdgeInsets.only(
left: 24,
right: 24,
top: 10,
bottom: 0,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
width: 60,
height: 4,
),
),
const SizedBox(
height: 36,
),
Text(
"${coin.prettyName} (${coin.ticker}) wallets",
style: STextStyles.pageTitleH2(context),
textAlign: TextAlign.left,
),
const SizedBox(
height: 16,
),
Flexible(
child: ListView.builder(
shrinkWrap: true,
itemCount: providers.length,
itemBuilder: (builderContext, index) {
final walletId = ref.watch(
providers[index].select((value) => value.walletId));
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: WalletSheetCard(
walletId: walletId,
popPrevious: true,
),
);
},
),
),
const SizedBox(
height: 24,
),
],
),
),
),
);
}
}

View file

@ -4,8 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/pages/wallets_sheet/wallets_sheet.dart'; import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
import 'package:stackwallet/pages/wallets_view/eth_wallets_overview.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
@ -46,13 +45,7 @@ class WalletListItem extends ConsumerWidget {
BorderRadius.circular(Constants.size.circularBorderRadius), BorderRadius.circular(Constants.size.circularBorderRadius),
), ),
onPressed: () async { onPressed: () async {
if (coin == Coin.ethereum) { if (walletCount == 1 && coin != Coin.ethereum) {
unawaited(
Navigator.of(context).pushNamed(
EthWalletsOverview.routeName,
),
);
} else if (walletCount == 1) {
final providersByCoin = ref final providersByCoin = ref
.watch(walletsChangeNotifierProvider .watch(walletsChangeNotifierProvider
.select((value) => value.getManagerProvidersByCoin())) .select((value) => value.getManagerProvidersByCoin()))
@ -77,15 +70,9 @@ class WalletListItem extends ConsumerWidget {
} }
} else { } else {
unawaited( unawaited(
showModalBottomSheet<dynamic>( Navigator.of(context).pushNamed(
backgroundColor: Colors.transparent, WalletsOverview.routeName,
context: context, arguments: coin,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
builder: (_) => WalletsSheet(coin: coin),
), ),
); );
} }

View file

@ -9,29 +9,35 @@ import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/master_wallet_card.dart'; import 'package:stackwallet/widgets/master_wallet_card.dart';
import 'package:stackwallet/widgets/wallet_card.dart';
class EthWalletsOverview extends ConsumerStatefulWidget { class WalletsOverview extends ConsumerStatefulWidget {
const EthWalletsOverview({Key? key}) : super(key: key); const WalletsOverview({
Key? key,
required this.coin,
}) : super(key: key);
final Coin coin;
static const routeName = "/ethWalletsOverview"; static const routeName = "/ethWalletsOverview";
@override @override
ConsumerState<EthWalletsOverview> createState() => _EthWalletsOverviewState(); ConsumerState<WalletsOverview> createState() => _EthWalletsOverviewState();
} }
class _EthWalletsOverviewState extends ConsumerState<EthWalletsOverview> { class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
final isDesktop = Util.isDesktop; final isDesktop = Util.isDesktop;
final List<String> ethWalletIds = []; final List<String> walletIds = [];
@override @override
void initState() { void initState() {
final walletsData = final walletsData =
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData(); ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
walletsData.removeWhere((key, value) => value.coin != Coin.ethereum); walletsData.removeWhere((key, value) => value.coin != widget.coin);
ethWalletIds.clear(); walletIds.clear();
ethWalletIds.addAll(walletsData.values.map((e) => e.walletId)); walletIds.addAll(walletsData.values.map((e) => e.walletId));
super.initState(); super.initState();
} }
@ -47,7 +53,7 @@ class _EthWalletsOverviewState extends ConsumerState<EthWalletsOverview> {
appBar: AppBar( appBar: AppBar(
leading: const AppBarBackButton(), leading: const AppBarBackButton(),
title: Text( title: Text(
"Ethereum (ETH) wallets", "${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
style: STextStyles.navBarTitle(context), style: STextStyles.navBarTitle(context),
), ),
), ),
@ -59,13 +65,17 @@ class _EthWalletsOverviewState extends ConsumerState<EthWalletsOverview> {
), ),
), ),
child: ListView.separated( child: ListView.separated(
itemCount: ethWalletIds.length, itemCount: walletIds.length,
separatorBuilder: (_, __) => const SizedBox( separatorBuilder: (_, __) => const SizedBox(
height: 8, height: 8,
), ),
itemBuilder: (_, index) => MasterWalletCard( itemBuilder: (_, index) => widget.coin == Coin.ethereum
walletId: ethWalletIds[index], ? MasterWalletCard(
), walletId: walletIds[index],
)
: WalletSheetCard(
walletId: walletIds[index],
),
), ),
), ),
); );

View file

@ -106,7 +106,7 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.d
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart';
import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/pages/wallets_view/eth_wallets_overview.dart'; import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; import 'package:stackwallet/pages/wallets_view/wallets_view.dart';
import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart';
import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart'; import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart';
@ -280,14 +280,19 @@ class RouteGenerator {
), ),
); );
case EthWalletsOverview.routeName: case WalletsOverview.routeName:
return getRoute( if (args is Coin) {
shouldUseMaterialRoute: useMaterialPageRoute, return getRoute(
builder: (_) => const EthWalletsOverview(), shouldUseMaterialRoute: useMaterialPageRoute,
settings: RouteSettings( builder: (_) => WalletsOverview(
name: settings.name, coin: args,
), ),
); settings: RouteSettings(
name: settings.name,
),
);
}
return _routeError("${settings.name} invalid args: ${args.toString()}");
case TokenContractDetailsView.routeName: case TokenContractDetailsView.routeName:
if (args is Tuple2<String, String>) { if (args is Tuple2<String, String>) {