Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.youversion.reactnativesdk

import com.youversion.reactnativesdk.views.BibleReaderViewProps
import com.youversion.reactnativesdk.views.YVPBibleReaderView
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
Expand All @@ -8,6 +9,8 @@ class RNBibleReaderViewModule : Module() {
override fun definition() = ModuleDefinition {
Name("BibleReaderView")

View(YVPBibleReaderView::class)
View("YVPBibleReaderView") { props: BibleReaderViewProps ->
YVPBibleReaderView(props)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package com.youversion.reactnativesdk

import androidx.compose.runtime.remember
import com.youversion.reactnativesdk.api.VerseTappedEvent
import com.youversion.reactnativesdk.views.BibleTextViewProps
import com.youversion.reactnativesdk.views.YVPBibleTextView
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
import expo.modules.kotlin.viewevent.getValue

class RNBibleTextViewModule : Module() {
override fun definition() = ModuleDefinition {
Name("BibleTextView")

View(YVPBibleTextView::class) {
Events("onTap")
View(
name = "YVPBibleTextView",
events = { Events("onTap") }
) { props: BibleTextViewProps ->
val onTap by remember { EventDispatcher<VerseTappedEvent>() }

YVPBibleTextView(props) { event: VerseTappedEvent ->
onTap(event)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.youversion.reactnativesdk

import com.youversion.reactnativesdk.views.BibleWidgetViewProps
import com.youversion.reactnativesdk.views.YVPBibleWidgetView
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
Expand All @@ -8,6 +9,8 @@ class RNBibleWidgetViewModule : Module() {
override fun definition() = ModuleDefinition {
Name("BibleWidgetView")

View(YVPBibleWidgetView::class)
View("YVPBibleWidgetView") { props: BibleWidgetViewProps ->
YVPBibleWidgetView(props)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
package com.youversion.reactnativesdk

import androidx.compose.runtime.remember
import com.youversion.reactnativesdk.views.SignInWithYouVersionButtonProps
import com.youversion.reactnativesdk.views.YVPSignInWithYouVersionButton
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
import expo.modules.kotlin.viewevent.getValue

class RNSignInWithYouVersionButtonModule : Module() {
override fun definition() = ModuleDefinition {
Name("SignInWithYouVersionButton")

View(YVPSignInWithYouVersionButton::class) {
Events("onTap")
View(
name = "YVPSignInWithYouVersionButton",
events = { Events("onTap") }
) { props: SignInWithYouVersionButtonProps ->
val onTap by remember { EventDispatcher<Unit>() }

YVPSignInWithYouVersionButton(
props = props
) {
onTap(Unit)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
package com.youversion.reactnativesdk

import androidx.compose.runtime.remember
import com.youversion.reactnativesdk.views.VotdViewProps
import com.youversion.reactnativesdk.views.YVPVotdView
import expo.modules.kotlin.modules.Module
import expo.modules.kotlin.modules.ModuleDefinition
import expo.modules.kotlin.viewevent.getValue

class RNVotdViewModule : Module() {
override fun definition() = ModuleDefinition {
Name("VotdView")

View(YVPVotdView::class)
View(
name = "YVPVotdView",
events = { Events("onSharePress", "onFullChapterPress") }
) { props: VotdViewProps ->
val onSharePress by remember { EventDispatcher<Unit>() }
val onFullChapterPress by remember { EventDispatcher<Unit>() }

YVPVotdView(
props = props,
onSharePress = { onSharePress(Unit) },
onFullChapterPress = { onFullChapterPress(Unit) }
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.youversion.reactnativesdk.api

import com.youversion.platform.core.bibles.domain.BibleReference
import com.youversion.platform.core.bibles.models.BibleBook
import com.youversion.platform.core.bibles.models.BibleChapter
import com.youversion.platform.core.bibles.models.BibleVersion
Expand Down Expand Up @@ -61,6 +62,20 @@ data class LanguageRecord(
)
}

data class VerseTappedEvent(
@Field
val bibleReference: BibleReferenceRecord
) : Record {
constructor(bibleReference: BibleReference) : this(
bibleReference = BibleReferenceRecord(
versionId = bibleReference.versionId,
bookUSFM = bibleReference.bookUSFM,
chapter = bibleReference.chapter,
verse = bibleReference.verseStart
)
)
}

data class BibleVersionRecord(
@Field
val id: Int,
Expand Down Expand Up @@ -155,6 +170,8 @@ data class BibleReferenceRecord(
val bookUSFM: String,
@Field
val chapter: Int,
@Field
val verse: Int?
) : Record

data class HighlightRecord(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,67 +1,55 @@
package com.youversion.reactnativesdk.views

import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import com.youversion.platform.core.bibles.domain.BibleReference
import com.youversion.platform.reader.BibleReader
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.views.ComposableScope
import expo.modules.kotlin.views.ComposeProps
import expo.modules.kotlin.views.ExpoComposeView

const val DEFAULT_BEREAN_STANDARD_BIBLE_VERSION = 3034

data class BibleReaderViewProps(
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 appName: MutableState<String?> = mutableStateOf(null),
val signInMessage: MutableState<String?> = mutableStateOf(null),
val hasReference: MutableState<Boolean?> = mutableStateOf(null)
val versionId: Int? = null,
val bookUSFM: String? = null,
val chapter: Int? = null,
val verse: Int? = null,
val verseStart: Int? = null,
val verseEnd: Int? = null,
val appName: String? = null,
val signInMessage: String? = null,
val hasReference: Boolean? = null
) : ComposeProps

class YVPBibleReaderView(context: Context, appContext: AppContext) :
ExpoComposeView<BibleReaderViewProps>(context, appContext, withHostingView = true) {
override val props = BibleReaderViewProps()
@Composable
fun YVPBibleReaderView(props: BibleReaderViewProps) {
BibleReader(
appName = props.appName ?: "",
appSignInMessage = props.signInMessage ?: "",
bibleReference = bibleReference(props),
)
}

@Composable
override fun ComposableScope.Content() {
BibleReader(
appName = props.appName.value ?: "",
appSignInMessage = props.signInMessage.value ?: "",
bibleReference = bibleReference(),
fun bibleReference(props: BibleReaderViewProps): BibleReference? {
val start = props.verseStart
val end = props.verseEnd

if (start != null && end != null) {
return BibleReference(
versionId = props.versionId ?: DEFAULT_BEREAN_STANDARD_BIBLE_VERSION,
bookUSFM = props.bookUSFM ?: "JHN",
chapter = props.chapter ?: 1,
verseStart = start,
verseEnd = end
)
}

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
if (props.hasReference == true) {
return BibleReference(
versionId = props.versionId ?: DEFAULT_BEREAN_STANDARD_BIBLE_VERSION,
bookUSFM = props.bookUSFM ?: "JHN",
chapter = props.chapter ?: 1,
verse = props.verse
)
}

return null
}
Loading
Loading