-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathbackup_warning_overlay.dart
More file actions
163 lines (156 loc) · 6.42 KB
/
Copy pathbackup_warning_overlay.dart
File metadata and controls
163 lines (156 loc) · 6.42 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import 'package:bb_mobile/core/themes/app_theme.dart';
import 'package:bb_mobile/core/utils/build_context_x.dart';
import 'package:bb_mobile/core/widgets/buttons/button.dart';
import 'package:bb_mobile/core/widgets/text/text.dart';
import 'package:bb_mobile/features/backup_settings/ui/backup_settings_router.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:gap/gap.dart';
import 'package:go_router/go_router.dart';
class BackupWarningOverlay extends StatelessWidget {
const BackupWarningOverlay({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
return BlocBuilder<WalletBloc, WalletState>(
buildWhen: (previous, current) =>
previous.showBackupWarning() != current.showBackupWarning(),
builder: (context, state) {
return Stack(
children: [
child,
if (state.showBackupWarning()) const _BackupWarningBlocker(),
],
);
},
);
}
}
class _BackupWarningBlocker extends StatefulWidget {
const _BackupWarningBlocker();
@override
State<_BackupWarningBlocker> createState() => _BackupWarningBlockerState();
}
class _BackupWarningBlockerState extends State<_BackupWarningBlocker> {
@override
void initState() {
super.initState();
context.read<WalletBloc>().add(const VerifyBackupStatus());
}
@override
Widget build(BuildContext context) {
return Positioned.fill(
child: Material(
color: context.appColors.surface.withAlpha(100),
child: Align(
alignment: Alignment.bottomCenter,
child: SafeArea(
child: ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
),
child: Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: context.appColors.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(16),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Flexible(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
BBText(
context.loc.backupWarningTitle,
style: context.font.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
),
color: context.appColors.onSurface,
),
const Gap(16),
BBText(
context.loc.backupWarningDescription,
style: context.font.bodyMedium,
color: context.appColors.onSurface,
),
const Gap(8),
for (final reason in [
context.loc.backupWarningLoseReasonLostPhone,
context.loc.backupWarningLoseReasonDeletedApp,
context.loc.backupWarningLoseReasonCriticalIssue,
context.loc.backupWarningLoseReasonKeystore,
context.loc.backupWarningLoseReasonCloudRestore,
])
Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BBText(
'• ',
style: context.font.bodyMedium,
color: context.appColors.onSurface,
),
Expanded(
child: BBText(
reason,
style: context.font.bodyMedium,
color: context.appColors.onSurface,
),
),
],
),
),
const Gap(8),
BBText(
context.loc.backupWarningNoRecovery,
style: context.font.bodyMedium?.copyWith(
fontWeight: FontWeight.bold,
),
color: context.appColors.onSurface,
),
],
),
),
),
const Gap(24),
BBButton.big(
label: context.loc.backupWarningBackupNow,
onPressed: () {
context.pushNamed(
BackupSettingsSubroute.backupOptions.name,
);
},
bgColor: context.appColors.onSurface,
textColor: context.appColors.surface,
),
const Gap(12),
BBButton.big(
label: context.loc.backupWarningBackupLater,
onPressed: () {
context
.read<WalletBloc>()
.add(const DismissBackupWarning());
},
bgColor: context.appColors.surface,
textColor: context.appColors.onSurface,
outlined: true,
),
],
),
),
),
),
),
),
);
}
}