-
-
Notifications
You must be signed in to change notification settings - Fork 128
feat: KeyboardToolbar.Exclude
#881
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.reactnativekeyboardcontroller.managers | ||
|
|
||
| import com.facebook.react.bridge.ReactApplicationContext | ||
| import com.facebook.react.uimanager.ThemedReactContext | ||
| import com.reactnativekeyboardcontroller.views.KeyboardToolbarExcludeReactViewGroup | ||
|
|
||
| @Suppress("detekt:UnusedPrivateProperty") | ||
| class KeyboardToolbarExcludeViewManagerImpl( | ||
| mReactContext: ReactApplicationContext, | ||
| ) { | ||
| fun createViewInstance(reactContext: ThemedReactContext): KeyboardToolbarExcludeReactViewGroup = | ||
| KeyboardToolbarExcludeReactViewGroup(reactContext) | ||
|
|
||
| companion object { | ||
| const val NAME = "KeyboardToolbarExcludeView" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.reactnativekeyboardcontroller.views | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import com.facebook.react.uimanager.ThemedReactContext | ||
| import com.facebook.react.views.view.ReactViewGroup | ||
|
|
||
| @SuppressLint("ViewConstructor") | ||
| class KeyboardToolbarExcludeReactViewGroup( | ||
| reactContext: ThemedReactContext, | ||
| ) : ReactViewGroup(reactContext) { | ||
| // semantic view used in KeyboardToolbar traverse algorithm | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.reactnativekeyboardcontroller | ||
|
|
||
| import com.facebook.react.bridge.ReactApplicationContext | ||
| import com.facebook.react.uimanager.ThemedReactContext | ||
| import com.facebook.react.views.view.ReactViewManager | ||
| import com.reactnativekeyboardcontroller.managers.KeyboardToolbarExcludeViewManagerImpl | ||
| import com.reactnativekeyboardcontroller.views.KeyboardToolbarExcludeReactViewGroup | ||
|
|
||
| class KeyboardToolbarExcludeViewManager( | ||
| mReactContext: ReactApplicationContext, | ||
| ) : ReactViewManager() { | ||
| private val manager = KeyboardToolbarExcludeViewManagerImpl(mReactContext) | ||
|
|
||
| override fun getName(): String = KeyboardToolbarExcludeViewManagerImpl.NAME | ||
|
|
||
| override fun createViewInstance(reactContext: ThemedReactContext): KeyboardToolbarExcludeReactViewGroup = | ||
| manager.createViewInstance(reactContext) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ public class ViewHierarchyNavigator: NSObject { | |
|
|
||
| if let textInput = isValidTextInput(view) { | ||
| textInputs.append(textInput) | ||
| } else { | ||
| } else if String(describing: type(of: view)) != "KeyboardToolbarExcludeView" { | ||
| for subview in view.subviews { | ||
| findTextInputs(in: subview) | ||
| } | ||
|
|
@@ -91,6 +91,8 @@ public class ViewHierarchyNavigator: NSObject { | |
| return validTextInput | ||
| } | ||
|
|
||
| guard String(describing: type(of: view)) != "KeyboardToolbarExcludeView" else { return nil } | ||
|
Contributor
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.
|
||
|
|
||
| // Determine the iteration order based on the direction | ||
| let subviews = direction == "next" ? view.subviews : view.subviews.reversed() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // | ||
| // KeyboardToolbarExcludeViewManager.h | ||
| // KeyboardController | ||
| // | ||
| // Created by Kiryl Ziusko on 26/12/2024. | ||
| // | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| #import <React/RCTViewComponentView.h> | ||
| #else | ||
| #import <React/RCTBridge.h> | ||
| #endif | ||
| #import <React/RCTViewManager.h> | ||
| #import <UIKit/UIKit.h> | ||
|
|
||
| @interface KeyboardToolbarExcludeViewManager : RCTViewManager | ||
| @end | ||
|
|
||
| @interface KeyboardToolbarExcludeView : | ||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| RCTViewComponentView | ||
| #else | ||
| UIView | ||
|
|
||
| - (instancetype)initWithBridge:(RCTBridge *)bridge; | ||
|
|
||
| #endif | ||
| @end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // | ||
| // KeyboardToolbarExcludeViewManager.mm | ||
| // react-native-keyboard-controller | ||
| // | ||
| // Created by Kiryl Ziusko on 26/12/2024. | ||
| // | ||
|
|
||
| #import "KeyboardToolbarExcludeViewManager.h" | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| #import <react/renderer/components/reactnativekeyboardcontroller/ComponentDescriptors.h> | ||
| #import <react/renderer/components/reactnativekeyboardcontroller/EventEmitters.h> | ||
| #import <react/renderer/components/reactnativekeyboardcontroller/Props.h> | ||
| #import <react/renderer/components/reactnativekeyboardcontroller/RCTComponentViewHelpers.h> | ||
|
|
||
| #import "RCTFabricComponentsPlugins.h" | ||
| #endif | ||
|
|
||
| #import <UIKit/UIKit.h> | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| using namespace facebook::react; | ||
| #endif | ||
|
|
||
| // MARK: Manager | ||
| @implementation KeyboardToolbarExcludeViewManager | ||
|
|
||
| RCT_EXPORT_MODULE(KeyboardToolbarExcludeViewManager) | ||
|
|
||
| + (BOOL)requiresMainQueueSetup | ||
| { | ||
| return NO; | ||
| } | ||
|
|
||
| #ifndef RCT_NEW_ARCH_ENABLED | ||
| - (UIView *)view | ||
| { | ||
| return [[KeyboardToolbarExcludeView alloc] initWithBridge:self.bridge]; | ||
| } | ||
| #endif | ||
|
|
||
| @end | ||
|
|
||
| // MARK: View | ||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| @interface KeyboardToolbarExcludeView () <RCTKeyboardToolbarExcludeViewViewProtocol> | ||
| @end | ||
| #endif | ||
|
|
||
| @implementation KeyboardToolbarExcludeView { | ||
| } | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| + (ComponentDescriptorProvider)componentDescriptorProvider | ||
| { | ||
| return concreteComponentDescriptorProvider<KeyboardToolbarExcludeViewComponentDescriptor>(); | ||
| } | ||
| #endif | ||
|
|
||
| // Needed because of this: https://github.com/facebook/react-native/pull/37274 | ||
| + (void)load | ||
| { | ||
| [super load]; | ||
| } | ||
|
|
||
| // MARK: Constructor | ||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| - (instancetype)init | ||
| { | ||
| self = [super init]; | ||
| return self; | ||
| } | ||
| #else | ||
| - (instancetype)initWithBridge:(RCTBridge *)bridge | ||
| { | ||
| self = [super init]; | ||
| return self; | ||
| } | ||
| #endif | ||
|
|
||
| #ifdef RCT_NEW_ARCH_ENABLED | ||
| Class<RCTComponentViewProtocol> KeyboardToolbarExcludeViewCls(void) | ||
| { | ||
| return KeyboardToolbarExcludeView.class; | ||
| } | ||
| #endif | ||
|
|
||
| @end |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -60,3 +60,5 @@ export const KeyboardGestureArea: React.FC<KeyboardGestureAreaProps> = | |||||
| : ({ children }: KeyboardGestureAreaProps) => children; | ||||||
| export const RCTOverKeyboardView: React.FC<OverKeyboardViewProps> = | ||||||
| require("./specs/OverKeyboardViewNativeComponent").default; | ||||||
| export const RCTKeyboardToolbarExcludeView: React.FC<OverKeyboardViewProps> = | ||||||
|
||||||
| export const RCTKeyboardToolbarExcludeView: React.FC<OverKeyboardViewProps> = | |
| export const RCTKeyboardToolbarExcludeView: React.FC<KeyboardToolbarExcludeViewProps> = |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent"; | ||
|
|
||
| import type { HostComponent } from "react-native"; | ||
| import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes"; | ||
|
|
||
| export interface NativeProps extends ViewProps {} | ||
|
|
||
| export default codegenNativeComponent<NativeProps>( | ||
| "KeyboardToolbarExcludeView", | ||
| ) as HostComponent<NativeProps>; |
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.
this check repeats twice, would it be better to use helper function for this?