mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-08 19:59:29 +00:00
go directly to wallet view on single wallet per coin on desktop and mobile
This commit is contained in:
parent
9e24f2bdbc
commit
7d10ae2011
4 changed files with 52 additions and 12 deletions
|
@ -1,16 +1,19 @@
|
|||
import 'dart:async';
|
||||
|
||||
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/providers/providers.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/format.dart';
|
||||
import 'package:stackwallet/utilities/prefs.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class WalletListItem extends ConsumerWidget {
|
||||
const WalletListItem({
|
||||
|
@ -41,17 +44,37 @@ class WalletListItem extends ConsumerWidget {
|
|||
borderRadius:
|
||||
BorderRadius.circular(Constants.size.circularBorderRadius),
|
||||
),
|
||||
onPressed: () {
|
||||
showModalBottomSheet<dynamic>(
|
||||
backgroundColor: Colors.transparent,
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20),
|
||||
onPressed: () async {
|
||||
if (walletCount == 1) {
|
||||
final providersByCoin = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManagerProvidersByCoin()));
|
||||
final manager = ref.read(providersByCoin[coin]!.first);
|
||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||
await manager.initializeExisting();
|
||||
}
|
||||
unawaited(
|
||||
Navigator.of(context).pushNamed(
|
||||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
manager.walletId,
|
||||
providersByCoin[coin]!.first,
|
||||
),
|
||||
),
|
||||
),
|
||||
builder: (_) => WalletsSheet(coin: coin),
|
||||
);
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
showModalBottomSheet<dynamic>(
|
||||
backgroundColor: Colors.transparent,
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
builder: (_) => WalletsSheet(coin: coin),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/coin_wallets_table.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
|
@ -43,7 +44,18 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
(value) => value
|
||||
.getManagerProvidersForCoin(providersByCoin[i].key)));
|
||||
|
||||
VoidCallback? expandOverride;
|
||||
if (providers.length == 1) {
|
||||
expandOverride = () {
|
||||
Navigator.of(context).pushNamed(
|
||||
DesktopWalletView.routeName,
|
||||
arguments: ref.read(providers.first).walletId,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
return TableViewRow(
|
||||
expandOverride: expandOverride,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 16,
|
||||
|
|
|
@ -20,6 +20,7 @@ class Expandable extends StatefulWidget {
|
|||
this.animationDurationMultiplier = 1.0,
|
||||
this.onExpandChanged,
|
||||
this.controller,
|
||||
this.expandOverride,
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget header;
|
||||
|
@ -29,6 +30,7 @@ class Expandable extends StatefulWidget {
|
|||
final double animationDurationMultiplier;
|
||||
final void Function(ExpandableState)? onExpandChanged;
|
||||
final ExpandableController? controller;
|
||||
final VoidCallback? expandOverride;
|
||||
|
||||
@override
|
||||
State<Expandable> createState() => _ExpandableState();
|
||||
|
@ -92,7 +94,7 @@ class _ExpandableState extends State<Expandable> with TickerProviderStateMixin {
|
|||
MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: toggle,
|
||||
onTap: widget.expandOverride ?? toggle,
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: widget.header,
|
||||
|
|
|
@ -10,6 +10,7 @@ class TableViewRow extends StatefulWidget {
|
|||
required this.expandingChild,
|
||||
this.decoration,
|
||||
this.onExpandChanged,
|
||||
this.expandOverride,
|
||||
this.padding = const EdgeInsets.all(0),
|
||||
this.spacing = 0.0,
|
||||
this.crossAxisAlignment = CrossAxisAlignment.center,
|
||||
|
@ -19,6 +20,7 @@ class TableViewRow extends StatefulWidget {
|
|||
final Widget? expandingChild;
|
||||
final BoxDecoration? decoration;
|
||||
final void Function(ExpandableState)? onExpandChanged;
|
||||
final VoidCallback? expandOverride;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final double spacing;
|
||||
final CrossAxisAlignment crossAxisAlignment;
|
||||
|
@ -74,6 +76,7 @@ class _TableViewRowState extends State<TableViewRow> {
|
|||
),
|
||||
)
|
||||
: Expandable(
|
||||
expandOverride: widget.expandOverride,
|
||||
onExpandChanged: widget.onExpandChanged,
|
||||
header: MouseRegion(
|
||||
onEnter: (_) {
|
||||
|
|
Loading…
Reference in a new issue