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'),
Column(mainAxisSize: MainAxisSize.min, children: <Widget>[ Form(
TextFormField( key: formKey,
decoration: InputDecoration( child:
labelText: 'ID Server', Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
), TextFormField(
), decoration: InputDecoration(
TextFormField( labelText: 'ID Server',
decoration: InputDecoration( ),
labelText: 'Relay Server', validator: (value) {
), if (value.isEmpty) {
), return 'Please enter valid server address';
]), }
return null;
},
onSaved: (String value) {
id = value;
},
),
TextFormField(
decoration: InputDecoration(
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: () {
Navigator.pop(context); if (formKey.currentState.validate()) {
formKey.currentState.save();
Navigator.pop(context);
}
}, },
child: Text('OK'), child: Text('OK'),
), ),