Repository navigation
chore(android): drop deprecated event and package APIs #1219
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| package com.reactnativepagerview | ||
|
|
||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import com.facebook.react.bridge.ReadableArray | ||
| import com.facebook.react.module.annotations.ReactModule | ||
| import com.facebook.react.uimanager.* | ||
| import com.facebook.react.uimanager.ThemedReactContext | ||
| import com.facebook.react.uimanager.ViewGroupManager | ||
| import com.facebook.react.uimanager.ViewManagerDelegate | ||
| import com.facebook.react.uimanager.annotations.ReactProp | ||
| import com.facebook.react.viewmanagers.RNCViewPagerManagerDelegate | ||
| import com.facebook.react.viewmanagers.RNCViewPagerManagerInterface | ||
|
|
@@ -16,21 +16,18 @@ | |
| @ReactModule(name = PagerViewViewManager.NAME) | ||
| class PagerViewViewManager : ViewGroupManager<ComposePagerView>(), RNCViewPagerManagerInterface<ComposePagerView> { | ||
| companion object { | ||
| const val NAME = "RNCViewPager" | ||
|
Check failure on line 19 in android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 Major · Removed receiveCommand override may stop JS commands from reaching the delegate The PR deletes the explicit Suggested change Either keep the explicit Detailspersona: Reply Useful? Reply |
||
| } | ||
|
|
||
| private val mDelegate: ViewManagerDelegate<ComposePagerView> = RNCViewPagerManagerDelegate(this) | ||
| private val delegate: RNCViewPagerManagerDelegate<ComposePagerView, PagerViewViewManager> = | ||
| RNCViewPagerManagerDelegate(this) | ||
|
|
||
| override fun getDelegate() = mDelegate | ||
| override fun getDelegate(): ViewManagerDelegate<ComposePagerView> = delegate | ||
|
|
||
| override fun getName(): String { | ||
| return NAME | ||
| } | ||
|
|
||
| override fun receiveCommand(root: ComposePagerView, commandId: String, args: ReadableArray?) { | ||
| mDelegate.receiveCommand(root, commandId, args) | ||
| } | ||
|
|
||
| public override fun createViewInstance(reactContext: ThemedReactContext): ComposePagerView { | ||
| return ComposePagerView(reactContext) | ||
| } | ||
|
|
@@ -67,83 +64,64 @@ | |
| } | ||
|
|
||
| @ReactProp(name = "scrollEnabled", defaultBoolean = true) | ||
| override fun setScrollEnabled(view: ComposePagerView?, value: Boolean) { | ||
| if (view != null) { | ||
| view.setScrollEnabled(value) | ||
| } | ||
| override fun setScrollEnabled(view: ComposePagerView, value: Boolean) { | ||
| view.setScrollEnabled(value) | ||
| } | ||
|
|
||
| @ReactProp(name = "layoutDirection") | ||
| override fun setLayoutDirection(view: ComposePagerView?, value: String?) { | ||
| if (view != null && value != null) { | ||
| override fun setLayoutDirection(view: ComposePagerView, value: String?) { | ||
| if (value != null) { | ||
| view.setLayoutDirection(value) | ||
| } | ||
| } | ||
|
|
||
| @ReactProp(name = "initialPage", defaultInt = 0) | ||
| override fun setInitialPage(view: ComposePagerView?, value: Int) { | ||
| if (view != null) { | ||
| view.setInitialPage(value) | ||
| } | ||
| override fun setInitialPage(view: ComposePagerView, value: Int) { | ||
| view.setInitialPage(value) | ||
| } | ||
|
|
||
| @ReactProp(name = "orientation") | ||
| override fun setOrientation(view: ComposePagerView?, value: String?) { | ||
| if (view != null && value != null) { | ||
| override fun setOrientation(view: ComposePagerView, value: String?) { | ||
| if (value != null) { | ||
| view.setOrientation(value) | ||
| } | ||
| } | ||
|
|
||
| @ReactProp(name = "offscreenPageLimit", defaultInt = -1) | ||
| override fun setOffscreenPageLimit(view: ComposePagerView?, value: Int) { | ||
| if (view != null) { | ||
| view.setOffscreenPageLimit(value) | ||
| } | ||
| override fun setOffscreenPageLimit(view: ComposePagerView, value: Int) { | ||
| view.setOffscreenPageLimit(value) | ||
| } | ||
|
|
||
| @ReactProp(name = "pageMargin", defaultInt = 0) | ||
| override fun setPageMargin(view: ComposePagerView?, value: Int) { | ||
| if (view != null) { | ||
| view.setPageMargin(value) | ||
| } | ||
| override fun setPageMargin(view: ComposePagerView, value: Int) { | ||
| view.setPageMargin(value) | ||
| } | ||
|
|
||
| @ReactProp(name = "overScrollMode") | ||
| override fun setOverScrollMode(view: ComposePagerView?, value: String?) { | ||
| if (view != null && value != null) { | ||
| override fun setOverScrollMode(view: ComposePagerView, value: String?) { | ||
| if (value != null) { | ||
| view.setOverScrollMode(value) | ||
| } | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer raised on 🔵 Nit · No-op prop stubs carry inconsistent one-line comments that point outside the module
Suggested change Use one comment style for both Android no-op props and point at the file that already handles the behaviour (lib/src/PagerView.tsx) rather than a bare "see PagerView.tsx". Detailspersona: Reply Useful? Reply |
||
| // iOS only. | ||
| @ReactProp(name = "overdrag") | ||
| override fun setOverdrag(view: ComposePagerView?, value: Boolean) { | ||
| return | ||
| } | ||
| override fun setOverdrag(view: ComposePagerView, value: Boolean) = Unit | ||
|
|
||
| // Dismissed from JS on Android, see PagerView.tsx. | ||
| @ReactProp(name = "keyboardDismissMode") | ||
| override fun setKeyboardDismissMode(view: ComposePagerView?, value: String?) { | ||
| return | ||
| } | ||
|
|
||
| fun goTo(root: ComposePagerView?, selectedPage: Int, scrollWithAnimation: Boolean) { | ||
| if (root == null) { | ||
| return | ||
| } | ||
| root.setCurrentItem(selectedPage, scrollWithAnimation) | ||
| } | ||
| override fun setKeyboardDismissMode(view: ComposePagerView, value: String?) = Unit | ||
|
krozniata marked this conversation as resolved.
Resolved
|
||
|
|
||
| override fun setPage(view: ComposePagerView?, selectedPage: Int) { | ||
| goTo(view, selectedPage, true) | ||
| override fun setPage(view: ComposePagerView, selectedPage: Int) { | ||
| view.setCurrentItem(selectedPage, true) | ||
|
Check notice on line 116 in android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt
|
||
| } | ||
|
|
||
| override fun setPageWithoutAnimation(view: ComposePagerView?, selectedPage: Int) { | ||
| goTo(view, selectedPage, false) | ||
| override fun setPageWithoutAnimation(view: ComposePagerView, selectedPage: Int) { | ||
| view.setCurrentItem(selectedPage, false) | ||
| } | ||
|
|
||
| override fun setScrollEnabledImperatively(view: ComposePagerView?, scrollEnabled: Boolean) { | ||
| if (view != null) { | ||
| view.setScrollEnabled(scrollEnabled) | ||
| } | ||
| override fun setScrollEnabledImperatively(view: ComposePagerView, scrollEnabled: Boolean) { | ||
| view.setScrollEnabled(scrollEnabled) | ||
| } | ||
|
|
||
| override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> = mutableMapOf( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,19 @@ | ||
| package com.reactnativepagerview | ||
|
|
||
| import com.facebook.react.ReactPackage | ||
| import com.facebook.react.BaseReactPackage | ||
| import com.facebook.react.bridge.NativeModule | ||
| import com.facebook.react.bridge.ReactApplicationContext | ||
| import com.facebook.react.module.model.ReactModuleInfoProvider | ||
| import com.facebook.react.uimanager.ViewManager | ||
|
|
||
|
|
||
| class PagerViewPackage : ReactPackage { | ||
| override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> { | ||
| return emptyList() | ||
| } | ||
|
|
||
| class PagerViewPackage : BaseReactPackage() { | ||
| override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> { | ||
| return listOf(PagerViewViewManager()) | ||
| } | ||
|
|
||
| // The package only provides a view manager. | ||
| override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🆕 🔵 Nit · getReactModuleInfoProvider() returns an empty map, bypassing generated module info PagerViewPackage now extends BaseReactPackage but overrides getReactModuleInfoProvider() to return Suggested change Drop the getReactModuleInfoProvider() override and rely on BaseReactPackage's generated ReactPackageSupport-backed implementation; only supply a custom provider if a native module is actually added to this package. Detailspersona: Reply Useful? Reply |
||
| override fun getReactModuleInfoProvider() = ReactModuleInfoProvider { emptyMap() } | ||
|
Check notice on line 18 in android/src/main/java/com/reactnativepagerview/PagerViewViewPackage.kt
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer raised on
58496ba.🔵 Nit ·
reverseLayout = falseremovals are unrelated to this PR's scopeDropping the explicit
reverseLayout = falsein both HorizontalPager calls is a no-op (the default is false), but it is a Compose API change bundled into a PR whose title is about deprecated event/package APIs; it also silently changes behavior on any Compose Foundation version where the parameter has no default. Split it into its own commit so a bisect over Android event regressions does not land on it.Suggested change
Move the two
reverseLayout = falseremovals into a separate commit (or keep them and mention them in the PR description).Details
persona:
maintainability,senior-developerReply
@apex-sentinel-staging note ...to add context, or@apex-sentinel-staging pivot ...if this is wrong — I will re-check the cited code.Useful? Reply
@apex-sentinel-staging like, or@apex-sentinel-staging dislike <why>if it is not.