From 90587cd30a2b4926a253a70bfc0cd656d2a50902 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Thu, 25 Jul 2019 13:37:31 +0200 Subject: [PATCH] All LocalStorage --- mobile-app/lib/data/github_adapter.dart | 8 ++++- mobile-app/lib/screens/settings_screen.dart | 3 ++ .../lib/widgets/warband_drawer_widget.dart | 14 ++++----- mobile-app/pubspec.lock | 30 ++++++++++++++----- mobile-app/pubspec.yaml | 1 + 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/mobile-app/lib/data/github_adapter.dart b/mobile-app/lib/data/github_adapter.dart index 43d65c9..4a92c2d 100644 --- a/mobile-app/lib/data/github_adapter.dart +++ b/mobile-app/lib/data/github_adapter.dart @@ -4,10 +4,13 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:preferences/preferences.dart'; -import 'package:toolheim/data/warband_roster.dart'; +import 'package:localstorage/localstorage.dart'; import 'package:yaml/yaml.dart'; +import 'package:toolheim/data/warband_roster.dart'; class GitHubAdapter extends ChangeNotifier { + final LocalStorage storage = new LocalStorage('rosters'); + List _syncErrors = new List(); DateTime _lastSync; @@ -165,6 +168,8 @@ class GitHubAdapter extends ChangeNotifier { roster.lastSyncVersion = roster.currentVersion; _rosters.add(roster); + //https://github.com/lesnitsky/flutter_localstorage/blob/master/example/lib/main.dart + storage.setItem(player['player'], roster); notifyListeners(); } } catch (e) { @@ -183,6 +188,7 @@ class GitHubAdapter extends ChangeNotifier { _lastSync = DateTime.now(); _syncinProgress = false; + storage.setItem('lastSync', _lastSync); notifyListeners(); } diff --git a/mobile-app/lib/screens/settings_screen.dart b/mobile-app/lib/screens/settings_screen.dart index 11d1591..7ddce05 100644 --- a/mobile-app/lib/screens/settings_screen.dart +++ b/mobile-app/lib/screens/settings_screen.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart'; import 'package:preferences/preferences.dart'; +// TODO: Add the search button here +// TODO: Display possible errors here + class SettingsScreen extends StatelessWidget { @override Widget build(BuildContext context) { diff --git a/mobile-app/lib/widgets/warband_drawer_widget.dart b/mobile-app/lib/widgets/warband_drawer_widget.dart index d58447f..6893e67 100644 --- a/mobile-app/lib/widgets/warband_drawer_widget.dart +++ b/mobile-app/lib/widgets/warband_drawer_widget.dart @@ -96,13 +96,13 @@ class WarbandDrawerWidget extends StatelessWidget { // Show some stats for the own warband tiles.add(UserAccountsDrawerHeader( otherAccountsPictures: [ - IconButton( - icon: Icon(Icons.refresh), - color: Colors.white, - highlightColor: Colors.brown, - tooltip: 'Refresh warbands', - onPressed: github.update, - ), + //IconButton( + // icon: Icon(Icons.refresh), + // color: Colors.white, + // highlightColor: Colors.brown, + // tooltip: 'Refresh warbands', + // onPressed: github.update, + //), IconButton( icon: Icon(Icons.search), color: Colors.white, diff --git a/mobile-app/pubspec.lock b/mobile-app/pubspec.lock index a02211f..a0094e8 100644 --- a/mobile-app/pubspec.lock +++ b/mobile-app/pubspec.lock @@ -7,7 +7,7 @@ packages: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.36.4" + version: "0.37.0" args: dependency: transitive description: @@ -56,7 +56,7 @@ packages: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.0.0" build_resolvers: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.6.1" + version: "1.6.2" build_runner_core: dependency: transitive description: @@ -178,7 +178,7 @@ packages: name: front_end url: "https://pub.dartlang.org" source: hosted - version: "0.1.19" + version: "0.1.20" glob: dependency: transitive description: @@ -248,14 +248,21 @@ packages: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" kernel: dependency: transitive description: name: kernel url: "https://pub.dartlang.org" source: hosted - version: "0.3.19" + version: "0.3.20" + localstorage: + dependency: "direct main" + description: + name: localstorage + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" logging: dependency: transitive description: @@ -305,6 +312,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.2" + path_provider: + dependency: transitive + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" pedantic: dependency: transitive description: @@ -360,7 +374,7 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.3+2" + version: "0.5.3+4" shelf: dependency: transitive description: @@ -386,7 +400,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.4+2" + version: "0.9.4+3" source_span: dependency: transitive description: diff --git a/mobile-app/pubspec.yaml b/mobile-app/pubspec.yaml index 7ee304b..dc4ccd7 100644 --- a/mobile-app/pubspec.yaml +++ b/mobile-app/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: badges: shared_preferences: preferences: + localstorage: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.