~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.
6ce3325a
—
pyrossh 2 years ago
improve code
- lib/utils/side_menu_modal.dart +10 -7
- lib/widgets/bible_selector.dart +41 -44
- lib/widgets/book_selector.dart +58 -55
- lib/widgets/chapter_selector.dart +32 -35
lib/utils/side_menu_modal.dart
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "package:flutter/material.dart";
|
|
2
|
-
import
|
|
2
|
+
import "package:only_bible_app/state.dart";
|
|
3
3
|
|
|
4
4
|
class SideMenuModal extends ModalRoute<void> {
|
|
5
5
|
final Widget child;
|
|
@@ -38,12 +38,15 @@ class SideMenuModal extends ModalRoute<void> {
|
|
|
38
38
|
child: Container(
|
|
39
39
|
color: Theme.of(context).colorScheme.background,
|
|
40
40
|
margin: EdgeInsets.only(left: 0, right: isWide(context) ? 650 : 0),
|
|
41
|
+
child: Container(
|
|
42
|
+
margin: EdgeInsets.only(top: isWide(context) ? 5 : 0, left: 20, right: 20),
|
|
41
|
-
|
|
43
|
+
child: isWide(context)
|
|
42
|
-
|
|
44
|
+
? child
|
|
43
|
-
|
|
45
|
+
: SlideTransition(
|
|
44
|
-
|
|
46
|
+
position: Tween(begin: const Offset(-1, 0), end: Offset.zero).animate(animation),
|
|
45
|
-
|
|
47
|
+
child: child,
|
|
46
|
-
|
|
48
|
+
),
|
|
49
|
+
),
|
|
47
50
|
),
|
|
48
51
|
);
|
|
49
52
|
}
|
lib/widgets/bible_selector.dart
CHANGED
|
@@ -7,54 +7,51 @@ class BibleSelector extends StatelessWidget {
|
|
|
7
7
|
|
|
8
8
|
@override
|
|
9
9
|
Widget build(BuildContext context) {
|
|
10
|
-
return
|
|
10
|
+
return Column(
|
|
11
|
-
margin: EdgeInsets.only(top: isWide(context) ? 5 : 0, left: 20),
|
|
12
|
-
child: Column(
|
|
13
|
-
|
|
11
|
+
crossAxisAlignment: CrossAxisAlignment.start,
|
|
14
|
-
|
|
12
|
+
children: [
|
|
15
|
-
|
|
13
|
+
Container(
|
|
16
|
-
|
|
14
|
+
margin: const EdgeInsets.only(bottom: 10),
|
|
17
|
-
|
|
15
|
+
child: Row(
|
|
18
|
-
|
|
16
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
|
19
|
-
|
|
17
|
+
children: [
|
|
20
|
-
|
|
18
|
+
Expanded(
|
|
21
|
-
|
|
19
|
+
child: Text("Bibles", style: Theme.of(context).textTheme.headlineMedium),
|
|
20
|
+
),
|
|
21
|
+
Container(
|
|
22
|
+
margin: const EdgeInsets.only(right: 10),
|
|
23
|
+
child: IconButton(
|
|
24
|
+
icon: const Icon(Icons.close, size: 28),
|
|
25
|
+
onPressed: () {
|
|
26
|
+
Navigator.of(context).pop();
|
|
27
|
+
},
|
|
22
28
|
),
|
|
23
|
-
Container(
|
|
24
|
-
margin: const EdgeInsets.only(right: 10),
|
|
25
|
-
child: IconButton(
|
|
26
|
-
icon: const Icon(Icons.close, size: 28),
|
|
27
|
-
onPressed: () {
|
|
28
|
-
Navigator.of(context).pop();
|
|
29
|
-
},
|
|
30
|
-
),
|
|
31
|
-
|
|
29
|
+
)
|
|
32
|
-
|
|
30
|
+
],
|
|
33
|
-
),
|
|
34
31
|
),
|
|
32
|
+
),
|
|
35
|
-
|
|
33
|
+
Expanded(
|
|
36
|
-
|
|
34
|
+
child: GridView.count(
|
|
37
|
-
|
|
35
|
+
crossAxisCount: 2,
|
|
38
|
-
|
|
36
|
+
padding: EdgeInsets.zero,
|
|
39
|
-
|
|
37
|
+
shrinkWrap: true,
|
|
40
|
-
|
|
38
|
+
crossAxisSpacing: 0,
|
|
41
|
-
|
|
39
|
+
mainAxisSpacing: 0,
|
|
42
|
-
|
|
40
|
+
childAspectRatio: 4,
|
|
43
|
-
|
|
41
|
+
children: List.of(
|
|
44
|
-
|
|
42
|
+
bibles.map((bible) {
|
|
45
|
-
|
|
43
|
+
return Container(
|
|
46
|
-
|
|
44
|
+
margin: const EdgeInsets.only(right: 16, bottom: 16),
|
|
47
|
-
|
|
45
|
+
child: TextButton(
|
|
48
|
-
|
|
46
|
+
child: Text(bible.name),
|
|
49
|
-
|
|
47
|
+
onPressed: () => changeBible(context, bible.id),
|
|
50
|
-
|
|
48
|
+
),
|
|
51
|
-
|
|
49
|
+
);
|
|
52
|
-
|
|
50
|
+
}),
|
|
53
|
-
),
|
|
54
51
|
),
|
|
55
52
|
),
|
|
53
|
+
),
|
|
56
|
-
|
|
54
|
+
],
|
|
57
|
-
),
|
|
58
55
|
);
|
|
59
56
|
}
|
|
60
57
|
}
|
lib/widgets/book_selector.dart
CHANGED
|
@@ -7,70 +7,73 @@ class BookSelector extends StatelessWidget {
|
|
|
7
7
|
const BookSelector({super.key});
|
|
8
8
|
|
|
9
9
|
onBookSelected(BuildContext context, int index) {
|
|
10
|
-
Navigator.of(context).pushReplacement(
|
|
10
|
+
Navigator.of(context).pushReplacement(
|
|
11
|
+
SideMenuModal(
|
|
12
|
+
child: ChapterSelector(
|
|
13
|
+
selectedBookIndex: index,
|
|
14
|
+
),
|
|
15
|
+
),
|
|
16
|
+
);
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
@override
|
|
14
20
|
Widget build(BuildContext context) {
|
|
15
|
-
return Container(
|
|
16
|
-
margin: EdgeInsets.only(top: isWide(context) ? 5 : 0, left: 20, right: 20),
|
|
17
|
-
|
|
21
|
+
return CustomScrollView(
|
|
18
|
-
|
|
22
|
+
slivers: [
|
|
19
|
-
|
|
23
|
+
SliverToBoxAdapter(
|
|
20
|
-
|
|
24
|
+
child: Container(
|
|
21
|
-
|
|
25
|
+
margin: const EdgeInsets.only(bottom: 10),
|
|
22
|
-
|
|
26
|
+
child: Row(
|
|
23
|
-
|
|
27
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
|
24
|
-
|
|
28
|
+
children: [
|
|
25
|
-
|
|
29
|
+
Expanded(
|
|
26
|
-
|
|
30
|
+
child: Text("Old Testament", style: Theme.of(context).textTheme.headlineMedium),
|
|
27
|
-
|
|
31
|
+
),
|
|
28
|
-
|
|
32
|
+
IconButton(
|
|
29
|
-
|
|
33
|
+
icon: const Icon(Icons.close, size: 28),
|
|
30
|
-
|
|
34
|
+
onPressed: () {
|
|
31
|
-
|
|
35
|
+
Navigator.of(context).pop();
|
|
32
|
-
|
|
36
|
+
},
|
|
33
|
-
|
|
37
|
+
),
|
|
34
|
-
|
|
38
|
+
],
|
|
35
|
-
),
|
|
36
39
|
),
|
|
37
40
|
),
|
|
41
|
+
),
|
|
38
|
-
|
|
42
|
+
SliverGrid.count(
|
|
39
|
-
|
|
43
|
+
crossAxisCount: 6,
|
|
40
|
-
|
|
44
|
+
crossAxisSpacing: 16,
|
|
41
|
-
|
|
45
|
+
mainAxisSpacing: 16,
|
|
42
|
-
|
|
46
|
+
childAspectRatio: 1.6,
|
|
43
|
-
|
|
47
|
+
children: List.of(
|
|
44
|
-
|
|
48
|
+
selectedBible.value!.getOldBooks().map((book) {
|
|
45
|
-
|
|
49
|
+
return TextButton(
|
|
46
|
-
|
|
50
|
+
child: Text(book.shortName()),
|
|
47
|
-
|
|
51
|
+
onPressed: () => onBookSelected(context, book.index),
|
|
48
|
-
|
|
52
|
+
);
|
|
49
|
-
|
|
53
|
+
}),
|
|
50
|
-
),
|
|
51
54
|
),
|
|
55
|
+
),
|
|
52
|
-
|
|
56
|
+
SliverToBoxAdapter(
|
|
53
|
-
|
|
57
|
+
child: Container(
|
|
54
|
-
|
|
58
|
+
margin: const EdgeInsets.only(top: 30, bottom: 20),
|
|
55
|
-
|
|
59
|
+
child: Text("New Testament", style: Theme.of(context).textTheme.headlineMedium),
|
|
56
|
-
),
|
|
57
60
|
),
|
|
61
|
+
),
|
|
58
|
-
|
|
62
|
+
SliverGrid.count(
|
|
59
|
-
|
|
63
|
+
crossAxisCount: 6,
|
|
60
|
-
|
|
64
|
+
crossAxisSpacing: 16,
|
|
61
|
-
|
|
65
|
+
mainAxisSpacing: 16,
|
|
62
|
-
|
|
66
|
+
childAspectRatio: 1.6,
|
|
63
|
-
|
|
67
|
+
children: List.of(
|
|
64
|
-
|
|
68
|
+
selectedBible.value!.getNewBooks().map((book) {
|
|
65
|
-
|
|
69
|
+
return TextButton(
|
|
66
|
-
|
|
70
|
+
child: Text(book.shortName()),
|
|
67
|
-
|
|
71
|
+
onPressed: () => onBookSelected(context, book.index),
|
|
68
|
-
|
|
72
|
+
);
|
|
69
|
-
|
|
73
|
+
}),
|
|
70
|
-
),
|
|
71
74
|
),
|
|
75
|
+
),
|
|
72
|
-
|
|
76
|
+
],
|
|
73
|
-
),
|
|
74
77
|
);
|
|
75
78
|
}
|
|
76
79
|
}
|
lib/widgets/chapter_selector.dart
CHANGED
|
@@ -13,43 +13,40 @@ class ChapterSelector extends StatelessWidget {
|
|
|
13
13
|
@override
|
|
14
14
|
Widget build(BuildContext context) {
|
|
15
15
|
final book = selectedBible.value!.books[selectedBookIndex];
|
|
16
|
-
return Container(
|
|
17
|
-
margin: EdgeInsets.only(top: isWide(context) ? 5 : 0, left: 20, right: 20),
|
|
18
|
-
|
|
16
|
+
return CustomScrollView(
|
|
19
|
-
|
|
17
|
+
slivers: [
|
|
20
|
-
|
|
18
|
+
SliverToBoxAdapter(
|
|
21
|
-
|
|
19
|
+
child: Container(
|
|
22
|
-
|
|
20
|
+
margin: const EdgeInsets.only(bottom: 10),
|
|
23
|
-
|
|
21
|
+
child: Row(
|
|
24
|
-
|
|
22
|
+
mainAxisAlignment: MainAxisAlignment.center,
|
|
25
|
-
|
|
23
|
+
children: [
|
|
26
|
-
|
|
24
|
+
Expanded(
|
|
27
|
-
|
|
25
|
+
child: Text(book.name, style: Theme.of(context).textTheme.headlineMedium),
|
|
28
|
-
|
|
26
|
+
),
|
|
29
|
-
|
|
27
|
+
IconButton(
|
|
30
|
-
|
|
28
|
+
icon: const Icon(Icons.close, size: 28),
|
|
31
|
-
|
|
29
|
+
onPressed: () {
|
|
32
|
-
|
|
30
|
+
Navigator.of(context).pop();
|
|
33
|
-
|
|
31
|
+
},
|
|
34
|
-
|
|
32
|
+
),
|
|
35
|
-
|
|
33
|
+
],
|
|
36
|
-
),
|
|
37
34
|
),
|
|
38
35
|
),
|
|
36
|
+
),
|
|
39
|
-
|
|
37
|
+
SliverGrid.count(
|
|
40
|
-
|
|
38
|
+
crossAxisCount: 6,
|
|
41
|
-
|
|
39
|
+
crossAxisSpacing: 16,
|
|
42
|
-
|
|
40
|
+
mainAxisSpacing: 16,
|
|
43
|
-
|
|
41
|
+
childAspectRatio: 1.6,
|
|
44
|
-
|
|
42
|
+
children: List.generate(book.chapters.length, (index) {
|
|
45
|
-
|
|
43
|
+
return TextButton(
|
|
46
|
-
|
|
44
|
+
child: Text("${index + 1}"),
|
|
47
|
-
|
|
45
|
+
onPressed: () => onChapterSelected(context, index),
|
|
48
|
-
|
|
46
|
+
);
|
|
49
|
-
|
|
47
|
+
}),
|
|
50
|
-
|
|
48
|
+
),
|
|
51
|
-
|
|
49
|
+
],
|
|
52
|
-
),
|
|
53
50
|
);
|
|
54
51
|
}
|
|
55
52
|
}
|