account_settings_view.dart
5.08 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
import 'package:doublefeel_flutter/core/theme/app_colors.dart';
import 'package:doublefeel_flutter/core/theme/app_theme.dart';
import 'package:doublefeel_flutter/core/util/size_extensions.dart';
import 'package:doublefeel_flutter/data/models/user/user_models.dart';
import 'package:doublefeel_flutter/r.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../controllers/account_settings_controller.dart';
class AccountSettingsView extends GetView<AccountSettingsController> {
const AccountSettingsView({super.key});
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.light,
systemNavigationBarColor: context.colors.backgroundPage,
systemNavigationBarIconBrightness: Brightness.dark,
),
child: Scaffold(
backgroundColor: context.colors.backgroundPage,
appBar: AppBar(
title: Text(
'账号设置',
),
leading: IconButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.zero,
onPressed: controller.executeBackLogic,
icon: Image.asset(
R.assetsImagesNavBackIcon,
width: 28.dp,
height: 28.dp,
),
),
),
body: Obx(() {
final user = controller.userPrefs.preferences.value.meUserInfo;
return Column(
children: [
SizedBox(height: 16.dp),
_AccountCard(user: user, onLogout: controller.logout),
SizedBox(height: 17.dp),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: controller.openOnboarding,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 32.dp,
vertical: 8.dp,
),
child: Text(
'注销账号',
style: TextStyle(
color: context.colors.warning,
fontSize: 12.dp,
fontWeight: FontWeight.w400,
height: 1.25,
),
),
),
),
],
);
}),
),
);
}
}
class _AccountCard extends StatelessWidget {
const _AccountCard({
required this.user,
required this.onLogout,
});
final UserInfoResponse? user;
final VoidCallback onLogout;
@override
Widget build(BuildContext context) {
return Container(
height: 110.dp,
margin: EdgeInsets.symmetric(horizontal: 15.dp),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.dp),
),
child: Column(
children: [
SizedBox(
height: 54.dp,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20.dp),
child: Row(
children: [
Text(
'手机号',
style: TextStyle(
color: AppColors.textPrimary,
fontSize: 14.dp,
fontWeight: FontWeight.w400,
height: 1.25,
),
),
const Spacer(),
Text(
_formatPhone(user?.telephone),
style: TextStyle(
color: AppColors.textSecondary,
fontSize: 14.dp,
fontWeight: FontWeight.w400,
height: 1.25,
),
),
],
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20.dp),
child: Divider(
height: 1.dp,
thickness: 1.dp,
color: const Color(0xFFF3F3F3),
),
),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onLogout,
child: Center(
child: Text(
'退出登录',
style: TextStyle(
color: AppColors.primary,
fontSize: 14.dp,
fontWeight: FontWeight.w500,
height: 1.25,
),
),
),
),
),
],
),
);
}
String _formatPhone(String? phone) {
final normalized = phone?.replaceAll(' ', '').trim();
if (normalized == null || normalized.isEmpty) {
return '130 1478 9632';
}
if (normalized.length == 11) {
return '${normalized.substring(0, 3)} '
'${normalized.substring(3, 7)} '
'${normalized.substring(7)}';
}
return normalized;
}
}