watch_theme_dialogs.dart
6.75 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class WatchThemeRenameDialog extends StatefulWidget {
const WatchThemeRenameDialog({super.key, required this.initialValue});
final String initialValue;
@override
State<WatchThemeRenameDialog> createState() => _WatchThemeRenameDialogState();
}
class _WatchThemeRenameDialogState extends State<WatchThemeRenameDialog> {
late final TextEditingController _controller;
@override
void initState() {
super.initState();
_controller = TextEditingController(text: widget.initialValue);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
insetPadding: EdgeInsets.zero,
child: Container(
width: 300,
padding: const EdgeInsets.fromLTRB(24, 24, 24, 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
'修改状态名称',
style: TextStyle(
color: Color(0xFF141414),
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 16),
ValueListenableBuilder<TextEditingValue>(
valueListenable: _controller,
builder: (context, value, _) {
return Container(
height: 52,
width: 252,
padding: const EdgeInsets.symmetric(horizontal: 22),
decoration: BoxDecoration(
color: const Color(0xFFF3F3F3),
borderRadius: BorderRadius.circular(27),
),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
maxLength: 4,
decoration: const InputDecoration(
counterText: '',
hintText: '请输入昵称',
hintStyle: TextStyle(color: Color(0xFFB0B0B6)),
border: InputBorder.none,
isCollapsed: true,
),
style: const TextStyle(fontSize: 16),
),
),
Text(
'${value.text.characters.length}/4',
style: const TextStyle(
color: Color(0xFFD9D9D9),
fontSize: 16,
),
),
],
),
);
},
),
const SizedBox(height: 24),
ValueListenableBuilder<TextEditingValue>(
valueListenable: _controller,
builder: (context, value, _) {
final enabled = value.text.trim().isNotEmpty;
return Opacity(
opacity: enabled ? 1 : 0.4,
child: GestureDetector(
onTap: enabled ? () => Get.back(result: value.text) : null,
child: Container(
width: 220,
height: 48,
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color(0xFF845EEE),
borderRadius: BorderRadius.circular(24),
),
child: const Text(
'保存',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
),
);
},
),
],
),
),
);
}
}
class WatchThemeConfirmDialog extends StatelessWidget {
const WatchThemeConfirmDialog({
super.key,
required this.title,
required this.message,
required this.primaryText,
required this.secondaryText,
});
final String title;
final String message;
final String primaryText;
final String secondaryText;
@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.transparent,
insetPadding: EdgeInsets.zero,
child: Container(
width: 300,
padding: const EdgeInsets.fromLTRB(24, 24, 24, 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
style: const TextStyle(
color: Color(0xFF141414),
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 16),
Text(
message,
textAlign: TextAlign.center,
style: const TextStyle(
color: Color(0xFF6E6D80),
fontSize: 15,
height: 1.35,
),
),
const SizedBox(height: 20),
GestureDetector(
onTap: () => Get.back(result: true),
child: Container(
width: 220,
height: 48,
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color(0xFF845EEE),
borderRadius: BorderRadius.circular(24),
),
child: Text(
primaryText,
style: const TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
),
const SizedBox(height: 4),
GestureDetector(
onTap: () => Get.back(result: false),
child: SizedBox(
width: 220,
height: 48,
child: Center(
child: Text(
secondaryText,
style: const TextStyle(
color: Color(0xFF6E6D80),
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
),
),
),
],
),
),
);
}
}