Changed to closable auth screens. Added alert with confirmation for new wallet's seed have written.
M committed
Sep 25, 2020 at 13:26 UTC
9c1f726c43cd739906f9aa0e7aa3c0ee01dff969
4 files changed
+132
-82
lib/di.dart
+3
-3
@@ -195,9 +195,9 @@ Future setup(
195
instanceName: 'login');
196
197
getIt
198
- .registerFactoryParam<AuthPage, void Function(bool, AuthPageState), void>(
199
- (onAuthFinished, _) => AuthPage(getIt.get<AuthViewModel>(),
200
- onAuthenticationFinished: onAuthFinished, closable: false));
198
+ .registerFactoryParam<AuthPage, void Function(bool, AuthPageState), bool>(
199
+ (onAuthFinished, closable) => AuthPage(getIt.get<AuthViewModel>(),
200
+ onAuthenticationFinished: onAuthFinished, closable: closable ?? false));
201
202
getIt.registerFactory<DashboardPage>(() => DashboardPage(
203
walletViewModel: getIt.get<DashboardViewModel>(),
lib/router.dart
+4
-2
@@ -215,13 +215,15 @@ class Router {
215
return MaterialPageRoute<void>(
216
fullscreenDialog: true,
217
builder: (_) => getIt.get<AuthPage>(
218
- param1: settings.arguments as OnAuthenticationFinished));
218
+ param1: settings.arguments as OnAuthenticationFinished,
219
+ param2: true));
220
221
case Routes.unlock:
222
return MaterialPageRoute<void>(
223
fullscreenDialog: true,
224
builder: (_) => getIt.get<AuthPage>(
224
- param1: settings.arguments as OnAuthenticationFinished));
225
+ param1: settings.arguments as OnAuthenticationFinished,
226
+ param2: false));
227
228
case Routes.nodeList:
229
return CupertinoPageRoute<void>(
lib/src/screens/auth/auth_page.dart
+6
-4
@@ -27,7 +27,7 @@ class AuthPageState extends State<AuthPage> {
27
final _key = GlobalKey<ScaffoldState>();
28
final _pinCodeKey = GlobalKey<PinCodeState>();
29
final _backArrowImageDarkTheme =
30
- Image.asset('assets/images/back_arrow_dark_theme.png');
30
+ Image.asset('assets/images/close_button.png');
31
ReactionDisposer _reaction;
32
33
@override
@@ -122,9 +122,11 @@ class AuthPageState extends State<AuthPage> {
122
key: _key,
123
appBar: CupertinoNavigationBar(
124
leading: widget.closable
125
- ? SizedBox(
125
+ ? Container(
126
+ padding: EdgeInsets.only(top: 10),
127
+ child: SizedBox(
128
height: 37,
127
- width: 20,
129
+ width: 37,
130
child: ButtonTheme(
131
minWidth: double.minPositive,
132
child: FlatButton(
@@ -134,7 +136,7 @@ class AuthPageState extends State<AuthPage> {
136
onPressed: () => Navigator.of(context).pop(),
137
child: _backArrowImageDarkTheme),
138
),
137
- )
139
+ ))
140
: Container(),
141
backgroundColor: Theme.of(context).backgroundColor,
142
border: null),
lib/src/screens/seed/wallet_seed_page.dart
+119
-73
@@ -1,5 +1,6 @@
1
import 'package:cake_wallet/di.dart';
2
import 'package:cake_wallet/palette.dart';
3
+import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
4
import 'package:cake_wallet/store/settings_store.dart';
5
import 'package:flutter/cupertino.dart';
6
import 'package:flutter/material.dart';
@@ -24,9 +25,28 @@ class WalletSeedPage extends BasePage {
25
final WalletSeedViewModel walletSeedViewModel;
26
27
@override
27
- void onClose(BuildContext context) => isNewWalletCreated
28
- ? Navigator.of(context).popUntil((route) => route.isFirst)
29
- : Navigator.of(context).pop();
28
+ void onClose(BuildContext context) async {
29
+ if (isNewWalletCreated) {
30
+ final confirmed = await showDialog<bool>(context: context, builder: (BuildContext context) {
31
+ // FIXME: add translations
32
+ return AlertWithTwoActions(
33
+ alertTitle: 'Attention',
34
+ alertContent: 'Have you written it down? The seed is the only way to recover your wallet.',
35
+ leftButtonText: 'Not yet',
36
+ rightButtonText: 'Yes, I have',
37
+ actionLeftButton: () => Navigator.of(context).pop(false),
38
+ actionRightButton: () => Navigator.of(context).pop(true));
39
+ }) ?? false;
40
+
41
+ if (confirmed) {
42
+ Navigator.of(context).popUntil((route) => route.isFirst);
43
+ }
44
+
45
+ return;
46
+ }
47
+
48
+ Navigator.of(context).pop();
49
+ }
50
51
@override
52
Widget leading(BuildContext context) =>
@@ -36,31 +56,39 @@ class WalletSeedPage extends BasePage {
56
Widget trailing(BuildContext context) {
57
return isNewWalletCreated
58
? GestureDetector(
39
- onTap: () => onClose(context),
40
- child: Container(
41
- width: 100,
42
- height: 32,
43
- alignment: Alignment.center,
44
- margin: EdgeInsets.only(left: 10),
45
- decoration: BoxDecoration(
46
- borderRadius: BorderRadius.all(Radius.circular(16)),
47
- color: Theme.of(context).accentTextTheme.caption.color),
48
- child: Text(
49
- S.of(context).seed_language_next,
50
- style: TextStyle(
51
- fontSize: 14,
52
- fontWeight: FontWeight.w600,
53
- color: Palette.blueCraiola),
54
- ),
55
- ),
56
- )
59
+ onTap: () => onClose(context),
60
+ child: Container(
61
+ width: 100,
62
+ height: 32,
63
+ alignment: Alignment.center,
64
+ margin: EdgeInsets.only(left: 10),
65
+ decoration: BoxDecoration(
66
+ borderRadius: BorderRadius.all(Radius.circular(16)),
67
+ color: Theme
68
+ .of(context)
69
+ .accentTextTheme
70
+ .caption
71
+ .color),
72
+ child: Text(
73
+ S
74
+ .of(context)
75
+ .seed_language_next,
76
+ style: TextStyle(
77
+ fontSize: 14,
78
+ fontWeight: FontWeight.w600,
79
+ color: Palette.blueCraiola),
80
+ ),
81
+ ),
82
+ )
83
: Offstage();
84
}
85
86
@override
87
Widget body(BuildContext context) {
88
final image =
63
- getIt.get<SettingsStore>().isDarkTheme ? imageDark : imageLight;
89
+ getIt
90
+ .get<SettingsStore>()
91
+ .isDarkTheme ? imageDark : imageLight;
92
93
return Container(
94
padding: EdgeInsets.all(24),
@@ -87,21 +115,23 @@ class WalletSeedPage extends BasePage {
115
style: TextStyle(
116
fontSize: 20,
117
fontWeight: FontWeight.w600,
90
- color: Theme.of(context)
118
+ color: Theme
119
+ .of(context)
120
.primaryTextTheme
121
.title
122
.color),
123
),
124
Padding(
125
padding:
97
- EdgeInsets.only(top: 20, left: 16, right: 16),
126
+ EdgeInsets.only(top: 20, left: 16, right: 16),
127
child: Text(
128
walletSeedViewModel.seed,
129
textAlign: TextAlign.center,
130
style: TextStyle(
131
fontSize: 14,
132
fontWeight: FontWeight.normal,
104
- color: Theme.of(context)
133
+ color: Theme
134
+ .of(context)
135
.primaryTextTheme
136
.caption
137
.color),
@@ -115,62 +145,78 @@ class WalletSeedPage extends BasePage {
145
children: <Widget>[
146
isNewWalletCreated
147
? Padding(
118
- padding: EdgeInsets.only(
119
- bottom: 52, left: 43, right: 43),
120
- child: Text(
121
- S.of(context).seed_reminder,
122
- textAlign: TextAlign.center,
123
- style: TextStyle(
124
- fontSize: 12,
125
- fontWeight: FontWeight.normal,
126
- color: Theme.of(context)
127
- .primaryTextTheme
128
- .overline
129
- .color),
130
- ),
131
- )
148
+ padding: EdgeInsets.only(
149
+ bottom: 52, left: 43, right: 43),
150
+ child: Text(
151
+ S
152
+ .of(context)
153
+ .seed_reminder,
154
+ textAlign: TextAlign.center,
155
+ style: TextStyle(
156
+ fontSize: 12,
157
+ fontWeight: FontWeight.normal,
158
+ color: Theme
159
+ .of(context)
160
+ .primaryTextTheme
161
+ .overline
162
+ .color),
163
+ ),
164
+ )
165
: Offstage(),
166
Row(
167
mainAxisSize: MainAxisSize.max,
168
children: <Widget>[
169
Flexible(
170
child: Container(
138
- padding: EdgeInsets.only(right: 8.0),
139
- child: PrimaryButton(
140
- onPressed: () => Share.text(
141
- S.of(context).seed_share,
142
- walletSeedViewModel.seed,
143
- 'text/plain'),
144
- text: S.of(context).save,
145
- color: Colors.green,
146
- textColor: Colors.white),
147
- )),
171
+ padding: EdgeInsets.only(right: 8.0),
172
+ child: PrimaryButton(
173
+ onPressed: () =>
174
+ Share.text(
175
+ S
176
+ .of(context)
177
+ .seed_share,
178
+ walletSeedViewModel.seed,
179
+ 'text/plain'),
180
+ text: S
181
+ .of(context)
182
+ .save,
183
+ color: Colors.green,
184
+ textColor: Colors.white),
185
+ )),
186
Flexible(
187
child: Container(
150
- padding: EdgeInsets.only(left: 8.0),
151
- child: Builder(
152
- builder: (context) => PrimaryButton(
153
- onPressed: () {
154
- Clipboard.setData(ClipboardData(
155
- text: walletSeedViewModel.seed));
156
- Scaffold.of(context).showSnackBar(
157
- SnackBar(
158
- content: Text(S
159
- .of(context)
160
- .copied_to_clipboard),
161
- backgroundColor: Colors.green,
162
- duration:
163
- Duration(milliseconds: 1500),
164
- ),
165
- );
166
- },
167
- text: S.of(context).copy,
168
- color: Theme.of(context)
169
- .accentTextTheme
170
- .body2
171
- .color,
172
- textColor: Colors.white)),
173
- ))
188
+ padding: EdgeInsets.only(left: 8.0),
189
+ child: Builder(
190
+ builder: (context) =>
191
+ PrimaryButton(
192
+ onPressed: () {
193
+ Clipboard.setData(ClipboardData(
194
+ text: walletSeedViewModel
195
+ .seed));
196
+ Scaffold.of(context)
197
+ .showSnackBar(
198
+ SnackBar(
199
+ content: Text(S
200
+ .of(context)
201
+ .copied_to_clipboard),
202
+ backgroundColor: Colors
203
+ .green,
204
+ duration:
205
+ Duration(
206
+ milliseconds: 1500),
207
+ ),
208
+ );
209
+ },
210
+ text: S
211
+ .of(context)
212
+ .copy,
213
+ color: Theme
214
+ .of(context)
215
+ .accentTextTheme
216
+ .body2
217
+ .color,
218
+ textColor: Colors.white)),
219
+ ))
220
],
221
)
222
],