All LocalStorage

This commit is contained in:
Aaron Fischer 2019-07-25 13:37:31 +02:00
parent 5068592189
commit 90587cd30a
5 changed files with 40 additions and 16 deletions

View file

@ -4,10 +4,13 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:preferences/preferences.dart'; import 'package:preferences/preferences.dart';
import 'package:toolheim/data/warband_roster.dart'; import 'package:localstorage/localstorage.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'package:toolheim/data/warband_roster.dart';
class GitHubAdapter extends ChangeNotifier { class GitHubAdapter extends ChangeNotifier {
final LocalStorage storage = new LocalStorage('rosters');
List<String> _syncErrors = new List<String>(); List<String> _syncErrors = new List<String>();
DateTime _lastSync; DateTime _lastSync;
@ -165,6 +168,8 @@ class GitHubAdapter extends ChangeNotifier {
roster.lastSyncVersion = roster.currentVersion; roster.lastSyncVersion = roster.currentVersion;
_rosters.add(roster); _rosters.add(roster);
//https://github.com/lesnitsky/flutter_localstorage/blob/master/example/lib/main.dart
storage.setItem(player['player'], roster);
notifyListeners(); notifyListeners();
} }
} catch (e) { } catch (e) {
@ -183,6 +188,7 @@ class GitHubAdapter extends ChangeNotifier {
_lastSync = DateTime.now(); _lastSync = DateTime.now();
_syncinProgress = false; _syncinProgress = false;
storage.setItem('lastSync', _lastSync);
notifyListeners(); notifyListeners();
} }

View file

@ -1,6 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:preferences/preferences.dart'; import 'package:preferences/preferences.dart';
// TODO: Add the search button here
// TODO: Display possible errors here
class SettingsScreen extends StatelessWidget { class SettingsScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -96,13 +96,13 @@ class WarbandDrawerWidget extends StatelessWidget {
// Show some stats for the own warband // Show some stats for the own warband
tiles.add(UserAccountsDrawerHeader( tiles.add(UserAccountsDrawerHeader(
otherAccountsPictures: <Widget>[ otherAccountsPictures: <Widget>[
IconButton( //IconButton(
icon: Icon(Icons.refresh), // icon: Icon(Icons.refresh),
color: Colors.white, // color: Colors.white,
highlightColor: Colors.brown, // highlightColor: Colors.brown,
tooltip: 'Refresh warbands', // tooltip: 'Refresh warbands',
onPressed: github.update, // onPressed: github.update,
), //),
IconButton( IconButton(
icon: Icon(Icons.search), icon: Icon(Icons.search),
color: Colors.white, color: Colors.white,

View file

@ -7,7 +7,7 @@ packages:
name: analyzer name: analyzer
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.36.4" version: "0.37.0"
args: args:
dependency: transitive dependency: transitive
description: description:
@ -56,7 +56,7 @@ packages:
name: build_daemon name: build_daemon
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "2.0.0"
build_resolvers: build_resolvers:
dependency: transitive dependency: transitive
description: description:
@ -70,7 +70,7 @@ packages:
name: build_runner name: build_runner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.1" version: "1.6.2"
build_runner_core: build_runner_core:
dependency: transitive dependency: transitive
description: description:
@ -178,7 +178,7 @@ packages:
name: front_end name: front_end
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.19" version: "0.1.20"
glob: glob:
dependency: transitive dependency: transitive
description: description:
@ -248,14 +248,21 @@ packages:
name: json_serializable name: json_serializable
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.1.0"
kernel: kernel:
dependency: transitive dependency: transitive
description: description:
name: kernel name: kernel
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted 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: logging:
dependency: transitive dependency: transitive
description: description:
@ -305,6 +312,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.2" version: "1.6.2"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
@ -360,7 +374,7 @@ packages:
name: shared_preferences name: shared_preferences
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.5.3+2" version: "0.5.3+4"
shelf: shelf:
dependency: transitive dependency: transitive
description: description:
@ -386,7 +400,7 @@ packages:
name: source_gen name: source_gen
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.9.4+2" version: "0.9.4+3"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:

View file

@ -26,6 +26,7 @@ dependencies:
badges: badges:
shared_preferences: shared_preferences:
preferences: preferences:
localstorage:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.