2023-03-28 22:18:11 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:stackwallet/providers/providers.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/background.dart';
|
|
|
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/master_wallet_card.dart';
|
2023-04-10 15:12:07 +00:00
|
|
|
import 'package:stackwallet/widgets/wallet_card.dart';
|
2023-03-28 22:18:11 +00:00
|
|
|
|
2023-04-10 15:12:07 +00:00
|
|
|
class WalletsOverview extends ConsumerStatefulWidget {
|
|
|
|
const WalletsOverview({
|
|
|
|
Key? key,
|
|
|
|
required this.coin,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final Coin coin;
|
2023-03-28 22:18:11 +00:00
|
|
|
|
|
|
|
static const routeName = "/ethWalletsOverview";
|
|
|
|
|
|
|
|
@override
|
2023-04-10 15:12:07 +00:00
|
|
|
ConsumerState<WalletsOverview> createState() => _EthWalletsOverviewState();
|
2023-03-28 22:18:11 +00:00
|
|
|
}
|
|
|
|
|
2023-04-10 15:12:07 +00:00
|
|
|
class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
|
2023-03-28 22:18:11 +00:00
|
|
|
final isDesktop = Util.isDesktop;
|
|
|
|
|
2023-04-10 15:12:07 +00:00
|
|
|
final List<String> walletIds = [];
|
2023-03-28 22:18:11 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
final walletsData =
|
|
|
|
ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData();
|
2023-04-10 15:12:07 +00:00
|
|
|
walletsData.removeWhere((key, value) => value.coin != widget.coin);
|
|
|
|
walletIds.clear();
|
2023-03-28 22:18:11 +00:00
|
|
|
|
2023-04-10 15:12:07 +00:00
|
|
|
walletIds.addAll(walletsData.values.map((e) => e.walletId));
|
2023-03-28 22:18:11 +00:00
|
|
|
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Background(
|
|
|
|
child: ConditionalParent(
|
|
|
|
condition: !isDesktop,
|
|
|
|
builder: (child) => Scaffold(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: const AppBarBackButton(),
|
|
|
|
title: Text(
|
2023-04-10 15:12:07 +00:00
|
|
|
"${widget.coin.prettyName} (${widget.coin.ticker}) wallets",
|
2023-03-28 22:18:11 +00:00
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: SafeArea(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: ListView.separated(
|
2023-04-10 15:12:07 +00:00
|
|
|
itemCount: walletIds.length,
|
2023-03-28 22:18:11 +00:00
|
|
|
separatorBuilder: (_, __) => const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
2023-04-10 15:12:07 +00:00
|
|
|
itemBuilder: (_, index) => widget.coin == Coin.ethereum
|
|
|
|
? MasterWalletCard(
|
|
|
|
walletId: walletIds[index],
|
|
|
|
)
|
|
|
|
: WalletSheetCard(
|
|
|
|
walletId: walletIds[index],
|
|
|
|
),
|
2023-03-28 22:18:11 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|