From f7dc60ad50502f19097ef707df13812a481637c6 Mon Sep 17 00:00:00 2001 From: Levi Date: Thu, 18 Jan 2024 09:17:06 +0800 Subject: [PATCH] fix: proxy setting only numeric input (#328) --- .../modules/setting/views/setting_view.dart | 29 +++++-------------- ui/flutter/lib/i18n/langs/en_us.dart | 1 + ui/flutter/lib/i18n/langs/zh_cn.dart | 1 + ui/flutter/lib/i18n/langs/zh_tw.dart | 1 + 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/ui/flutter/lib/app/modules/setting/views/setting_view.dart b/ui/flutter/lib/app/modules/setting/views/setting_view.dart index f9a0a546..4db941ba 100644 --- a/ui/flutter/lib/app/modules/setting/views/setting_view.dart +++ b/ui/flutter/lib/app/modules/setting/views/setting_view.dart @@ -428,14 +428,14 @@ class SettingView extends GetView { ); final arr = proxy.host.split(':'); - var ip = ''; + var host = ''; var port = ''; if (arr.length > 1) { - ip = arr[0]; + host = arr[0]; port = arr[1]; } - final ipController = TextEditingController(text: ip); + final ipController = TextEditingController(text: host); final portController = TextEditingController(text: port); updateAddress() async { final newAddress = '${ipController.text}:${portController.text}'; @@ -448,18 +448,14 @@ class SettingView extends GetView { ipController.addListener(updateAddress); portController.addListener(updateAddress); - final host = [ + final server = [ Flexible( child: TextFormField( controller: ipController, - decoration: const InputDecoration( - labelText: 'IP', - contentPadding: EdgeInsets.all(0.0), + decoration: InputDecoration( + labelText: 'server'.tr, + contentPadding: const EdgeInsets.all(0.0), ), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp('[0-9.]')), - ], ), ), const Padding(padding: EdgeInsets.only(left: 10)), @@ -490,10 +486,6 @@ class SettingView extends GetView { labelText: 'username'.tr, contentPadding: const EdgeInsets.all(0.0), ), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp('[0-9.]')), - ], ), ), const Padding(padding: EdgeInsets.only(left: 10)), @@ -504,11 +496,6 @@ class SettingView extends GetView { labelText: 'password'.tr, contentPadding: const EdgeInsets.all(0.0), ), - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - NumericalRangeFormatter(min: 0, max: 65535), - ], ), ), ]; @@ -520,7 +507,7 @@ class SettingView extends GetView { switcher, scheme, Row( - children: host, + children: server, ), Row( children: auth, diff --git a/ui/flutter/lib/i18n/langs/en_us.dart b/ui/flutter/lib/i18n/langs/en_us.dart index db9bebee..bb80d3d0 100644 --- a/ui/flutter/lib/i18n/langs/en_us.dart +++ b/ui/flutter/lib/i18n/langs/en_us.dart @@ -79,6 +79,7 @@ const enUS = { 'serviceText': 'Running', 'network': 'Network', 'proxy': 'Proxy', + 'server': 'Server', 'username': 'Username', 'password': 'Password', 'thanks': 'Thanks', diff --git a/ui/flutter/lib/i18n/langs/zh_cn.dart b/ui/flutter/lib/i18n/langs/zh_cn.dart index b9aa28c3..3d2c28b5 100644 --- a/ui/flutter/lib/i18n/langs/zh_cn.dart +++ b/ui/flutter/lib/i18n/langs/zh_cn.dart @@ -77,6 +77,7 @@ const zhCN = { 'serviceText': '运行中', 'network': '网络', 'proxy': '代理', + 'server': '服务器', 'username': '用户名', 'password': '密码', 'thanks': '鸣谢', diff --git a/ui/flutter/lib/i18n/langs/zh_tw.dart b/ui/flutter/lib/i18n/langs/zh_tw.dart index 0560869c..1e556f06 100644 --- a/ui/flutter/lib/i18n/langs/zh_tw.dart +++ b/ui/flutter/lib/i18n/langs/zh_tw.dart @@ -77,6 +77,7 @@ const zhTW = { 'serviceText': '執行中', 'network': '網路', 'proxy': '代理', + 'server': '伺服器', 'username': '名稱', 'password': '密碼', 'thanks': '鳴謝',