~repos /only-bible-app

#kotlin#android#ios

git clone https://pyrossh.dev/repos/only-bible-app.git

The only bible app you will ever need. No ads. No in-app purchases. No distractions.


5afa081e pyrossh

2 years ago
save app model
Files changed (1) hide show
  1. lib/state.dart +10 -8
lib/state.dart CHANGED
@@ -23,11 +23,12 @@ class AppModel extends ChangeNotifier {
23
23
  return Provider.of(context, listen: false);
24
24
  }
25
25
 
26
- save(int bibleId) async {
26
+ save() async {
27
27
  final prefs = await SharedPreferences.getInstance();
28
- prefs.setInt("bibleId", bibleId);
28
+ await prefs.setInt("bibleId", bible.id);
29
- // save darkTheme
29
+ await prefs.setBool("darkMode", darkMode);
30
- // save fontBold
30
+ await prefs.setBool("fontBold", fontBold);
31
+ await prefs.setInt("fontSizeDelta", fontSizeDelta);
31
32
  }
32
33
 
33
34
  Future<(int, int)> loadData() async {
@@ -58,13 +59,14 @@ class AppModel extends ChangeNotifier {
58
59
  // TODO: maybe use a future as the bible needs to load
59
60
  bible = await loadBible(id);
60
61
  notifyListeners();
62
+ save();
61
63
  }
62
64
 
63
65
  toggleMode() async {
64
66
  darkMode = !darkMode;
65
67
  updateStatusBar();
66
68
  notifyListeners();
67
- (await SharedPreferences.getInstance()).setBool("darkMode", darkMode);
69
+ save();
68
70
  }
69
71
 
70
72
  updateStatusBar() {
@@ -88,19 +90,19 @@ class AppModel extends ChangeNotifier {
88
90
  toggleBold() async {
89
91
  fontBold = !fontBold;
90
92
  notifyListeners();
91
- (await SharedPreferences.getInstance()).setBool("fontBold", fontBold);
93
+ save();
92
94
  }
93
95
 
94
96
  increaseFont() async {
95
97
  fontSizeDelta += 1;
96
98
  notifyListeners();
97
- (await SharedPreferences.getInstance()).setInt("fontSizeDelta", fontSizeDelta);
99
+ save();
98
100
  }
99
101
 
100
102
  decreaseFont() async {
101
103
  fontSizeDelta -= 1;
102
104
  notifyListeners();
103
- (await SharedPreferences.getInstance()).setInt("fontSizeDelta", fontSizeDelta);
105
+ save();
104
106
  }
105
107
  }
106
108