diff --git a/lib/serverlist.dart b/lib/serverlist.dart index 50e3a6e..7a45bce 100644 --- a/lib/serverlist.dart +++ b/lib/serverlist.dart @@ -212,6 +212,70 @@ class _ServerListState extends State { }); } + void _modifyServerForm(Server server){ + TextEditingController servername = TextEditingController(text: server.displayName); + TextEditingController uri = TextEditingController(text: server.uri); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Adding a server'), + content: SingleChildScrollView( + child: Form( + key: _formKey, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + 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 _createChildren() { List list = new List.generate(servers.length, (int index) { Widget info = Row(children: [ @@ -313,7 +377,7 @@ class _ServerListState extends State { color: Colors.grey, ), onPressed: () { - _removeServer(index); + _modifyServerForm(servers[index]); }, ), ]), @@ -326,7 +390,6 @@ class _ServerListState extends State { setState(() { selectedServer = index; }); - print(index.toString() + " clicked"); }, child: Container( width: MediaQuery.of(context).size.width,