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() { void initState() {
super.initState(); super.initState();
// TODO: load shared preferences
_updateAllServers(); _updateAllServers();
timer = new Timer.periodic( timer = new Timer.periodic(
new Duration(seconds: 30), (_) => _updateAllServers()); new Duration(seconds: 30), (_) => _updateAllServers());
@ -62,46 +64,20 @@ class _ServerListState extends State<ServerList> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.title), title: Text(widget.title),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: _createChildren(),
), ),
body: SingleChildScrollView( ),
child: Column( floatingActionButton: FloatingActionButton(
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,
shape: CircleBorder(), shape: CircleBorder(),
children: [ child: Icon(Icons.settings),
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.
);
} }
void _settings() {} void _settings() {}
@ -162,6 +138,7 @@ class _ServerListState extends State<ServerList> {
} }
void _addServer(String customName, String uri) { void _addServer(String customName, String uri) {
// TODO: add to shared preferences
Server server = Server(customName, uri); Server server = Server(customName, uri);
servers.add(server); servers.add(server);
_updateServerStatus(server); _updateServerStatus(server);
@ -169,6 +146,7 @@ class _ServerListState extends State<ServerList> {
} }
void _removeServer(int index) { void _removeServer(int index) {
// TODO: remove from shared preferences
setState(() { setState(() {
servers.removeAt(index); servers.removeAt(index);
}); });