~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.
dcf194b3
—
pyrossh 1 year ago
move TextSettings
- app/src/main/java/dev/pyrossh/onlyBible/AppHost.kt +42 -38
- app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt +0 -9
- app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt +14 -5
- app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt +1 -11
- app/src/main/java/dev/pyrossh/onlyBible/composables/TextSettingsBottomSheet.kt +7 -17
- app/src/main/java/dev/pyrossh/onlyBible/composables/VerseText.kt +1 -0
app/src/main/java/dev/pyrossh/onlyBible/AppHost.kt
CHANGED
|
@@ -4,54 +4,58 @@ import androidx.compose.animation.EnterTransition
|
|
|
4
4
|
import androidx.compose.animation.ExitTransition
|
|
5
5
|
import androidx.compose.animation.core.tween
|
|
6
6
|
import androidx.compose.runtime.Composable
|
|
7
|
-
import androidx.
|
|
7
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
8
8
|
import androidx.navigation.compose.NavHost
|
|
9
9
|
import androidx.navigation.compose.composable
|
|
10
|
+
import androidx.navigation.compose.rememberNavController
|
|
10
11
|
import androidx.navigation.toRoute
|
|
12
|
+
import dev.pyrossh.onlyBible.utils.LocalNavController
|
|
11
13
|
|
|
12
14
|
@Composable
|
|
13
15
|
fun AppHost(
|
|
14
|
-
model: AppViewModel
|
|
16
|
+
model: AppViewModel
|
|
15
|
-
navController: NavHostController,
|
|
16
17
|
) {
|
|
17
|
-
val navigateToChapter = { props: ChapterScreenProps ->
|
|
18
|
-
|
|
18
|
+
val navController = rememberNavController()
|
|
19
|
-
}
|
|
20
19
|
if (!model.isLoading) {
|
|
20
|
+
CompositionLocalProvider(LocalNavController provides navController) {
|
|
21
|
-
|
|
21
|
+
NavHost(
|
|
22
|
-
|
|
22
|
+
navController = navController,
|
|
23
|
-
|
|
23
|
+
startDestination = ChapterScreenProps(
|
|
24
|
+
model.bookIndex,
|
|
25
|
+
model.chapterIndex,
|
|
26
|
+
model.verseIndex
|
|
27
|
+
)
|
|
24
|
-
|
|
28
|
+
) {
|
|
25
|
-
|
|
29
|
+
composable<ChapterScreenProps>(
|
|
26
|
-
|
|
30
|
+
enterTransition = {
|
|
27
|
-
|
|
31
|
+
val props = this.targetState.toRoute<ChapterScreenProps>()
|
|
28
|
-
|
|
32
|
+
slideIntoContainer(
|
|
29
|
-
|
|
33
|
+
Dir.valueOf(props.dir).slideDirection(),
|
|
30
|
-
|
|
34
|
+
tween(400),
|
|
31
|
-
|
|
35
|
+
)
|
|
32
|
-
|
|
36
|
+
},
|
|
33
|
-
|
|
37
|
+
exitTransition = {
|
|
34
|
-
|
|
38
|
+
ExitTransition.None
|
|
35
|
-
|
|
39
|
+
},
|
|
36
|
-
|
|
40
|
+
popEnterTransition = {
|
|
37
|
-
|
|
41
|
+
EnterTransition.None
|
|
38
|
-
|
|
42
|
+
},
|
|
39
|
-
|
|
43
|
+
popExitTransition = {
|
|
40
|
-
|
|
44
|
+
val props = this.targetState.toRoute<ChapterScreenProps>()
|
|
41
|
-
|
|
45
|
+
slideOutOfContainer(
|
|
42
|
-
|
|
46
|
+
Dir.valueOf(props.dir).reverse().slideDirection(),
|
|
43
|
-
|
|
47
|
+
tween(400),
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
) {
|
|
51
|
+
val props = it.toRoute<ChapterScreenProps>()
|
|
52
|
+
ChapterScreen(
|
|
53
|
+
model = model,
|
|
54
|
+
bookIndex = props.bookIndex,
|
|
55
|
+
chapterIndex = props.chapterIndex,
|
|
56
|
+
verseIndex = props.verseIndex,
|
|
44
57
|
)
|
|
45
58
|
}
|
|
46
|
-
) {
|
|
47
|
-
val props = it.toRoute<ChapterScreenProps>()
|
|
48
|
-
ChapterScreen(
|
|
49
|
-
model = model,
|
|
50
|
-
bookIndex = props.bookIndex,
|
|
51
|
-
chapterIndex = props.chapterIndex,
|
|
52
|
-
verseIndex = props.verseIndex,
|
|
53
|
-
navigateToChapter = navigateToChapter,
|
|
54
|
-
)
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/AppViewModel.kt
CHANGED
|
@@ -61,7 +61,6 @@ class AppViewModel : ViewModel() {
|
|
|
61
61
|
var isAudioPlaying by mutableStateOf(false)
|
|
62
62
|
val verses = MutableStateFlow(listOf<Verse>())
|
|
63
63
|
val bookNames = MutableStateFlow(listOf<String>())
|
|
64
|
-
var showBottomSheet by mutableStateOf(false)
|
|
65
64
|
private val highlightedVerses = MutableStateFlow(JSONObject())
|
|
66
65
|
|
|
67
66
|
var bible by mutableStateOf(bibles.first())
|
|
@@ -98,14 +97,6 @@ class AppViewModel : ViewModel() {
|
|
|
98
97
|
searchText.value = text
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
fun showSheet() {
|
|
102
|
-
showBottomSheet = true
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
fun closeSheet() {
|
|
106
|
-
showBottomSheet = false
|
|
107
|
-
}
|
|
108
|
-
|
|
109
100
|
fun setApplicationNightMode(context: Context, v: Int) {
|
|
110
101
|
val uiModeManager = context.getSystemService(UI_MODE_SERVICE) as UiModeManager
|
|
111
102
|
uiModeManager.setApplicationNightMode(v)
|
app/src/main/java/dev/pyrossh/onlyBible/ChapterScreen.kt
CHANGED
|
@@ -43,8 +43,10 @@ import androidx.compose.ui.unit.sp
|
|
|
43
43
|
import dev.pyrossh.onlyBible.composables.BibleSelector
|
|
44
44
|
import dev.pyrossh.onlyBible.composables.ChapterSelector
|
|
45
45
|
import dev.pyrossh.onlyBible.composables.EmbeddedSearchBar
|
|
46
|
+
import dev.pyrossh.onlyBible.composables.TextSettingsBottomSheet
|
|
46
47
|
import dev.pyrossh.onlyBible.composables.VerseHeading
|
|
47
48
|
import dev.pyrossh.onlyBible.composables.VerseText
|
|
49
|
+
import dev.pyrossh.onlyBible.utils.LocalNavController
|
|
48
50
|
import dev.pyrossh.onlyBible.utils.detectSwipe
|
|
49
51
|
import kotlinx.parcelize.Parcelize
|
|
50
52
|
import kotlinx.serialization.Serializable
|
|
@@ -55,7 +57,6 @@ data class ChapterScreenProps(
|
|
|
55
57
|
val bookIndex: Int,
|
|
56
58
|
val chapterIndex: Int,
|
|
57
59
|
val verseIndex: Int,
|
|
58
|
-
// TODO: fix this
|
|
59
60
|
val dir: String = Dir.Left.name,
|
|
60
61
|
) : Parcelable
|
|
61
62
|
|
|
@@ -82,10 +83,11 @@ fun ChapterScreen(
|
|
|
82
83
|
bookIndex: Int,
|
|
83
84
|
chapterIndex: Int,
|
|
84
85
|
verseIndex: Int,
|
|
85
|
-
navigateToChapter: (ChapterScreenProps) -> Unit,
|
|
86
86
|
) {
|
|
87
87
|
val view = LocalView.current
|
|
88
88
|
val context = LocalContext.current
|
|
89
|
+
val navController = LocalNavController.current
|
|
90
|
+
var isSettingsShown by remember { mutableStateOf(false) }
|
|
89
91
|
var isSearchShown by remember { mutableStateOf(false) }
|
|
90
92
|
var chapterSelectorShown by remember { mutableStateOf(false) }
|
|
91
93
|
var bibleSelectorShown by remember { mutableStateOf(false) }
|
|
@@ -144,6 +146,13 @@ fun ChapterScreen(
|
|
|
144
146
|
)
|
|
145
147
|
}
|
|
146
148
|
|
|
149
|
+
if (isSettingsShown) {
|
|
150
|
+
TextSettingsBottomSheet(
|
|
151
|
+
model = model,
|
|
152
|
+
onDismiss = { isSettingsShown = false }
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
147
156
|
Column(
|
|
148
157
|
modifier = Modifier
|
|
149
158
|
.fillMaxSize()
|
|
@@ -206,7 +215,7 @@ fun ChapterScreen(
|
|
|
206
215
|
TextButton(
|
|
207
216
|
onClick = {
|
|
208
217
|
view.playSoundEffect(SoundEffectConstants.CLICK)
|
|
209
|
-
|
|
218
|
+
isSettingsShown = true
|
|
210
219
|
}) {
|
|
211
220
|
Icon(
|
|
212
221
|
imageVector = Icons.Outlined.MoreVert,
|
|
@@ -226,7 +235,7 @@ fun ChapterScreen(
|
|
|
226
235
|
detectSwipe(
|
|
227
236
|
onSwipeLeft = {
|
|
228
237
|
val pair = getForwardPair(bookIndex, chapterIndex)
|
|
229
|
-
|
|
238
|
+
navController.navigate(
|
|
230
239
|
ChapterScreenProps(
|
|
231
240
|
bookIndex = pair.first,
|
|
232
241
|
chapterIndex = pair.second,
|
|
@@ -236,7 +245,7 @@ fun ChapterScreen(
|
|
|
236
245
|
},
|
|
237
246
|
onSwipeRight = {
|
|
238
247
|
val pair = getBackwardPair(bookIndex, chapterIndex)
|
|
239
|
-
|
|
248
|
+
navController.navigate(
|
|
240
249
|
ChapterScreenProps(
|
|
241
250
|
bookIndex = pair.first,
|
|
242
251
|
chapterIndex = pair.second,
|
app/src/main/java/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -5,11 +5,7 @@ import androidx.activity.ComponentActivity
|
|
|
5
5
|
import androidx.activity.compose.setContent
|
|
6
6
|
import androidx.activity.enableEdgeToEdge
|
|
7
7
|
import androidx.activity.viewModels
|
|
8
|
-
import androidx.compose.runtime.CompositionLocalProvider
|
|
9
8
|
import androidx.lifecycle.lifecycleScope
|
|
10
|
-
import androidx.navigation.compose.rememberNavController
|
|
11
|
-
import dev.pyrossh.onlyBible.composables.TextSettingsBottomSheet
|
|
12
|
-
import dev.pyrossh.onlyBible.utils.LocalNavController
|
|
13
9
|
import kotlinx.coroutines.launch
|
|
14
10
|
|
|
15
11
|
class MainActivity : ComponentActivity() {
|
|
@@ -28,13 +24,7 @@ class MainActivity : ComponentActivity() {
|
|
|
28
24
|
AppTheme(
|
|
29
25
|
nightMode = model.nightMode
|
|
30
26
|
) {
|
|
31
|
-
val navController = rememberNavController()
|
|
32
|
-
CompositionLocalProvider(LocalNavController provides navController) {
|
|
33
|
-
|
|
27
|
+
AppHost(model = model)
|
|
34
|
-
}
|
|
35
|
-
if (model.showBottomSheet) {
|
|
36
|
-
TextSettingsBottomSheet()
|
|
37
|
-
}
|
|
38
28
|
}
|
|
39
29
|
}
|
|
40
30
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/composables/TextSettingsBottomSheet.kt
CHANGED
|
@@ -30,7 +30,6 @@ import androidx.compose.material3.MaterialTheme
|
|
|
30
30
|
import androidx.compose.material3.ModalBottomSheet
|
|
31
31
|
import androidx.compose.material3.Surface
|
|
32
32
|
import androidx.compose.material3.Text
|
|
33
|
-
import androidx.compose.material3.rememberModalBottomSheetState
|
|
34
33
|
import androidx.compose.runtime.Composable
|
|
35
34
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
36
35
|
import androidx.compose.ui.Alignment
|
|
@@ -41,27 +40,23 @@ import androidx.compose.ui.text.TextStyle
|
|
|
41
40
|
import androidx.compose.ui.text.font.FontWeight
|
|
42
41
|
import androidx.compose.ui.unit.dp
|
|
43
42
|
import androidx.compose.ui.unit.sp
|
|
44
|
-
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
45
43
|
import dev.pyrossh.onlyBible.AppViewModel
|
|
46
44
|
import dev.pyrossh.onlyBible.FontType
|
|
47
45
|
import kotlinx.coroutines.launch
|
|
48
46
|
|
|
49
47
|
@Composable
|
|
50
48
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
51
|
-
fun TextSettingsBottomSheet(
|
|
49
|
+
fun TextSettingsBottomSheet(
|
|
50
|
+
model: AppViewModel,
|
|
51
|
+
onDismiss: () -> Unit,
|
|
52
|
+
) {
|
|
52
53
|
val view = LocalView.current
|
|
53
54
|
val context = LocalContext.current
|
|
54
55
|
val scope = rememberCoroutineScope()
|
|
55
|
-
val sheetState = rememberModalBottomSheetState()
|
|
56
56
|
return ModalBottomSheet(
|
|
57
57
|
tonalElevation = 2.dp,
|
|
58
|
-
sheetState = sheetState,
|
|
59
58
|
onDismissRequest = {
|
|
60
|
-
scope.launch {
|
|
61
|
-
sheetState.hide()
|
|
62
|
-
}.invokeOnCompletion {
|
|
63
|
-
|
|
59
|
+
onDismiss()
|
|
64
|
-
}
|
|
65
60
|
},
|
|
66
61
|
) {
|
|
67
62
|
Column(
|
|
@@ -85,11 +80,7 @@ fun TextSettingsBottomSheet(model: AppViewModel = viewModel()) {
|
|
|
85
80
|
Row(horizontalArrangement = Arrangement.End) {
|
|
86
81
|
IconButton(onClick = {
|
|
87
82
|
view.playSoundEffect(SoundEffectConstants.CLICK)
|
|
88
|
-
scope.launch {
|
|
89
|
-
sheetState.hide()
|
|
90
|
-
}.invokeOnCompletion {
|
|
91
|
-
|
|
83
|
+
onDismiss()
|
|
92
|
-
}
|
|
93
84
|
}) {
|
|
94
85
|
Icon(Icons.Filled.Close, "Close")
|
|
95
86
|
}
|
|
@@ -268,8 +259,7 @@ fun TextSettingsBottomSheet(model: AppViewModel = viewModel()) {
|
|
|
268
259
|
onClick = {
|
|
269
260
|
view.playSoundEffect(SoundEffectConstants.CLICK)
|
|
270
261
|
scope.launch {
|
|
271
|
-
sheetState.hide()
|
|
272
|
-
|
|
262
|
+
onDismiss()
|
|
273
263
|
model.setApplicationNightMode(context, it)
|
|
274
264
|
}
|
|
275
265
|
}
|
app/src/main/java/dev/pyrossh/onlyBible/composables/VerseText.kt
CHANGED
|
@@ -54,6 +54,7 @@ import androidx.compose.ui.unit.IntOffset
|
|
|
54
54
|
import androidx.compose.ui.unit.dp
|
|
55
55
|
import androidx.compose.ui.unit.sp
|
|
56
56
|
import androidx.compose.ui.window.Popup
|
|
57
|
+
import androidx.navigation.fragment.NavHostFragment
|
|
57
58
|
import dev.pyrossh.onlyBible.AppViewModel
|
|
58
59
|
import dev.pyrossh.onlyBible.ChapterScreenProps
|
|
59
60
|
import dev.pyrossh.onlyBible.FontType
|