~repos /only-bible-app
git clone
https://pyrossh.dev/repos/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.
d885b468
—
pyrossh 2 years ago
remove verse list
- lib/screens/chapter_view_screen.dart +23 -33
- lib/state.dart +5 -5
- lib/widgets/verse_list.dart +0 -66
- lib/widgets/verse_view.dart +0 -63
- lib/widgets/verses_view.dart +68 -0
lib/screens/chapter_view_screen.dart
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import "package:flutter/material.dart";
|
|
2
|
-
import "package:flutter_swipe_detector/flutter_swipe_detector.dart";
|
|
3
2
|
import "package:only_bible_app/widgets/chapter_app_bar.dart";
|
|
4
3
|
import "package:only_bible_app/widgets/header.dart";
|
|
5
4
|
import "package:only_bible_app/state.dart";
|
|
6
5
|
import "package:only_bible_app/widgets/sidebar.dart";
|
|
7
|
-
import "package:only_bible_app/widgets/
|
|
6
|
+
import "package:only_bible_app/widgets/verses_view.dart";
|
|
8
7
|
import "package:provider/provider.dart";
|
|
9
8
|
|
|
10
9
|
class ChapterViewScreen extends StatelessWidget {
|
|
@@ -33,42 +32,33 @@ class ChapterViewScreen extends StatelessWidget {
|
|
|
33
32
|
// },
|
|
34
33
|
// ),
|
|
35
34
|
final isDesktop = isWide(context);
|
|
35
|
+
return ChangeNotifierProvider(
|
|
36
|
-
|
|
36
|
+
create: (_) => ChapterViewModel(
|
|
37
|
-
|
|
37
|
+
book: book,
|
|
38
|
-
|
|
38
|
+
chapter: chapter,
|
|
39
|
-
|
|
39
|
+
selectedVerses: [],
|
|
40
|
-
|
|
40
|
+
),
|
|
41
|
-
return ChangeNotifierProvider.value(
|
|
42
|
-
value: model,
|
|
43
41
|
child: Scaffold(
|
|
44
42
|
appBar: isDesktop ? null : const ChapterAppBar(),
|
|
45
43
|
backgroundColor: Theme.of(context).colorScheme.background,
|
|
46
44
|
body: SafeArea(
|
|
47
|
-
child: SwipeDetector(
|
|
48
|
-
onSwipeLeft: (offset) {
|
|
49
|
-
model.onNext(context, book, chapter);
|
|
50
|
-
},
|
|
51
|
-
onSwipeRight: (offset) {
|
|
52
|
-
model.onPrevious(context, book, chapter);
|
|
53
|
-
},
|
|
54
|
-
|
|
45
|
+
child: isDesktop
|
|
55
|
-
|
|
46
|
+
? const Row(
|
|
56
|
-
|
|
47
|
+
children: [
|
|
57
|
-
|
|
48
|
+
Sidebar(),
|
|
58
|
-
|
|
49
|
+
Flexible(
|
|
59
|
-
|
|
50
|
+
child: Column(
|
|
60
|
-
|
|
51
|
+
children: [
|
|
61
|
-
|
|
52
|
+
Header(),
|
|
62
|
-
|
|
53
|
+
Flexible(
|
|
63
|
-
|
|
54
|
+
child: VersesView(),
|
|
64
|
-
|
|
55
|
+
),
|
|
65
|
-
|
|
56
|
+
],
|
|
66
|
-
),
|
|
67
57
|
),
|
|
58
|
+
),
|
|
68
|
-
|
|
59
|
+
],
|
|
69
|
-
|
|
60
|
+
)
|
|
70
|
-
|
|
61
|
+
: const VersesView(),
|
|
71
|
-
),
|
|
72
62
|
),
|
|
73
63
|
),
|
|
74
64
|
);
|
lib/state.dart
CHANGED
|
@@ -20,7 +20,7 @@ class AppModel extends ChangeNotifier {
|
|
|
20
20
|
Bible bible = bibles.first;
|
|
21
21
|
bool darkMode = false;
|
|
22
22
|
bool fontBold = false;
|
|
23
|
-
|
|
23
|
+
double textScaleFactor = 0;
|
|
24
24
|
|
|
25
25
|
static AppModel of(BuildContext context) {
|
|
26
26
|
return Provider.of(context, listen: true);
|
|
@@ -35,7 +35,7 @@ class AppModel extends ChangeNotifier {
|
|
|
35
35
|
await prefs.setInt("bibleId", bible.id);
|
|
36
36
|
await prefs.setBool("darkMode", darkMode);
|
|
37
37
|
await prefs.setBool("fontBold", fontBold);
|
|
38
|
-
await prefs.
|
|
38
|
+
await prefs.setDouble("textScaleFactor", textScaleFactor);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
Future<(int, int)> loadData() async {
|
|
@@ -43,7 +43,7 @@ class AppModel extends ChangeNotifier {
|
|
|
43
43
|
final bibleId = prefs.getInt("bibleId") ?? 1;
|
|
44
44
|
darkMode = prefs.getBool("darkMode") ?? false;
|
|
45
45
|
fontBold = prefs.getBool("fontBold") ?? false;
|
|
46
|
-
|
|
46
|
+
textScaleFactor = prefs.getDouble("textScaleFactor") ?? 1;
|
|
47
47
|
bible = await loadBible(bibleId);
|
|
48
48
|
// await Future.delayed(Duration(seconds: 3));
|
|
49
49
|
final book = prefs.getInt("book") ?? 0;
|
|
@@ -109,13 +109,13 @@ class AppModel extends ChangeNotifier {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
increaseFont() async {
|
|
112
|
-
|
|
112
|
+
textScaleFactor += 0.1;
|
|
113
113
|
notifyListeners();
|
|
114
114
|
save();
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
decreaseFont() async {
|
|
118
|
-
|
|
118
|
+
textScaleFactor -= 0.1;
|
|
119
119
|
notifyListeners();
|
|
120
120
|
save();
|
|
121
121
|
}
|
lib/widgets/verse_list.dart
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import "package:flutter/gestures.dart";
|
|
2
|
-
import "package:flutter/material.dart";
|
|
3
|
-
import "package:only_bible_app/state.dart";
|
|
4
|
-
|
|
5
|
-
class VerseList extends StatelessWidget {
|
|
6
|
-
const VerseList({super.key});
|
|
7
|
-
|
|
8
|
-
@override
|
|
9
|
-
Widget build(BuildContext context) {
|
|
10
|
-
final model = ChapterViewModel.of(context);
|
|
11
|
-
final chapter = ChapterViewModel.selectedChapter(context);
|
|
12
|
-
return SingleChildScrollView(
|
|
13
|
-
physics: const BouncingScrollPhysics(),
|
|
14
|
-
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
15
|
-
child: SelectableText.rich(
|
|
16
|
-
contextMenuBuilder: null,
|
|
17
|
-
textScaleFactor: 1,
|
|
18
|
-
onSelectionChanged: (selection, _) {
|
|
19
|
-
// Show copy, highlight, note, audio, share
|
|
20
|
-
//bottom: 55, // TODO: maybe make this 55 only when actions bar is show else 20
|
|
21
|
-
},
|
|
22
|
-
TextSpan(
|
|
23
|
-
style: DefaultTextStyle.of(context).style,
|
|
24
|
-
children: chapter.verses
|
|
25
|
-
.asMap()
|
|
26
|
-
.entries
|
|
27
|
-
.map(
|
|
28
|
-
(e) => [
|
|
29
|
-
WidgetSpan(
|
|
30
|
-
child: Transform.translate(
|
|
31
|
-
offset: const Offset(0, -2),
|
|
32
|
-
child: Text("${e.key + 1} ", style: Theme.of(context).textTheme.labelMedium),
|
|
33
|
-
),
|
|
34
|
-
),
|
|
35
|
-
TextSpan(
|
|
36
|
-
text: "${e.value.text}\n",
|
|
37
|
-
style: model.isVerseSelected(e.key)
|
|
38
|
-
? TextStyle(
|
|
39
|
-
backgroundColor: Theme.of(context).highlightColor,
|
|
40
|
-
)
|
|
41
|
-
: null,
|
|
42
|
-
recognizer: TapGestureRecognizer()..onTap = () => model.onVerseSelected(context, e.key),
|
|
43
|
-
),
|
|
44
|
-
const WidgetSpan(
|
|
45
|
-
child: Padding(
|
|
46
|
-
padding: EdgeInsets.only(bottom: 30),
|
|
47
|
-
),
|
|
48
|
-
),
|
|
49
|
-
],
|
|
50
|
-
)
|
|
51
|
-
.expand((element) => element)
|
|
52
|
-
.toList(),
|
|
53
|
-
),
|
|
54
|
-
// userSelections: model.selectedVerses
|
|
55
|
-
// .map(
|
|
56
|
-
// (e) => UserSelection(
|
|
57
|
-
// hasCaret: false,
|
|
58
|
-
// highlightStyle: _primaryHighlightStyle,
|
|
59
|
-
// selection: TextSelection(baseOffset: e , extentOffset: 10),
|
|
60
|
-
// ),
|
|
61
|
-
// )
|
|
62
|
-
// .toList(),
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
lib/widgets/verse_view.dart
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import "package:flutter/material.dart";
|
|
2
|
-
import "package:only_bible_app/state.dart";
|
|
3
|
-
|
|
4
|
-
class VerseText extends StatelessWidget {
|
|
5
|
-
final int index;
|
|
6
|
-
final String text;
|
|
7
|
-
|
|
8
|
-
const VerseText({super.key, required this.index, required this.text});
|
|
9
|
-
|
|
10
|
-
@override
|
|
11
|
-
Widget build(BuildContext context) {
|
|
12
|
-
final model = AppModel.of(context);
|
|
13
|
-
final selected = ChapterViewModel.of(context).isVerseSelected(index);
|
|
14
|
-
final bodySize = Theme.of(context).textTheme.bodyMedium!.fontSize! + model.fontSizeDelta;
|
|
15
|
-
final weight = model.fontBold ? FontWeight.w600 : Theme.of(context).textTheme.bodyMedium!.fontWeight;
|
|
16
|
-
|
|
17
|
-
return GestureDetector(
|
|
18
|
-
onTap: () {
|
|
19
|
-
ChapterViewModel.ofEvent(context).onVerseSelected(context, index);
|
|
20
|
-
},
|
|
21
|
-
child: DecoratedBox(
|
|
22
|
-
decoration: BoxDecoration(
|
|
23
|
-
color: selected ? Theme.of(context).highlightColor : Theme.of(context).colorScheme.background,
|
|
24
|
-
),
|
|
25
|
-
child: RichText(
|
|
26
|
-
text: TextSpan(
|
|
27
|
-
style: DefaultTextStyle.of(context).style,
|
|
28
|
-
children: [
|
|
29
|
-
WidgetSpan(
|
|
30
|
-
child: Transform.translate(
|
|
31
|
-
offset: const Offset(0, -2),
|
|
32
|
-
child: Text("${index + 1} ", style: Theme.of(context).textTheme.labelMedium),
|
|
33
|
-
),
|
|
34
|
-
),
|
|
35
|
-
TextSpan(
|
|
36
|
-
text: text,
|
|
37
|
-
style: TextStyle(fontSize: bodySize, fontWeight: weight),
|
|
38
|
-
),
|
|
39
|
-
],
|
|
40
|
-
),
|
|
41
|
-
),
|
|
42
|
-
// Row(
|
|
43
|
-
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
44
|
-
// children: [
|
|
45
|
-
// Container(
|
|
46
|
-
// margin: const EdgeInsets.only(right: 4),
|
|
47
|
-
// child: Transform.translate(
|
|
48
|
-
// offset: const Offset(0, 2),
|
|
49
|
-
// child: Text("${index + 1}", style: Theme.of(context).textTheme.labelMedium),
|
|
50
|
-
// ),
|
|
51
|
-
// ),
|
|
52
|
-
// Flexible(
|
|
53
|
-
// child: Text(
|
|
54
|
-
// text,
|
|
55
|
-
// style: TextStyle(fontSize: bodySize, fontWeight: weight),
|
|
56
|
-
// ),
|
|
57
|
-
// )
|
|
58
|
-
// ],
|
|
59
|
-
// ),
|
|
60
|
-
),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
lib/widgets/verses_view.dart
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import "package:flutter/gestures.dart";
|
|
2
|
+
import "package:flutter/material.dart";
|
|
3
|
+
import "package:flutter_swipe_detector/flutter_swipe_detector.dart";
|
|
4
|
+
import "package:only_bible_app/state.dart";
|
|
5
|
+
|
|
6
|
+
class VersesView extends StatelessWidget {
|
|
7
|
+
const VersesView({super.key});
|
|
8
|
+
|
|
9
|
+
@override
|
|
10
|
+
Widget build(BuildContext context) {
|
|
11
|
+
final textScaleFactor = AppModel.of(context).textScaleFactor;
|
|
12
|
+
final model = ChapterViewModel.of(context);
|
|
13
|
+
final chapter = ChapterViewModel.selectedChapter(context);
|
|
14
|
+
return SwipeDetector(
|
|
15
|
+
onSwipeLeft: (offset) {
|
|
16
|
+
model.onNext(context, model.book, model.chapter);
|
|
17
|
+
},
|
|
18
|
+
onSwipeRight: (offset) {
|
|
19
|
+
model.onPrevious(context, model.book, model.chapter);
|
|
20
|
+
},
|
|
21
|
+
child: Padding(
|
|
22
|
+
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
23
|
+
child: SelectableText.rich(
|
|
24
|
+
scrollPhysics: const BouncingScrollPhysics(),
|
|
25
|
+
contextMenuBuilder: null,
|
|
26
|
+
textScaleFactor: textScaleFactor,
|
|
27
|
+
// onSelectionChanged: (selection, _) {
|
|
28
|
+
// // Show copy, highlight, note, audio, share
|
|
29
|
+
// //bottom: 55, // TODO: maybe make this 55 only when actions bar is shown else 20
|
|
30
|
+
// },
|
|
31
|
+
TextSpan(
|
|
32
|
+
style: DefaultTextStyle.of(context).style,
|
|
33
|
+
// recognizer: TapAndPanGestureRecognizer()..onDragEnd = (e) => print("Hello"),
|
|
34
|
+
children: chapter.verses
|
|
35
|
+
.asMap()
|
|
36
|
+
.entries
|
|
37
|
+
.map(
|
|
38
|
+
(e) => [
|
|
39
|
+
WidgetSpan(
|
|
40
|
+
child: Transform.translate(
|
|
41
|
+
offset: const Offset(0, -2),
|
|
42
|
+
child: Text("${e.key + 1} ", style: Theme.of(context).textTheme.labelMedium),
|
|
43
|
+
),
|
|
44
|
+
),
|
|
45
|
+
TextSpan(
|
|
46
|
+
text: "${e.value.text}\n",
|
|
47
|
+
style: model.isVerseSelected(e.key)
|
|
48
|
+
? TextStyle(
|
|
49
|
+
backgroundColor: Theme.of(context).highlightColor,
|
|
50
|
+
)
|
|
51
|
+
: null,
|
|
52
|
+
recognizer: TapGestureRecognizer()..onTap = () => model.onVerseSelected(context, e.key),
|
|
53
|
+
),
|
|
54
|
+
const WidgetSpan(
|
|
55
|
+
child: Padding(
|
|
56
|
+
padding: EdgeInsets.only(bottom: 30),
|
|
57
|
+
),
|
|
58
|
+
),
|
|
59
|
+
],
|
|
60
|
+
)
|
|
61
|
+
.expand((element) => element)
|
|
62
|
+
.toList(),
|
|
63
|
+
),
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|