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
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies {
implementation 'androidx.compose.foundation:foundation-android:1.9.1'
implementation 'androidx.compose.material3:material3-android:1.3.2'

implementation 'com.youversion.platform:platform-core:0.6.0'
implementation 'com.youversion.platform:platform-ui:0.6.0'
implementation 'com.youversion.platform:platform-reader:0.6.0'
implementation 'com.youversion.platform:platform-core:1.0.1'
implementation 'com.youversion.platform:platform-ui:1.0.1'
implementation 'com.youversion.platform:platform-reader:1.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ import com.youversion.platform.core.bibles.domain.BibleVersionRepository

object YVPBibleApi {
suspend fun versions(languageTag: String?): List<BibleVersionRecord> {
val response = YouVersionApi.bible.versions(languageTag)
val records = response.map { BibleVersionRecord(it) }
return records
val allResults = mutableListOf<BibleVersionRecord>()
var pageToken: String? = null

do {
val response = YouVersionApi.bible.versions(languageTag, pageToken = pageToken)
allResults.addAll(response.data.map { BibleVersionRecord(it) })

pageToken = response.nextPageToken
} while (pageToken != null)

return allResults
}

suspend fun version(versionId: Int): BibleVersionRecord {
Expand All @@ -19,14 +27,13 @@ object YVPBibleApi {
}

suspend fun chapter(bibleReference: BibleReferenceRecord, context: Context): String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unused context parameter and stale imports

The refactored chapter() function no longer uses the context: Context parameter or the two domain imports that were needed by the old BibleVersionRepository-based implementation. These should be cleaned up to avoid dead code and potential compiler warnings.

Suggested change
suspend fun chapter(bibleReference: BibleReferenceRecord, context: Context): String {
suspend fun chapter(bibleReference: BibleReferenceRecord): String {

Also remove the two now-unused import lines at the top of the file:

import com.youversion.platform.core.bibles.domain.BibleReference
import com.youversion.platform.core.bibles.domain.BibleVersionRepository

val response = BibleVersionRepository(context).chapter(
reference = BibleReference(
versionId = bibleReference.versionId,
bookUSFM = bibleReference.bookUSFM,
chapter = bibleReference.chapter,
)
val passageId = bibleReference.bookUSFM + "." + bibleReference.chapter.toString()

val response = YouVersionApi.bible.passage(
versionId = bibleReference.versionId,
passageId = passageId
)

return response
return response.content
Comment on lines +30 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Unused context parameter in chapter() after switching to YouVersionApi.bible.passage()

The chapter() function was refactored to use YouVersionApi.bible.passage() which does not require an Android Context, but the context: Context parameter was left in the function signature. The caller at RNYouVersionPlatformModule.kt:59-66 still obtains and passes the ReactContext, which would throw IllegalStateException if ReactContext is not yet available — an unnecessary risk for a parameter that's no longer used. The now-unused BibleVersionRepository import at YVPBibleApi.kt:6 also remains.

Prompt for agents
In android/src/main/java/com/youversion/reactnativesdk/api/YVPBibleApi.kt:
1. Remove the unused import of BibleVersionRepository on line 6
2. Remove the unused import of android.content.Context on line 3
3. Change the chapter function signature on line 29 from `suspend fun chapter(bibleReference: BibleReferenceRecord, context: Context): String` to `suspend fun chapter(bibleReference: BibleReferenceRecord): String`

In android/src/main/java/com/youversion/reactnativesdk/RNYouVersionPlatformModule.kt:
1. On lines 59-66, remove the context-obtaining code and simplify to just: `return@Coroutine YVPBibleApi.chapter(bibleReference = bibleReference)`
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import com.youversion.platform.core.api.YouVersionApi

object YVPLanguagesApi {
suspend fun languages(country: String?): List<LanguageRecord> {
val response = YouVersionApi.languages.languages(country)
val records = response.map { LanguageRecord(it) }
return records
val allResults = mutableListOf<LanguageRecord>()
var pageToken: String? = null

do {
val response = YouVersionApi.languages.languages(country, pageToken = pageToken)
allResults.addAll(response.data.map { LanguageRecord(it) })

pageToken = response.nextPageToken
} while (pageToken != null)

return allResults
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ data class YouVersionVerseOfTheDayRecord(

data class LanguageRecord(
@Field
val id: String,
val id: String?,
@Field
val language: String,
val language: String?,
@Field
val script: String?,
@Field
val scriptName: String?,
@Field
val aliases: List<String>,
val aliases: List<String>?,
@Field
val displayNames: Map<String, String>,
val displayNames: Map<String, String>?,
@Field
val scripts: List<String>,
val scripts: List<String>?,
@Field
val variants: List<String>,
val variants: List<String>?,
@Field
val countries: List<String>,
val countries: List<String>?,
@Field
val textDirection: String,
@Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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

Expand All @@ -30,7 +31,7 @@ class YVPBibleReaderView(context: Context, appContext: AppContext) :
override val props = BibleReaderViewProps()

@Composable
override fun Content(modifier: Modifier) {
override fun ComposableScope.Content() {
BibleReader(
appName = props.appName.value ?: "",
appSignInMessage = props.signInMessage.value ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.viewevent.EventDispatcher
import expo.modules.kotlin.views.ComposableScope
import expo.modules.kotlin.views.ComposeProps
import expo.modules.kotlin.views.ExpoComposeView

Expand Down Expand Up @@ -43,16 +44,16 @@ class YVPBibleTextView(context: Context, appContext: AppContext) :
private val onTap by EventDispatcher()

@Composable
override fun Content(modifier: Modifier) {
override fun ComposableScope.Content() {
// TODO: Replace with actual BibleText composable when Kotlin SDK is ready
Box(
modifier = modifier
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
Text(
text = "BibleTextView placeholder - versionId: ${props.versionId.value}, " +
"book: ${props.bookUSFM.value}, chapter: ${props.chapter.value}",
"book: ${props.bookUSFM.value}, chapter: ${props.chapter.value}",
color = Color.Gray
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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

Expand All @@ -36,7 +37,7 @@ class YVPBibleWidgetView(context: Context, appContext: AppContext) :
override val props = BibleWidgetViewProps()

@Composable
override fun Content(modifier: Modifier) {
override fun ComposableScope.Content() {
val isDark = when (props.colorScheme.value) {
"dark" -> true
"light" -> false
Expand All @@ -45,7 +46,7 @@ class YVPBibleWidgetView(context: Context, appContext: AppContext) :

// TODO: Replace with actual BibleWidget composable when Kotlin SDK is ready
Box(
modifier = modifier
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import androidx.compose.foundation.isSystemInDarkTheme
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.Shape
import com.youversion.platform.ui.views.SignInWithYouVersionButton
import com.youversion.platform.ui.views.SignInWithYouVersionButtonDefaults
import com.youversion.platform.ui.views.SignInWithYouVersionButtonMode
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.views.AutoSizingComposable
import expo.modules.kotlin.views.ComposableScope
import expo.modules.kotlin.views.ComposeProps
import expo.modules.kotlin.views.Direction
import expo.modules.kotlin.views.ExpoComposeView
import java.util.EnumSet

data class SignInWithYouVersionButtonProps(
val mode: MutableState<String?> = mutableStateOf("full"),
Expand All @@ -30,16 +27,14 @@ class YVPSignInWithYouVersionButton(context: Context, appContext: AppContext) :
// private val onTap by EventDispatcher()

@Composable
override fun Content(modifier: Modifier) {
AutoSizingComposable(shadowNodeProxy, axis = EnumSet.of(Direction.HORIZONTAL, Direction.VERTICAL)) {
SignInWithYouVersionButton(
mode = mode(),
stroked = stroked(),
shape = shape(),
dark = isDark(),
permissions = { HashSet() }
)
}
override fun ComposableScope.Content() {
SignInWithYouVersionButton(
mode = mode(),
stroked = stroked(),
shape = shape(),
dark = isDark(),
permissions = { HashSet() }
)
}

fun mode(): SignInWithYouVersionButtonMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.views.ComposableScope
import expo.modules.kotlin.views.ComposeProps
import expo.modules.kotlin.views.ExpoComposeView

Expand All @@ -27,7 +28,7 @@ class YVPVotdView(context: Context, appContext: AppContext) :
override val props = VotdViewProps()

@Composable
override fun Content(modifier: Modifier) {
override fun ComposableScope.Content() {
val isDark = when (props.colorScheme.value) {
"dark" -> true
"light" -> false
Expand All @@ -36,7 +37,7 @@ class YVPVotdView(context: Context, appContext: AppContext) :

// TODO: Replace with actual VerseOfTheDay composable when Kotlin SDK is ready
Box(
modifier = modifier
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
) {
Expand Down
3 changes: 3 additions & 0 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
{
"ios": {
"deploymentTarget": "17.0"
},
"android": {
"kotlinVersion": "2.3.0"
}
}
]
Expand Down
11 changes: 7 additions & 4 deletions src/components/BibleReaderView.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Host } from "@expo/ui/swift-ui";
import { Host as AndroidHost } from "@expo/ui/jetpack-compose";
import { Host as IosHost } from "@expo/ui/swift-ui";
import { requireNativeView } from "expo";
import { StyleSheet } from "react-native";
import { Platform, StyleSheet } from "react-native";

import { BibleReference } from "../types";

const NativeView: React.ComponentType<NativeProps> =
requireNativeView("BibleReaderView");

const PlatformHost = Platform.OS === "ios" ? IosHost : AndroidHost;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Incomplete platform-specific Host migration — 3 of 5 TSX components still use iOS-only Host

The PR introduces the PlatformHost pattern in BibleReaderView.tsx and SignInWithYouVersionButton.tsx to select the correct Host component per platform (AndroidHost for Android, IosHost for iOS). However, the same transformation was not applied to src/components/BibleTextView.tsx:1, src/components/BibleWidgetView.tsx:1, and src/components/VotdView.tsx:1, which still import and use Host from @expo/ui/swift-ui (iOS-only). Since this PR also sets up all five Android Kotlin view files (e.g. YVPBibleTextView.kt, YVPBibleWidgetView.kt, YVPVotdView.kt), those three components will fail to render on Android because they wrap their native views in an iOS-only Host.

Prompt for agents
Apply the same platform-specific Host pattern used in src/components/BibleReaderView.tsx and src/components/SignInWithYouVersionButton.tsx to the three remaining component files:

1. src/components/BibleTextView.tsx (line 1): Replace `import { Host } from "@expo/ui/swift-ui";` with the AndroidHost/IosHost pattern, add Platform import, define PlatformHost, and use PlatformHost instead of Host in the JSX.

2. src/components/BibleWidgetView.tsx (line 1): Same changes — import both hosts, define PlatformHost, use PlatformHost instead of Host.

3. src/components/VotdView.tsx (line 1): Same changes — import both hosts, define PlatformHost, use PlatformHost instead of Host.

The pattern to follow is:
  import { Host as AndroidHost } from "@expo/ui/jetpack-compose";
  import { Host as IosHost } from "@expo/ui/swift-ui";
  import { Platform } from "react-native";
  const PlatformHost = Platform.OS === "ios" ? IosHost : AndroidHost;
Then replace all <Host .../> usages with <PlatformHost .../>.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


/**
* A full-featured Bible reader component.
* It allows the user to control font customizations, switch Bible versions and access their verse highlights.
Expand All @@ -15,13 +18,13 @@ const NativeView: React.ComponentType<NativeProps> =
*/
export function BibleReaderView({ reference, ...props }: BibleReaderViewProps) {
return (
<Host style={styles.view}>
<PlatformHost style={styles.view}>
<NativeView
hasReference={!!reference}
{...(reference || {})}
{...props}
/>
</Host>
</PlatformHost>
);
}

Expand Down
11 changes: 7 additions & 4 deletions src/components/SignInWithYouVersionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { CommonViewModifierProps, Host } from "@expo/ui/swift-ui";
import { Host as AndroidHost } from "@expo/ui/jetpack-compose";
import { CommonViewModifierProps, Host as IosHost } from "@expo/ui/swift-ui";
import { fixedSize } from "@expo/ui/swift-ui/modifiers";
import { requireNativeView } from "expo";
import { StyleProp, ViewStyle } from "react-native";
import { Platform, StyleProp, ViewStyle } from "react-native";

const PlatformHost = Platform.OS === "ios" ? IosHost : AndroidHost;

const NativeView: React.ComponentType<NativeProps> = requireNativeView(
"SignInWithYouVersionButton",
Expand Down Expand Up @@ -61,7 +64,7 @@ export function SignInWithYouVersionButton({
...props
}: SignInWithYouVersionButtonProps) {
return (
<Host matchContents={{ vertical: true, horizontal: true }} style={style}>
<PlatformHost matchContents style={style}>
<NativeView
{...props}
mode={mode}
Expand All @@ -71,6 +74,6 @@ export function SignInWithYouVersionButton({
onTap={onPress}
modifiers={[fixedSize()]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 SwiftUI-only fixedSize() modifier applied on Android

fixedSize() is imported from @expo/ui/swift-ui/modifiers and has no Android equivalent. On iOS, combined with the old AutoSizingComposable wrapper (which has since been removed from the Kotlin side), it controlled button sizing. Now that AutoSizingComposable is gone and Android uses AndroidHost, this modifier will be silently ignored on Android.

Please verify that the SignInWithYouVersionButton renders and sizes correctly on Android without this modifier taking effect. If auto-sizing on Android is handled entirely by the new ComposableScope API, a comment here explaining that would help future readers understand why a SwiftUI modifier is still present in a cross-platform component.

/>
</Host>
</PlatformHost>
);
}
Loading