~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.
2277c94f
—
Peter John 1 year ago
fix view model issues
- app/src/main/java/dev/pyrossh/onlyBible/AppDrawer.kt +1 -2
- app/src/main/java/dev/pyrossh/onlyBible/AppHost.kt +6 -4
- app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt +1 -1
- app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt +0 -2
- app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt +5 -6
- app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt +1 -2
app/src/main/java/dev/pyrossh/onlyBible/AppDrawer.kt
CHANGED
|
@@ -38,7 +38,6 @@ import androidx.compose.ui.text.TextStyle
|
|
|
38
38
|
import androidx.compose.ui.text.font.FontWeight
|
|
39
39
|
import androidx.compose.ui.unit.dp
|
|
40
40
|
import androidx.compose.ui.unit.sp
|
|
41
|
-
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
42
41
|
import androidx.navigation.NavController
|
|
43
42
|
import kotlinx.coroutines.Job
|
|
44
43
|
import kotlinx.coroutines.launch
|
|
@@ -78,7 +77,7 @@ val bibles = listOf(
|
|
|
78
77
|
|
|
79
78
|
@Composable
|
|
80
79
|
fun AppDrawer(
|
|
81
|
-
model: AppViewModel
|
|
80
|
+
model: AppViewModel,
|
|
82
81
|
navController: NavController,
|
|
83
82
|
content: @Composable ((MenuType, Int) -> Job) -> Unit
|
|
84
83
|
) {
|
app/src/main/java/dev/pyrossh/onlyBible/AppHost.kt
CHANGED
|
@@ -22,12 +22,14 @@ import androidx.navigation.toRoute
|
|
|
22
22
|
fun AppHost(model: AppViewModel = viewModel()) {
|
|
23
23
|
val navController = rememberNavController()
|
|
24
24
|
Box(
|
|
25
|
-
modifier = Modifier
|
|
25
|
+
modifier = Modifier
|
|
26
|
+
.fillMaxSize()
|
|
27
|
+
.let {
|
|
26
|
-
|
|
28
|
+
if (model.isLoading) it.alpha(0.5f) else it
|
|
27
|
-
|
|
29
|
+
}
|
|
28
30
|
) {
|
|
29
31
|
if (model.verses.isNotEmpty()) {
|
|
30
|
-
AppDrawer(navController = navController) { openDrawer ->
|
|
32
|
+
AppDrawer(model = model, navController = navController) { openDrawer ->
|
|
31
33
|
NavHost(
|
|
32
34
|
navController = navController,
|
|
33
35
|
startDestination = ChapterScreenProps(model.bookIndex, model.chapterIndex)
|
app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
CHANGED
|
@@ -99,7 +99,6 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
99
99
|
getPreferencesKey = ::booleanPreferencesKey,
|
|
100
100
|
)
|
|
101
101
|
|
|
102
|
-
|
|
103
102
|
fun isDarkTheme(isSystemDark: Boolean): Boolean {
|
|
104
103
|
val themeType = ThemeType.valueOf(themeType)
|
|
105
104
|
return themeType == ThemeType.Dark || (themeType == ThemeType.Auto && isSystemDark)
|
|
@@ -125,6 +124,7 @@ class AppViewModel(application: Application) : AndroidViewModel(application) {
|
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
fun loadBible(context: Context) {
|
|
127
|
+
println("LoadBible")
|
|
128
128
|
viewModelScope.launch(Dispatchers.IO) {
|
|
129
129
|
launch(Dispatchers.Main) {
|
|
130
130
|
isLoading = true
|
app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
-
import android.annotation.SuppressLint
|
|
4
3
|
import android.graphics.Typeface
|
|
5
4
|
import android.os.Parcelable
|
|
6
5
|
import android.text.Html
|
|
@@ -95,7 +94,6 @@ enum class Dir : Parcelable {
|
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
98
|
-
@SuppressLint("MutableCollectionMutableState")
|
|
99
97
|
@Composable
|
|
100
98
|
fun ChapterScreen(
|
|
101
99
|
model: AppViewModel,
|
app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -7,7 +7,7 @@ import androidx.activity.enableEdgeToEdge
|
|
|
7
7
|
import androidx.activity.viewModels
|
|
8
8
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
|
9
9
|
import androidx.lifecycle.lifecycleScope
|
|
10
|
-
import kotlinx.coroutines.flow.
|
|
10
|
+
import kotlinx.coroutines.flow.first
|
|
11
11
|
import kotlinx.coroutines.launch
|
|
12
12
|
|
|
13
13
|
class MainActivity : ComponentActivity() {
|
|
@@ -19,17 +19,16 @@ class MainActivity : ComponentActivity() {
|
|
|
19
19
|
super.onCreate(savedInstanceState)
|
|
20
20
|
enableEdgeToEdge()
|
|
21
21
|
lifecycleScope.launch {
|
|
22
|
-
applicationContext.dataStore.data.
|
|
22
|
+
val data = applicationContext.dataStore.data.first()
|
|
23
|
-
|
|
23
|
+
model.initData(data)
|
|
24
|
-
|
|
24
|
+
model.loadBible(applicationContext)
|
|
25
|
-
}
|
|
26
25
|
}
|
|
27
26
|
splashScreen.setKeepOnScreenCondition { model.isLoading }
|
|
28
27
|
setContent {
|
|
29
28
|
AppTheme {
|
|
30
29
|
AppHost()
|
|
31
30
|
if (model.showBottomSheet) {
|
|
32
|
-
TextSettingsBottomSheet()
|
|
31
|
+
TextSettingsBottomSheet(model = model)
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/TextSettingsBottomSheet.kt
CHANGED
|
@@ -35,7 +35,6 @@ import androidx.compose.ui.text.TextStyle
|
|
|
35
35
|
import androidx.compose.ui.text.font.FontWeight
|
|
36
36
|
import androidx.compose.ui.unit.dp
|
|
37
37
|
import androidx.compose.ui.unit.sp
|
|
38
|
-
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
39
38
|
import dev.pyrossh.onlyBible.ThemeType.Auto
|
|
40
39
|
import dev.pyrossh.onlyBible.ThemeType.Dark
|
|
41
40
|
import dev.pyrossh.onlyBible.ThemeType.Light
|
|
@@ -43,7 +42,7 @@ import kotlinx.coroutines.launch
|
|
|
43
42
|
|
|
44
43
|
@Composable
|
|
45
44
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
46
|
-
fun TextSettingsBottomSheet(model: AppViewModel
|
|
45
|
+
fun TextSettingsBottomSheet(model: AppViewModel) {
|
|
47
46
|
val scope = rememberCoroutineScope()
|
|
48
47
|
val sheetState = rememberModalBottomSheetState()
|
|
49
48
|
val themeType = ThemeType.valueOf(model.themeType)
|