privacy_settings_view.dart
3.99 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
import 'package:doublefeel_flutter/core/theme/app_colors.dart';
import 'package:doublefeel_flutter/core/util/size_extensions.dart';
import 'package:doublefeel_flutter/l10n/l10n_extensions.dart';
import 'package:doublefeel_flutter/r.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/privacy_settings_controller.dart';
class PrivacySettingsView extends GetView<PrivacySettingsController> {
const PrivacySettingsView({super.key});
static const _background = Color(0xFFF5F2FF);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: _background,
appBar: AppBar(
backgroundColor: Colors.transparent,
toolbarHeight: 44.dp,
centerTitle: true,
title: Text(
context.l10n.privacySettingsTitle,
style: const TextStyle(
fontSize: 16,
color: Color(0xFF000000),
fontWeight: FontWeight.w500,
),
),
leading: IconButton(
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onPressed: () {
controller.executeBackLogic();
},
icon: Image(
width: 24.w,
height: 24.w,
alignment: Alignment.centerLeft,
image: AssetImage(R.assetsImagesNavBackIcon),
),
),
),
body: PopScope(canPop: false, child: _buildContentView(context)),
);
}
Widget _buildContentView(BuildContext context) {
return SizedBox(
width: double.infinity,
height: double.infinity,
child: Column(
children: [
SizedBox(height: 16.dp),
noAddByIdView(context),
SizedBox(height: 12.dp),
showRealtimeStressView(context),
],
),
);
}
Widget noAddByIdView(BuildContext context) {
return _settingRow(
title: context.l10n.privacySettingsDisableAddById,
value: controller.enableAddWithUCode,
onChanged: () => controller.isUpdatingEnableAddWithUCode.value
? null
: controller.updateEnableAddWithUCode,
);
}
Widget showRealtimeStressView(BuildContext context) {
return _settingRow(
title: context.l10n.privacySettingsShowRealtimeStress,
value: controller.showRealtimeStress,
onChanged: () => controller.updateShowRealtimeStress,
height: 56.dp,
titleAccessory: () => controller.isVip.value
? const SizedBox.shrink()
: SizedBox(
width: 43.dp,
height: 16.dp,
child: Image.asset(
'assets/images/common/ic_pro_badge.webp',
fit: BoxFit.fill,
),
),
);
}
Widget _settingRow({
required String title,
required RxBool value,
required ValueChanged<bool>? Function() onChanged,
Widget Function()? titleAccessory,
double? height,
}) {
return Container(
width: double.infinity,
height: height ?? 48.dp,
margin: EdgeInsets.symmetric(horizontal: 16.dp),
padding: EdgeInsets.symmetric(horizontal: 20.dp),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.dp),
),
child: Row(
children: [
Text(
title,
style: const TextStyle(
fontSize: 14,
color: AppColors.textPrimary,
),
),
if (titleAccessory != null) ...[
SizedBox(width: 4.dp),
Obx(titleAccessory),
],
const Spacer(),
Obx(
() => Transform.scale(
scaleX: 52 / 51,
scaleY: 28 / 31,
child: CupertinoSwitch(
value: value.value,
activeTrackColor: AppColors.primary,
inactiveTrackColor: const Color(0xFFE5E5EA),
onChanged: onChanged(),
),
),
),
],
),
);
}
}