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


bible.fbs CHANGED
@@ -1,5 +1,3 @@
1
- namespace OnlyBibleApp.Bible;
2
-
3
1
  table Verse {
4
2
  index:int;
5
3
  book:int;
lib/widgets/home_app_bar.dart CHANGED
@@ -66,7 +66,7 @@ class HomeAppBar extends StatelessWidget implements PreferredSizeWidget {
66
66
  ),
67
67
  ),
68
68
  Padding(
69
- padding: const EdgeInsets.only(left: 16, right: 16),
69
+ padding: const EdgeInsets.only(left: 0, right: 8),
70
70
  child: IconButton(
71
71
  key: const Key("settingsButton"),
72
72
  padding: EdgeInsets.zero,
lib/widgets/verses_view.dart CHANGED
@@ -1,3 +1,4 @@
1
+ import "package:flutter/gestures.dart";
1
2
  import "package:flutter/material.dart";
2
3
  import "package:flutter_swipe_detector/flutter_swipe_detector.dart";
3
4
  import "package:only_bible_app/gen/bible.gen.dart";
@@ -28,6 +29,7 @@ class VersesView extends StatelessWidget {
28
29
  onSwipeLeft: (offset) => context.dispatch(NextChapterAction(bible, chapter.book, chapter.index)),
29
30
  onSwipeRight: (offset) => context.dispatch(PreviousChapterAction(bible, chapter.book, chapter.index)),
30
31
  child: SingleChildScrollView(
32
+ key: ValueKey("${chapter.book}-${chapter.index}"),
31
33
  physics: const BouncingScrollPhysics(),
32
34
  padding: const EdgeInsets.symmetric(horizontal: 20),
33
35
  child: Column(
@@ -44,10 +46,7 @@ class VersesView extends StatelessWidget {
44
46
  style: baseStyle,
45
47
  children: [
46
48
  if (v.heading != null && v.heading!.isNotEmpty)
47
- TextSpan(
48
- text: "${v.heading!.replaceAll("<br>", "\n")}\n",
49
+ ..._buildHeadingSpans(context, v.heading!, theme.labelLarge!),
49
- style: theme.labelLarge,
50
- ),
51
50
  TextSpan(
52
51
  text: "${v.index + 1} ",
53
52
  style: theme.labelMedium!.copyWith(
@@ -78,4 +77,41 @@ class VersesView extends StatelessWidget {
78
77
  ],
79
78
  );
80
79
  }
80
+
81
+ static final _linkPattern = RegExp(r"RF:(\d+):(\d+):(\d+)");
82
+
83
+ List<InlineSpan> _buildHeadingSpans(BuildContext context, String heading, TextStyle style) {
84
+ final text = heading.replaceAll("<br>", "\n");
85
+ final spans = <InlineSpan>[];
86
+ var lastEnd = 0;
87
+
88
+ for (final match in _linkPattern.allMatches(text)) {
89
+ if (match.start > lastEnd) {
90
+ spans.add(TextSpan(text: text.substring(lastEnd, match.start), style: style));
91
+ }
92
+ final bookIndex = int.parse(match.group(1)!);
93
+ final chapterIndex = int.parse(match.group(2)!);
94
+ final verseIndex = int.parse(match.group(3)!);
95
+ final bookName = bible.books![bookIndex].name ?? "";
96
+ final label = "$bookName ${chapterIndex + 1}:${verseIndex + 1}";
97
+ spans.add(
98
+ TextSpan(
99
+ text: label,
100
+ style: style.copyWith(
101
+ color: Theme.of(context).colorScheme.primary,
102
+ decoration: TextDecoration.underline,
103
+ ),
104
+ recognizer: TapGestureRecognizer()
105
+ ..onTap = () => context.dispatch(GoToChapterAction(bookIndex, chapterIndex)),
106
+ ),
107
+ );
108
+ lastEnd = match.end;
109
+ }
110
+
111
+ if (lastEnd < text.length) {
112
+ spans.add(TextSpan(text: text.substring(lastEnd), style: style));
113
+ }
114
+ spans.add(TextSpan(text: "\n", style: style));
115
+ return spans;
116
+ }
81
117
  }
scripts/files/en_kjv.txt CHANGED
@@ -1,4 +1,4 @@
1
- Genesis|0|0|0|The History of Creation <br> (<a href="42:0:0">John 1:1–5</a> ; <a href="57:10:1">Hebrews 11:1–3</a>)|In the beginning God created the heaven and the earth.
1
+ Genesis|0|0|0|The History of Creation <br> (RF:42:0:0; RF:57:10:1)|In the beginning God created the heaven and the earth.
2
2
  Genesis|0|0|1||And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
3
3
  Genesis|0|0|2||And God said, Let there be light: and there was light.
4
4
  Genesis|0|0|3||And God saw the light, that it was good: and God divided the light from the darkness.