-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathwallet_cards.dart
More file actions
71 lines (62 loc) · 2.23 KB
/
Copy pathwallet_cards.dart
File metadata and controls
71 lines (62 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import 'package:bb_mobile/core/themes/app_theme.dart';
import 'package:bb_mobile/core/wallet/domain/entities/wallet.dart';
import 'package:bb_mobile/core/widgets/cards/wallet_card.dart';
import 'package:bb_mobile/features/wallet/presentation/bloc/wallet_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:bull_ui/bull_ui.dart' show Gap;
class WalletCards extends StatelessWidget {
const WalletCards({
super.key,
this.padding,
this.onTap,
this.localSignersOnly = false,
this.fiatCurrency,
});
final EdgeInsetsGeometry? padding;
final bool localSignersOnly;
final Function(Wallet wallet)? onTap;
final String? fiatCurrency;
static Color cardDetails(BuildContext context, Wallet wallet) {
final isTestnet = wallet.isTestnet;
final isLiquid = wallet.isLiquid;
final watchOrSignsRemotely = wallet.isWatchOnly || wallet.signsRemotely;
final watchonlyColor = context.appColors.secondary;
if (watchOrSignsRemotely && !isTestnet) return watchonlyColor;
if (watchOrSignsRemotely && isTestnet) return watchonlyColor;
if (isLiquid) return context.appColors.tertiary;
if (isTestnet) return context.appColors.onTertiary;
return context.appColors.onTertiary;
}
@override
Widget build(BuildContext context) {
final wallets = context.select(
(WalletBloc bloc) => localSignersOnly
? bloc.state.wallets.where((w) => w.signsLocally)
: bloc.state.wallets,
);
final syncStatus = context.select(
(WalletBloc bloc) => bloc.state.syncStatus,
);
return Padding(
padding: padding ?? const EdgeInsets.all(13.0),
child: Column(
crossAxisAlignment: .stretch,
children: [
for (final (index, w) in wallets.indexed) ...[
if (index > 0) const Gap(8),
WalletCard(
tagColor: cardDetails(context, w),
title: w.displayLabel(context),
description: w.walletTypeString,
balanceSat: w.balanceSat.toInt(),
isSyncing: syncStatus[w.id] ?? false,
fiatCurrency: fiatCurrency,
onTap: () => onTap?.call(w),
),
],
],
),
);
}
}