~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.
0ab8e2f7
—
Peter John 1 year ago
improve drawer
- .idea/deploymentTargetSelector.xml +8 -0
- .idea/gradle.xml +1 -0
- app/build.gradle.kts +2 -0
- app/src/main/java/dev/pyros/bibleapp/AppHost.kt +11 -1
- app/src/main/java/dev/pyros/bibleapp/ChapterScreen.kt +83 -35
- app/src/main/java/dev/pyros/bibleapp/Consts.kt +137 -0
- app/src/main/java/dev/pyros/bibleapp/Drawer.kt +167 -26
- app/src/main/java/dev/pyros/bibleapp/MainActivity.kt +2 -1
- app/src/main/java/dev/pyros/bibleapp/ui/theme/Font.kt +16 -0
- app/src/main/java/dev/pyros/bibleapp/ui/theme/Theme.kt +20 -5
- app/src/main/res/values/font_certs.xml +31 -0
- gradle/libs.versions.toml +4 -0
.idea/deploymentTargetSelector.xml
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
<selectionStates>
|
|
5
5
|
<SelectionState runConfigName="app">
|
|
6
6
|
<option name="selectionMode" value="DROPDOWN" />
|
|
7
|
+
<DropdownSelection timestamp="2024-06-05T08:06:31.463811Z">
|
|
8
|
+
<Target type="DEFAULT_BOOT">
|
|
9
|
+
<handle>
|
|
10
|
+
<DeviceId pluginId="LocalEmulator" identifier="path=/Users/peterjohn/.android/avd/Pixel_3a_API_34_extension_level_7_arm64-v8a.avd" />
|
|
11
|
+
</handle>
|
|
12
|
+
</Target>
|
|
13
|
+
</DropdownSelection>
|
|
14
|
+
<DialogSelection />
|
|
7
15
|
</SelectionState>
|
|
8
16
|
</selectionStates>
|
|
9
17
|
</component>
|
.idea/gradle.xml
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
|
+
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
3
4
|
<component name="GradleSettings">
|
|
4
5
|
<option name="linkedExternalProjectsSettings">
|
|
5
6
|
<GradleProjectSettings>
|
app/build.gradle.kts
CHANGED
|
@@ -72,4 +72,6 @@ dependencies {
|
|
|
72
72
|
debugImplementation(libs.androidx.ui.tooling)
|
|
73
73
|
debugImplementation(libs.androidx.ui.test.manifest)
|
|
74
74
|
implementation(libs.androidx.foundation)
|
|
75
|
+
implementation(libs.accompanist.systemuicontroller)
|
|
76
|
+
implementation(libs.androidx.ui.text.google.fonts)
|
|
75
77
|
}
|
app/src/main/java/dev/pyros/bibleapp/AppHost.kt
CHANGED
|
@@ -3,6 +3,10 @@ package dev.pyros.bibleapp
|
|
|
3
3
|
import androidx.compose.animation.AnimatedContentTransitionScope
|
|
4
4
|
import androidx.compose.animation.core.tween
|
|
5
5
|
import androidx.compose.runtime.Composable
|
|
6
|
+
import androidx.compose.runtime.getValue
|
|
7
|
+
import androidx.compose.runtime.mutableIntStateOf
|
|
8
|
+
import androidx.compose.runtime.saveable.rememberSaveable
|
|
9
|
+
import androidx.compose.runtime.setValue
|
|
6
10
|
import androidx.navigation.NavType
|
|
7
11
|
import androidx.navigation.compose.NavHost
|
|
8
12
|
import androidx.navigation.compose.composable
|
|
@@ -12,7 +16,13 @@ import androidx.navigation.navArgument
|
|
|
12
16
|
@Composable
|
|
13
17
|
fun AppHost(verses: List<Verse>) {
|
|
14
18
|
val navController = rememberNavController()
|
|
19
|
+
var bookIndex by rememberSaveable {
|
|
20
|
+
mutableIntStateOf(0)
|
|
21
|
+
}
|
|
22
|
+
val setBookIndex = { v: Int ->
|
|
23
|
+
bookIndex = v
|
|
24
|
+
}
|
|
15
|
-
Drawer(navController
|
|
25
|
+
Drawer(navController, bookIndex, setBookIndex) { openDrawer ->
|
|
16
26
|
NavHost(
|
|
17
27
|
navController = navController,
|
|
18
28
|
startDestination = "/books/{book}/chapters/{chapter}",
|
app/src/main/java/dev/pyros/bibleapp/ChapterScreen.kt
CHANGED
|
@@ -6,17 +6,23 @@ import androidx.compose.foundation.border
|
|
|
6
6
|
import androidx.compose.foundation.gestures.AnchoredDraggableState
|
|
7
7
|
import androidx.compose.foundation.gestures.DraggableAnchors
|
|
8
8
|
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
|
|
9
|
+
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
10
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
9
11
|
import androidx.compose.foundation.layout.Column
|
|
12
|
+
import androidx.compose.foundation.layout.Row
|
|
10
13
|
import androidx.compose.foundation.layout.WindowInsets
|
|
11
14
|
import androidx.compose.foundation.layout.absolutePadding
|
|
12
15
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
16
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
13
17
|
import androidx.compose.foundation.layout.padding
|
|
14
18
|
import androidx.compose.foundation.lazy.grid.GridCells
|
|
15
19
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|
16
20
|
import androidx.compose.foundation.rememberScrollState
|
|
17
21
|
import androidx.compose.foundation.verticalScroll
|
|
18
22
|
import androidx.compose.material.icons.Icons
|
|
23
|
+
import androidx.compose.material.icons.filled.Close
|
|
19
24
|
import androidx.compose.material.icons.filled.Menu
|
|
25
|
+
import androidx.compose.material.icons.outlined.MoreVert
|
|
20
26
|
import androidx.compose.material3.Button
|
|
21
27
|
import androidx.compose.material3.Divider
|
|
22
28
|
import androidx.compose.material3.DrawerValue
|
|
@@ -40,6 +46,8 @@ import androidx.compose.runtime.mutableStateOf
|
|
|
40
46
|
import androidx.compose.runtime.remember
|
|
41
47
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
42
48
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
49
|
+
import androidx.compose.runtime.setValue
|
|
50
|
+
import androidx.compose.ui.Alignment
|
|
43
51
|
import androidx.compose.ui.Modifier
|
|
44
52
|
import androidx.compose.ui.graphics.Color
|
|
45
53
|
import androidx.compose.ui.input.pointer.pointerInput
|
|
@@ -47,13 +55,16 @@ import androidx.compose.ui.platform.LocalDensity
|
|
|
47
55
|
import androidx.compose.ui.text.SpanStyle
|
|
48
56
|
import androidx.compose.ui.text.TextStyle
|
|
49
57
|
import androidx.compose.ui.text.buildAnnotatedString
|
|
58
|
+
import androidx.compose.ui.text.font.FontFamily
|
|
59
|
+
import androidx.compose.ui.text.font.FontSynthesis
|
|
50
60
|
import androidx.compose.ui.text.font.FontWeight
|
|
51
61
|
import androidx.compose.ui.text.withStyle
|
|
52
62
|
import androidx.compose.ui.unit.dp
|
|
53
63
|
import androidx.compose.ui.unit.sp
|
|
54
64
|
import androidx.navigation.NavController
|
|
65
|
+
import bookNames
|
|
66
|
+
import fontFamily
|
|
55
67
|
import kotlinx.coroutines.Job
|
|
56
|
-
import kotlinx.coroutines.launch
|
|
57
68
|
import kotlinx.serialization.Serializable
|
|
58
69
|
|
|
59
70
|
enum class DragAnchors {
|
|
@@ -77,7 +88,7 @@ fun ChapterScreen(
|
|
|
77
88
|
bookIndex: Int,
|
|
78
89
|
chapterIndex: Int,
|
|
79
90
|
navController: NavController,
|
|
80
|
-
openDrawer: () -> Job,
|
|
91
|
+
openDrawer: (MenuType) -> Job,
|
|
81
92
|
) {
|
|
82
93
|
val chapters =
|
|
83
94
|
verses.filter { it.bookIndex == bookIndex }.map { it.chapterIndex }.distinct();
|
|
@@ -110,19 +121,6 @@ fun ChapterScreen(
|
|
|
110
121
|
verses.filter { it.bookIndex == bookIndex && it.chapterIndex == chapterIndex };
|
|
111
122
|
Scaffold(
|
|
112
123
|
modifier = Modifier.fillMaxSize(),
|
|
113
|
-
topBar = {
|
|
114
|
-
TopAppBar(
|
|
115
|
-
colors = topAppBarColors(
|
|
116
|
-
containerColor = Color(0xFFFFFFFF),
|
|
117
|
-
titleContentColor = Color(0xFF000000),
|
|
118
|
-
),
|
|
119
|
-
title = {
|
|
120
|
-
Surface(onClick = { openDrawer() }) {
|
|
121
|
-
Text("Genesis ${chapterIndex + 1}")
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
)
|
|
125
|
-
}
|
|
126
124
|
) { innerPadding ->
|
|
127
125
|
Column(
|
|
128
126
|
modifier = Modifier
|
|
@@ -143,29 +141,79 @@ fun ChapterScreen(
|
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
143
|
) {
|
|
144
|
+
Row(
|
|
145
|
+
modifier = Modifier.fillMaxWidth(),
|
|
146
|
+
horizontalArrangement = Arrangement.Start,
|
|
147
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
148
|
+
) {
|
|
149
|
+
Row(
|
|
150
|
+
horizontalArrangement = Arrangement.Start,
|
|
151
|
+
) {
|
|
152
|
+
Surface(onClick = { openDrawer(MenuType.Book) }) {
|
|
153
|
+
Text(bookNames[bookIndex], style = TextStyle(
|
|
154
|
+
fontSize = 22.sp,
|
|
155
|
+
fontWeight = FontWeight.W500,
|
|
146
|
-
|
|
156
|
+
color = Color.Black,
|
|
157
|
+
))
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
Surface(onClick = { openDrawer(MenuType.Chapter) }) {
|
|
147
|
-
|
|
161
|
+
Text(
|
|
148
|
-
|
|
162
|
+
"${chapterIndex + 1}", style = TextStyle(
|
|
149
|
-
text = buildAnnotatedString {
|
|
150
|
-
withStyle(
|
|
151
|
-
style = SpanStyle(
|
|
152
|
-
fontSize =
|
|
163
|
+
fontSize = 22.sp,
|
|
153
164
|
fontWeight = FontWeight.W500,
|
|
154
|
-
color = Color
|
|
165
|
+
color = Color.Black,
|
|
155
|
-
)
|
|
156
|
-
) {
|
|
157
|
-
append((it.verseIndex + 1).toString() + " ")
|
|
158
|
-
}
|
|
159
|
-
withStyle(
|
|
160
|
-
style = SpanStyle(
|
|
161
|
-
fontSize = 18.sp,
|
|
162
|
-
fontWeight = FontWeight.W400,
|
|
163
166
|
)
|
|
164
|
-
)
|
|
167
|
+
)
|
|
165
|
-
append(it.text)
|
|
166
|
-
}
|
|
167
168
|
}
|
|
169
|
+
}
|
|
170
|
+
Row(
|
|
171
|
+
modifier = Modifier.fillMaxWidth(),
|
|
172
|
+
horizontalArrangement = Arrangement.End,
|
|
173
|
+
) {
|
|
174
|
+
IconButton(onClick = { }) {
|
|
175
|
+
Icon(Icons.Outlined.MoreVert, "Close")
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
chapterVerses.map {
|
|
180
|
+
var isSelected by rememberSaveable {
|
|
181
|
+
mutableStateOf(false)
|
|
182
|
+
}
|
|
183
|
+
val background = if (isSelected) Color(0xFFEEEEEE) else MaterialTheme.colorScheme.background
|
|
184
|
+
Surface(onClick = { isSelected = !isSelected }, interactionSource = MutableInteractionSource()) {
|
|
185
|
+
Text(
|
|
186
|
+
modifier = Modifier.padding(bottom = 12.dp),
|
|
187
|
+
text = buildAnnotatedString {
|
|
188
|
+
withStyle(
|
|
189
|
+
style = SpanStyle(
|
|
190
|
+
background = background,
|
|
191
|
+
fontFamily = fontFamily,
|
|
192
|
+
fontSize = 14.sp,
|
|
193
|
+
color = Color(0xFF9A1111),
|
|
194
|
+
// fontSize = if (it.verseIndex == 0) 24.sp else 14.sp,
|
|
195
|
+
fontWeight = FontWeight.W600,
|
|
196
|
+
// color = if (it.verseIndex == 0) Color.Black else Color(0xFF9A1111),
|
|
168
|
-
|
|
197
|
+
)
|
|
198
|
+
) {
|
|
199
|
+
append("${it.verseIndex + 1} ")
|
|
200
|
+
// append(if (it.verseIndex == 0) "${chapterIndex + 1} " else "${it.verseIndex + 1} ")
|
|
201
|
+
}
|
|
202
|
+
withStyle(
|
|
203
|
+
style = SpanStyle(
|
|
204
|
+
background = background,
|
|
205
|
+
// fontFamily = fontFamily,
|
|
206
|
+
fontFamily = FontFamily.Serif,
|
|
207
|
+
fontSize = 15.sp,
|
|
208
|
+
fontWeight = FontWeight.W400,
|
|
209
|
+
color = Color.Black,
|
|
210
|
+
)
|
|
211
|
+
) {
|
|
212
|
+
append(it.text)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
}
|
|
169
217
|
}
|
|
170
218
|
}
|
|
171
219
|
}
|
app/src/main/java/dev/pyros/bibleapp/Consts.kt
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
val bookNames = listOf(
|
|
2
|
+
"Genesis",
|
|
3
|
+
"Exodus",
|
|
4
|
+
"Leviticus",
|
|
5
|
+
"Numbers",
|
|
6
|
+
"Deuteronomy",
|
|
7
|
+
"Joshua",
|
|
8
|
+
"Judges",
|
|
9
|
+
"Ruth",
|
|
10
|
+
"1 Samuel",
|
|
11
|
+
"2 Samuel",
|
|
12
|
+
"1 Kings",
|
|
13
|
+
"2 Kings",
|
|
14
|
+
"1 Chronicles",
|
|
15
|
+
"2 Chronicles",
|
|
16
|
+
"Ezra",
|
|
17
|
+
"Nehemiah",
|
|
18
|
+
"Esther",
|
|
19
|
+
"Job",
|
|
20
|
+
"Psalms",
|
|
21
|
+
"Proverbs",
|
|
22
|
+
"Ecclesiastes",
|
|
23
|
+
"Song of Solomon",
|
|
24
|
+
"Isaiah",
|
|
25
|
+
"Jeremiah",
|
|
26
|
+
"Lamentations",
|
|
27
|
+
"Ezekiel",
|
|
28
|
+
"Daniel",
|
|
29
|
+
"Hosea",
|
|
30
|
+
"Joel",
|
|
31
|
+
"Amos",
|
|
32
|
+
"Obadiah",
|
|
33
|
+
"Jonah",
|
|
34
|
+
"Micah",
|
|
35
|
+
"Nahum",
|
|
36
|
+
"Habakkuk",
|
|
37
|
+
"Zephaniah",
|
|
38
|
+
"Haggai",
|
|
39
|
+
"Zechariah",
|
|
40
|
+
"Malachi",
|
|
41
|
+
"Matthew",
|
|
42
|
+
"Mark",
|
|
43
|
+
"Luke",
|
|
44
|
+
"John",
|
|
45
|
+
"Acts",
|
|
46
|
+
"Romans",
|
|
47
|
+
"1 Corinthians",
|
|
48
|
+
"2 Corinthians",
|
|
49
|
+
"Galatians",
|
|
50
|
+
"Ephesians",
|
|
51
|
+
"Philippians",
|
|
52
|
+
"Colossians",
|
|
53
|
+
"1 Thessalonians",
|
|
54
|
+
"2 Thessalonians",
|
|
55
|
+
"1 Timothy",
|
|
56
|
+
"2 Timothy",
|
|
57
|
+
"Titus",
|
|
58
|
+
"Philemon",
|
|
59
|
+
"Hebrews",
|
|
60
|
+
"James",
|
|
61
|
+
"1 Peter",
|
|
62
|
+
"2 Peter",
|
|
63
|
+
"1 John",
|
|
64
|
+
"2 John",
|
|
65
|
+
"3 John",
|
|
66
|
+
"Jude",
|
|
67
|
+
"Revelation",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
val chapterSizes = listOf(
|
|
71
|
+
50,
|
|
72
|
+
40,
|
|
73
|
+
27,
|
|
74
|
+
36,
|
|
75
|
+
34,
|
|
76
|
+
24,
|
|
77
|
+
21,
|
|
78
|
+
4,
|
|
79
|
+
31,
|
|
80
|
+
24,
|
|
81
|
+
22,
|
|
82
|
+
25,
|
|
83
|
+
29,
|
|
84
|
+
36,
|
|
85
|
+
10,
|
|
86
|
+
13,
|
|
87
|
+
10,
|
|
88
|
+
42,
|
|
89
|
+
150,
|
|
90
|
+
31,
|
|
91
|
+
12,
|
|
92
|
+
8,
|
|
93
|
+
66,
|
|
94
|
+
52,
|
|
95
|
+
5,
|
|
96
|
+
48,
|
|
97
|
+
12,
|
|
98
|
+
14,
|
|
99
|
+
3,
|
|
100
|
+
9,
|
|
101
|
+
1,
|
|
102
|
+
4,
|
|
103
|
+
7,
|
|
104
|
+
3,
|
|
105
|
+
3,
|
|
106
|
+
3,
|
|
107
|
+
2,
|
|
108
|
+
14,
|
|
109
|
+
4,
|
|
110
|
+
28,
|
|
111
|
+
16,
|
|
112
|
+
24,
|
|
113
|
+
21,
|
|
114
|
+
28,
|
|
115
|
+
16,
|
|
116
|
+
16,
|
|
117
|
+
13,
|
|
118
|
+
6,
|
|
119
|
+
6,
|
|
120
|
+
4,
|
|
121
|
+
4,
|
|
122
|
+
5,
|
|
123
|
+
3,
|
|
124
|
+
6,
|
|
125
|
+
4,
|
|
126
|
+
3,
|
|
127
|
+
1,
|
|
128
|
+
13,
|
|
129
|
+
5,
|
|
130
|
+
5,
|
|
131
|
+
3,
|
|
132
|
+
5,
|
|
133
|
+
1,
|
|
134
|
+
1,
|
|
135
|
+
1,
|
|
136
|
+
22
|
|
137
|
+
)
|
app/src/main/java/dev/pyros/bibleapp/Drawer.kt
CHANGED
|
@@ -1,32 +1,111 @@
|
|
|
1
1
|
package dev.pyros.bibleapp
|
|
2
2
|
|
|
3
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
4
|
+
import androidx.compose.foundation.layout.Box
|
|
5
|
+
import androidx.compose.foundation.layout.Column
|
|
6
|
+
import androidx.compose.foundation.layout.PaddingValues
|
|
7
|
+
import androidx.compose.foundation.layout.Row
|
|
8
|
+
import androidx.compose.foundation.layout.absolutePadding
|
|
9
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
10
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
3
11
|
import androidx.compose.foundation.layout.padding
|
|
4
12
|
import androidx.compose.foundation.lazy.grid.GridCells
|
|
5
13
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|
14
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
15
|
+
import androidx.compose.material.icons.Icons
|
|
16
|
+
import androidx.compose.material.icons.filled.Close
|
|
6
17
|
import androidx.compose.material3.Button
|
|
18
|
+
import androidx.compose.material3.ButtonDefaults
|
|
7
|
-
import androidx.compose.material3.
|
|
19
|
+
import androidx.compose.material3.DrawerDefaults
|
|
8
20
|
import androidx.compose.material3.DrawerValue
|
|
21
|
+
import androidx.compose.material3.Icon
|
|
22
|
+
import androidx.compose.material3.IconButton
|
|
9
23
|
import androidx.compose.material3.ModalDrawerSheet
|
|
10
24
|
import androidx.compose.material3.ModalNavigationDrawer
|
|
11
25
|
import androidx.compose.material3.Text
|
|
12
26
|
import androidx.compose.material3.rememberDrawerState
|
|
13
27
|
import androidx.compose.runtime.Composable
|
|
28
|
+
import androidx.compose.runtime.getValue
|
|
29
|
+
import androidx.compose.runtime.mutableStateOf
|
|
14
30
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
31
|
+
import androidx.compose.runtime.saveable.rememberSaveable
|
|
32
|
+
import androidx.compose.runtime.setValue
|
|
33
|
+
import androidx.compose.ui.Alignment
|
|
15
34
|
import androidx.compose.ui.Modifier
|
|
16
35
|
import androidx.compose.ui.graphics.Color
|
|
36
|
+
import androidx.compose.ui.graphics.RectangleShape
|
|
17
37
|
import androidx.compose.ui.text.TextStyle
|
|
38
|
+
import androidx.compose.ui.text.font.FontFamily
|
|
18
39
|
import androidx.compose.ui.text.font.FontWeight
|
|
19
40
|
import androidx.compose.ui.unit.dp
|
|
20
41
|
import androidx.compose.ui.unit.sp
|
|
21
42
|
import androidx.navigation.NavController
|
|
43
|
+
import bookNames
|
|
44
|
+
import chapterSizes
|
|
22
45
|
import kotlinx.coroutines.Job
|
|
23
46
|
import kotlinx.coroutines.launch
|
|
24
47
|
|
|
48
|
+
enum class MenuType {
|
|
49
|
+
Bible,
|
|
50
|
+
Book,
|
|
51
|
+
Chapter,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun shortName(name: String): String {
|
|
55
|
+
if (name[0] == '1' || name[0] == '2' || name[0] == '3') {
|
|
56
|
+
return "${name[0]}${name[2].uppercase()}${name.substring(3, 4).lowercase()}"
|
|
57
|
+
}
|
|
58
|
+
return "${name[0].uppercase()}${name.substring(1, 3).lowercase()}"
|
|
59
|
+
}
|
|
60
|
+
|
|
25
61
|
@Composable
|
|
62
|
+
fun NonlazyGrid(
|
|
63
|
+
columns: Int,
|
|
64
|
+
itemCount: Int,
|
|
65
|
+
modifier: Modifier = Modifier,
|
|
66
|
+
content: @Composable() (Int) -> Unit
|
|
67
|
+
) {
|
|
68
|
+
Column(modifier = modifier) {
|
|
69
|
+
var rows = (itemCount / columns)
|
|
70
|
+
if (itemCount.mod(columns) > 0) {
|
|
71
|
+
rows += 1
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (rowId in 0 until rows) {
|
|
75
|
+
val firstIndex = rowId * columns
|
|
76
|
+
|
|
77
|
+
Row {
|
|
78
|
+
for (columnId in 0 until columns) {
|
|
79
|
+
val index = firstIndex + columnId
|
|
80
|
+
Box(
|
|
81
|
+
modifier = Modifier
|
|
82
|
+
.fillMaxWidth()
|
|
83
|
+
.weight(1f)
|
|
84
|
+
) {
|
|
85
|
+
if (index < itemCount) {
|
|
86
|
+
content(index)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Composable
|
|
96
|
+
fun Drawer(
|
|
97
|
+
navController: NavController,
|
|
98
|
+
bookIndex: Int,
|
|
99
|
+
setBookIndex: (Int) -> Unit,
|
|
26
|
-
|
|
100
|
+
content: @Composable ((MenuType) -> Job) -> Unit
|
|
101
|
+
) {
|
|
27
102
|
val scope = rememberCoroutineScope()
|
|
28
103
|
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
|
104
|
+
var menuType by rememberSaveable {
|
|
105
|
+
mutableStateOf(MenuType.Chapter)
|
|
106
|
+
}
|
|
29
|
-
val openDrawer = {
|
|
107
|
+
val openDrawer = { m: MenuType ->
|
|
108
|
+
menuType = m
|
|
30
109
|
scope.launch {
|
|
31
110
|
drawerState.apply {
|
|
32
111
|
if (isClosed) open() else close()
|
|
@@ -34,33 +113,95 @@ fun Drawer(navController: NavController, content: @Composable (() -> Job) -> Uni
|
|
|
34
113
|
}
|
|
35
114
|
}
|
|
36
115
|
ModalNavigationDrawer(
|
|
37
|
-
gesturesEnabled =
|
|
116
|
+
gesturesEnabled = drawerState.isOpen,
|
|
38
117
|
drawerState = drawerState,
|
|
39
118
|
drawerContent = {
|
|
40
|
-
ModalDrawerSheet
|
|
119
|
+
ModalDrawerSheet(
|
|
41
|
-
|
|
120
|
+
drawerContainerColor = Color.White,
|
|
121
|
+
drawerContentColor = Color.Black,
|
|
122
|
+
drawerTonalElevation = 0.dp,
|
|
123
|
+
) {
|
|
124
|
+
Column(
|
|
125
|
+
modifier = Modifier
|
|
42
|
-
|
|
126
|
+
.fillMaxSize()
|
|
43
|
-
LazyVerticalGrid(
|
|
44
|
-
|
|
127
|
+
.padding(horizontal = 16.dp),
|
|
45
128
|
) {
|
|
129
|
+
Row(
|
|
130
|
+
modifier = Modifier.fillMaxWidth(),
|
|
131
|
+
horizontalArrangement = Arrangement.SpaceBetween,
|
|
132
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
133
|
+
) {
|
|
134
|
+
Text(
|
|
135
|
+
"Select a ${menuType.name.lowercase()}",
|
|
136
|
+
fontSize = 20.sp,
|
|
137
|
+
fontWeight = FontWeight.W500
|
|
138
|
+
)
|
|
139
|
+
IconButton(onClick = {
|
|
140
|
+
scope.launch {
|
|
141
|
+
drawerState.close();
|
|
142
|
+
}
|
|
143
|
+
}) {
|
|
144
|
+
Icon(Icons.Filled.Close, "Close")
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
LazyVerticalGrid(
|
|
148
|
+
modifier = Modifier.fillMaxSize(),
|
|
149
|
+
verticalArrangement = Arrangement.spacedBy(10.dp),
|
|
150
|
+
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
|
151
|
+
columns = GridCells.Fixed(
|
|
152
|
+
count = when (menuType) {
|
|
153
|
+
MenuType.Bible -> 2
|
|
154
|
+
MenuType.Book -> 4
|
|
155
|
+
MenuType.Chapter -> 5
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
) {
|
|
159
|
+
items(
|
|
160
|
+
when (menuType) {
|
|
161
|
+
MenuType.Bible -> 1
|
|
162
|
+
MenuType.Book -> bookNames.size
|
|
163
|
+
MenuType.Chapter -> chapterSizes[bookIndex]
|
|
164
|
+
}
|
|
46
|
-
|
|
165
|
+
) { c ->
|
|
47
|
-
|
|
166
|
+
Button(
|
|
48
|
-
|
|
167
|
+
shape = RoundedCornerShape(2.dp),
|
|
49
|
-
onClick = {
|
|
50
|
-
scope.launch {
|
|
51
|
-
navController.navigate(route = "/books/0/chapters/${c}")
|
|
52
|
-
drawerState.close();
|
|
53
|
-
}
|
|
54
|
-
}) {
|
|
55
|
-
Text(
|
|
56
|
-
|
|
168
|
+
colors = ButtonDefaults.buttonColors(
|
|
57
|
-
style = TextStyle(
|
|
58
|
-
fontSize = 16.sp,
|
|
59
|
-
fontWeight = FontWeight.W500,
|
|
60
|
-
|
|
169
|
+
containerColor = Color(0xFFEAE9E9),
|
|
170
|
+
contentColor = Color.Black,
|
|
61
171
|
),
|
|
172
|
+
contentPadding = PaddingValues(4.dp),
|
|
173
|
+
elevation = ButtonDefaults.elevatedButtonElevation(),
|
|
174
|
+
onClick = {
|
|
175
|
+
scope.launch {
|
|
176
|
+
when (menuType) {
|
|
177
|
+
MenuType.Bible -> ""
|
|
178
|
+
MenuType.Book -> {
|
|
179
|
+
setBookIndex(c)
|
|
180
|
+
menuType = MenuType.Chapter
|
|
181
|
+
// navController.navigate(route = "/books/${c}/chapters/0")
|
|
182
|
+
}
|
|
183
|
+
MenuType.Chapter -> {
|
|
184
|
+
navController.navigate(route = "/books/${bookIndex}/chapters/${c}")
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
drawerState.close();
|
|
188
|
+
}
|
|
189
|
+
}) {
|
|
190
|
+
Text(
|
|
191
|
+
modifier = Modifier.padding(bottom = 4.dp),
|
|
192
|
+
style = TextStyle(
|
|
193
|
+
// fontFamily = FontFamily.Monospace,
|
|
194
|
+
fontSize = 18.sp,
|
|
195
|
+
fontWeight = FontWeight.W500,
|
|
196
|
+
color = Color(0xFF8A4242)
|
|
197
|
+
),
|
|
62
|
-
|
|
198
|
+
text = when (menuType) {
|
|
199
|
+
MenuType.Bible -> ""
|
|
200
|
+
MenuType.Book -> shortName(bookNames[c])
|
|
201
|
+
MenuType.Chapter -> "${c + 1}"
|
|
202
|
+
}
|
|
63
|
-
|
|
203
|
+
)
|
|
204
|
+
}
|
|
64
205
|
}
|
|
65
206
|
}
|
|
66
207
|
}
|
app/src/main/java/dev/pyros/bibleapp/MainActivity.kt
CHANGED
|
@@ -5,6 +5,7 @@ import android.util.Log
|
|
|
5
5
|
import androidx.activity.ComponentActivity
|
|
6
6
|
import androidx.activity.compose.setContent
|
|
7
7
|
import androidx.activity.enableEdgeToEdge
|
|
8
|
+
import bookNames
|
|
8
9
|
import dev.pyros.bibleapp.ui.theme.BibleAppTheme
|
|
9
10
|
import java.io.BufferedReader
|
|
10
11
|
|
|
@@ -28,7 +29,7 @@ fun parseBibleTxt(name: String, buffer: BufferedReader): List<Verse> {
|
|
|
28
29
|
val verseText = arr.subList(4, arr.size).joinToString("|")
|
|
29
30
|
Verse(
|
|
30
31
|
bookIndex = book,
|
|
31
|
-
bookName =
|
|
32
|
+
bookName = bookNames[book],
|
|
32
33
|
chapterIndex = chapter,
|
|
33
34
|
verseIndex = verseNo,
|
|
34
35
|
heading = heading,
|
app/src/main/java/dev/pyros/bibleapp/ui/theme/Font.kt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import androidx.compose.ui.text.font.FontFamily
|
|
2
|
+
import androidx.compose.ui.text.googlefonts.Font
|
|
3
|
+
import androidx.compose.ui.text.googlefonts.GoogleFont
|
|
4
|
+
import dev.pyros.bibleapp.R
|
|
5
|
+
|
|
6
|
+
val provider = GoogleFont.Provider(
|
|
7
|
+
providerAuthority = "com.google.android.gms.fonts",
|
|
8
|
+
providerPackage = "com.google.android.gms",
|
|
9
|
+
certificates = R.array.com_google_android_gms_fonts_certs
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
val fontName = GoogleFont("Roboto")
|
|
13
|
+
|
|
14
|
+
val fontFamily = FontFamily(
|
|
15
|
+
Font(googleFont = fontName, fontProvider = provider)
|
|
16
|
+
)
|
app/src/main/java/dev/pyros/bibleapp/ui/theme/Theme.kt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package dev.pyros.bibleapp.ui.theme
|
|
2
2
|
|
|
3
|
-
import android.app.Activity
|
|
4
3
|
import android.os.Build
|
|
5
4
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
6
5
|
import androidx.compose.material3.MaterialTheme
|
|
@@ -9,7 +8,9 @@ import androidx.compose.material3.dynamicDarkColorScheme
|
|
|
9
8
|
import androidx.compose.material3.dynamicLightColorScheme
|
|
10
9
|
import androidx.compose.material3.lightColorScheme
|
|
11
10
|
import androidx.compose.runtime.Composable
|
|
11
|
+
import androidx.compose.ui.graphics.Color
|
|
12
12
|
import androidx.compose.ui.platform.LocalContext
|
|
13
|
+
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
|
13
14
|
|
|
14
15
|
private val DarkColorScheme = darkColorScheme(
|
|
15
16
|
primary = Purple80,
|
|
@@ -18,9 +19,13 @@ private val DarkColorScheme = darkColorScheme(
|
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
private val LightColorScheme = lightColorScheme(
|
|
21
|
-
primary =
|
|
22
|
+
primary = Color.Black,
|
|
22
|
-
secondary =
|
|
23
|
+
secondary = Purple80,
|
|
23
|
-
tertiary =
|
|
24
|
+
tertiary = Pink80,
|
|
25
|
+
background = Color.White,
|
|
26
|
+
onBackground = Color.Black,
|
|
27
|
+
surface = Color.White,
|
|
28
|
+
onSurface = Color.White,
|
|
24
29
|
|
|
25
30
|
/* Other default colors to override
|
|
26
31
|
background = Color(0xFFFFFBFE),
|
|
@@ -40,6 +45,16 @@ fun BibleAppTheme(
|
|
|
40
45
|
dynamicColor: Boolean = true,
|
|
41
46
|
content: @Composable () -> Unit
|
|
42
47
|
) {
|
|
48
|
+
val systemUiController = rememberSystemUiController()
|
|
49
|
+
if(darkTheme){
|
|
50
|
+
systemUiController.setSystemBarsColor(
|
|
51
|
+
color = Color.White
|
|
52
|
+
)
|
|
53
|
+
} else{
|
|
54
|
+
systemUiController.setSystemBarsColor(
|
|
55
|
+
color = Color.White
|
|
56
|
+
)
|
|
57
|
+
}
|
|
43
58
|
val colorScheme = when {
|
|
44
59
|
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
|
45
60
|
val context = LocalContext.current
|
|
@@ -51,7 +66,7 @@ fun BibleAppTheme(
|
|
|
51
66
|
}
|
|
52
67
|
|
|
53
68
|
MaterialTheme(
|
|
54
|
-
colorScheme =
|
|
69
|
+
colorScheme = LightColorScheme,
|
|
55
70
|
typography = Typography,
|
|
56
71
|
content = content
|
|
57
72
|
)
|
app/src/main/res/values/font_certs.xml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!--
|
|
2
|
+
Copyright 2022 The Android Open Source Project
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<resources>
|
|
17
|
+
<array name="com_google_android_gms_fonts_certs">
|
|
18
|
+
<item>@array/com_google_android_gms_fonts_certs_dev</item>
|
|
19
|
+
<item>@array/com_google_android_gms_fonts_certs_prod</item>
|
|
20
|
+
</array>
|
|
21
|
+
<string-array name="com_google_android_gms_fonts_certs_dev">
|
|
22
|
+
<item>
|
|
23
|
+
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4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zSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
|
|
29
|
+
</item>
|
|
30
|
+
</string-array>
|
|
31
|
+
</resources>
|
gradle/libs.versions.toml
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
[versions]
|
|
2
|
+
accompanistSystemuicontroller = "0.27.0"
|
|
2
3
|
agp = "8.4.0"
|
|
3
4
|
foundation = "1.6.7"
|
|
4
5
|
kotlin = "1.9.0"
|
|
@@ -11,14 +12,17 @@ lifecycleRuntimeKtx = "2.6.1"
|
|
|
11
12
|
activityCompose = "1.8.0"
|
|
12
13
|
composeBom = "2023.08.00"
|
|
13
14
|
navigationFragmentKtx = "2.7.7"
|
|
15
|
+
uiTextGoogleFonts = "1.6.7"
|
|
14
16
|
uiUtilAndroid = "1.6.7"
|
|
15
17
|
|
|
16
18
|
[libraries]
|
|
19
|
+
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanistSystemuicontroller" }
|
|
17
20
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
|
18
21
|
androidx-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "foundation" }
|
|
19
22
|
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationFragmentKtx" }
|
|
20
23
|
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
|
|
21
24
|
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationFragmentKtx" }
|
|
25
|
+
androidx-ui-text-google-fonts = { module = "androidx.compose.ui:ui-text-google-fonts", version.ref = "uiTextGoogleFonts" }
|
|
22
26
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
|
23
27
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
|
24
28
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|