-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Implement all Compose views #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sidorchukandrew
wants to merge
15
commits into
main
Choose a base branch
from
as/kotlin-widget-view
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b851faf
chore: refactor to follow Expo's guidance
sidorchukandrew ff51b2a
chore: add icon assets for bottom nav
sidorchukandrew de840a3
chore: use icons in bottom navigation
sidorchukandrew 6f94d06
chore: refactor VOTD Compose to be functional component
sidorchukandrew c8b2ef8
chore: refactor BibleReaderView to be functional component
sidorchukandrew 0db5795
feat: implement BibleTextView as functional component
sidorchukandrew 5841a7a
feat: implement BibleWidgetView as functional component
sidorchukandrew 1703776
chore: refactor sign in button as functional component
sidorchukandrew 3f53858
chore: use correct <Host /> for each platform
sidorchukandrew 9222a32
chore: implement onTap callback
sidorchukandrew e4d75e5
chore: remove unnecessary color utility function
sidorchukandrew 95aa638
chore: swap order of styles to allow for overriding
sidorchukandrew 8ce7ac1
chore: update default Bible version to 3034
sidorchukandrew 74d74e3
chore: remove mutableState
sidorchukandrew 483bef5
chore: make urlScheme and footnotes optional
sidorchukandrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
android/src/main/java/com/youversion/reactnativesdk/RNBibleTextViewModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 14 additions & 2 deletions
16
android/src/main/java/com/youversion/reactnativesdk/RNSignInWithYouVersionButtonModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
| } | ||
| } | ||
| } |
17 changes: 16 additions & 1 deletion
17
android/src/main/java/com/youversion/reactnativesdk/RNVotdViewModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) } | ||
| ) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 37 additions & 49 deletions
86
android/src/main/java/com/youversion/reactnativesdk/views/YVPBibleReaderView.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.