~repos /only-bible-app
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.
10bedde4
—
pyrossh 2 years ago
fix selected verses
- lib/sheets/actions_sheet.dart +1 -1
- lib/store/actions.dart +4 -3
- lib/store/state.dart +10 -10
lib/sheets/actions_sheet.dart
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "package:flutter/material.dart";
|
|
2
2
|
import "package:only_bible_app/models.dart";
|
|
3
3
|
import "package:only_bible_app/navigation.dart";
|
|
4
|
-
import
|
|
4
|
+
import "package:only_bible_app/store/state.dart";
|
|
5
5
|
import "package:only_bible_app/utils.dart";
|
|
6
6
|
|
|
7
7
|
class ActionsSheet extends StatelessWidget {
|
lib/store/actions.dart
CHANGED
|
@@ -36,12 +36,13 @@ class SetPlaying implements AppAction {
|
|
|
36
36
|
const SetPlaying(this.value);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
class
|
|
39
|
+
class SelectVerse implements AppAction {
|
|
40
|
-
final
|
|
40
|
+
final Verse verse;
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const SelectVerse(this.verse);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
|
|
45
46
|
class ClearSelectedVerses implements AppAction {
|
|
46
47
|
const ClearSelectedVerses();
|
|
47
48
|
}
|
lib/store/state.dart
CHANGED
|
@@ -144,15 +144,19 @@ final isPlaying = Atom(
|
|
|
144
144
|
},
|
|
145
145
|
);
|
|
146
146
|
|
|
147
|
-
final selectedVersesAtom = Atom(
|
|
147
|
+
final selectedVersesAtom = Atom<List<Verse>, AppAction>(
|
|
148
148
|
key: "selectedVerses",
|
|
149
|
-
initialState:
|
|
149
|
+
initialState: [],
|
|
150
150
|
reducer: (state, action) {
|
|
151
|
-
if (action is
|
|
151
|
+
if (action is SelectVerse) {
|
|
152
|
-
|
|
152
|
+
if (isVerseSelected(action.verse)) {
|
|
153
|
+
return (state as List<Verse>).removeBy((it) => it.index == action.verse.index).toList();
|
|
154
|
+
} else {
|
|
155
|
+
return (state as List<Verse>).addBy(action.verse).toList();
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
if (action is ClearSelectedVerses) {
|
|
155
|
-
return [];
|
|
159
|
+
return List<Verse>.from([]);
|
|
156
160
|
}
|
|
157
161
|
return state;
|
|
158
162
|
},
|
|
@@ -199,11 +203,7 @@ bool watchVerseSelected(BuildContext context, Verse v) {
|
|
|
199
203
|
}
|
|
200
204
|
|
|
201
205
|
void onVerseSelected(BuildContext context, Bible bible, Verse v) {
|
|
202
|
-
|
|
206
|
+
dispatch(SelectVerse(v));
|
|
203
|
-
dispatch(SetSelectedVerses(selectedVersesAtom.value.removeBy((it) => it.index == v.index).toList()));
|
|
204
|
-
} else {
|
|
205
|
-
dispatch(SetSelectedVerses(selectedVersesAtom.value.addBy(v).toList()));
|
|
206
|
-
}
|
|
207
207
|
if (selectedVersesAtom.value.isNotEmpty) {
|
|
208
208
|
showActions(context, bible);
|
|
209
209
|
}
|