fix: 优化删除账号code传4,修改常见问题文案,禁用输入框悬浮按钮,修复登录ios输入框聚焦问题
This commit is contained in:
parent
ab8eb891cc
commit
b96008d6dc
@ -60,9 +60,9 @@ class HIHelpController extends GetxController {
|
|||||||
KRMessage(
|
KRMessage(
|
||||||
title: '设备与绑定问题',
|
title: '设备与绑定问题',
|
||||||
content: [
|
content: [
|
||||||
'在绑定新设备之前请先添加您的邮箱。',
|
'在绑定新设备之前请先添加您的邮箱并设置账户密码。',
|
||||||
'Hi快VPN支持最多两台设备同时在线,包括一台iOS设备或Android,加一台Mac或PC。',
|
'Hi快VPN支持最多两台设备同时在线,包括一台iOS设备或Android,加一台Mac或PC。',
|
||||||
'如超出设备数量限制,最早登陆的同类设备将会自动下线,需要重新登陆,设备限制为系统固定设定,不支持调整。',
|
'如超出设备数量限制,请先手动移除设备后再进行登录,设备限制为系统固定设定,不支持调整。',
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
KRMessage(
|
KRMessage(
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class KRDeleteAccountController extends GetxController {
|
|||||||
// 发送验证码(简化后的 API 只需要 email 和 type)
|
// 发送验证码(简化后的 API 只需要 email 和 type)
|
||||||
final result = await _authApi.kr_sendCode(
|
final result = await _authApi.kr_sendCode(
|
||||||
account, // 邮箱地址
|
account, // 邮箱地址
|
||||||
2, // 删除账号的验证码类型
|
4, // 删除账号的验证码类型
|
||||||
);
|
);
|
||||||
|
|
||||||
result.fold(
|
result.fold(
|
||||||
|
|||||||
@ -159,6 +159,7 @@ class KRDeleteAccountView extends GetView<KRDeleteAccountController> {
|
|||||||
height: 50.w,
|
height: 50.w,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: controller.kr_codeController,
|
controller: controller.kr_codeController,
|
||||||
|
contextMenuBuilder: (context, editableTextState) => const SizedBox.shrink(),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
autofillHints: const [AutofillHints.oneTimeCode],
|
autofillHints: const [AutofillHints.oneTimeCode],
|
||||||
|
|||||||
@ -169,6 +169,7 @@ class KRInviteView extends GetView<KRInviteController> {
|
|||||||
RepaintBoundary(
|
RepaintBoundary(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: controller.otherInviteCodeController,
|
controller: controller.otherInviteCodeController,
|
||||||
|
contextMenuBuilder: (context, editableTextState) => const SizedBox.shrink(),
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
onSubmitted: (_) => controller.kr_handleBindInviteCode(),
|
onSubmitted: (_) => controller.kr_handleBindInviteCode(),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
|||||||
@ -89,7 +89,7 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
final account = KRAppRunData.getInstance().kr_account.value;
|
final account = KRAppRunData.getInstance().kr_account.value;
|
||||||
final isDeviceLogin =
|
final isDeviceLogin =
|
||||||
account != null && account.startsWith('9000');
|
account != null && account.startsWith('9000');
|
||||||
final accountText = (account ==null || isDeviceLogin)
|
final accountText = (account == null || isDeviceLogin)
|
||||||
? '待绑定'
|
? '待绑定'
|
||||||
: '${KRAppRunData.getInstance().kr_account.value.toString()}';
|
: '${KRAppRunData.getInstance().kr_account.value.toString()}';
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Obx(() => _buildStandardInputField(
|
Obx(() => _buildStandardInputField(
|
||||||
controller: controller.accountController,
|
textController: controller.accountController,
|
||||||
hintText: '请输入邮箱地址',
|
hintText: '请输入邮箱地址',
|
||||||
suffixes: const [
|
suffixes: const [
|
||||||
'@gmail.com',
|
'@gmail.com',
|
||||||
@ -161,7 +161,7 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
|
|
||||||
/// 构建标准输入框
|
/// 构建标准输入框
|
||||||
Widget _buildStandardInputField({
|
Widget _buildStandardInputField({
|
||||||
required TextEditingController controller,
|
required TextEditingController textController,
|
||||||
required String hintText,
|
required String hintText,
|
||||||
bool isPassword = false,
|
bool isPassword = false,
|
||||||
List<String>? suffixes,
|
List<String>? suffixes,
|
||||||
@ -173,8 +173,9 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
VoidCallback? onEditingComplete,
|
VoidCallback? onEditingComplete,
|
||||||
}) {
|
}) {
|
||||||
return TextField(
|
return TextField(
|
||||||
controller: controller,
|
controller: textController,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
|
contextMenuBuilder: (context, editableTextState) => const SizedBox.shrink(),
|
||||||
onEditingComplete: onEditingComplete,
|
onEditingComplete: onEditingComplete,
|
||||||
obscureText: isPassword,
|
obscureText: isPassword,
|
||||||
style: KrAppTextStyle(
|
style: KrAppTextStyle(
|
||||||
@ -217,8 +218,8 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
// 使用 RawAutocomplete 实现带提示的输入框
|
// 使用 RawAutocomplete 实现带提示的输入框
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
child: RawAutocomplete<String>(
|
child: RawAutocomplete<String>(
|
||||||
textEditingController: controller,
|
textEditingController: textController,
|
||||||
focusNode: FocusNode(),
|
focusNode: this.controller.kr_accountFocusNode,
|
||||||
optionsBuilder: (TextEditingValue textEditingValue) {
|
optionsBuilder: (TextEditingValue textEditingValue) {
|
||||||
final inputText = textEditingValue.text;
|
final inputText = textEditingValue.text;
|
||||||
|
|
||||||
@ -228,22 +229,17 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
// 1. 匹配历史记录 (只要输入内容匹配历史记录的开头,或者输入为空)
|
// 1. 匹配历史记录 (只要输入内容匹配历史记录的开头,或者输入为空)
|
||||||
if (historyEmails != null) {
|
if (historyEmails != null) {
|
||||||
if (inputText.isEmpty) {
|
if (inputText.isEmpty) {
|
||||||
// 理论上 RawAutocomplete 默认不显示空输入的 options,除非自定义 fieldViewBuilder 监听
|
|
||||||
// 但 RawAutocomplete 的 optionsBuilder 在 text 变化时触发。
|
|
||||||
// 若要空内容显示,通常需要 Focus 触发。这里先处理有内容的情况,
|
|
||||||
// 或者如果 RawAutocomplete 支持空内容(通过 initialValue? 不行,得看 triggerMode)
|
|
||||||
// 简单处理:如果为空,返回所有历史记录
|
|
||||||
options.addAll(historyEmails);
|
options.addAll(historyEmails);
|
||||||
} else {
|
} else {
|
||||||
options.addAll(historyEmails
|
options.addAll(
|
||||||
.where((email) => email.startsWith(inputText)));
|
historyEmails.where((email) => email.startsWith(inputText)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 匹配后缀 (仅当有输入且不含 @ 或含 @ 但未完整时)
|
// 2. 匹配后缀 (仅当有输入且不含 @ 或含 @ 但未完整时)
|
||||||
if (suffixes != null && inputText.isNotEmpty) {
|
if (suffixes != null && inputText.isNotEmpty) {
|
||||||
if (!inputText.contains('@')) {
|
if (!inputText.contains('@')) {
|
||||||
options.addAll(suffixes.map((suffix) => '$inputText$suffix'));
|
options.addAll(suffixes.map((suffix) => '$inputText$suffix'));
|
||||||
} else {
|
} else {
|
||||||
final atIndex = inputText.indexOf('@');
|
final atIndex = inputText.indexOf('@');
|
||||||
final prefix = inputText.substring(0, atIndex);
|
final prefix = inputText.substring(0, atIndex);
|
||||||
@ -254,21 +250,22 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
.map((suffix) => '$prefix$suffix'));
|
.map((suffix) => '$prefix$suffix'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去重
|
// 去重
|
||||||
return options.toSet().toList();
|
return options.toSet().toList();
|
||||||
},
|
},
|
||||||
fieldViewBuilder: (
|
fieldViewBuilder: (
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
TextEditingController textEditingController,
|
TextEditingController
|
||||||
|
textEditingController, // This textEditingController is provided by RawAutocomplete
|
||||||
FocusNode focusNode,
|
FocusNode focusNode,
|
||||||
VoidCallback onFieldSubmitted,
|
VoidCallback onFieldSubmitted,
|
||||||
) {
|
) {
|
||||||
// 这里我们使用传入的 controller,而不是 fieldViewBuilder 提供的 textEditingController
|
// Here we use the passed in textController, not the textEditingController provided by fieldViewBuilder
|
||||||
// 因为我们需要外部控制 controller。
|
// because we need to control the textController externally.
|
||||||
// 注意:RawAutocomplete 默认会监听 textEditingController,
|
// Note: RawAutocomplete listens to textEditingController by default,
|
||||||
// 如果我们传入了自己的 controller 给 RawAutocomplete,
|
// if we pass our own textController to RawAutocomplete,
|
||||||
// fieldViewBuilder 的 textEditingController 其实就是我们传入的那个。
|
// the fieldViewBuilder's textEditingController is actually the one we passed.
|
||||||
return buildTextField(
|
return buildTextField(
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
onEditingComplete: onFieldSubmitted,
|
onEditingComplete: onFieldSubmitted,
|
||||||
@ -338,6 +335,7 @@ class KRLoginView extends GetView<KRLoginController> {
|
|||||||
height: 50, // 固定高度
|
height: 50, // 固定高度
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: controller.codeController,
|
controller: controller.codeController,
|
||||||
|
contextMenuBuilder: (context, editableTextState) => const SizedBox.shrink(),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
autofillHints: const [AutofillHints.oneTimeCode],
|
autofillHints: const [AutofillHints.oneTimeCode],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user