This commit is contained in:
open-trade 2020-11-26 00:47:52 +08:00
parent ae6198813c
commit 11796de5d7

View File

@ -210,22 +210,46 @@ class _HomePageState extends State<HomePage> {
} }
void showServer(BuildContext context) { void showServer(BuildContext context) {
final formKey = GlobalKey<FormState>();
var id = '';
var relay = '';
showAlertDialog( showAlertDialog(
context, context,
(setState) => Tuple3( (setState) => Tuple3(
Text('ID/Relay Server'), Text('ID/Relay Server'),
Form(
key: formKey,
child:
Column(mainAxisSize: MainAxisSize.min, children: <Widget>[ Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
TextFormField( TextFormField(
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'ID Server', labelText: 'ID Server',
), ),
validator: (value) {
if (value.isEmpty) {
return 'Please enter valid server address';
}
return null;
},
onSaved: (String value) {
id = value;
},
), ),
TextFormField( TextFormField(
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Relay Server', labelText: 'Relay Server',
), ),
validator: (value) {
if (value.isEmpty) {
return 'Please enter valid server address';
}
return null;
},
onSaved: (String value) {
relay = value;
},
), ),
]), ])),
[ [
FlatButton( FlatButton(
textColor: MyTheme.accent, textColor: MyTheme.accent,
@ -237,7 +261,10 @@ void showServer(BuildContext context) {
FlatButton( FlatButton(
textColor: MyTheme.accent, textColor: MyTheme.accent,
onPressed: () { onPressed: () {
if (formKey.currentState.validate()) {
formKey.currentState.save();
Navigator.pop(context); Navigator.pop(context);
}
}, },
child: Text('OK'), child: Text('OK'),
), ),