diff --git a/android/src/main/java/com/youversion/reactnativesdk/views/YVPBibleReaderView.kt b/android/src/main/java/com/youversion/reactnativesdk/views/YVPBibleReaderView.kt index 3b17ceb..afdc20e 100644 --- a/android/src/main/java/com/youversion/reactnativesdk/views/YVPBibleReaderView.kt +++ b/android/src/main/java/com/youversion/reactnativesdk/views/YVPBibleReaderView.kt @@ -1,55 +1,66 @@ package com.youversion.reactnativesdk.views import android.content.Context -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -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.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp +import com.youversion.platform.core.bibles.domain.BibleReference +import com.youversion.platform.reader.BibleReader import expo.modules.kotlin.AppContext import expo.modules.kotlin.views.ComposeProps import expo.modules.kotlin.views.ExpoComposeView +const val DEFAULT_BEREAN_STANDARD_BIBLE_VERSION = 3034 + data class BibleReaderViewProps( - // Bible reference val versionId: MutableState = mutableStateOf(null), val bookUSFM: MutableState = mutableStateOf(null), val chapter: MutableState = mutableStateOf(null), val verse: MutableState = mutableStateOf(null), val verseStart: MutableState = mutableStateOf(null), val verseEnd: MutableState = mutableStateOf(null), - val appName: MutableState = mutableStateOf(null), val signInMessage: MutableState = mutableStateOf(null), - val hasReference: MutableState = mutableStateOf(false), + val hasReference: MutableState = mutableStateOf(null) ) : ComposeProps class YVPBibleReaderView(context: Context, appContext: AppContext) : ExpoComposeView(context, appContext, withHostingView = true) { - override val props = BibleReaderViewProps() @Composable override fun Content(modifier: Modifier) { - // TODO: Replace with actual BibleReaderView composable when Kotlin SDK is ready - Box( - modifier = modifier - .fillMaxSize() - .padding(16.dp), - contentAlignment = Alignment.Center - ) { - Text( - text = "BibleReaderView placeholder\n" + - "App: ${props.appName.value}\n" + - "Reference: ${props.bookUSFM.value} ${props.chapter.value}", - color = Color.Gray + BibleReader( + appName = props.appName.value ?: "", + appSignInMessage = props.signInMessage.value ?: "", + bibleReference = bibleReference(), + ) + } + + fun bibleReference(): BibleReference? { + val start = props.verseStart.value + val end = props.verseEnd.value + + if (start != null && end != null) { + return BibleReference( + versionId = props.versionId.value ?: DEFAULT_BEREAN_STANDARD_BIBLE_VERSION, + bookUSFM = props.bookUSFM.value ?: "JHN", + chapter = props.chapter.value ?: 1, + verseStart = start, + verseEnd = end ) } + + if (props.hasReference.value == true) { + return BibleReference( + versionId = props.versionId.value ?: DEFAULT_BEREAN_STANDARD_BIBLE_VERSION, + bookUSFM = props.bookUSFM.value ?: "JHN", + chapter = props.chapter.value ?: 1, + verse = props.verse.value + ) + } + + return null } }