~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.
1acf4f30
—
pyrossh 2 years ago
add page transitions
- lib/routes/home_screen.dart +27 -25
- lib/state.dart +9 -2
lib/routes/home_screen.dart
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "package:flutter/material.dart";
|
|
2
2
|
import 'package:flutter_swipe_detector/flutter_swipe_detector.dart';
|
|
3
3
|
import 'package:go_router/go_router.dart';
|
|
4
|
-
import 'package:only_bible_app/components/header.dart';
|
|
5
4
|
import 'package:only_bible_app/components/verse_view.dart';
|
|
6
5
|
import 'package:only_bible_app/state.dart';
|
|
7
6
|
|
|
@@ -17,7 +16,19 @@ class HomeScreen extends GoRouteData {
|
|
|
17
16
|
Page buildPage(BuildContext context, GoRouterState state) {
|
|
18
17
|
final selectedBook = selectedBible.value.firstWhere((it) => book == it.name);
|
|
19
18
|
final verses = selectedBook.chapters[chapter].verses;
|
|
20
|
-
return
|
|
19
|
+
return CustomTransitionPage(
|
|
20
|
+
barrierDismissible: false,
|
|
21
|
+
barrierColor: Theme.of(context).colorScheme.background,
|
|
22
|
+
transitionDuration: const Duration(milliseconds: 360),
|
|
23
|
+
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
24
|
+
return SlideTransition(
|
|
25
|
+
textDirection: slideTextDir.value,
|
|
26
|
+
position: Tween(begin: const Offset(1, 0), end: Offset.zero)
|
|
27
|
+
.chain(CurveTween(curve: Curves.linear))
|
|
28
|
+
.animate(animation),
|
|
29
|
+
child: child,
|
|
30
|
+
);
|
|
31
|
+
},
|
|
21
32
|
child: SwipeDetector(
|
|
22
33
|
onSwipeLeft: (offset) {
|
|
23
34
|
onNext(context);
|
|
@@ -25,29 +36,20 @@ class HomeScreen extends GoRouteData {
|
|
|
25
36
|
onSwipeRight: (offset) {
|
|
26
37
|
onPrevious(context);
|
|
27
38
|
},
|
|
28
|
-
child:
|
|
39
|
+
child: SelectionArea(
|
|
40
|
+
child: ListView.builder(
|
|
29
|
-
|
|
41
|
+
padding: EdgeInsets.symmetric(
|
|
30
|
-
|
|
42
|
+
horizontal: isWide(context) ? 40 : 20,
|
|
43
|
+
vertical: 8,
|
|
31
|
-
|
|
44
|
+
),
|
|
32
|
-
child: Column(
|
|
33
|
-
children: [
|
|
34
|
-
const Header(),
|
|
35
|
-
Flexible(
|
|
36
|
-
child: SelectionArea(
|
|
37
|
-
child: ListView.builder(
|
|
38
|
-
padding: const EdgeInsets.symmetric(vertical: 20),
|
|
39
|
-
|
|
45
|
+
itemCount: verses.length,
|
|
40
|
-
|
|
46
|
+
itemBuilder: (BuildContext context, int index) {
|
|
41
|
-
|
|
47
|
+
final v = verses[index];
|
|
42
|
-
|
|
48
|
+
return Container(
|
|
43
|
-
|
|
49
|
+
margin: const EdgeInsets.symmetric(vertical: 6),
|
|
44
|
-
|
|
50
|
+
child: VerseText(index: index, text: v.text),
|
|
45
|
-
|
|
51
|
+
);
|
|
46
|
-
|
|
52
|
+
},
|
|
47
|
-
),
|
|
48
|
-
),
|
|
49
|
-
),
|
|
50
|
-
],
|
|
51
53
|
),
|
|
52
54
|
),
|
|
53
55
|
),
|
lib/state.dart
CHANGED
|
@@ -9,6 +9,9 @@ import 'package:just_audio/just_audio.dart';
|
|
|
9
9
|
import 'package:only_bible_app/utils/dialog.dart';
|
|
10
10
|
import 'package:only_bible_app/models/book.dart';
|
|
11
11
|
|
|
12
|
+
final shellNavigatorKey = GlobalKey<NavigatorState>();
|
|
13
|
+
final routeNavigatorKey = GlobalKey<NavigatorState>();
|
|
14
|
+
|
|
12
15
|
final darkMode = PersistentValueNotifier<bool>(
|
|
13
16
|
sharedPreferencesKey: 'darkMode',
|
|
14
17
|
initialValue: false,
|
|
@@ -34,6 +37,7 @@ final chapterIndex = PersistentValueNotifier<int>(
|
|
|
34
37
|
initialValue: 0,
|
|
35
38
|
);
|
|
36
39
|
|
|
40
|
+
final slideTextDir = ValueNotifier<TextDirection>(TextDirection.ltr);
|
|
37
41
|
final selectedBible = ValueNotifier<List<Book>>([]);
|
|
38
42
|
final selectedVerses = ValueNotifier([]);
|
|
39
43
|
final isPlaying = ValueNotifier(false);
|
|
@@ -68,15 +72,15 @@ updateStatusBar() {
|
|
|
68
72
|
if (darkMode.value) {
|
|
69
73
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
|
70
74
|
systemNavigationBarColor: Colors.black,
|
|
71
|
-
systemNavigationBarIconBrightness: Brightness.light,
|
|
72
75
|
statusBarColor: Colors.black,
|
|
76
|
+
systemNavigationBarIconBrightness: Brightness.light,
|
|
73
77
|
statusBarIconBrightness: Brightness.light,
|
|
74
78
|
));
|
|
75
79
|
} else {
|
|
76
80
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
|
77
81
|
systemNavigationBarColor: Colors.white,
|
|
78
|
-
systemNavigationBarIconBrightness: Brightness.dark,
|
|
79
82
|
statusBarColor: Colors.white,
|
|
83
|
+
systemNavigationBarIconBrightness: Brightness.dark,
|
|
80
84
|
statusBarIconBrightness: Brightness.dark,
|
|
81
85
|
));
|
|
82
86
|
}
|
|
@@ -86,11 +90,13 @@ navigateBookChapter(BuildContext context, int book, int chapter) {
|
|
|
86
90
|
bookIndex.value = book;
|
|
87
91
|
chapterIndex.value = chapter;
|
|
88
92
|
context.push("/${selectedBible.value[book].name}/$chapter");
|
|
93
|
+
context.pop();
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
onNext(BuildContext context) {
|
|
92
97
|
final selectedBook = selectedBible.value[bookIndex.value];
|
|
93
98
|
final chapter = chapterIndex.value;
|
|
99
|
+
slideTextDir.value = TextDirection.ltr;
|
|
94
100
|
if (selectedBook.chapters.length > chapter + 1) {
|
|
95
101
|
navigateBookChapter(context, selectedBook.index, chapter + 1);
|
|
96
102
|
} else {
|
|
@@ -104,6 +110,7 @@ onNext(BuildContext context) {
|
|
|
104
110
|
onPrevious(BuildContext context) {
|
|
105
111
|
final selectedBook = selectedBible.value[bookIndex.value];
|
|
106
112
|
final chapter = chapterIndex.value;
|
|
113
|
+
slideTextDir.value = TextDirection.rtl;
|
|
107
114
|
if (chapter - 1 >= 0) {
|
|
108
115
|
navigateBookChapter(context, selectedBook.index, chapter - 1);
|
|
109
116
|
} else {
|