mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-25 11:45:59 +00:00
sort wallet coins alphabetically
This commit is contained in:
parent
197a2a1f19
commit
69782a1bb2
5 changed files with 44 additions and 31 deletions
|
@ -17,8 +17,13 @@ class WalletsSheet extends ConsumerWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final providers = ref.watch(walletsChangeNotifierProvider
|
final providers = ref
|
||||||
.select((value) => value.getManagerProvidersByCoin()))[coin];
|
.watch(walletsChangeNotifierProvider
|
||||||
|
.select((value) => value.getManagerProvidersByCoin()))
|
||||||
|
.where((e) => e.item1 == coin)
|
||||||
|
.map((e) => e.item2)
|
||||||
|
.expand((e) => e)
|
||||||
|
.toList();
|
||||||
|
|
||||||
final maxHeight = MediaQuery.of(context).size.height * 0.60;
|
final maxHeight = MediaQuery.of(context).size.height * 0.60;
|
||||||
|
|
||||||
|
@ -70,7 +75,7 @@ class WalletsSheet extends ConsumerWidget {
|
||||||
Flexible(
|
Flexible(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: providers!.length,
|
itemCount: providers.length,
|
||||||
itemBuilder: (builderContext, index) {
|
itemBuilder: (builderContext, index) {
|
||||||
final walletId = ref.watch(
|
final walletId = ref.watch(
|
||||||
providers[index].select((value) => value.walletId));
|
providers[index].select((value) => value.walletId));
|
||||||
|
|
|
@ -44,9 +44,8 @@ class AllWallets extends StatelessWidget {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: providersByCoin.length,
|
itemCount: providersByCoin.length,
|
||||||
itemBuilder: (builderContext, index) {
|
itemBuilder: (builderContext, index) {
|
||||||
final coin =
|
final coin = providersByCoin[index].item1;
|
||||||
providersByCoin.keys.toList(growable: false)[index];
|
final int walletCount = providersByCoin[index].item2.length;
|
||||||
final int walletCount = providersByCoin[coin]!.length;
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
child: WalletListItem(
|
child: WalletListItem(
|
||||||
|
|
|
@ -46,9 +46,14 @@ class WalletListItem extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (walletCount == 1) {
|
if (walletCount == 1) {
|
||||||
final providersByCoin = ref.watch(walletsChangeNotifierProvider
|
final providersByCoin = ref
|
||||||
.select((value) => value.getManagerProvidersByCoin()));
|
.watch(walletsChangeNotifierProvider
|
||||||
final manager = ref.read(providersByCoin[coin]!.first);
|
.select((value) => value.getManagerProvidersByCoin()))
|
||||||
|
.where((e) => e.item1 == coin)
|
||||||
|
.map((e) => e.item2)
|
||||||
|
.expand((e) => e)
|
||||||
|
.toList();
|
||||||
|
final manager = ref.read(providersByCoin.first);
|
||||||
if (coin == Coin.monero || coin == Coin.wownero) {
|
if (coin == Coin.monero || coin == Coin.wownero) {
|
||||||
await manager.initializeExisting();
|
await manager.initializeExisting();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +62,7 @@ class WalletListItem extends ConsumerWidget {
|
||||||
WalletView.routeName,
|
WalletView.routeName,
|
||||||
arguments: Tuple2(
|
arguments: Tuple2(
|
||||||
manager.walletId,
|
manager.walletId,
|
||||||
providersByCoin[coin]!.first,
|
providersByCoin.first,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,24 +25,19 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint("BUILD: $runtimeType");
|
debugPrint("BUILD: $runtimeType");
|
||||||
final providersByCoin = ref
|
final providersByCoin = ref.watch(
|
||||||
.watch(
|
walletsChangeNotifierProvider.select(
|
||||||
walletsChangeNotifierProvider.select(
|
(value) => value.getManagerProvidersByCoin(),
|
||||||
(value) => value.getManagerProvidersByCoin(),
|
),
|
||||||
),
|
);
|
||||||
)
|
|
||||||
.entries
|
|
||||||
.toList(growable: false);
|
|
||||||
|
|
||||||
return TableView(
|
return TableView(
|
||||||
rows: [
|
rows: [
|
||||||
for (int i = 0; i < providersByCoin.length; i++)
|
for (int i = 0; i < providersByCoin.length; i++)
|
||||||
Builder(
|
Builder(
|
||||||
key: Key("${providersByCoin[i].key.name}_${runtimeType}_key"),
|
key: Key("${providersByCoin[i].item1.name}_${runtimeType}_key"),
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final providers = ref.watch(walletsChangeNotifierProvider.select(
|
final providers = providersByCoin[i].item2;
|
||||||
(value) => value
|
|
||||||
.getManagerProvidersForCoin(providersByCoin[i].key)));
|
|
||||||
|
|
||||||
VoidCallback? expandOverride;
|
VoidCallback? expandOverride;
|
||||||
if (providers.length == 1) {
|
if (providers.length == 1) {
|
||||||
|
@ -77,7 +72,7 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.svg.iconFor(coin: providersByCoin[i].key),
|
Assets.svg.iconFor(coin: providersByCoin[i].item1),
|
||||||
width: 28,
|
width: 28,
|
||||||
height: 28,
|
height: 28,
|
||||||
),
|
),
|
||||||
|
@ -85,7 +80,7 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
width: 10,
|
width: 10,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
providersByCoin[i].key.prettyName,
|
providersByCoin[i].item1.prettyName,
|
||||||
style: STextStyles.desktopTextExtraSmall(context)
|
style: STextStyles.desktopTextExtraSmall(context)
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
|
@ -113,12 +108,12 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
||||||
TableViewCell(
|
TableViewCell(
|
||||||
flex: 6,
|
flex: 6,
|
||||||
child: TablePriceInfo(
|
child: TablePriceInfo(
|
||||||
coin: providersByCoin[i].key,
|
coin: providersByCoin[i].item1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
expandingChild: CoinWalletsTable(
|
expandingChild: CoinWalletsTable(
|
||||||
coin: providersByCoin[i].key,
|
coin: providersByCoin[i].item1,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -62,15 +62,24 @@ class Wallets extends ChangeNotifier {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Coin, List<ChangeNotifierProvider<Manager>>> getManagerProvidersByCoin() {
|
List<Tuple2<Coin, List<ChangeNotifierProvider<Manager>>>>
|
||||||
Map<Coin, List<ChangeNotifierProvider<Manager>>> result = {};
|
getManagerProvidersByCoin() {
|
||||||
|
Map<Coin, List<ChangeNotifierProvider<Manager>>> map = {};
|
||||||
for (final manager in _managerMap.values) {
|
for (final manager in _managerMap.values) {
|
||||||
if (result[manager.coin] == null) {
|
if (map[manager.coin] == null) {
|
||||||
result[manager.coin] = [];
|
map[manager.coin] = [];
|
||||||
}
|
}
|
||||||
result[manager.coin]!.add(_managerProviderMap[manager.walletId]
|
map[manager.coin]!.add(_managerProviderMap[manager.walletId]
|
||||||
as ChangeNotifierProvider<Manager>);
|
as ChangeNotifierProvider<Manager>);
|
||||||
}
|
}
|
||||||
|
final List<Tuple2<Coin, List<ChangeNotifierProvider<Manager>>>> result = [];
|
||||||
|
|
||||||
|
for (final coin in map.keys) {
|
||||||
|
result.add(Tuple2(coin, map[coin]!));
|
||||||
|
}
|
||||||
|
|
||||||
|
result.sort((a, b) => a.item1.prettyName.compareTo(b.item1.prettyName));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue