~repos /only-bible-app

#kotlin#android#ios

GIT_CONFIG_PARAMETERS="'http.version=HTTP/1.1'" git clone https://git.pyrossh.dev/only-bible-app.git
Discussions: https://groups.google.com/g/rust-embed-devs

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


lib/home.dart CHANGED
@@ -4,7 +4,6 @@ import "package:only_bible_app/gen/bible.gen.dart";
4
4
  import "package:only_bible_app/store/app_state.dart";
5
5
  import "package:only_bible_app/theme.dart";
6
6
  import "package:only_bible_app/widgets/home_app_bar.dart";
7
- import "package:flutter_swipe_detector/flutter_swipe_detector.dart";
8
7
  import "package:only_bible_app/store/actions_navigation.dart";
9
8
  import "package:only_bible_app/store/app_navigator.dart";
10
9
  import "package:only_bible_app/widgets/menu_overlay.dart";
@@ -122,11 +121,19 @@ class _HomeState extends State<Home> {
122
121
  body: SafeArea(
123
122
  child: Stack(
124
123
  children: [
125
- SwipeDetector(
124
+ _ChapterSwipeDetector(
126
- onSwipeLeft: (offset) =>
125
+ onSwipeLeft: () =>
127
126
  context.dispatch(NextChapterAction(context.router, bible, chapter.book, chapter.index)),
128
- onSwipeRight: (offset) =>
127
+ onSwipeRight: () =>
129
128
  context.dispatch(PreviousChapterAction(context.router, bible, chapter.book, chapter.index)),
129
+ onEdgeSwipeRight: () {
130
+ final router = context.router;
131
+ if (router.canPop()) {
132
+ router.pop();
133
+ } else {
134
+ context.dispatch(PreviousChapterAction(router, bible, chapter.book, chapter.index));
135
+ }
136
+ },
130
137
  child: SingleChildScrollView(
131
138
  key: ValueKey("${chapter.book}-${chapter.index}"),
132
139
  physics: const BouncingScrollPhysics(),
@@ -172,6 +179,52 @@ class _HomeState extends State<Home> {
172
179
  }
173
180
  }
174
181
 
182
+ class _ChapterSwipeDetector extends StatefulWidget {
183
+ final VoidCallback onSwipeLeft;
184
+ final VoidCallback onSwipeRight;
185
+ final VoidCallback onEdgeSwipeRight;
186
+ final Widget child;
187
+
188
+ const _ChapterSwipeDetector({
189
+ required this.onSwipeLeft,
190
+ required this.onSwipeRight,
191
+ required this.onEdgeSwipeRight,
192
+ required this.child,
193
+ });
194
+
195
+ @override
196
+ State<_ChapterSwipeDetector> createState() => _ChapterSwipeDetectorState();
197
+ }
198
+
199
+ class _ChapterSwipeDetectorState extends State<_ChapterSwipeDetector> {
200
+ double? _startX;
201
+
202
+ @override
203
+ Widget build(BuildContext context) {
204
+ return GestureDetector(
205
+ onHorizontalDragStart: (details) {
206
+ _startX = details.globalPosition.dx;
207
+ },
208
+ onHorizontalDragEnd: (details) {
209
+ final startX = _startX;
210
+ _startX = null;
211
+ if (startX == null) return;
212
+ final velocity = details.primaryVelocity ?? 0;
213
+ if (velocity < -300) {
214
+ widget.onSwipeLeft();
215
+ } else if (velocity > 300) {
216
+ if (startX < 40) {
217
+ widget.onEdgeSwipeRight();
218
+ } else {
219
+ widget.onSwipeRight();
220
+ }
221
+ }
222
+ },
223
+ child: widget.child,
224
+ );
225
+ }
226
+ }
227
+
175
228
  class _VerseText extends StatefulWidget {
176
229
  final Verse verse;
177
230
  final Bible bible;
lib/store/actions_navigation.dart CHANGED
@@ -182,11 +182,6 @@ class PreviousChapterAction extends ReduxAction<AppState> {
182
182
  int? newBook;
183
183
  int? newChapter;
184
184
 
185
- if (router.canPop()) {
186
- router.pop();
187
- return null;
188
- }
189
-
190
185
  if (chapter - 1 >= 0) {
191
186
  newBook = selectedBook.index;
192
187
  newChapter = chapter - 1;
pubspec.lock CHANGED
@@ -403,14 +403,6 @@ packages:
403
403
  url: "https://pub.dev"
404
404
  source: hosted
405
405
  version: "3.5.4"
406
- flutter_swipe_detector:
407
- dependency: "direct main"
408
- description:
409
- name: flutter_swipe_detector
410
- sha256: ae6fe331de414632c0122a7047d64dfe2332c95b3f06a05118a7ea538ff19eda
411
- url: "https://pub.dev"
412
- source: hosted
413
- version: "2.0.0"
414
406
  flutter_test:
415
407
  dependency: "direct dev"
416
408
  description: flutter
pubspec.yaml CHANGED
@@ -12,7 +12,6 @@ dependencies:
12
12
  cupertino_icons: ^1.0.8
13
13
  path_provider: ^2.1.5
14
14
  flutter_native_splash: ^2.4.7
15
- flutter_swipe_detector: ^2.0.0
16
15
  share_plus: ^12.0.1
17
16
  package_info_plus: ^9.0.0
18
17
  flutter_azure_tts: ^1.0.0