fix TextField cursor problem
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
6ea16e4cdb
commit
b004f4b9ee
@ -806,6 +806,8 @@ Future<bool> loginDialog() async {
|
|||||||
var userNameMsg = "";
|
var userNameMsg = "";
|
||||||
String pass = "";
|
String pass = "";
|
||||||
var passMsg = "";
|
var passMsg = "";
|
||||||
|
var userContontroller = TextEditingController(text: userName);
|
||||||
|
var pwdController = TextEditingController(text: pass);
|
||||||
|
|
||||||
var isInProgress = false;
|
var isInProgress = false;
|
||||||
var completer = Completer<bool>();
|
var completer = Completer<bool>();
|
||||||
@ -833,13 +835,10 @@ Future<bool> loginDialog() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
userName = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText: userNameMsg.isNotEmpty ? userNameMsg : null),
|
errorText: userNameMsg.isNotEmpty ? userNameMsg : null),
|
||||||
controller: TextEditingController(text: userName),
|
controller: userContontroller,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -859,13 +858,10 @@ Future<bool> loginDialog() async {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
onChanged: (s) {
|
|
||||||
pass = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText: passMsg.isNotEmpty ? passMsg : null),
|
errorText: passMsg.isNotEmpty ? passMsg : null),
|
||||||
controller: TextEditingController(text: pass),
|
controller: pwdController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -896,8 +892,8 @@ Future<bool> loginDialog() async {
|
|||||||
isInProgress = false;
|
isInProgress = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
userName = userName;
|
userName = userContontroller.text;
|
||||||
pass = pass;
|
pass = pwdController.text;
|
||||||
if (userName.isEmpty) {
|
if (userName.isEmpty) {
|
||||||
userNameMsg = translate("Username missed");
|
userNameMsg = translate("Username missed");
|
||||||
cancel();
|
cancel();
|
||||||
|
@ -1025,7 +1025,6 @@ class _ComboBox extends StatelessWidget {
|
|||||||
|
|
||||||
void changeServer() async {
|
void changeServer() async {
|
||||||
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
|
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
|
||||||
print("${oldOptions}");
|
|
||||||
String idServer = oldOptions['custom-rendezvous-server'] ?? "";
|
String idServer = oldOptions['custom-rendezvous-server'] ?? "";
|
||||||
var idServerMsg = "";
|
var idServerMsg = "";
|
||||||
String relayServer = oldOptions['relay-server'] ?? "";
|
String relayServer = oldOptions['relay-server'] ?? "";
|
||||||
@ -1033,6 +1032,10 @@ void changeServer() async {
|
|||||||
String apiServer = oldOptions['api-server'] ?? "";
|
String apiServer = oldOptions['api-server'] ?? "";
|
||||||
var apiServerMsg = "";
|
var apiServerMsg = "";
|
||||||
var key = oldOptions['key'] ?? "";
|
var key = oldOptions['key'] ?? "";
|
||||||
|
var idController = TextEditingController(text: idServer);
|
||||||
|
var relayController = TextEditingController(text: relayServer);
|
||||||
|
var apiController = TextEditingController(text: apiServer);
|
||||||
|
var keyController = TextEditingController(text: key);
|
||||||
|
|
||||||
var isInProgress = false;
|
var isInProgress = false;
|
||||||
gFFI.dialogManager.show((setState, close) {
|
gFFI.dialogManager.show((setState, close) {
|
||||||
@ -1057,13 +1060,10 @@ void changeServer() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
idServer = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText: idServerMsg.isNotEmpty ? idServerMsg : null),
|
errorText: idServerMsg.isNotEmpty ? idServerMsg : null),
|
||||||
controller: TextEditingController(text: idServer),
|
controller: idController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1082,14 +1082,11 @@ void changeServer() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
relayServer = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText:
|
errorText:
|
||||||
relayServerMsg.isNotEmpty ? relayServerMsg : null),
|
relayServerMsg.isNotEmpty ? relayServerMsg : null),
|
||||||
controller: TextEditingController(text: relayServer),
|
controller: relayController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1108,14 +1105,11 @@ void changeServer() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
apiServer = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText:
|
errorText:
|
||||||
apiServerMsg.isNotEmpty ? apiServerMsg : null),
|
apiServerMsg.isNotEmpty ? apiServerMsg : null),
|
||||||
controller: TextEditingController(text: apiServer),
|
controller: apiController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1134,13 +1128,10 @@ void changeServer() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
key = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
),
|
),
|
||||||
controller: TextEditingController(text: key),
|
controller: keyController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1171,10 +1162,10 @@ void changeServer() async {
|
|||||||
isInProgress = false;
|
isInProgress = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
idServer = idServer.trim();
|
idServer = idController.text.trim();
|
||||||
relayServer = relayServer.trim();
|
relayServer = relayController.text.trim();
|
||||||
apiServer = apiServer.trim();
|
apiServer = apiController.text.trim().toLowerCase();
|
||||||
key = key.trim();
|
key = keyController.text.trim();
|
||||||
|
|
||||||
if (idServer.isNotEmpty) {
|
if (idServer.isNotEmpty) {
|
||||||
idServerMsg = translate(
|
idServerMsg = translate(
|
||||||
@ -1230,6 +1221,7 @@ void changeWhiteList() async {
|
|||||||
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
|
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
|
||||||
var newWhiteList = ((oldOptions['whitelist'] ?? "") as String).split(',');
|
var newWhiteList = ((oldOptions['whitelist'] ?? "") as String).split(',');
|
||||||
var newWhiteListField = newWhiteList.join('\n');
|
var newWhiteListField = newWhiteList.join('\n');
|
||||||
|
var controller = TextEditingController(text: newWhiteListField);
|
||||||
var msg = "";
|
var msg = "";
|
||||||
var isInProgress = false;
|
var isInProgress = false;
|
||||||
gFFI.dialogManager.show((setState, close) {
|
gFFI.dialogManager.show((setState, close) {
|
||||||
@ -1246,15 +1238,12 @@ void changeWhiteList() async {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
newWhiteListField = s;
|
|
||||||
},
|
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText: msg.isEmpty ? null : translate(msg),
|
errorText: msg.isEmpty ? null : translate(msg),
|
||||||
),
|
),
|
||||||
controller: TextEditingController(text: newWhiteListField),
|
controller: controller,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1277,7 +1266,7 @@ void changeWhiteList() async {
|
|||||||
msg = "";
|
msg = "";
|
||||||
isInProgress = true;
|
isInProgress = true;
|
||||||
});
|
});
|
||||||
newWhiteListField = newWhiteListField.trim();
|
newWhiteListField = controller.text.trim();
|
||||||
var newWhiteList = "";
|
var newWhiteList = "";
|
||||||
if (newWhiteListField.isEmpty) {
|
if (newWhiteListField.isEmpty) {
|
||||||
// pass
|
// pass
|
||||||
@ -1319,6 +1308,9 @@ void changeSocks5Proxy() async {
|
|||||||
username = socks[1];
|
username = socks[1];
|
||||||
password = socks[2];
|
password = socks[2];
|
||||||
}
|
}
|
||||||
|
var proxyController = TextEditingController(text: proxy);
|
||||||
|
var userController = TextEditingController(text: username);
|
||||||
|
var pwdController = TextEditingController(text: password);
|
||||||
|
|
||||||
var isInProgress = false;
|
var isInProgress = false;
|
||||||
gFFI.dialogManager.show((setState, close) {
|
gFFI.dialogManager.show((setState, close) {
|
||||||
@ -1343,13 +1335,10 @@ void changeSocks5Proxy() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
proxy = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
errorText: proxyMsg.isNotEmpty ? proxyMsg : null),
|
errorText: proxyMsg.isNotEmpty ? proxyMsg : null),
|
||||||
controller: TextEditingController(text: proxy),
|
controller: proxyController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1368,13 +1357,10 @@ void changeSocks5Proxy() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
username = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
),
|
),
|
||||||
controller: TextEditingController(text: username),
|
controller: userController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1393,13 +1379,10 @@ void changeSocks5Proxy() async {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (s) {
|
|
||||||
password = s;
|
|
||||||
},
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
),
|
),
|
||||||
controller: TextEditingController(text: password),
|
controller: pwdController,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -1428,9 +1411,9 @@ void changeSocks5Proxy() async {
|
|||||||
isInProgress = false;
|
isInProgress = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
proxy = proxy.trim();
|
proxy = proxyController.text.trim();
|
||||||
username = username.trim();
|
username = userController.text.trim();
|
||||||
password = password.trim();
|
password = pwdController.text.trim();
|
||||||
|
|
||||||
if (proxy.isNotEmpty) {
|
if (proxy.isNotEmpty) {
|
||||||
proxyMsg =
|
proxyMsg =
|
||||||
|
@ -462,6 +462,7 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
void _rename(String id) async {
|
void _rename(String id) async {
|
||||||
var isInProgress = false;
|
var isInProgress = false;
|
||||||
var name = await bind.mainGetPeerOption(id: id, key: 'alias');
|
var name = await bind.mainGetPeerOption(id: id, key: 'alias');
|
||||||
|
var controller = TextEditingController(text: name);
|
||||||
if (widget.type == PeerType.ab) {
|
if (widget.type == PeerType.ab) {
|
||||||
final peer = gFFI.abModel.peers.firstWhere((p) => id == p['id']);
|
final peer = gFFI.abModel.peers.firstWhere((p) => id == p['id']);
|
||||||
if (peer == null) {
|
if (peer == null) {
|
||||||
@ -470,7 +471,6 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
name = peer['alias'] ?? "";
|
name = peer['alias'] ?? "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final k = GlobalKey<FormState>();
|
|
||||||
gFFI.dialogManager.show((setState, close) {
|
gFFI.dialogManager.show((setState, close) {
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate("Rename")),
|
title: Text(translate("Rename")),
|
||||||
@ -480,22 +480,9 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: k,
|
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: TextEditingController(text: name),
|
controller: controller,
|
||||||
decoration: InputDecoration(border: OutlineInputBorder()),
|
decoration: InputDecoration(border: OutlineInputBorder()),
|
||||||
onChanged: (newStr) {
|
|
||||||
name = newStr;
|
|
||||||
},
|
|
||||||
validator: (s) {
|
|
||||||
if (s == null || s.isEmpty) {
|
|
||||||
return translate("Empty");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
onSaved: (s) {
|
|
||||||
name = s ?? "unnamed";
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -513,22 +500,17 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
setState(() {
|
setState(() {
|
||||||
isInProgress = true;
|
isInProgress = true;
|
||||||
});
|
});
|
||||||
if (k.currentState != null) {
|
name = controller.text;
|
||||||
if (k.currentState!.validate()) {
|
await bind.mainSetPeerOption(id: id, key: 'alias', value: name);
|
||||||
k.currentState!.save();
|
if (widget.type == PeerType.ab) {
|
||||||
await bind.mainSetPeerOption(
|
gFFI.abModel.setPeerOption(id, 'alias', name);
|
||||||
id: id, key: 'alias', value: name);
|
await gFFI.abModel.updateAb();
|
||||||
if (widget.type == PeerType.ab) {
|
} else {
|
||||||
gFFI.abModel.setPeerOption(id, 'alias', name);
|
Future.delayed(Duration.zero, () {
|
||||||
await gFFI.abModel.updateAb();
|
this.setState(() {});
|
||||||
} else {
|
});
|
||||||
Future.delayed(Duration.zero, () {
|
|
||||||
this.setState(() {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
close();
|
||||||
setState(() {
|
setState(() {
|
||||||
isInProgress = false;
|
isInProgress = false;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user