9
import 'package:cake_wallet/src/widgets/bottom_sheet/base_bottom_sheet_widget.dart';
10
import 'package:cake_wallet/src/widgets/bottom_sheet/confirm_sending_bottom_sheet_widget.dart';
11
import 'package:cake_wallet/src/widgets/bottom_sheet/info_bottom_sheet_widget.dart';
12
+import 'package:cake_wallet/src/widgets/bottom_sheet/tooltip_bottom_sheet.dart';
13
import 'package:cake_wallet/src/widgets/gradient_background.dart';
14
+import 'package:cake_wallet/utils/responsive_layout_util.dart';
15
import 'package:cake_wallet/utils/show_pop_up.dart';
16
import 'package:cake_wallet/view_model/integrations/deuro_view_model.dart';
17
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
39
@override
40
String get title => S.current.deuro_savings;
41
40
- Widget trailing(BuildContext context) => MergeSemantics(
41
- child: SizedBox(
42
- height: 37,
43
- width: 37,
44
- child: ButtonTheme(
45
- minWidth: double.minPositive,
46
- child: Semantics(
47
- label: "Refresh",
48
- child: TextButton(
49
- style: TextButton.styleFrom(
50
- foregroundColor: Theme.of(context).colorScheme.onSurface,
51
- overlayColor: WidgetStateColor.resolveWith((states) => Colors.transparent),
52
- ),
53
- onPressed: _dEuroViewModel.reloadSavingsUserData,
54
- child: Icon(
55
- Icons.refresh,
56
- color: pageIconColor(context),
57
- size: 20,
58
- ),
59
- ),
60
- ),
61
- ),
62
- ),
63
- );
64
-
42
@override
43
Widget body(BuildContext context) {
44
WidgetsBinding.instance.addPostFrameCallback((_) => _setReactions(context, _dEuroViewModel));
45
69
- return Container(
70
- width: double.infinity,
71
- child: Column(
72
- children: <Widget>[
73
- Observer(
74
- builder: (_) => SavingsCard(
75
- isDarkTheme: currentTheme.isDark,
76
- interestRate: "${_dEuroViewModel.interestRate}%",
77
- savingsBalance: _dEuroViewModel.savingsBalance,
78
- fiatSavingsBalance: _dEuroViewModel.fiatSavingsBalance,
79
- currency: CryptoCurrency.deuro,
80
- fiatCurrency: _dEuroViewModel.isFiatDisabled ? null : _dEuroViewModel.fiat,
81
- onAddSavingsPressed: () => _onSavingsAdd(context),
82
- onRemoveSavingsPressed: () => _onSavingsRemove(context),
83
- onApproveSavingsPressed: _dEuroViewModel.prepareApproval,
84
- onTooltipPressed: () => _onSavingsTooltipPressed(context),
85
- isEnabled: _dEuroViewModel.isEnabled,
86
- isLoading: _dEuroViewModel.isLoading,
87
- ),
88
- ),
89
- Observer(
90
- builder: (_) => InterestCardWidget(
91
- isDarkTheme: currentTheme.isDark,
92
- title: S.of(context).deuro_savings_collect_interest,
93
- fiatAccruedInterest: _dEuroViewModel.fiatAccruedInterest,
94
- fiatCurrency: _dEuroViewModel.isFiatDisabled ? null : _dEuroViewModel.fiat,
95
- accruedInterest: _dEuroViewModel.accruedInterest,
96
- onCollectInterest: _dEuroViewModel.prepareCollectInterest,
97
- onReinvestInterest: _dEuroViewModel.prepareReinvestInterest,
98
- onTooltipPressed: () => _onInterestTooltipPressed(context),
99
- isEnabled: _dEuroViewModel.isEnabled,
100
- ),
101
- ),
102
- Spacer(),
103
- SafeArea(
104
- child: Padding(
105
- padding: EdgeInsets.only(bottom: 30),
106
- child: Row(
107
- mainAxisAlignment: MainAxisAlignment.center,
108
- children: [
109
- InfoChip(
110
- label: S.of(context).deuro_about_deuro,
111
- icon: CupertinoIcons.info,
112
- onPressed: () => _showWelcomeTooltip(context),
46
+ return RefreshIndicator(
47
+ displacement: responsiveLayoutUtil.screenHeight * 0.1,
48
+ onRefresh: _dEuroViewModel.reloadSavingsUserData,
49
+ child: CustomScrollView(
50
+ slivers: <Widget>[
51
+ SliverFillRemaining(
52
+ child: SizedBox(
53
+ width: double.infinity,
54
+ child: Column(
55
+ children: <Widget>[
56
+ Observer(
57
+ builder: (_) => SavingsCard(
58
+ isDarkTheme: currentTheme.isDark,
59
+ interestRate: "${_dEuroViewModel.interestRateFormated}%",
60
+ savingsBalance: _dEuroViewModel.savingsBalanceFormated,
61
+ fiatSavingsBalance: _dEuroViewModel.fiatSavingsBalanceFormated,
62
+ currency: CryptoCurrency.deuro,
63
+ fiatCurrency: _dEuroViewModel.isFiatDisabled ? null : _dEuroViewModel.fiat,
64
+ onAddSavingsPressed: () => _onSavingsAdd(context),
65
+ onRemoveSavingsPressed: () => _onSavingsRemove(context),
66
+ onApproveSavingsPressed: _dEuroViewModel.prepareApproval,
67
+ onTooltipPressed: () => _onSavingsTooltipPressed(context),
68
+ isEnabled: _dEuroViewModel.isEnabled,
69
+ isLoading: _dEuroViewModel.isLoading,
70
+ ),
71
+ ),
72
+ Observer(
73
+ builder: (_) => InterestCardWidget(
74
+ isDarkTheme: currentTheme.isDark,
75
+ title: S.of(context).deuro_savings_collect_interest,
76
+ fiatAccruedInterest: _dEuroViewModel.fiatAccruedInterestFormated,
77
+ fiatCurrency: _dEuroViewModel.isFiatDisabled ? null : _dEuroViewModel.fiat,
78
+ accruedInterest: _dEuroViewModel.accruedInterestFormated,
79
+ onCollectInterest: _onCollectInterest,
80
+ onReinvestInterest: _onReinvestInterest,
81
+ onTooltipPressed: () => _onInterestTooltipPressed(context),
82
+ isEnabled: _dEuroViewModel.isSavingsActionsEnabled,
83
+ ),
84
+ ),
85
+ Spacer(),
86
+ SafeArea(
87
+ child: Padding(
88
+ padding: EdgeInsets.only(bottom: 30),
89
+ child: Row(
90
+ mainAxisAlignment: MainAxisAlignment.center,
91
+ children: [
92
+ InfoChip(
93
+ label: S.of(context).deuro_about_deuro,
94
+ icon: CupertinoIcons.info,
95
+ onPressed: () => _showWelcomeTooltip(context),
96
+ ),
97
+ SizedBox(width: 10),
98
+ InfoChip(
99
+ label: S.of(context).website,
100
+ icon: CupertinoIcons.globe,
101
+ onPressed: () => launchUrlString("https://deuro.com/"),
102
+ )
103
+ ],
104
+ ),
105
+ ),
106
),
114
- SizedBox(width: 10),
115
- InfoChip(
116
- label: S.of(context).website,
117
- icon: CupertinoIcons.globe,
118
- onPressed: () => launchUrlString("https://deuro.com/"),
119
- )
107
],
108
),
109
),
113
);
114
}
115
116
+ bool _editSheetIsOpen = false;
117
+
118
Future<void> _onSavingsAdd(BuildContext context) async {
119
+ if (_editSheetIsOpen) return;
120
+ _editSheetIsOpen = true;
121
final amount = await _showEditBottomSheet(context, isAdding: true);
122
if (amount != null) _dEuroViewModel.prepareSavingsEdit(amount, true);
123
+ _editSheetIsOpen = false;
124
}
125
126
Future<void> _onSavingsRemove(BuildContext context) async {
127
+ if (_editSheetIsOpen) return;
128
+ _editSheetIsOpen = true;
129
final amount = await _showEditBottomSheet(context, isAdding: false);
130
if (amount != null) _dEuroViewModel.prepareSavingsEdit(amount, false);
131
+ _editSheetIsOpen = false;
132
+ }
133
+
134
+ Future<void> _onReinvestInterest() async {
135
+ if (_editSheetIsOpen) return;
136
+ _editSheetIsOpen = true;
137
+ await _dEuroViewModel.prepareReinvestInterest();
138
+ _editSheetIsOpen = false;
139
+ }
140
+
141
+ Future<void> _onCollectInterest() async {
142
+ if (_editSheetIsOpen) return;
143
+ _editSheetIsOpen = true;
144
+ await _dEuroViewModel.prepareCollectInterest();
145
+ _editSheetIsOpen = false;
146
}
147
148
bool _isReactionsSet = false;
184
currency: CryptoCurrency.deuro,
185
amount: S.of(bottomSheetContext).send_amount,
186
amountValue: _dEuroViewModel.actionType == DEuroActionType.reinvest
178
- ? _dEuroViewModel.accruedInterest
187
+ ? _dEuroViewModel.accruedInterestFormated
188
: tx.amountFormatted,
189
fiatAmountValue: _dEuroViewModel.actionType == DEuroActionType.reinvest
181
- ? _dEuroViewModel.fiatAccruedInterest
190
+ ? _dEuroViewModel.fiatAccruedInterestFormated
191
: _dEuroViewModel.pendingTransactionFiatAmountFormatted,
192
fee: S.of(bottomSheetContext).send_estimated_fee,
193
feeValue: tx.feeFormatted,
310
311
showModalBottomSheet<void>(
312
context: context,
304
- builder: (BuildContext bottomSheetContext) => InfoBottomSheet(
313
+ builder: (BuildContext bottomSheetContext) => TooltipSheet(
314
currentTheme: currentTheme,
315
titleText: title,
316
titleIconPath: CryptoCurrency.deuro.iconPath,
308
- content: content,
317
+ tooltip: content,
318
footerType: FooterType.doubleActionButton,
319
doubleActionRightButtonText: S.of(context).close,
320
rightActionButtonKey: ValueKey('deuro_page_tooltip_dialog_${key}_ok_button_key'),
367
content: S.of(context).deuro_tooltip_no_eth,
368
singleActionButtonKey: ValueKey('deuro_page_tooltip_dialog_no_eth_ok_button_key'),
369
singleActionButtonText: S.of(context).close,
361
- onSingleActionButtonPressed: () => Navigator.of(bottomSheetContext).pop(), footerType: FooterType.singleActionButton,
370
+ onSingleActionButtonPressed: () => Navigator.of(bottomSheetContext).pop(),
371
+ footerType: FooterType.singleActionButton,
372
),
373
);
374
}
385
balanceTitle: isAdding
386
? S.of(context).deuro_savings_available_to_add
387
: S.of(context).deuro_savings_available_to_remove,
378
- balance: isAdding ? _dEuroViewModel.accountBalance : _dEuroViewModel.savingsBalance,
388
+ balance: isAdding
389
+ ? _dEuroViewModel.accountBalanceFormated
390
+ : _dEuroViewModel.savingsBalanceFormated,
391
footerType: FooterType.none,
392
maxHeight: MediaQuery.of(context).size.height * 0.8,
393
),