~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.
a3c5849c
—
pyrossh 1 year ago
fix ios theme not switching
composeApp/src/commonMain/kotlin/dev/pyrossh/only_bible_app/App.kt
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package dev.pyrossh.only_bible_app
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
4
5
|
import androidx.lifecycle.DefaultLifecycleObserver
|
|
5
6
|
import androidx.lifecycle.LifecycleOwner
|
|
6
7
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
|
@@ -9,16 +10,20 @@ import com.russhwolf.settings.Settings
|
|
|
9
10
|
|
|
10
11
|
@Composable
|
|
11
12
|
fun App(model: AppViewModel = viewModel { AppViewModel() }, settings: Settings) {
|
|
13
|
+
val lifeCycleOwner = LocalLifecycleOwner.current
|
|
14
|
+
LaunchedEffect("") {
|
|
12
|
-
|
|
15
|
+
lifeCycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
|
|
13
|
-
|
|
16
|
+
override fun onCreate(owner: LifecycleOwner) {
|
|
14
|
-
|
|
17
|
+
super.onCreate(owner)
|
|
15
|
-
|
|
18
|
+
model.loadData(settings)
|
|
16
|
-
|
|
19
|
+
}
|
|
20
|
+
|
|
17
|
-
|
|
21
|
+
override fun onPause(owner: LifecycleOwner) {
|
|
18
|
-
|
|
22
|
+
super.onPause(owner)
|
|
19
|
-
|
|
23
|
+
model.saveData(settings)
|
|
20
|
-
|
|
24
|
+
}
|
|
21
|
-
|
|
25
|
+
})
|
|
26
|
+
}
|
|
22
27
|
AppTheme(themeType = model.themeType) {
|
|
23
28
|
AppHost(model = model)
|
|
24
29
|
}
|
composeApp/src/commonMain/kotlin/dev/pyrossh/only_bible_app/AppViewModel.kt
CHANGED
|
@@ -91,6 +91,7 @@ class AppViewModel : ViewModel() {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
fun loadData(s: Settings) {
|
|
94
|
+
println("loadData")
|
|
94
95
|
viewModelScope.launch(Dispatchers.IO) {
|
|
95
96
|
viewModelScope.launch(Dispatchers.Main) {
|
|
96
97
|
isLoading = true
|
|
@@ -121,6 +122,7 @@ class AppViewModel : ViewModel() {
|
|
|
121
122
|
|
|
122
123
|
@OptIn(ExperimentalResourceApi::class)
|
|
123
124
|
suspend fun loadBible(b: Bible) {
|
|
125
|
+
println("loadBible")
|
|
124
126
|
try {
|
|
125
127
|
val buffer = Res.readBytes("files/${b.filename()}.txt").decodeToString()
|
|
126
128
|
val localVerses = buffer.split("\n").filter { it.isNotEmpty() }.map {
|
|
@@ -157,6 +159,7 @@ class AppViewModel : ViewModel() {
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
fun saveData(s: Settings) {
|
|
162
|
+
println("saveData")
|
|
160
163
|
viewModelScope.launch(Dispatchers.IO) {
|
|
161
164
|
s.putString("bible", bible.filename())
|
|
162
165
|
s.putInt("bookIndex", bookIndex)
|
iosApp/iosApp/Info.plist
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<key>CFBundleShortVersionString</key>
|
|
20
20
|
<string>2.0.0</string>
|
|
21
21
|
<key>CFBundleVersion</key>
|
|
22
|
-
<string>
|
|
22
|
+
<string>14</string>
|
|
23
23
|
<key>LSRequiresIPhoneOS</key>
|
|
24
24
|
<true/>
|
|
25
25
|
<key>UIApplicationSceneManifest</key>
|