mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 20:29:57 +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/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/wallets_sheet/wallets_sheet.dart';
|
import 'package:stackwallet/pages/wallets_sheet/wallets_sheet.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/format.dart';
|
import 'package:stackwallet/utilities/format.dart';
|
||||||
import 'package:stackwallet/utilities/prefs.dart';
|
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
class WalletListItem extends ConsumerWidget {
|
class WalletListItem extends ConsumerWidget {
|
||||||
const WalletListItem({
|
const WalletListItem({
|
||||||
|
@ -41,17 +44,37 @@ class WalletListItem extends ConsumerWidget {
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.circular(Constants.size.circularBorderRadius),
|
BorderRadius.circular(Constants.size.circularBorderRadius),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
showModalBottomSheet<dynamic>(
|
if (walletCount == 1) {
|
||||||
backgroundColor: Colors.transparent,
|
final providersByCoin = ref.watch(walletsChangeNotifierProvider
|
||||||
context: context,
|
.select((value) => value.getManagerProvidersByCoin()));
|
||||||
shape: const RoundedRectangleBorder(
|
final manager = ref.read(providersByCoin[coin]!.first);
|
||||||
borderRadius: BorderRadius.vertical(
|
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||||
top: Radius.circular(20),
|
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(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -2,6 +2,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_desktop_specific/my_stack_view/coin_wallets_table.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/providers/providers.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
@ -43,7 +44,18 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
(value) => value
|
(value) => value
|
||||||
.getManagerProvidersForCoin(providersByCoin[i].key)));
|
.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(
|
return TableViewRow(
|
||||||
|
expandOverride: expandOverride,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 20,
|
horizontal: 20,
|
||||||
vertical: 16,
|
vertical: 16,
|
||||||
|
|
|
@ -20,6 +20,7 @@ class Expandable extends StatefulWidget {
|
||||||
this.animationDurationMultiplier = 1.0,
|
this.animationDurationMultiplier = 1.0,
|
||||||
this.onExpandChanged,
|
this.onExpandChanged,
|
||||||
this.controller,
|
this.controller,
|
||||||
|
this.expandOverride,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget header;
|
final Widget header;
|
||||||
|
@ -29,6 +30,7 @@ class Expandable extends StatefulWidget {
|
||||||
final double animationDurationMultiplier;
|
final double animationDurationMultiplier;
|
||||||
final void Function(ExpandableState)? onExpandChanged;
|
final void Function(ExpandableState)? onExpandChanged;
|
||||||
final ExpandableController? controller;
|
final ExpandableController? controller;
|
||||||
|
final VoidCallback? expandOverride;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Expandable> createState() => _ExpandableState();
|
State<Expandable> createState() => _ExpandableState();
|
||||||
|
@ -92,7 +94,7 @@ class _ExpandableState extends State<Expandable> with TickerProviderStateMixin {
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor: SystemMouseCursors.click,
|
cursor: SystemMouseCursors.click,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: toggle,
|
onTap: widget.expandOverride ?? toggle,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: widget.header,
|
child: widget.header,
|
||||||
|
|
|
@ -10,6 +10,7 @@ class TableViewRow extends StatefulWidget {
|
||||||
required this.expandingChild,
|
required this.expandingChild,
|
||||||
this.decoration,
|
this.decoration,
|
||||||
this.onExpandChanged,
|
this.onExpandChanged,
|
||||||
|
this.expandOverride,
|
||||||
this.padding = const EdgeInsets.all(0),
|
this.padding = const EdgeInsets.all(0),
|
||||||
this.spacing = 0.0,
|
this.spacing = 0.0,
|
||||||
this.crossAxisAlignment = CrossAxisAlignment.center,
|
this.crossAxisAlignment = CrossAxisAlignment.center,
|
||||||
|
@ -19,6 +20,7 @@ class TableViewRow extends StatefulWidget {
|
||||||
final Widget? expandingChild;
|
final Widget? expandingChild;
|
||||||
final BoxDecoration? decoration;
|
final BoxDecoration? decoration;
|
||||||
final void Function(ExpandableState)? onExpandChanged;
|
final void Function(ExpandableState)? onExpandChanged;
|
||||||
|
final VoidCallback? expandOverride;
|
||||||
final EdgeInsetsGeometry padding;
|
final EdgeInsetsGeometry padding;
|
||||||
final double spacing;
|
final double spacing;
|
||||||
final CrossAxisAlignment crossAxisAlignment;
|
final CrossAxisAlignment crossAxisAlignment;
|
||||||
|
@ -74,6 +76,7 @@ class _TableViewRowState extends State<TableViewRow> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Expandable(
|
: Expandable(
|
||||||
|
expandOverride: widget.expandOverride,
|
||||||
onExpandChanged: widget.onExpandChanged,
|
onExpandChanged: widget.onExpandChanged,
|
||||||
header: MouseRegion(
|
header: MouseRegion(
|
||||||
onEnter: (_) {
|
onEnter: (_) {
|
||||||
|
|
Loading…
Reference in a new issue