~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.
e892205b
—
pyrossh 2 years ago
move navigation to state
- lib/routes/home_screen.dart +2 -16
- lib/state.dart +27 -1
lib/routes/home_screen.dart
CHANGED
|
@@ -20,24 +20,10 @@ class HomeScreen extends GoRouteData {
|
|
|
20
20
|
return NoTransitionPage(
|
|
21
21
|
child: SwipeDetector(
|
|
22
22
|
onSwipeLeft: (offset) {
|
|
23
|
-
if (selectedBook.chapters.length > chapter + 1) {
|
|
24
|
-
navigateBookChapter(context, selectedBook.index, chapter + 1);
|
|
25
|
-
} else {
|
|
26
|
-
if (selectedBook.index + 1 < selectedBible.value.length) {
|
|
27
|
-
final nextBook = selectedBible.value[selectedBook.index + 1];
|
|
28
|
-
|
|
23
|
+
onNext(context);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
24
|
},
|
|
32
25
|
onSwipeRight: (offset) {
|
|
33
|
-
|
|
26
|
+
onPrevious(context);
|
|
34
|
-
navigateBookChapter(context, selectedBook.index, chapter - 1);
|
|
35
|
-
} else {
|
|
36
|
-
if (selectedBook.index - 1 >= 0) {
|
|
37
|
-
final prevBook = selectedBible.value[selectedBook.index - 1];
|
|
38
|
-
navigateBookChapter(context, prevBook.index, prevBook.chapters.length - 1);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
27
|
},
|
|
42
28
|
child: Container(
|
|
43
29
|
margin: EdgeInsets.symmetric(
|
lib/state.dart
CHANGED
|
@@ -80,6 +80,32 @@ navigateBookChapter(BuildContext context, int book, int chapter) {
|
|
|
80
80
|
context.push("/${selectedBible.value[book].name}/$chapter");
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
onNext(BuildContext context) {
|
|
84
|
+
final selectedBook = selectedBible.value[bookIndex.value];
|
|
85
|
+
final chapter = chapterIndex.value;
|
|
86
|
+
if (selectedBook.chapters.length > chapter + 1) {
|
|
87
|
+
navigateBookChapter(context, selectedBook.index, chapter + 1);
|
|
88
|
+
} else {
|
|
89
|
+
if (selectedBook.index + 1 < selectedBible.value.length) {
|
|
90
|
+
final nextBook = selectedBible.value[selectedBook.index + 1];
|
|
91
|
+
navigateBookChapter(context, nextBook.index, 0);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onPrevious(BuildContext context) {
|
|
97
|
+
final selectedBook = selectedBible.value[bookIndex.value];
|
|
98
|
+
final chapter = chapterIndex.value;
|
|
99
|
+
if (chapter - 1 >= 0) {
|
|
100
|
+
navigateBookChapter(context, selectedBook.index, chapter - 1);
|
|
101
|
+
} else {
|
|
102
|
+
if (selectedBook.index - 1 >= 0) {
|
|
103
|
+
final prevBook = selectedBible.value[selectedBook.index - 1];
|
|
104
|
+
navigateBookChapter(context, prevBook.index, prevBook.chapters.length - 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
83
109
|
loadBible() async {
|
|
84
110
|
final value = await getBibleFromAsset(selectedBibleName.value);
|
|
85
111
|
selectedBible.value = value;
|
|
@@ -133,7 +159,7 @@ onPlay(BuildContext context) async {
|
|
|
133
159
|
final filteredVerses = verses.asMap().keys.where((it) => selectedVerses.value.contains(it)).map((it) => verses[it]);
|
|
134
160
|
final player = AudioPlayer();
|
|
135
161
|
player.setUrl(
|
|
136
|
-
"https://github.com/pyrossh/bible-app/raw/master/
|
|
162
|
+
"https://github.com/pyrossh/only-bible-app/raw/master/assets/output.mp3",
|
|
137
163
|
);
|
|
138
164
|
// player.setUrl("asset:output.mp3");
|
|
139
165
|
if (isPlaying.value) {
|