mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
skip summary view and coin selection when adding wallets on single coin app
This commit is contained in:
parent
20f743932b
commit
7c40dd1546
6 changed files with 92 additions and 16 deletions
|
@ -24,6 +24,8 @@ abstract class AppConfig {
|
|||
|
||||
static List<CryptoCurrency> get coins => _supportedCoins;
|
||||
|
||||
static bool get isSingleCoinApp => coins.length == 1;
|
||||
|
||||
static CryptoCurrency? getCryptoCurrencyFor(String coinIdentifier) {
|
||||
try {
|
||||
return coins.firstWhere((e) => e.identifier == coinIdentifier);
|
||||
|
|
|
@ -10,12 +10,17 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
import 'wallet_list_item.dart';
|
||||
|
||||
import '../../../app_config.dart';
|
||||
import '../../../models/add_wallet_list_entity/sub_classes/coin_entity.dart';
|
||||
import '../../../themes/stack_colors.dart';
|
||||
import '../../../utilities/text_styles.dart';
|
||||
import '../../../wallets/isar/providers/all_wallets_info_provider.dart';
|
||||
import '../../../widgets/custom_buttons/blue_text_button.dart';
|
||||
import '../../add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
import '../../add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
|
||||
import '../wallets_overview.dart';
|
||||
import 'wallet_list_item.dart';
|
||||
|
||||
class AllWallets extends StatelessWidget {
|
||||
const AllWallets({super.key});
|
||||
|
@ -37,7 +42,19 @@ class AllWallets extends StatelessWidget {
|
|||
CustomTextButton(
|
||||
text: "Add new",
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(AddWalletView.routeName);
|
||||
final String route;
|
||||
final Object? args;
|
||||
if (AppConfig.isSingleCoinApp) {
|
||||
route = CreateOrRestoreWalletView.routeName;
|
||||
args = CoinEntity(AppConfig.coins.first);
|
||||
} else {
|
||||
route = AddWalletView.routeName;
|
||||
args = null;
|
||||
}
|
||||
Navigator.of(context).pushNamed(
|
||||
route,
|
||||
arguments: args,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -50,6 +67,12 @@ class AllWallets extends StatelessWidget {
|
|||
builder: (_, ref, __) {
|
||||
final walletsByCoin = ref.watch(pAllWalletsInfoByCoin);
|
||||
|
||||
if (AppConfig.isSingleCoinApp && walletsByCoin.isNotEmpty) {
|
||||
return WalletsOverview(
|
||||
coin: AppConfig.coins.first,
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: walletsByCoin.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
|
|
|
@ -13,12 +13,16 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import '../../add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
|
||||
import '../../../app_config.dart';
|
||||
import '../../../models/add_wallet_list_entity/sub_classes/coin_entity.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 '../../add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
import '../../add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
|
||||
|
||||
class EmptyWallets extends ConsumerWidget {
|
||||
const EmptyWallets({super.key});
|
||||
|
@ -116,13 +120,30 @@ class AddWalletButton extends ConsumerWidget {
|
|||
.extension<StackColors>()!
|
||||
.getPrimaryEnabledButtonStyle(context),
|
||||
onPressed: () {
|
||||
if (isDesktop) {
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pushNamed(AddWalletView.routeName);
|
||||
if (AppConfig.isSingleCoinApp) {
|
||||
if (isDesktop) {
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pushNamed(
|
||||
CreateOrRestoreWalletView.routeName,
|
||||
arguments: CoinEntity(AppConfig.coins.first),
|
||||
);
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(
|
||||
CreateOrRestoreWalletView.routeName,
|
||||
arguments: CoinEntity(AppConfig.coins.first),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(AddWalletView.routeName);
|
||||
if (isDesktop) {
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pushNamed(AddWalletView.routeName);
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(AddWalletView.routeName);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Center(
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'package:flutter_svg/svg.dart';
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import '../../app_config.dart';
|
||||
import '../../models/add_wallet_list_entity/sub_classes/coin_entity.dart';
|
||||
import '../../models/isar/models/ethereum/eth_contract.dart';
|
||||
import '../../pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart';
|
||||
|
@ -44,10 +45,12 @@ class WalletsOverview extends ConsumerStatefulWidget {
|
|||
super.key,
|
||||
required this.coin,
|
||||
this.navigatorState,
|
||||
this.overrideSimpleWalletCardPopPreviousValueWith,
|
||||
});
|
||||
|
||||
final CryptoCurrency coin;
|
||||
final NavigatorState? navigatorState;
|
||||
final bool? overrideSimpleWalletCardPopPreviousValueWith;
|
||||
|
||||
static const routeName = "/walletsOverview";
|
||||
|
||||
|
@ -176,7 +179,7 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ConditionalParent(
|
||||
condition: !isDesktop,
|
||||
condition: !isDesktop && !AppConfig.isSingleCoinApp,
|
||||
builder: (child) => Background(
|
||||
child: Scaffold(
|
||||
backgroundColor:
|
||||
|
@ -321,7 +324,12 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
|||
),
|
||||
child: SimpleWalletCard(
|
||||
walletId: element.item1.walletId,
|
||||
popPrevious: isDesktop,
|
||||
popPrevious: widget
|
||||
.overrideSimpleWalletCardPopPreviousValueWith ==
|
||||
null
|
||||
? isDesktop
|
||||
: widget
|
||||
.overrideSimpleWalletCardPopPreviousValueWith!,
|
||||
desktopNavigatorState:
|
||||
isDesktop ? widget.navigatorState : null,
|
||||
),
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../app_config.dart';
|
||||
import '../../models/add_wallet_list_entity/sub_classes/coin_entity.dart';
|
||||
import '../../pages/add_wallet_views/add_wallet_view/add_wallet_view.dart';
|
||||
import '../../pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
|
||||
import '../../pages/wallets_view/wallets_overview.dart';
|
||||
import '../../providers/providers.dart';
|
||||
import '../../themes/stack_colors.dart';
|
||||
import '../../utilities/text_styles.dart';
|
||||
|
@ -68,10 +72,23 @@ class _MyWalletsState extends ConsumerState<MyWallets> {
|
|||
CustomTextButton(
|
||||
text: "Add new wallet",
|
||||
onTap: () {
|
||||
final String route;
|
||||
final Object? args;
|
||||
if (AppConfig.isSingleCoinApp) {
|
||||
route = CreateOrRestoreWalletView.routeName;
|
||||
args = CoinEntity(AppConfig.coins.first);
|
||||
} else {
|
||||
route = AddWalletView.routeName;
|
||||
args = null;
|
||||
}
|
||||
|
||||
Navigator.of(
|
||||
context,
|
||||
rootNavigator: true,
|
||||
).pushNamed(AddWalletView.routeName);
|
||||
).pushNamed(
|
||||
route,
|
||||
arguments: args,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -80,8 +97,14 @@ class _MyWalletsState extends ConsumerState<MyWallets> {
|
|||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
const Expanded(
|
||||
child: WalletSummaryTable(),
|
||||
Expanded(
|
||||
child: AppConfig.isSingleCoinApp
|
||||
? WalletsOverview(
|
||||
coin: AppConfig.coins.first,
|
||||
navigatorState: Navigator.of(context),
|
||||
overrideSimpleWalletCardPopPreviousValueWith: false,
|
||||
)
|
||||
: const WalletSummaryTable(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -55,7 +55,6 @@ const ({String light, String dark})? _appIconAsset = (
|
|||
|
||||
final List<CryptoCurrency> _supportedCoins = List.unmodifiable([
|
||||
Firo(CryptoCurrencyNetwork.main),
|
||||
Firo(CryptoCurrencyNetwork.test),
|
||||
]);
|
||||
|
||||
EOF
|
Loading…
Reference in a new issue