~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.


c4e072eb pyrossh

2 years ago
try fix header transition
Files changed (1) hide show
  1. lib/routes/home_screen.dart +59 -45
lib/routes/home_screen.dart CHANGED
@@ -16,66 +16,80 @@ class HomeScreen extends GoRouteData {
16
16
  @override
17
17
  Page buildPage(BuildContext context, GoRouterState state) {
18
18
  if (slideTextDir.value == null) {
19
- return NoTransitionPage(child: Home(book: book, chapter: chapter));
19
+ return NoTransitionPage(
20
+ child: SwipeDetector(
21
+ onSwipeLeft: (offset) {
22
+ onNext(context);
23
+ },
24
+ onSwipeRight: (offset) {
25
+ onPrevious(context);
26
+ },
27
+ child: const Column(
28
+ children: [
29
+ Header(),
30
+ Flexible(
31
+ child: VerseList(),
32
+ ),
33
+ ],
34
+ ),
35
+ ),
36
+ );
20
37
  }
21
38
  return CustomTransitionPage(
22
39
  barrierDismissible: false,
23
40
  barrierColor: Theme.of(context).colorScheme.background,
24
41
  transitionDuration: const Duration(milliseconds: 360),
25
42
  transitionsBuilder: (context, animation, secondaryAnimation, child) {
43
+ return SwipeDetector(
44
+ onSwipeLeft: (offset) {
45
+ onNext(context);
46
+ },
47
+ onSwipeRight: (offset) {
48
+ onPrevious(context);
49
+ },
50
+ child: Column(
51
+ children: [
52
+ const Header(),
53
+ Flexible(
26
- return SlideTransition(
54
+ child: SlideTransition(
27
- textDirection: slideTextDir.value,
55
+ textDirection: slideTextDir.value,
28
- position: Tween(begin: const Offset(1, 0), end: Offset.zero)
56
+ position: Tween(begin: const Offset(1, 0), end: Offset.zero)
29
- .chain(CurveTween(curve: Curves.linear))
57
+ .chain(CurveTween(curve: Curves.linear))
30
- .animate(animation),
58
+ .animate(animation),
31
- child: child,
59
+ child: child,
60
+ ),
61
+ ),
62
+ ],
63
+ ),
32
64
  );
33
65
  },
34
- child: Home(book: book, chapter: chapter),
66
+ child: const VerseList(),
35
67
  );
36
68
  }
37
69
  }
38
70
 
39
- class Home extends StatelessWidget {
71
+ class VerseList extends StatelessWidget {
40
- final String book;
41
- final int chapter;
42
-
43
- const Home({required this.book, required this.chapter});
72
+ const VerseList({super.key});
44
73
 
45
74
  @override
46
75
  Widget build(BuildContext context) {
47
- final selectedBook = selectedBible.value.firstWhere((it) => book == it.name);
76
+ final selectedBook = selectedBible.value[bookIndex.value];
48
- final verses = selectedBook.chapters[chapter].verses;
77
+ final verses = selectedBook.chapters[chapterIndex.value].verses;
49
- return SwipeDetector(
78
+ return SelectionArea(
79
+ child: ListView.builder(
80
+ padding: const EdgeInsets.only(
81
+ left: 20,
82
+ right: 20,
83
+ bottom: 20,
84
+ ),
50
- onSwipeLeft: (offset) {
85
+ itemCount: verses.length,
86
+ itemBuilder: (BuildContext context, int index) {
87
+ final v = verses[index];
51
- onNext(context);
88
+ return Container(
89
+ margin: const EdgeInsets.symmetric(vertical: 6),
90
+ child: VerseText(index: index, text: v.text),
91
+ );
52
- },
92
+ },
53
- onSwipeRight: (offset) {
54
- onPrevious(context);
55
- },
56
- child: Column(
57
- children: [
58
- const Header(),
59
- Flexible(
60
- child: SelectionArea(
61
- child: ListView.builder(
62
- padding: const EdgeInsets.only(
63
- left: 20,
64
- right: 20,
65
- bottom: 20,
66
- ),
67
- itemCount: verses.length,
68
- itemBuilder: (BuildContext context, int index) {
69
- final v = verses[index];
70
- return Container(
71
- margin: const EdgeInsets.symmetric(vertical: 6),
72
- child: VerseText(index: index, text: v.text),
73
- );
74
- },
75
- ),
76
- ),
77
- ),
78
- ],
79
93
  ),
80
94
  );
81
95
  }