|
@@ -92,66 +92,66 @@ class PhoneLoginView extends GetView<LoginController> { |
|
@@ -92,66 +92,66 @@ class PhoneLoginView extends GetView<LoginController> { |
|
92
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
92
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
93
|
children: [
|
93
|
children: [
|
|
94
|
// 手机号输入框
|
94
|
// 手机号输入框
|
|
95
|
- Obx(() {
|
|
|
|
96
|
- final phoneNotEmpty =
|
|
|
|
97
|
- controller.phoneInput.value.isNotEmpty;
|
|
|
|
98
|
- return TextField(
|
|
|
|
99
|
- controller: controller.phoneController,
|
|
|
|
100
|
- keyboardType: TextInputType.phone,
|
|
|
|
101
|
- maxLength: 13,
|
|
|
|
102
|
- contextMenuBuilder: (BuildContext context,
|
|
|
|
103
|
- EditableTextState editableTextState) {
|
|
|
|
104
|
- // 获取默认的菜单项列表
|
|
|
|
105
|
- List<ContextMenuButtonItem> buttonItems =
|
|
|
|
106
|
- editableTextState.contextMenuButtonItems;
|
95
|
+ TextField(
|
|
|
|
96
|
+ controller: controller.phoneController,
|
|
|
|
97
|
+ keyboardType: TextInputType.phone,
|
|
|
|
98
|
+ maxLength: 13,
|
|
|
|
99
|
+ contextMenuBuilder: (BuildContext context,
|
|
|
|
100
|
+ EditableTextState editableTextState) {
|
|
|
|
101
|
+ // 获取默认的菜单项列表
|
|
|
|
102
|
+ List<ContextMenuButtonItem> buttonItems =
|
|
|
|
103
|
+ editableTextState.contextMenuButtonItems;
|
|
107
|
|
104
|
|
|
108
|
- // 例如:只保留“粘贴” (Paste)
|
|
|
|
109
|
- buttonItems.removeWhere((item) =>
|
|
|
|
110
|
- item.type != ContextMenuButtonType.paste);
|
|
|
|
111
|
- return AdaptiveTextSelectionToolbar.buttonItems(
|
|
|
|
112
|
- anchors: editableTextState.contextMenuAnchors,
|
|
|
|
113
|
- buttonItems: buttonItems,
|
|
|
|
114
|
- );
|
|
|
|
115
|
- },
|
|
|
|
116
|
- inputFormatters: [
|
|
|
|
117
|
- FilteringTextInputFormatter.allow(
|
|
|
|
118
|
- RegExp(r'[0-9\s]')),
|
|
|
|
119
|
- _PhoneTextInputFormatter(),
|
|
|
|
120
|
- ],
|
|
|
|
121
|
- style: TextStyle(
|
|
|
|
122
|
- color: context.colors.textPrimary,
|
105
|
+ // 例如:只保留“粘贴” (Paste)
|
|
|
|
106
|
+ buttonItems.removeWhere((item) =>
|
|
|
|
107
|
+ item.type != ContextMenuButtonType.paste);
|
|
|
|
108
|
+ return AdaptiveTextSelectionToolbar.buttonItems(
|
|
|
|
109
|
+ anchors: editableTextState.contextMenuAnchors,
|
|
|
|
110
|
+ buttonItems: buttonItems,
|
|
|
|
111
|
+ );
|
|
|
|
112
|
+ },
|
|
|
|
113
|
+ inputFormatters: [
|
|
|
|
114
|
+ FilteringTextInputFormatter.allow(
|
|
|
|
115
|
+ RegExp(r'[0-9\s]')),
|
|
|
|
116
|
+ _PhoneTextInputFormatter(),
|
|
|
|
117
|
+ ],
|
|
|
|
118
|
+ style: TextStyle(
|
|
|
|
119
|
+ color: context.colors.textPrimary,
|
|
|
|
120
|
+ fontSize: 16,
|
|
|
|
121
|
+ fontWeight: FontWeight.w400,
|
|
|
|
122
|
+ ),
|
|
|
|
123
|
+ decoration: InputDecoration(
|
|
|
|
124
|
+ hintText: l10n.phoneLoginPhoneHint,
|
|
|
|
125
|
+ hintStyle: TextStyle(
|
|
|
|
126
|
+ color: context.colors.textTertiary,
|
|
123
|
fontSize: 16,
|
127
|
fontSize: 16,
|
|
124
|
- fontWeight: FontWeight.w400,
|
|
|
|
125
|
),
|
128
|
),
|
|
126
|
- decoration: InputDecoration(
|
|
|
|
127
|
- hintText: l10n.phoneLoginPhoneHint,
|
|
|
|
128
|
- hintStyle: TextStyle(
|
|
|
|
129
|
- color: context.colors.textTertiary,
|
|
|
|
130
|
- fontSize: 16,
|
|
|
|
131
|
- ),
|
|
|
|
132
|
- counterText: '',
|
|
|
|
133
|
- filled: true,
|
|
|
|
134
|
- fillColor: Color(0xFFF3F3F3),
|
|
|
|
135
|
- contentPadding: const EdgeInsets.symmetric(
|
|
|
|
136
|
- horizontal: 20,
|
|
|
|
137
|
- vertical: 16,
|
|
|
|
138
|
- ),
|
|
|
|
139
|
- border: OutlineInputBorder(
|
|
|
|
140
|
- borderRadius: BorderRadius.circular(27),
|
|
|
|
141
|
- borderSide: BorderSide.none,
|
|
|
|
142
|
- ),
|
|
|
|
143
|
- enabledBorder: OutlineInputBorder(
|
|
|
|
144
|
- borderRadius: BorderRadius.circular(27),
|
|
|
|
145
|
- borderSide: BorderSide.none,
|
|
|
|
146
|
- ),
|
|
|
|
147
|
- focusedBorder: OutlineInputBorder(
|
|
|
|
148
|
- borderRadius: BorderRadius.circular(27),
|
|
|
|
149
|
- borderSide: BorderSide(
|
|
|
|
150
|
- color: context.colors.primary,
|
|
|
|
151
|
- width: 1,
|
|
|
|
152
|
- ),
|
129
|
+ counterText: '',
|
|
|
|
130
|
+ filled: true,
|
|
|
|
131
|
+ fillColor: const Color(0xFFF3F3F3),
|
|
|
|
132
|
+ contentPadding: const EdgeInsets.symmetric(
|
|
|
|
133
|
+ horizontal: 20,
|
|
|
|
134
|
+ vertical: 16,
|
|
|
|
135
|
+ ),
|
|
|
|
136
|
+ border: OutlineInputBorder(
|
|
|
|
137
|
+ borderRadius: BorderRadius.circular(27),
|
|
|
|
138
|
+ borderSide: BorderSide.none,
|
|
|
|
139
|
+ ),
|
|
|
|
140
|
+ enabledBorder: OutlineInputBorder(
|
|
|
|
141
|
+ borderRadius: BorderRadius.circular(27),
|
|
|
|
142
|
+ borderSide: BorderSide.none,
|
|
|
|
143
|
+ ),
|
|
|
|
144
|
+ focusedBorder: OutlineInputBorder(
|
|
|
|
145
|
+ borderRadius: BorderRadius.circular(27),
|
|
|
|
146
|
+ borderSide: BorderSide(
|
|
|
|
147
|
+ color: context.colors.primary,
|
|
|
|
148
|
+ width: 1,
|
|
153
|
),
|
149
|
),
|
|
154
|
- suffixIcon: phoneNotEmpty
|
150
|
+ ),
|
|
|
|
151
|
+ suffixIcon: Obx(() {
|
|
|
|
152
|
+ final phoneNotEmpty =
|
|
|
|
153
|
+ controller.phoneInput.value.isNotEmpty;
|
|
|
|
154
|
+ return phoneNotEmpty
|
|
155
|
? GestureDetector(
|
155
|
? GestureDetector(
|
|
156
|
onTap: controller.phoneController.clear,
|
156
|
onTap: controller.phoneController.clear,
|
|
157
|
child: Icon(
|
157
|
child: Icon(
|
|
@@ -160,82 +160,84 @@ class PhoneLoginView extends GetView<LoginController> { |
|
@@ -160,82 +160,84 @@ class PhoneLoginView extends GetView<LoginController> { |
|
160
|
size: 18,
|
160
|
size: 18,
|
|
161
|
),
|
161
|
),
|
|
162
|
)
|
162
|
)
|
|
163
|
- : null,
|
|
|
|
164
|
- ),
|
|
|
|
165
|
- );
|
|
|
|
166
|
- }),
|
163
|
+ : const SizedBox.shrink();
|
|
|
|
164
|
+ }),
|
|
|
|
165
|
+ ),
|
|
|
|
166
|
+ ),
|
|
167
|
|
167
|
|
|
168
|
const SizedBox(height: 16),
|
168
|
const SizedBox(height: 16),
|
|
169
|
|
169
|
|
|
170
|
// 验证码输入框(内嵌发送按钮)
|
170
|
// 验证码输入框(内嵌发送按钮)
|
|
171
|
- Obx(() {
|
|
|
|
172
|
- final countdown = controller.countdownSeconds.value;
|
|
|
|
173
|
- final isSending = controller.isSendingCode.value;
|
|
|
|
174
|
- final isCounting = countdown > 0;
|
|
|
|
175
|
- final hasSent = controller.hasSentCode.value;
|
|
|
|
176
|
-
|
|
|
|
177
|
- String btnText = hasSent
|
|
|
|
178
|
- ? l10n.phoneLoginResend
|
|
|
|
179
|
- : l10n.phoneLoginSendCode;
|
|
|
|
180
|
- if (isSending) {
|
|
|
|
181
|
- btnText = l10n.phoneLoginSending;
|
|
|
|
182
|
- } else if (isCounting) {
|
|
|
|
183
|
- btnText = l10n.phoneLoginSentCountdown(countdown);
|
|
|
|
184
|
- }
|
|
|
|
185
|
-
|
|
|
|
186
|
- return TextField(
|
|
|
|
187
|
- controller: controller.codeController,
|
|
|
|
188
|
- focusNode: controller.codeFocusNode,
|
|
|
|
189
|
- keyboardType: TextInputType.number,
|
|
|
|
190
|
- maxLength: 6,
|
|
|
|
191
|
- contextMenuBuilder: (BuildContext context,
|
|
|
|
192
|
- EditableTextState editableTextState) {
|
|
|
|
193
|
- // 获取默认的菜单项列表
|
|
|
|
194
|
- List<ContextMenuButtonItem> buttonItems =
|
|
|
|
195
|
- editableTextState.contextMenuButtonItems;
|
171
|
+ TextField(
|
|
|
|
172
|
+ controller: controller.codeController,
|
|
|
|
173
|
+ focusNode: controller.codeFocusNode,
|
|
|
|
174
|
+ keyboardType: TextInputType.number,
|
|
|
|
175
|
+ maxLength: 6,
|
|
|
|
176
|
+ contextMenuBuilder: (BuildContext context,
|
|
|
|
177
|
+ EditableTextState editableTextState) {
|
|
|
|
178
|
+ // 获取默认的菜单项列表
|
|
|
|
179
|
+ List<ContextMenuButtonItem> buttonItems =
|
|
|
|
180
|
+ editableTextState.contextMenuButtonItems;
|
|
196
|
|
181
|
|
|
197
|
- // 例如:只保留“粘贴” (Paste)
|
|
|
|
198
|
- buttonItems.removeWhere((item) =>
|
|
|
|
199
|
- item.type != ContextMenuButtonType.paste);
|
|
|
|
200
|
- return AdaptiveTextSelectionToolbar.buttonItems(
|
|
|
|
201
|
- anchors: editableTextState.contextMenuAnchors,
|
|
|
|
202
|
- buttonItems: buttonItems,
|
|
|
|
203
|
- );
|
|
|
|
204
|
- },
|
|
|
|
205
|
- style: TextStyle(
|
|
|
|
206
|
- color: context.colors.textPrimary,
|
182
|
+ // 例如:只保留“粘贴” (Paste)
|
|
|
|
183
|
+ buttonItems.removeWhere((item) =>
|
|
|
|
184
|
+ item.type != ContextMenuButtonType.paste);
|
|
|
|
185
|
+ return AdaptiveTextSelectionToolbar.buttonItems(
|
|
|
|
186
|
+ anchors: editableTextState.contextMenuAnchors,
|
|
|
|
187
|
+ buttonItems: buttonItems,
|
|
|
|
188
|
+ );
|
|
|
|
189
|
+ },
|
|
|
|
190
|
+ style: TextStyle(
|
|
|
|
191
|
+ color: context.colors.textPrimary,
|
|
|
|
192
|
+ fontSize: 16,
|
|
|
|
193
|
+ fontWeight: FontWeight.w400,
|
|
|
|
194
|
+ ),
|
|
|
|
195
|
+ decoration: InputDecoration(
|
|
|
|
196
|
+ hintText: l10n.phoneLoginCodeHint,
|
|
|
|
197
|
+ hintStyle: TextStyle(
|
|
|
|
198
|
+ color: context.colors.textTertiary,
|
|
207
|
fontSize: 16,
|
199
|
fontSize: 16,
|
|
208
|
- fontWeight: FontWeight.w400,
|
|
|
|
209
|
),
|
200
|
),
|
|
210
|
- decoration: InputDecoration(
|
|
|
|
211
|
- hintText: l10n.phoneLoginCodeHint,
|
|
|
|
212
|
- hintStyle: TextStyle(
|
|
|
|
213
|
- color: context.colors.textTertiary,
|
|
|
|
214
|
- fontSize: 16,
|
|
|
|
215
|
- ),
|
|
|
|
216
|
- counterText: '',
|
|
|
|
217
|
- filled: true,
|
|
|
|
218
|
- fillColor: Color(0xFFF3F3F3),
|
|
|
|
219
|
- contentPadding: const EdgeInsets.symmetric(
|
|
|
|
220
|
- horizontal: 20,
|
|
|
|
221
|
- vertical: 16,
|
|
|
|
222
|
- ),
|
|
|
|
223
|
- border: OutlineInputBorder(
|
|
|
|
224
|
- borderRadius: BorderRadius.circular(27),
|
|
|
|
225
|
- borderSide: BorderSide.none,
|
|
|
|
226
|
- ),
|
|
|
|
227
|
- enabledBorder: OutlineInputBorder(
|
|
|
|
228
|
- borderRadius: BorderRadius.circular(27),
|
|
|
|
229
|
- borderSide: BorderSide.none,
|
|
|
|
230
|
- ),
|
|
|
|
231
|
- focusedBorder: OutlineInputBorder(
|
|
|
|
232
|
- borderRadius: BorderRadius.circular(27),
|
|
|
|
233
|
- borderSide: BorderSide(
|
|
|
|
234
|
- color: context.colors.primary,
|
|
|
|
235
|
- width: 1,
|
|
|
|
236
|
- ),
|
201
|
+ counterText: '',
|
|
|
|
202
|
+ filled: true,
|
|
|
|
203
|
+ fillColor: const Color(0xFFF3F3F3),
|
|
|
|
204
|
+ contentPadding: const EdgeInsets.symmetric(
|
|
|
|
205
|
+ horizontal: 20,
|
|
|
|
206
|
+ vertical: 16,
|
|
|
|
207
|
+ ),
|
|
|
|
208
|
+ border: OutlineInputBorder(
|
|
|
|
209
|
+ borderRadius: BorderRadius.circular(27),
|
|
|
|
210
|
+ borderSide: BorderSide.none,
|
|
|
|
211
|
+ ),
|
|
|
|
212
|
+ enabledBorder: OutlineInputBorder(
|
|
|
|
213
|
+ borderRadius: BorderRadius.circular(27),
|
|
|
|
214
|
+ borderSide: BorderSide.none,
|
|
|
|
215
|
+ ),
|
|
|
|
216
|
+ focusedBorder: OutlineInputBorder(
|
|
|
|
217
|
+ borderRadius: BorderRadius.circular(27),
|
|
|
|
218
|
+ borderSide: BorderSide(
|
|
|
|
219
|
+ color: context.colors.primary,
|
|
|
|
220
|
+ width: 1,
|
|
237
|
),
|
221
|
),
|
|
238
|
- suffixIcon: Padding(
|
222
|
+ ),
|
|
|
|
223
|
+ suffixIcon: Obx(() {
|
|
|
|
224
|
+ final countdown =
|
|
|
|
225
|
+ controller.countdownSeconds.value;
|
|
|
|
226
|
+ final isSending = controller.isSendingCode.value;
|
|
|
|
227
|
+ final isCounting = countdown > 0;
|
|
|
|
228
|
+ final hasSent = controller.hasSentCode.value;
|
|
|
|
229
|
+
|
|
|
|
230
|
+ String btnText = hasSent
|
|
|
|
231
|
+ ? l10n.phoneLoginResend
|
|
|
|
232
|
+ : l10n.phoneLoginSendCode;
|
|
|
|
233
|
+ if (isSending) {
|
|
|
|
234
|
+ btnText = l10n.phoneLoginSending;
|
|
|
|
235
|
+ } else if (isCounting) {
|
|
|
|
236
|
+ btnText =
|
|
|
|
237
|
+ l10n.phoneLoginSentCountdown(countdown);
|
|
|
|
238
|
+ }
|
|
|
|
239
|
+
|
|
|
|
240
|
+ return Padding(
|
|
239
|
padding: const EdgeInsets.only(right: 12),
|
241
|
padding: const EdgeInsets.only(right: 12),
|
|
240
|
child: TextButton(
|
242
|
child: TextButton(
|
|
241
|
onPressed: controller.canRequestCode
|
243
|
onPressed: controller.canRequestCode
|
|
@@ -257,12 +259,12 @@ class PhoneLoginView extends GetView<LoginController> { |
|
@@ -257,12 +259,12 @@ class PhoneLoginView extends GetView<LoginController> { |
|
257
|
),
|
259
|
),
|
|
258
|
child: Text(btnText),
|
260
|
child: Text(btnText),
|
|
259
|
),
|
261
|
),
|
|
260
|
- ),
|
|
|
|
261
|
- suffixIconConstraints:
|
|
|
|
262
|
- const BoxConstraints(minWidth: 0),
|
|
|
|
263
|
- ),
|
|
|
|
264
|
- );
|
|
|
|
265
|
- }),
|
262
|
+ );
|
|
|
|
263
|
+ }),
|
|
|
|
264
|
+ suffixIconConstraints:
|
|
|
|
265
|
+ const BoxConstraints(minWidth: 0),
|
|
|
|
266
|
+ ),
|
|
|
|
267
|
+ ),
|
|
266
|
|
268
|
|
|
267
|
const SizedBox(height: 56),
|
269
|
const SizedBox(height: 56),
|
|
268
|
|
270
|
|