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

Merged
Hugo Bayer merged 1 commit from Hugo/124129012020/AddedSharedPreferencesTODO into master 2020-01-29 11:43:49 +00:00

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());
@ -74,33 +76,7 @@ class _ServerListState extends State<ServerList> {
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,
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.
);
}
@ -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);
});