mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
mobile open wallet gui flow changes
This commit is contained in:
parent
b3b4d803a6
commit
000e98cbb6
4 changed files with 42 additions and 141 deletions
|
@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,8 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.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/eth_wallets_overview.dart';
|
||||
import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
|
@ -46,13 +45,7 @@ class WalletListItem extends ConsumerWidget {
|
|||
BorderRadius.circular(Constants.size.circularBorderRadius),
|
||||
),
|
||||
onPressed: () async {
|
||||
if (coin == Coin.ethereum) {
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
EthWalletsOverview.routeName,
|
||||
),
|
||||
);
|
||||
} else if (walletCount == 1) {
|
||||
if (walletCount == 1 && coin != Coin.ethereum) {
|
||||
final providersByCoin = ref
|
||||
.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManagerProvidersByCoin()))
|
||||
|
@ -77,15 +70,9 @@ class WalletListItem extends ConsumerWidget {
|
|||
}
|
||||
} else {
|
||||
unawaited(
|
||||
showModalBottomSheet<dynamic>(
|
||||
backgroundColor: Colors.transparent,
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
builder: (_) => WalletsSheet(coin: coin),
|
||||
Navigator.of(context).pushNamed(
|
||||
WalletsOverview.routeName,
|
||||
arguments: coin,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,29 +9,35 @@ import 'package:stackwallet/widgets/background.dart';
|
|||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/master_wallet_card.dart';
|
||||
import 'package:stackwallet/widgets/wallet_card.dart';
|
||||
|
||||
class EthWalletsOverview extends ConsumerStatefulWidget {
|
||||
const EthWalletsOverview({Key? key}) : super(key: key);
|
||||
class WalletsOverview extends ConsumerStatefulWidget {
|
||||
const WalletsOverview({
|
||||
Key? key,
|
||||
required this.coin,
|
||||
}) : super(key: key);
|
||||
|
||||
final Coin coin;
|
||||
|
||||
static const routeName = "/ethWalletsOverview";
|
||||
|
||||
@override
|
||||
ConsumerState<EthWalletsOverview> createState() => _EthWalletsOverviewState();
|
||||
ConsumerState<WalletsOverview> createState() => _EthWalletsOverviewState();
|
||||
}
|
||||
|
||||
class _EthWalletsOverviewState extends ConsumerState<EthWalletsOverview> {
|
||||
class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
||||
final isDesktop = Util.isDesktop;
|
||||
|
||||
final List<String> ethWalletIds = [];
|
||||
final List<String> walletIds = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
final walletsData =
|
||||
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
|
||||
walletsData.removeWhere((key, value) => value.coin != Coin.ethereum);
|
||||
ethWalletIds.clear();
|
||||
walletsData.removeWhere((key, value) => value.coin != widget.coin);
|
||||
walletIds.clear();
|
||||
|
||||
ethWalletIds.addAll(walletsData.values.map((e) => e.walletId));
|
||||
walletIds.addAll(walletsData.values.map((e) => e.walletId));
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
@ -47,7 +53,7 @@ class _EthWalletsOverviewState extends ConsumerState<EthWalletsOverview> {
|
|||
appBar: AppBar(
|
||||
leading: const AppBarBackButton(),
|
||||
title: Text(
|
||||
"Ethereum (ETH) wallets",
|
||||
"${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
),
|
||||
),
|
||||
|
@ -59,13 +65,17 @@ class _EthWalletsOverviewState extends ConsumerState<EthWalletsOverview> {
|
|||
),
|
||||
),
|
||||
child: ListView.separated(
|
||||
itemCount: ethWalletIds.length,
|
||||
itemCount: walletIds.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
itemBuilder: (_, index) => MasterWalletCard(
|
||||
walletId: ethWalletIds[index],
|
||||
),
|
||||
itemBuilder: (_, index) => widget.coin == Coin.ethereum
|
||||
? MasterWalletCard(
|
||||
walletId: walletIds[index],
|
||||
)
|
||||
: WalletSheetCard(
|
||||
walletId: walletIds[index],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
|
@ -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_search_filter_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_desktop_specific/address_book_view/desktop_address_book.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart';
|
||||
|
@ -280,14 +280,19 @@ class RouteGenerator {
|
|||
),
|
||||
);
|
||||
|
||||
case EthWalletsOverview.routeName:
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => const EthWalletsOverview(),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
case WalletsOverview.routeName:
|
||||
if (args is Coin) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => WalletsOverview(
|
||||
coin: args,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case TokenContractDetailsView.routeName:
|
||||
if (args is Tuple2<String, String>) {
|
||||
|
|
Loading…
Reference in a new issue