~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.
a1055d7c
—
Peter John 1 year ago
improve app
- app/src/main/java/dev/pyrossh/onlyBible/AppHost.kt +1 -1
- app/src/main/java/dev/pyrossh/onlyBible/AppSettings.kt +2 -2
- app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt +1 -2
- app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt +12 -14
- app/src/main/java/dev/pyrossh/onlyBible/Drawer.kt +1 -2
- app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt +1 -1
- app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt +1 -1
- readme.md +1 -0
app/src/main/java/dev/pyrossh/onlyBible/AppHost.kt
CHANGED
|
@@ -12,7 +12,7 @@ import androidx.navigation.toRoute
|
|
|
12
12
|
@Composable
|
|
13
13
|
fun AppHost(verses: List<Verse>) {
|
|
14
14
|
val navController = rememberNavController()
|
|
15
|
-
val state =
|
|
15
|
+
val state = LocalSettings.current!!
|
|
16
16
|
val bookNames = verses.distinctBy { it.bookName }.map { it.bookName }
|
|
17
17
|
Drawer(bookNames, navController) { openDrawer ->
|
|
18
18
|
NavHost(
|
app/src/main/java/dev/pyrossh/onlyBible/AppSettings.kt
CHANGED
|
@@ -12,7 +12,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
|
|
|
12
12
|
import androidx.lifecycle.ViewModel
|
|
13
13
|
import java.util.Locale
|
|
14
14
|
|
|
15
|
-
val
|
|
15
|
+
val LocalSettings = staticCompositionLocalOf<State?> { null }
|
|
16
16
|
|
|
17
17
|
class State(p: SharedPreferences, val bibles: List<String>, val reload: () -> Unit) : ViewModel() {
|
|
18
18
|
private val prefs: SharedPreferences = p
|
|
@@ -106,5 +106,5 @@ class State(p: SharedPreferences, val bibles: List<String>, val reload: () -> Un
|
|
|
106
106
|
@Composable
|
|
107
107
|
@ReadOnlyComposable
|
|
108
108
|
fun isDarkMode(): Boolean {
|
|
109
|
-
return
|
|
109
|
+
return LocalSettings.current!!.themeType == ThemeType.Dark || (LocalSettings.current!!.themeType == ThemeType.Auto && isSystemInDarkTheme())
|
|
110
110
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/AppTheme.kt
CHANGED
|
@@ -5,7 +5,6 @@ import androidx.compose.foundation.isSystemInDarkTheme
|
|
|
5
5
|
import androidx.compose.foundation.layout.Arrangement
|
|
6
6
|
import androidx.compose.foundation.layout.Column
|
|
7
7
|
import androidx.compose.foundation.layout.padding
|
|
8
|
-
import androidx.compose.foundation.layout.width
|
|
9
8
|
import androidx.compose.material3.Icon
|
|
10
9
|
import androidx.compose.material3.MaterialTheme
|
|
11
10
|
import androidx.compose.material3.Text
|
|
@@ -108,7 +107,7 @@ fun AppTheme(
|
|
|
108
107
|
content: @Composable() () -> Unit
|
|
109
108
|
) {
|
|
110
109
|
val context = LocalContext.current
|
|
111
|
-
val state =
|
|
110
|
+
val state = LocalSettings.current!!
|
|
112
111
|
val darkTheme = isSystemInDarkTheme()
|
|
113
112
|
val systemUiController = rememberSystemUiController()
|
|
114
113
|
val colorScheme = when {
|
app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
CHANGED
|
@@ -26,7 +26,6 @@ import androidx.compose.material.icons.outlined.MoreVert
|
|
|
26
26
|
import androidx.compose.material.icons.outlined.Share
|
|
27
27
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
28
28
|
import androidx.compose.material3.Icon
|
|
29
|
-
import androidx.compose.material3.IconButton
|
|
30
29
|
import androidx.compose.material3.MaterialTheme
|
|
31
30
|
import androidx.compose.material3.Scaffold
|
|
32
31
|
import androidx.compose.material3.Text
|
|
@@ -94,7 +93,7 @@ fun ChapterScreen(
|
|
|
94
93
|
openDrawer: (MenuType, Int) -> Job,
|
|
95
94
|
) {
|
|
96
95
|
val context = LocalContext.current
|
|
97
|
-
val state =
|
|
96
|
+
val state = LocalSettings.current!!
|
|
98
97
|
val darkTheme = isDarkMode()
|
|
99
98
|
val fontFamily = state.fontType.family()
|
|
100
99
|
val boldWeight = if (state.boldEnabled) FontWeight.W700 else FontWeight.W400
|
|
@@ -105,7 +104,6 @@ fun ChapterScreen(
|
|
|
105
104
|
var dragAmount by remember {
|
|
106
105
|
mutableFloatStateOf(0.0f)
|
|
107
106
|
}
|
|
108
|
-
val buttonInteractionSource = remember { MutableInteractionSource() }
|
|
109
107
|
val chapterVerses =
|
|
110
108
|
verses.filter { it.bookIndex == bookIndex && it.chapterIndex == chapterIndex }
|
|
111
109
|
LoadingBox(isLoading = state.isLoading) {
|
|
@@ -124,11 +122,9 @@ fun ChapterScreen(
|
|
|
124
122
|
verticalAlignment = Alignment.CenterVertically,
|
|
125
123
|
) {
|
|
126
124
|
Text(
|
|
127
|
-
modifier = Modifier
|
|
125
|
+
modifier = Modifier.clickable {
|
|
128
|
-
// .padding(end = 16.dp)
|
|
129
|
-
.clickable {
|
|
130
|
-
|
|
126
|
+
openDrawer(MenuType.Book, bookIndex)
|
|
131
|
-
|
|
127
|
+
},
|
|
132
128
|
text = bookNames[bookIndex],
|
|
133
129
|
style = TextStyle(
|
|
134
130
|
fontSize = 22.sp,
|
|
@@ -149,7 +145,7 @@ fun ChapterScreen(
|
|
|
149
145
|
},
|
|
150
146
|
actions = {
|
|
151
147
|
if (selectedVerses.isNotEmpty()) {
|
|
152
|
-
|
|
148
|
+
TextButton(onClick = {
|
|
153
149
|
scope.launch {
|
|
154
150
|
convertVersesToSpeech(scope,
|
|
155
151
|
selectedVerses.sortedBy { it.verseIndex })
|
|
@@ -162,7 +158,7 @@ fun ChapterScreen(
|
|
|
162
158
|
contentDescription = "Audio",
|
|
163
159
|
)
|
|
164
160
|
}
|
|
165
|
-
|
|
161
|
+
TextButton(onClick = {
|
|
166
162
|
shareVerses(context, selectedVerses)
|
|
167
163
|
selectedVerses = listOf()
|
|
168
164
|
}) {
|
|
@@ -181,9 +177,10 @@ fun ChapterScreen(
|
|
|
181
177
|
),
|
|
182
178
|
)
|
|
183
179
|
}
|
|
180
|
+
TextButton(
|
|
184
|
-
|
|
181
|
+
onClick = {
|
|
185
|
-
|
|
182
|
+
state.showSheet()
|
|
186
|
-
|
|
183
|
+
}) {
|
|
187
184
|
Icon(Icons.Outlined.MoreVert, "More")
|
|
188
185
|
}
|
|
189
186
|
},
|
|
@@ -295,12 +292,13 @@ fun ChapterScreen(
|
|
|
295
292
|
fontFamily = fontFamily,
|
|
296
293
|
fontSize = (16 + state.fontSizeDelta).sp,
|
|
297
294
|
fontWeight = FontWeight.W700,
|
|
298
|
-
color = MaterialTheme.
|
|
295
|
+
color = MaterialTheme.colorScheme.primary,
|
|
299
296
|
),
|
|
300
297
|
text = v.heading
|
|
301
298
|
)
|
|
302
299
|
}
|
|
303
300
|
val isSelected = selectedVerses.contains(v);
|
|
301
|
+
val buttonInteractionSource = remember { MutableInteractionSource() }
|
|
304
302
|
Text(
|
|
305
303
|
modifier = Modifier
|
|
306
304
|
.clickable(
|
app/src/main/java/dev/pyrossh/onlyBible/Drawer.kt
CHANGED
|
@@ -21,7 +21,6 @@ import androidx.compose.material3.Button
|
|
|
21
21
|
import androidx.compose.material3.DrawerValue
|
|
22
22
|
import androidx.compose.material3.Icon
|
|
23
23
|
import androidx.compose.material3.IconButton
|
|
24
|
-
import androidx.compose.material3.MaterialTheme
|
|
25
24
|
import androidx.compose.material3.ModalDrawerSheet
|
|
26
25
|
import androidx.compose.material3.ModalNavigationDrawer
|
|
27
26
|
import androidx.compose.material3.Text
|
|
@@ -69,7 +68,7 @@ fun Drawer(
|
|
|
69
68
|
navController: NavController,
|
|
70
69
|
content: @Composable ((MenuType, Int) -> Job) -> Unit
|
|
71
70
|
) {
|
|
72
|
-
val state =
|
|
71
|
+
val state = LocalSettings.current!!
|
|
73
72
|
val scope = rememberCoroutineScope()
|
|
74
73
|
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
|
75
74
|
var bookIndex by rememberSaveable {
|
app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -26,7 +26,7 @@ class MainActivity : ComponentActivity() {
|
|
|
26
26
|
assets.open("bibles/${fileName}.txt").bufferedReader()
|
|
27
27
|
)
|
|
28
28
|
setContent {
|
|
29
|
-
CompositionLocalProvider(
|
|
29
|
+
CompositionLocalProvider(LocalSettings provides state) {
|
|
30
30
|
AppTheme {
|
|
31
31
|
AppHost(
|
|
32
32
|
verses = verses
|
app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt
CHANGED
|
@@ -41,7 +41,7 @@ import kotlinx.coroutines.launch
|
|
|
41
41
|
fun TextSettingsBottomSheet() {
|
|
42
42
|
val scope = rememberCoroutineScope()
|
|
43
43
|
val sheetState = rememberModalBottomSheetState()
|
|
44
|
-
val state =
|
|
44
|
+
val state = LocalSettings.current!!
|
|
45
45
|
return ModalBottomSheet(
|
|
46
46
|
tonalElevation = 2.dp,
|
|
47
47
|
sheetState = sheetState,
|
readme.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
## TODO
|
|
2
2
|
|
|
3
|
+
* Fix swipe calculations (look at horizontal pager)
|
|
3
4
|
* Improve Paging in dark scheme
|
|
4
5
|
* Use DataManager
|