mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-22 15:19:11 +00:00
fix wallets not showing up when more than 1 of the same type are created
This commit is contained in:
parent
00f89e7d1b
commit
ef8f38aeb8
5 changed files with 111 additions and 109 deletions
|
@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.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/wallet_view/desktop_wallet_view.dart';
|
||||||
|
import 'package:stackwallet/providers/global/wallets_provider.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/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart';
|
import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart';
|
||||||
|
@ -10,13 +12,16 @@ import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart';
|
||||||
class CoinWalletsTable extends ConsumerWidget {
|
class CoinWalletsTable extends ConsumerWidget {
|
||||||
const CoinWalletsTable({
|
const CoinWalletsTable({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.walletIds,
|
required this.coin,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final List<String> walletIds;
|
final Coin coin;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final walletIds = ref.watch(walletsChangeNotifierProvider
|
||||||
|
.select((value) => value.getWalletIdsFor(coin: coin)));
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||||
|
@ -38,7 +43,7 @@ class CoinWalletsTable extends ConsumerWidget {
|
||||||
children: [
|
children: [
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 32,
|
height: 8,
|
||||||
),
|
),
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -23,6 +23,7 @@ class WalletSummaryTable extends ConsumerStatefulWidget {
|
||||||
class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
debugPrint("BUILD: $runtimeType");
|
||||||
final providersByCoin = ref
|
final providersByCoin = ref
|
||||||
.watch(
|
.watch(
|
||||||
walletsChangeNotifierProvider.select(
|
walletsChangeNotifierProvider.select(
|
||||||
|
@ -35,72 +36,75 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
return TableView(
|
return TableView(
|
||||||
rows: [
|
rows: [
|
||||||
for (int i = 0; i < providersByCoin.length; i++)
|
for (int i = 0; i < providersByCoin.length; i++)
|
||||||
TableViewRow(
|
Builder(
|
||||||
padding: const EdgeInsets.symmetric(
|
builder: (context) {
|
||||||
horizontal: 20,
|
final providers = ref.watch(walletsChangeNotifierProvider.select(
|
||||||
vertical: 16,
|
(value) => value
|
||||||
),
|
.getManagerProvidersForCoin(providersByCoin[i].key)));
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
return TableViewRow(
|
||||||
borderRadius: BorderRadius.circular(
|
padding: const EdgeInsets.symmetric(
|
||||||
Constants.size.circularBorderRadius,
|
horizontal: 20,
|
||||||
),
|
vertical: 16,
|
||||||
),
|
),
|
||||||
cells: [
|
decoration: BoxDecoration(
|
||||||
TableViewCell(
|
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||||
flex: 4,
|
borderRadius: BorderRadius.circular(
|
||||||
child: Row(
|
Constants.size.circularBorderRadius,
|
||||||
children: [
|
),
|
||||||
SvgPicture.asset(
|
),
|
||||||
Assets.svg.iconFor(coin: providersByCoin[i].key),
|
cells: [
|
||||||
width: 28,
|
TableViewCell(
|
||||||
height: 28,
|
flex: 4,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.svg.iconFor(coin: providersByCoin[i].key),
|
||||||
|
width: 28,
|
||||||
|
height: 28,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
providersByCoin[i].key.prettyName,
|
||||||
|
style: STextStyles.desktopTextExtraSmall(context)
|
||||||
|
.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textDark,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
),
|
||||||
width: 10,
|
TableViewCell(
|
||||||
),
|
flex: 4,
|
||||||
Text(
|
child: Text(
|
||||||
providersByCoin[i].key.prettyName,
|
providers.length == 1
|
||||||
|
? "${providers.length} wallet"
|
||||||
|
: "${providers.length} wallets",
|
||||||
style:
|
style:
|
||||||
STextStyles.desktopTextExtraSmall(context).copyWith(
|
STextStyles.desktopTextExtraSmall(context).copyWith(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.textDark,
|
.textSubtitle1,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TableViewCell(
|
|
||||||
flex: 4,
|
|
||||||
child: Text(
|
|
||||||
providersByCoin[i].value.length == 1
|
|
||||||
? "${providersByCoin[i].value.length} wallet"
|
|
||||||
: "${providersByCoin[i].value.length} wallets",
|
|
||||||
style: STextStyles.desktopTextExtraSmall(context).copyWith(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.textSubtitle1,
|
|
||||||
),
|
),
|
||||||
),
|
TableViewCell(
|
||||||
),
|
flex: 6,
|
||||||
TableViewCell(
|
child: TablePriceInfo(
|
||||||
flex: 6,
|
coin: providersByCoin[i].key,
|
||||||
child: TablePriceInfo(
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
expandingChild: CoinWalletsTable(
|
||||||
coin: providersByCoin[i].key,
|
coin: providersByCoin[i].key,
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
expandingChild: CoinWalletsTable(
|
),
|
||||||
walletIds: ref.watch(
|
|
||||||
walletsChangeNotifierProvider.select(
|
|
||||||
(value) => value.getWalletIdsFor(
|
|
||||||
coin: providersByCoin[i].key,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,17 @@ class Wallets extends ChangeNotifier {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ChangeNotifierProvider<Manager>> getManagerProvidersForCoin(Coin coin) {
|
||||||
|
List<ChangeNotifierProvider<Manager>> result = [];
|
||||||
|
for (final manager in _managerMap.values) {
|
||||||
|
if (manager.coin == coin) {
|
||||||
|
result.add(_managerProviderMap[manager.walletId]
|
||||||
|
as ChangeNotifierProvider<Manager>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ChangeNotifierProvider<Manager> getManagerProvider(String walletId) {
|
ChangeNotifierProvider<Manager> getManagerProvider(String walletId) {
|
||||||
return _managerProviderMap[walletId] as ChangeNotifierProvider<Manager>;
|
return _managerProviderMap[walletId] as ChangeNotifierProvider<Manager>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class TableView extends StatefulWidget {
|
class TableView extends StatelessWidget {
|
||||||
const TableView({
|
const TableView({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.rows,
|
required this.rows,
|
||||||
|
@ -11,25 +11,26 @@ class TableView extends StatefulWidget {
|
||||||
final List<Widget> rows;
|
final List<Widget> rows;
|
||||||
final double rowSpacing;
|
final double rowSpacing;
|
||||||
final bool shrinkWrap;
|
final bool shrinkWrap;
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
State<TableView> createState() => _TableViewState();
|
// State<TableView> createState() => _TableViewState();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
class _TableViewState extends State<TableView> {
|
// class _TableViewState extends State<TableView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
debugPrint("BUILD: $runtimeType");
|
||||||
return ListView(
|
return ListView(
|
||||||
shrinkWrap: widget.shrinkWrap,
|
shrinkWrap: shrinkWrap,
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < widget.rows.length; i++)
|
for (int i = 0; i < rows.length; i++)
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: widget.rowSpacing,
|
height: rowSpacing,
|
||||||
),
|
),
|
||||||
widget.rows[i],
|
rows[i],
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,40 +28,21 @@ class TableViewRow extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TableViewRowState extends State<TableViewRow> {
|
class _TableViewRowState extends State<TableViewRow> {
|
||||||
late final List<TableViewCell> cells;
|
|
||||||
late final Widget? expandingChild;
|
|
||||||
late final BoxDecoration? decoration;
|
|
||||||
late final void Function(ExpandableState)? onExpandChanged;
|
|
||||||
late final EdgeInsetsGeometry padding;
|
|
||||||
late final double spacing;
|
|
||||||
late final CrossAxisAlignment crossAxisAlignment;
|
|
||||||
|
|
||||||
bool _hovering = false;
|
bool _hovering = false;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
cells = widget.cells;
|
|
||||||
expandingChild = widget.expandingChild;
|
|
||||||
decoration = widget.decoration;
|
|
||||||
onExpandChanged = widget.onExpandChanged;
|
|
||||||
padding = widget.padding;
|
|
||||||
spacing = widget.spacing;
|
|
||||||
crossAxisAlignment = widget.crossAxisAlignment;
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
debugPrint("BUILD: $runtimeType");
|
||||||
return Container(
|
return Container(
|
||||||
decoration: !_hovering
|
decoration: !_hovering
|
||||||
? decoration
|
? widget.decoration
|
||||||
: decoration?.copyWith(
|
: widget.decoration?.copyWith(
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
Theme.of(context).extension<StackColors>()!.standardBoxShadow,
|
Theme.of(context).extension<StackColors>()!.standardBoxShadow,
|
||||||
Theme.of(context).extension<StackColors>()!.standardBoxShadow,
|
Theme.of(context).extension<StackColors>()!.standardBoxShadow,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: expandingChild == null
|
child: widget.expandingChild == null
|
||||||
? MouseRegion(
|
? MouseRegion(
|
||||||
onEnter: (_) {
|
onEnter: (_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -74,18 +55,18 @@ class _TableViewRowState extends State<TableViewRow> {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: padding,
|
padding: widget.padding,
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: crossAxisAlignment,
|
crossAxisAlignment: widget.crossAxisAlignment,
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < cells.length; i++) ...[
|
for (int i = 0; i < widget.cells.length; i++) ...[
|
||||||
if (i != 0 && i != cells.length)
|
if (i != 0 && i != widget.cells.length)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: spacing,
|
width: widget.spacing,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: cells[i].flex,
|
flex: widget.cells[i].flex,
|
||||||
child: cells[i],
|
child: widget.cells[i],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -93,7 +74,7 @@ class _TableViewRowState extends State<TableViewRow> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Expandable(
|
: Expandable(
|
||||||
onExpandChanged: onExpandChanged,
|
onExpandChanged: widget.onExpandChanged,
|
||||||
header: MouseRegion(
|
header: MouseRegion(
|
||||||
onEnter: (_) {
|
onEnter: (_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -106,17 +87,17 @@ class _TableViewRowState extends State<TableViewRow> {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: padding,
|
padding: widget.padding,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < cells.length; i++) ...[
|
for (int i = 0; i < widget.cells.length; i++) ...[
|
||||||
if (i != 0 && i != cells.length)
|
if (i != 0 && i != widget.cells.length)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: spacing,
|
width: widget.spacing,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: cells[i].flex,
|
flex: widget.cells[i].flex,
|
||||||
child: cells[i],
|
child: widget.cells[i],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -132,7 +113,7 @@ class _TableViewRowState extends State<TableViewRow> {
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 1,
|
height: 1,
|
||||||
),
|
),
|
||||||
expandingChild!,
|
widget.expandingChild!,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue