Added the abillity to edit an existing Server #19

Merged
Hugo Bayer merged 1 commit from Hugo/111129012020/AddedTheAbilityToEditTheServer into master 2020-01-29 10:12:13 +00:00

View file

@ -199,6 +199,69 @@ class _ServerListState extends State<ServerList> {
});
}
void _modifyServerForm(Server server){
TextEditingController servername = TextEditingController(text: server.displayName);
TextEditingController uri = TextEditingController(text: server.uri);
showDialog<String>(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Adding a server'),
content: SingleChildScrollView(
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: 'Custom Name',
),
controller: servername,
),
TextFormField(
controller: uri,
decoration: InputDecoration(
labelText: 'URI',
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(children: [
Expanded(
child: RaisedButton(
child: Text("Confirm"),
onPressed: () {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
Navigator.of(context).pop();
}
},
),
),
RaisedButton(
child: Text("Confirm"),
onPressed: () {
if (_formKey.currentState.validate()) {
_formKey.currentState.save();
setState(() {
server.displayName=servername.text;
server.uri = uri.text;
});
Navigator.of(context).pop();
}
},
)
]),
)
],
),
),
),
);
},
);
}
List<Widget> _createChildren() {
List<Widget> list = new List<Widget>.generate(servers.length, (int index) {
Widget info = Row(children: [