try fix mac textedit of server config (#10135)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-12-02 12:35:44 +08:00 committed by GitHub
parent 5a2a94d2cc
commit dc58c85e30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1362,11 +1362,30 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
bool locked = !isWeb && bind.mainIsInstalled(); bool locked = !isWeb && bind.mainIsInstalled();
final scrollController = ScrollController();
late final TextEditingController idController;
late final TextEditingController relayController;
late final TextEditingController apiController;
late final TextEditingController keyController;
@override
void initState() {
super.initState();
Map<String, dynamic> oldOptions = jsonDecode(bind.mainGetOptionsSync());
old(String key) {
return (oldOptions[key] ?? '').trim();
}
idController = TextEditingController(text: old('custom-rendezvous-server'));
relayController = TextEditingController(text: old('relay-server'));
apiController = TextEditingController(text: old('api-server'));
keyController = TextEditingController(text: old('key'));
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
bool enabled = !locked; bool enabled = !locked;
final scrollController = ScrollController();
final hideServer = final hideServer =
bind.mainGetBuildinOption(key: kOptionHideServerSetting) == 'Y'; bind.mainGetBuildinOption(key: kOptionHideServerSetting) == 'Y';
// TODO: support web proxy // TODO: support web proxy
@ -1395,19 +1414,10 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
// Simple temp wrapper for PR check // Simple temp wrapper for PR check
tmpWrapper() { tmpWrapper() {
// Setting page is not modal, oldOptions should only be used when getting options, never when setting. // Setting page is not modal, oldOptions should only be used when getting options, never when setting.
Map<String, dynamic> oldOptions = jsonDecode(bind.mainGetOptionsSync());
old(String key) {
return (oldOptions[key] ?? '').trim();
}
RxString idErrMsg = ''.obs; RxString idErrMsg = ''.obs;
RxString relayErrMsg = ''.obs; RxString relayErrMsg = ''.obs;
RxString apiErrMsg = ''.obs; RxString apiErrMsg = ''.obs;
var idController =
TextEditingController(text: old('custom-rendezvous-server'));
var relayController = TextEditingController(text: old('relay-server'));
var apiController = TextEditingController(text: old('api-server'));
var keyController = TextEditingController(text: old('key'));
final controllers = [ final controllers = [
idController, idController,
relayController, relayController,
@ -2251,26 +2261,39 @@ _LabeledTextField(
String errorText, String errorText,
bool enabled, bool enabled,
bool secure) { bool secure) {
return Row( return Table(
columnWidths: const {
0: FixedColumnWidth(150),
1: FlexColumnWidth(),
},
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: [ children: [
ConstrainedBox( TableRow(
constraints: const BoxConstraints(minWidth: 140), children: [
child: Text( Padding(
'${translate(label)}:', padding: const EdgeInsets.only(right: 10),
textAlign: TextAlign.right, child: Text(
style: TextStyle( '${translate(label)}:',
fontSize: 16, color: disabledTextColor(context, enabled)), textAlign: TextAlign.right,
).marginOnly(right: 10)), style: TextStyle(
Expanded( fontSize: 16,
child: TextField( color: disabledTextColor(context, enabled),
),
),
),
TextField(
controller: controller, controller: controller,
enabled: enabled, enabled: enabled,
obscureText: secure, obscureText: secure,
autocorrect: false,
decoration: InputDecoration( decoration: InputDecoration(
errorText: errorText.isNotEmpty ? errorText : null), errorText: errorText.isNotEmpty ? errorText : null,
),
style: TextStyle( style: TextStyle(
color: disabledTextColor(context, enabled), color: disabledTextColor(context, enabled),
)), ),
),
],
), ),
], ],
).marginOnly(bottom: 8); ).marginOnly(bottom: 8);