mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +00:00
redo desktop enter wallet gui
This commit is contained in:
parent
5e5b3100c4
commit
c530aef112
4 changed files with 711 additions and 207 deletions
|
@ -0,0 +1,347 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/services/coins/ethereum/ethereum_wallet.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/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
|
||||
import 'package:stackwallet/widgets/expandable.dart';
|
||||
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/wallet_card.dart';
|
||||
import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart';
|
||||
import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart';
|
||||
|
||||
class DesktopCoinWalletsDialog extends ConsumerStatefulWidget {
|
||||
const DesktopCoinWalletsDialog({
|
||||
Key? key,
|
||||
required this.coin,
|
||||
required this.navigatorState,
|
||||
}) : super(key: key);
|
||||
|
||||
final Coin coin;
|
||||
final NavigatorState navigatorState;
|
||||
|
||||
@override
|
||||
ConsumerState<DesktopCoinWalletsDialog> createState() =>
|
||||
_DesktopCoinWalletsDialogState();
|
||||
}
|
||||
|
||||
class _DesktopCoinWalletsDialogState
|
||||
extends ConsumerState<DesktopCoinWalletsDialog> {
|
||||
final isDesktop = Util.isDesktop;
|
||||
|
||||
late final TextEditingController _searchController;
|
||||
late final FocusNode searchFieldFocusNode;
|
||||
|
||||
String _searchString = "";
|
||||
|
||||
final List<String> walletIds = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_searchController = TextEditingController();
|
||||
searchFieldFocusNode = FocusNode();
|
||||
|
||||
final walletsData =
|
||||
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
|
||||
walletsData.removeWhere((key, value) => value.coin != widget.coin);
|
||||
walletIds.clear();
|
||||
|
||||
walletIds.addAll(walletsData.values.map((e) => e.walletId));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
searchFieldFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
child: TextField(
|
||||
autocorrect: !isDesktop,
|
||||
enableSuggestions: !isDesktop,
|
||||
controller: _searchController,
|
||||
focusNode: searchFieldFocusNode,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_searchString = value;
|
||||
});
|
||||
},
|
||||
style: isDesktop
|
||||
? STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldActiveText,
|
||||
height: 1.8,
|
||||
)
|
||||
: STextStyles.field(context),
|
||||
decoration: standardInputDecoration(
|
||||
"Search...",
|
||||
searchFieldFocusNode,
|
||||
context,
|
||||
desktopMed: isDesktop,
|
||||
).copyWith(
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: isDesktop ? 12 : 10,
|
||||
vertical: isDesktop ? 18 : 16,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.search,
|
||||
width: isDesktop ? 20 : 16,
|
||||
height: isDesktop ? 20 : 16,
|
||||
),
|
||||
),
|
||||
suffixIcon: _searchController.text.isNotEmpty
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(right: 0),
|
||||
child: UnconstrainedBox(
|
||||
child: Row(
|
||||
children: [
|
||||
TextFieldIconButton(
|
||||
child: const XIcon(),
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
_searchController.text = "";
|
||||
_searchString = "";
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemBuilder: (_, index) => widget.coin == Coin.ethereum
|
||||
? _DesktopWalletCard(
|
||||
walletId: walletIds[index],
|
||||
navigatorState: widget.navigatorState,
|
||||
)
|
||||
: RoundedWhiteContainer(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 14,
|
||||
horizontal: 20,
|
||||
),
|
||||
borderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.backgroundAppBar,
|
||||
child: WalletSheetCard(
|
||||
walletId: walletIds[index],
|
||||
popPrevious: true,
|
||||
desktopNavigatorState: widget.navigatorState,
|
||||
),
|
||||
),
|
||||
separatorBuilder: (_, __) => const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemCount: walletIds.length,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DesktopWalletCard extends ConsumerStatefulWidget {
|
||||
const _DesktopWalletCard({
|
||||
Key? key,
|
||||
required this.walletId,
|
||||
required this.navigatorState,
|
||||
}) : super(key: key);
|
||||
|
||||
final String walletId;
|
||||
final NavigatorState navigatorState;
|
||||
|
||||
@override
|
||||
ConsumerState<_DesktopWalletCard> createState() => _DesktopWalletCardState();
|
||||
}
|
||||
|
||||
class _DesktopWalletCardState extends ConsumerState<_DesktopWalletCard> {
|
||||
final expandableController = ExpandableController();
|
||||
final rotateIconController = RotateIconController();
|
||||
final List<String> tokenContractAddresses = [];
|
||||
late final Coin coin;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
coin = ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.coin;
|
||||
|
||||
if (coin == Coin.ethereum) {
|
||||
tokenContractAddresses.addAll(
|
||||
(ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as EthereumWallet)
|
||||
.getWalletTokenContractAddresses(),
|
||||
);
|
||||
}
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RoundedWhiteContainer(
|
||||
padding: EdgeInsets.zero,
|
||||
borderColor: Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
||||
child: Expandable(
|
||||
controller: expandableController,
|
||||
expandOverride: () {},
|
||||
header: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 14,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
WalletInfoCoinIcon(
|
||||
coin: coin,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(
|
||||
ref.watch(
|
||||
walletsChangeNotifierProvider.select(
|
||||
(value) => value
|
||||
.getManager(widget.walletId)
|
||||
.walletName,
|
||||
),
|
||||
),
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: WalletInfoRowBalance(
|
||||
walletId: widget.walletId,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
MaterialButton(
|
||||
padding: const EdgeInsets.all(5),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
minWidth: 32,
|
||||
height: 32,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
elevation: 0,
|
||||
hoverElevation: 0,
|
||||
disabledElevation: 0,
|
||||
highlightElevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (expandableController.state == ExpandableState.collapsed) {
|
||||
rotateIconController.forward?.call();
|
||||
} else {
|
||||
rotateIconController.reverse?.call();
|
||||
}
|
||||
expandableController.toggle?.call();
|
||||
},
|
||||
child: RotateIcon(
|
||||
controller: rotateIconController,
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.chevronDown,
|
||||
width: 14,
|
||||
),
|
||||
curve: Curves.easeInOut,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
shrinkWrap: true,
|
||||
primary: false,
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 1,
|
||||
color:
|
||||
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 32,
|
||||
right: 14,
|
||||
top: 14,
|
||||
bottom: 14,
|
||||
),
|
||||
child: WalletSheetCard(
|
||||
walletId: widget.walletId,
|
||||
popPrevious: true,
|
||||
desktopNavigatorState: widget.navigatorState,
|
||||
),
|
||||
),
|
||||
...tokenContractAddresses.map(
|
||||
(e) => Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 32,
|
||||
right: 14,
|
||||
top: 14,
|
||||
bottom: 14,
|
||||
),
|
||||
child: WalletSheetCard(
|
||||
walletId: widget.walletId,
|
||||
contractAddress: e,
|
||||
popPrevious: true,
|
||||
desktopNavigatorState: widget.navigatorState,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,18 +1,16 @@
|
|||
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/pages_desktop_specific/my_stack_view/dialogs/desktop_coin_wallets_dialog.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/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/widgets/table_view/table_view.dart';
|
||||
import 'package:stackwallet/widgets/table_view/table_view_cell.dart';
|
||||
import 'package:stackwallet/widgets/table_view/table_view_row.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
|
||||
class WalletSummaryTable extends ConsumerStatefulWidget {
|
||||
const WalletSummaryTable({Key? key}) : super(key: key);
|
||||
|
@ -31,97 +29,217 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
),
|
||||
);
|
||||
|
||||
return TableView(
|
||||
rows: [
|
||||
for (int i = 0; i < providersByCoin.length; i++)
|
||||
Builder(
|
||||
key: Key("${providersByCoin[i].item1.name}_${runtimeType}_key"),
|
||||
builder: (context) {
|
||||
final providers = providersByCoin[i].item2;
|
||||
return ListView.separated(
|
||||
itemBuilder: (_, index) {
|
||||
final providers = providersByCoin[index].item2;
|
||||
final coin = providersByCoin[index].item1;
|
||||
|
||||
VoidCallback? expandOverride;
|
||||
if (providers.length == 1) {
|
||||
expandOverride = () async {
|
||||
final manager = ref.read(providers.first);
|
||||
if (manager.coin == Coin.monero ||
|
||||
manager.coin == Coin.wownero) {
|
||||
await manager.initializeExisting();
|
||||
}
|
||||
await Navigator.of(context).pushNamed(
|
||||
DesktopWalletView.routeName,
|
||||
arguments: manager.walletId,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
return TableViewRow(
|
||||
expandOverride: expandOverride,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
cells: [
|
||||
TableViewCell(
|
||||
flex: 4,
|
||||
child: Row(
|
||||
return RoundedWhiteContainer(
|
||||
padding: const EdgeInsets.all(20),
|
||||
onPressed: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (_) => DesktopDialog(
|
||||
maxHeight: 600,
|
||||
maxWidth: 700,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: providersByCoin[i].item1),
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
providersByCoin[i].item1.prettyName,
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 32),
|
||||
child: Text(
|
||||
"${coin.prettyName} (${coin.ticker}) wallets",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
)
|
||||
),
|
||||
const DesktopDialogCloseButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
TableViewCell(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
providers.length == 1
|
||||
? "${providers.length} wallet"
|
||||
: "${providers.length} wallets",
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 32,
|
||||
right: 32,
|
||||
bottom: 32,
|
||||
),
|
||||
child: DesktopCoinWalletsDialog(
|
||||
coin: coin,
|
||||
navigatorState: Navigator.of(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: providersByCoin[index].item1),
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
providersByCoin[index].item1.prettyName,
|
||||
style:
|
||||
STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
.textDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
TableViewCell(
|
||||
flex: 6,
|
||||
child: TablePriceInfo(
|
||||
coin: providersByCoin[i].item1,
|
||||
),
|
||||
),
|
||||
],
|
||||
expandingChild: CoinWalletsTable(
|
||||
coin: providersByCoin[i].item1,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Text(
|
||||
providers.length == 1
|
||||
? "${providers.length} wallet"
|
||||
: "${providers.length} wallets",
|
||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: TablePriceInfo(
|
||||
coin: providersByCoin[index].item1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) => const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
itemCount: providersByCoin.length,
|
||||
);
|
||||
}
|
||||
}
|
||||
//
|
||||
// class WalletSummaryTable extends ConsumerStatefulWidget {
|
||||
// const WalletSummaryTable({Key? key}) : super(key: key);
|
||||
//
|
||||
// @override
|
||||
// ConsumerState<WalletSummaryTable> createState() => _WalletTableState();
|
||||
// }
|
||||
//
|
||||
// class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// debugPrint("BUILD: $runtimeType");
|
||||
// final providersByCoin = ref.watch(
|
||||
// walletsChangeNotifierProvider.select(
|
||||
// (value) => value.getManagerProvidersByCoin(),
|
||||
// ),
|
||||
// );
|
||||
//
|
||||
// return TableView(
|
||||
// rows: [
|
||||
// for (int i = 0; i < providersByCoin.length; i++)
|
||||
// Builder(
|
||||
// key: Key("${providersByCoin[i].item1.name}_${runtimeType}_key"),
|
||||
// builder: (context) {
|
||||
// final providers = providersByCoin[i].item2;
|
||||
//
|
||||
// VoidCallback? expandOverride;
|
||||
// if (providers.length == 1) {
|
||||
// expandOverride = () async {
|
||||
// final manager = ref.read(providers.first);
|
||||
// if (manager.coin == Coin.monero ||
|
||||
// manager.coin == Coin.wownero) {
|
||||
// await manager.initializeExisting();
|
||||
// }
|
||||
// await Navigator.of(context).pushNamed(
|
||||
// DesktopWalletView.routeName,
|
||||
// arguments: manager.walletId,
|
||||
// );
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// return TableViewRow(
|
||||
// expandOverride: expandOverride,
|
||||
// padding: const EdgeInsets.symmetric(
|
||||
// horizontal: 20,
|
||||
// vertical: 16,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
// borderRadius: BorderRadius.circular(
|
||||
// Constants.size.circularBorderRadius,
|
||||
// ),
|
||||
// ),
|
||||
// cells: [
|
||||
// TableViewCell(
|
||||
// flex: 4,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// SvgPicture.asset(
|
||||
// Assets.svg.iconFor(coin: providersByCoin[i].item1),
|
||||
// width: 28,
|
||||
// height: 28,
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// width: 10,
|
||||
// ),
|
||||
// Text(
|
||||
// providersByCoin[i].item1.prettyName,
|
||||
// style: STextStyles.desktopTextExtraSmall(context)
|
||||
// .copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .extension<StackColors>()!
|
||||
// .textDark,
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// TableViewCell(
|
||||
// flex: 4,
|
||||
// child: Text(
|
||||
// providers.length == 1
|
||||
// ? "${providers.length} wallet"
|
||||
// : "${providers.length} wallets",
|
||||
// style:
|
||||
// STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .extension<StackColors>()!
|
||||
// .textSubtitle1,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// TableViewCell(
|
||||
// flex: 6,
|
||||
// child: TablePriceInfo(
|
||||
// coin: providersByCoin[i].item1,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// expandingChild: CoinWalletsTable(
|
||||
// coin: providersByCoin[i].item1,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
class TablePriceInfo extends ConsumerWidget {
|
||||
const TablePriceInfo({Key? key, required this.coin}) : super(key: key);
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/pages/token_view/token_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/secure_store_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
|
@ -13,6 +14,8 @@ import 'package:stackwallet/services/transaction_notification_tracker.dart';
|
|||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/show_loading.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||
import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -23,83 +26,108 @@ class WalletSheetCard extends ConsumerWidget {
|
|||
required this.walletId,
|
||||
this.contractAddress,
|
||||
this.popPrevious = false,
|
||||
this.desktopNavigatorState,
|
||||
}) : super(key: key);
|
||||
|
||||
final String walletId;
|
||||
final String? contractAddress;
|
||||
final bool popPrevious;
|
||||
final NavigatorState? desktopNavigatorState;
|
||||
|
||||
void _openWallet(BuildContext context, WidgetRef ref) async {
|
||||
final nav = Navigator.of(context);
|
||||
|
||||
final manager =
|
||||
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||
if (manager.coin == Coin.monero || manager.coin == Coin.wownero) {
|
||||
await manager.initializeExisting();
|
||||
}
|
||||
if (context.mounted) {
|
||||
if (popPrevious) nav.pop();
|
||||
|
||||
if (desktopNavigatorState != null) {
|
||||
unawaited(
|
||||
desktopNavigatorState!.pushNamed(
|
||||
DesktopWalletView.routeName,
|
||||
arguments: walletId,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
unawaited(
|
||||
nav.pushNamed(
|
||||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
walletId,
|
||||
ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManagerProvider(walletId),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (contractAddress != null) {
|
||||
final contract =
|
||||
ref.read(mainDBProvider).getEthContractSync(contractAddress!)!;
|
||||
ref.read(tokenServiceStateProvider.state).state = EthTokenWallet(
|
||||
token: contract,
|
||||
secureStore: ref.read(secureStoreProvider),
|
||||
ethWallet: manager.wallet as EthereumWallet,
|
||||
tracker: TransactionNotificationTracker(
|
||||
walletId: walletId,
|
||||
),
|
||||
);
|
||||
|
||||
await showLoading<void>(
|
||||
whileFuture: ref.read(tokenServiceProvider)!.initialize(),
|
||||
context: context,
|
||||
opaqueBG: true,
|
||||
message: "Loading ${contract.name}",
|
||||
);
|
||||
|
||||
// pop loading
|
||||
nav.pop();
|
||||
|
||||
if (desktopNavigatorState != null) {
|
||||
// await desktopNavigatorState !.pushNamed(
|
||||
// DesktopTokenView.routeName,
|
||||
// arguments: walletId,
|
||||
// );
|
||||
} else {
|
||||
await nav.pushNamed(
|
||||
TokenView.routeName,
|
||||
arguments: walletId,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return RoundedWhiteContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: MaterialButton(
|
||||
// splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
||||
key: Key("walletsSheetItemButtonKey_$walletId"),
|
||||
padding: const EdgeInsets.all(5),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
return ConditionalParent(
|
||||
condition: !Util.isDesktop,
|
||||
builder: (child) => RoundedWhiteContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: MaterialButton(
|
||||
// splashColor: Theme.of(context).extension<StackColors>()!.highlight,
|
||||
key: Key("walletsSheetItemButtonKey_$walletId"),
|
||||
padding: const EdgeInsets.all(5),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
onPressed: () => _openWallet(context, ref),
|
||||
child: child,
|
||||
),
|
||||
onPressed: () async {
|
||||
final nav = Navigator.of(context);
|
||||
|
||||
final manager =
|
||||
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||
if (manager.coin == Coin.monero || manager.coin == Coin.wownero) {
|
||||
await manager.initializeExisting();
|
||||
}
|
||||
if (context.mounted) {
|
||||
if (popPrevious) nav.pop();
|
||||
unawaited(
|
||||
nav.pushNamed(
|
||||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
walletId,
|
||||
ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManagerProvider(walletId)),
|
||||
),
|
||||
);
|
||||
|
||||
if (contractAddress != null) {
|
||||
final contract = ref
|
||||
.read(mainDBProvider)
|
||||
.getEthContractSync(contractAddress!)!;
|
||||
ref.read(tokenServiceStateProvider.state).state = EthTokenWallet(
|
||||
token: contract,
|
||||
secureStore: ref.read(secureStoreProvider),
|
||||
ethWallet: manager.wallet as EthereumWallet,
|
||||
tracker: TransactionNotificationTracker(
|
||||
walletId: walletId,
|
||||
),
|
||||
);
|
||||
|
||||
await showLoading<void>(
|
||||
whileFuture: ref.read(tokenServiceProvider)!.initialize(),
|
||||
context: context,
|
||||
opaqueBG: true,
|
||||
message: "Loading ${contract.name}",
|
||||
);
|
||||
|
||||
// pop loading
|
||||
nav.pop();
|
||||
|
||||
// if (context.mounted) {
|
||||
await nav.pushNamed(
|
||||
TokenView.routeName,
|
||||
arguments: walletId,
|
||||
);
|
||||
// }
|
||||
}
|
||||
}
|
||||
},
|
||||
child: WalletInfoRow(
|
||||
walletId: walletId,
|
||||
contractAddress: contractAddress,
|
||||
),
|
||||
),
|
||||
child: WalletInfoRow(
|
||||
walletId: walletId,
|
||||
contractAddress: contractAddress,
|
||||
onPressedDesktop:
|
||||
Util.isDesktop ? () => _openWallet(context, ref) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
||||
import 'package:stackwallet/pages/token_view/sub_widgets/token_summary.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance_future.dart';
|
||||
import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart';
|
||||
|
||||
|
@ -39,64 +38,76 @@ class WalletInfoRow extends ConsumerWidget {
|
|||
}
|
||||
|
||||
if (Util.isDesktop) {
|
||||
return MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: onPressedDesktop,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Row(
|
||||
children: [
|
||||
WalletInfoCoinIcon(
|
||||
coin: manager.coin,
|
||||
contractAddress: contractAddress,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(
|
||||
manager.walletName,
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
return Padding(
|
||||
padding: padding,
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Row(
|
||||
children: [
|
||||
WalletInfoCoinIcon(
|
||||
coin: manager.coin,
|
||||
contractAddress: contractAddress,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
contract != null
|
||||
? Row(
|
||||
children: [
|
||||
Text(
|
||||
contract.name,
|
||||
style:
|
||||
STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
CoinTickerTag(
|
||||
walletId: walletId,
|
||||
),
|
||||
],
|
||||
)
|
||||
: Text(
|
||||
manager.walletName,
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textDark,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: WalletInfoRowBalance(
|
||||
walletId: walletId,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 6,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.chevronRight,
|
||||
width: 20,
|
||||
height: 20,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textSubtitle1,
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: WalletInfoRowBalance(
|
||||
walletId: walletId,
|
||||
contractAddress: contractAddress,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
CustomTextButton(
|
||||
text: "Open wallet",
|
||||
onTap: onPressedDesktop,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue