mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +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
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final providers = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManagerProvidersByCoin()))[coin];
|
||||
final providers = ref
|
||||
.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;
|
||||
|
||||
|
@ -70,7 +75,7 @@ class WalletsSheet extends ConsumerWidget {
|
|||
Flexible(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: providers!.length,
|
||||
itemCount: providers.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final walletId = ref.watch(
|
||||
providers[index].select((value) => value.walletId));
|
||||
|
|
|
@ -44,9 +44,8 @@ class AllWallets extends StatelessWidget {
|
|||
return ListView.builder(
|
||||
itemCount: providersByCoin.length,
|
||||
itemBuilder: (builderContext, index) {
|
||||
final coin =
|
||||
providersByCoin.keys.toList(growable: false)[index];
|
||||
final int walletCount = providersByCoin[coin]!.length;
|
||||
final coin = providersByCoin[index].item1;
|
||||
final int walletCount = providersByCoin[index].item2.length;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: WalletListItem(
|
||||
|
|
|
@ -46,9 +46,14 @@ class WalletListItem extends ConsumerWidget {
|
|||
),
|
||||
onPressed: () async {
|
||||
if (walletCount == 1) {
|
||||
final providersByCoin = ref.watch(walletsChangeNotifierProvider
|
||||
.select((value) => value.getManagerProvidersByCoin()));
|
||||
final manager = ref.read(providersByCoin[coin]!.first);
|
||||
final providersByCoin = ref
|
||||
.watch(walletsChangeNotifierProvider
|
||||
.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) {
|
||||
await manager.initializeExisting();
|
||||
}
|
||||
|
@ -57,7 +62,7 @@ class WalletListItem extends ConsumerWidget {
|
|||
WalletView.routeName,
|
||||
arguments: Tuple2(
|
||||
manager.walletId,
|
||||
providersByCoin[coin]!.first,
|
||||
providersByCoin.first,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -25,24 +25,19 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
debugPrint("BUILD: $runtimeType");
|
||||
final providersByCoin = ref
|
||||
.watch(
|
||||
walletsChangeNotifierProvider.select(
|
||||
(value) => value.getManagerProvidersByCoin(),
|
||||
),
|
||||
)
|
||||
.entries
|
||||
.toList(growable: false);
|
||||
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].key.name}_${runtimeType}_key"),
|
||||
key: Key("${providersByCoin[i].item1.name}_${runtimeType}_key"),
|
||||
builder: (context) {
|
||||
final providers = ref.watch(walletsChangeNotifierProvider.select(
|
||||
(value) => value
|
||||
.getManagerProvidersForCoin(providersByCoin[i].key)));
|
||||
final providers = providersByCoin[i].item2;
|
||||
|
||||
VoidCallback? expandOverride;
|
||||
if (providers.length == 1) {
|
||||
|
@ -77,7 +72,7 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: providersByCoin[i].key),
|
||||
Assets.svg.iconFor(coin: providersByCoin[i].item1),
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
|
@ -85,7 +80,7 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
width: 10,
|
||||
),
|
||||
Text(
|
||||
providersByCoin[i].key.prettyName,
|
||||
providersByCoin[i].item1.prettyName,
|
||||
style: STextStyles.desktopTextExtraSmall(context)
|
||||
.copyWith(
|
||||
color: Theme.of(context)
|
||||
|
@ -113,12 +108,12 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
TableViewCell(
|
||||
flex: 6,
|
||||
child: TablePriceInfo(
|
||||
coin: providersByCoin[i].key,
|
||||
coin: providersByCoin[i].item1,
|
||||
),
|
||||
),
|
||||
],
|
||||
expandingChild: CoinWalletsTable(
|
||||
coin: providersByCoin[i].key,
|
||||
coin: providersByCoin[i].item1,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
@ -62,15 +62,24 @@ class Wallets extends ChangeNotifier {
|
|||
return result;
|
||||
}
|
||||
|
||||
Map<Coin, List<ChangeNotifierProvider<Manager>>> getManagerProvidersByCoin() {
|
||||
Map<Coin, List<ChangeNotifierProvider<Manager>>> result = {};
|
||||
List<Tuple2<Coin, List<ChangeNotifierProvider<Manager>>>>
|
||||
getManagerProvidersByCoin() {
|
||||
Map<Coin, List<ChangeNotifierProvider<Manager>>> map = {};
|
||||
for (final manager in _managerMap.values) {
|
||||
if (result[manager.coin] == null) {
|
||||
result[manager.coin] = [];
|
||||
if (map[manager.coin] == null) {
|
||||
map[manager.coin] = [];
|
||||
}
|
||||
result[manager.coin]!.add(_managerProviderMap[manager.walletId]
|
||||
map[manager.coin]!.add(_managerProviderMap[manager.walletId]
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue