-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathaccount_info_screen.dart
More file actions
191 lines (183 loc) · 6.47 KB
/
Copy pathaccount_info_screen.dart
File metadata and controls
191 lines (183 loc) · 6.47 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import 'package:bb_mobile/core/exchange/domain/entity/user_summary.dart';
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/text/text.dart';
import 'package:bb_mobile/features/exchange/presentation/exchange_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ExchangeAccountInfoScreen extends StatelessWidget {
const ExchangeAccountInfoScreen({super.key});
@override
Widget build(BuildContext context) {
final state = context.select((ExchangeCubit cubit) => cubit.state);
final userSummary = state.userSummary;
if (state.isFetchingUserSummary) {
return Scaffold(
backgroundColor: context.appColors.background,
appBar: AppBar(title: Text(context.loc.exchangeAccountInfoTitle)),
body: const Center(child: CircularProgressIndicator()),
);
}
if (userSummary == null) {
return Scaffold(
backgroundColor: context.appColors.background,
appBar: AppBar(title: Text(context.loc.exchangeAccountInfoTitle)),
body: Center(
child: BBText(
context.loc.exchangeAccountInfoLoadErrorMessage,
style: context.font.bodyMedium,
),
),
);
}
return Scaffold(
backgroundColor: context.appColors.background,
appBar: AppBar(title: Text(context.loc.exchangeAccountInfoTitle)),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: .start,
children: [
const SizedBox(height: 12),
_buildInfoField(
context,
context.loc.exchangeAccountInfoUserNumberLabel,
userSummary.userNumber.toString(),
isCopyable: true,
copiedMessage: context.loc.exchangeAccountInfoUserNumberCopiedMessage,
),
const SizedBox(height: 32),
_buildInfoField(
context,
context.loc.exchangeAccountInfoVerificationLevelLabel,
_getVerificationLevel(context, userSummary),
),
const SizedBox(height: 32),
_buildInfoField(
context,
context.loc.exchangeAccountInfoEmailLabel,
userSummary.email,
),
const SizedBox(height: 32),
_buildInfoField(
context,
context.loc.exchangeAccountInfoFirstNameLabel,
userSummary.profile.firstName,
),
const SizedBox(height: 32),
_buildInfoField(
context,
context.loc.exchangeAccountInfoLastNameLabel,
userSummary.profile.lastName,
),
],
),
),
),
);
}
String _getVerificationLevel(BuildContext context, UserSummary userSummary) {
if (userSummary.isFullyVerifiedKycLevel) {
return context.loc.exchangeAccountInfoVerificationIdentityVerified;
} else if (userSummary.isLightKycLevel) {
return context.loc.exchangeAccountInfoVerificationLightVerification;
} else if (userSummary.isLimitedKycLevel) {
return context.loc.exchangeAccountInfoVerificationLimitedVerification;
} else {
return context.loc.exchangeAccountInfoVerificationNotVerified;
}
}
Widget _buildInfoField(
BuildContext context,
String label,
String value, {
bool isCopyable = false,
String? copiedMessage,
}) {
return Column(
crossAxisAlignment: .start,
children: [
Row(
children: [
BBText(
label,
style: context.font.headlineMedium?.copyWith(
color: context.appColors.onSurfaceVariant,
fontWeight: .w500,
),
),
const Spacer(),
if (isCopyable)
Row(
mainAxisSize: .min,
children: [
BBText(
value,
style: context.font.bodyLarge?.copyWith(
color: context.appColors.secondary,
fontWeight: .w700,
),
),
const SizedBox(width: 8),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: value));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: BBText(
copiedMessage ?? '',
textAlign: .center,
style: TextStyle(
fontSize: 14,
color: context.appColors.surfaceFixed,
),
),
duration: const Duration(seconds: 2),
backgroundColor: context.appColors.onSurface
.withAlpha(204),
behavior: .floating,
elevation: 4,
margin: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 80,
),
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 12,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
),
);
},
child: Icon(
Icons.copy,
size: 18,
color: context.appColors.primary,
),
),
],
)
else
BBText(
value,
style: context.font.bodyLarge?.copyWith(
color: context.appColors.secondary,
fontWeight: .w700,
),
),
],
),
const SizedBox(height: 12),
Container(
width: double.infinity,
height: 1,
color: context.appColors.border,
),
],
);
}
}