Added shared preferences todo where it has to be saved, deleted and loaded #26

Merged
Hugo Bayer merged 1 commits from Hugo/124129012020/AddedSharedPreferencesTODO into master 2020-01-29 11:43:49 +00:00
1 changed files with 16 additions and 38 deletions

View File

@ -46,6 +46,8 @@ class _ServerListState extends State<ServerList> {
void initState() {
super.initState();
// TODO: load shared preferences
_updateAllServers();
timer = new Timer.periodic(
new Duration(seconds: 30), (_) => _updateAllServers());
@ -62,46 +64,20 @@ class _ServerListState extends State<ServerList> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: _createChildren(),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: _createChildren(),
),
),
floatingActionButton: FloatingActionButton(
shape: CircleBorder(),
child: Icon(Icons.settings),
)
/*SpeedDial(
animatedIcon: AnimatedIcons.menu_close,
animatedIconTheme: IconThemeData(size: 20.0),
animationSpeed: 50,
tooltip: 'Menu',
backgroundColor: Colors.red.shade900,
foregroundColor: Colors.white,
),
floatingActionButton: FloatingActionButton(
shape: CircleBorder(),
children: [
SpeedDialChild(
child: Icon(Icons.settings),
label: 'Settings',
backgroundColor: Colors.red.shade600,
foregroundColor: Colors.white,
labelStyle: TextStyle(fontSize: 18.0),
onTap: _settings,
),
SpeedDialChild(
child: Icon(Icons.add),
label: 'Add server',
backgroundColor: Colors.red.shade600,
foregroundColor: Colors.white,
labelStyle: TextStyle(fontSize: 18.0),
onTap: _addServer,
),
],*/ // This trailing comma makes auto-formatting nicer for build methods.
);
child: Icon(Icons.settings),
),
);
}
void _settings() {}
@ -162,6 +138,7 @@ class _ServerListState extends State<ServerList> {
}
void _addServer(String customName, String uri) {
// TODO: add to shared preferences
Server server = Server(customName, uri);
servers.add(server);
_updateServerStatus(server);
@ -169,6 +146,7 @@ class _ServerListState extends State<ServerList> {
}
void _removeServer(int index) {
// TODO: remove from shared preferences
setState(() {
servers.removeAt(index);
});