-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathYVPBibleWidgetView.kt
More file actions
61 lines (54 loc) · 2.33 KB
/
YVPBibleWidgetView.kt
File metadata and controls
61 lines (54 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.youversion.reactnativesdk.views
import android.content.Context
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.views.ComposableScope
import expo.modules.kotlin.views.ComposeProps
import expo.modules.kotlin.views.ExpoComposeView
data class BibleWidgetViewProps(
// Bible reference
val versionId: MutableState<Int?> = mutableStateOf(null),
val bookUSFM: MutableState<String?> = mutableStateOf(null),
val chapter: MutableState<Int?> = mutableStateOf(null),
val verse: MutableState<Int?> = mutableStateOf(null),
val verseStart: MutableState<Int?> = mutableStateOf(null),
val verseEnd: MutableState<Int?> = mutableStateOf(null),
val fontSize: MutableState<Float?> = mutableStateOf(23f),
val colorScheme: MutableState<String?> = mutableStateOf(null),
) : ComposeProps
class YVPBibleWidgetView(context: Context, appContext: AppContext) :
ExpoComposeView<BibleWidgetViewProps>(context, appContext, withHostingView = true) {
override val props = BibleWidgetViewProps()
@Composable
override fun ComposableScope.Content() {
val isDark = when (props.colorScheme.value) {
"dark" -> true
"light" -> false
else -> isSystemInDarkTheme()
}
// TODO: Replace with actual BibleWidget composable when Kotlin SDK is ready
Box(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
Text(
text = "BibleWidgetView placeholder\n" +
"${props.bookUSFM.value} ${props.chapter.value}:${props.verse.value ?: "${props.verseStart.value}-${props.verseEnd.value}"}",
color = if (isDark) Color.White else Color.DarkGray,
fontSize = (props.fontSize.value ?: 23f).sp
)
}
}
}