Skip to content
Merged
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
Expand Up @@ -11,6 +11,8 @@ class KeyboardControllerModule(

override fun getName(): String = KeyboardControllerModuleImpl.NAME

override fun getTypedExportedConstants(): Map<String, Any> = module.getConstants()

override fun setInputMode(mode: Double) {
module.setInputMode(mode.toInt())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class KeyboardControllerModuleImpl(
private val controller = KeyboardAnimationController()
private val mDefaultMode: Int = getCurrentMode()

// region Module methods
fun setInputMode(mode: Int) {
setSoftInputMode(mode)
}
Expand Down Expand Up @@ -102,7 +103,9 @@ class KeyboardControllerModuleImpl(
promise.resolve(map)
}
}
// endregion

// region Helpers
private fun setSoftInputMode(mode: Int) {
UiThreadUtil.runOnUiThread {
if (getCurrentMode() != mode) {
Expand All @@ -118,8 +121,13 @@ class KeyboardControllerModuleImpl(
?.attributes
?.softInputMode
?: WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED
// endregion

// region Module constants
fun getConstants(): MutableMap<String, Any> = mutableMapOf("keyboardBorderRadius" to 0)

companion object {
const val NAME = "KeyboardController"
}
// endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class KeyboardControllerModule(

override fun getName(): String = KeyboardControllerModuleImpl.NAME

override fun getConstants(): MutableMap<String, Any> = module.getConstants()

@ReactMethod
fun setInputMode(mode: Int) {
module.setInputMode(mode)
Expand Down
Binary file modified e2e/kit/assets/ios/iPhone 17 Pro/ToolbarAllButtonsEnabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/kit/assets/ios/iPhone 17 Pro/ToolbarFirstInputFocused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/kit/assets/ios/iPhone 17 Pro/ToolbarLastInputFocused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions ios/KeyboardControllerModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ + (BOOL)requiresMainQueueSetup
return NO;
}

- (NSDictionary *)constantsToExport
{
return @{
@"keyboardBorderRadius" : @([KeyboardExtenderContainerView keyboardBorderRadius]),
};
}

- (NSDictionary *)getConstants
{
return [self constantsToExport];
}

#ifdef RCT_NEW_ARCH_ENABLED
- (void)setDefaultMode
#else
Expand Down
18 changes: 14 additions & 4 deletions ios/views/KeyboardExtenderContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@ import UIKit

@objc
public class KeyboardExtenderContainerView: NSObject {
@objc public static func create(frame: CGRect, contentView: UIView) -> UIView {
private static func usesModernKeyboard() -> Bool {
#if canImport(UIKit.UIGlassEffect)
if #available(iOS 26.0, *) {
let requiresCompat = Bundle.main.object(forInfoDictionaryKey: "UIDesignRequiresCompatibility") as? Bool ?? false
if !requiresCompat {
return ModernContainerView(frame: frame, contentView: contentView)
}
return !requiresCompat
}
#endif
return false
}

@objc public static func keyboardBorderRadius() -> CGFloat {
return usesModernKeyboard() ? 30 : 0
}

@objc public static func create(frame: CGRect, contentView: UIView) -> UIView {
if usesModernKeyboard() {
if #available(iOS 26.0, *) {
return ModernContainerView(frame: frame, contentView: contentView)
}
}
return LegacyContainerView(frame: frame, contentView: contentView)
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const KeyboardControllerNative: KeyboardControllerNativeModule = {
Promise.resolve({ x: 0, y: 0, width: 0, height: 0 }),
addListener: NOOP,
removeListeners: NOOP,
getConstants: () => ({
keyboardBorderRadius: 0,
}),
};
/**
* An event emitter that provides a way to subscribe to next keyboard events:
Expand Down
5 changes: 2 additions & 3 deletions src/components/KeyboardToolbar/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Platform } from "react-native";
import { KEYBOARD_BORDER_RADIUS } from "../../constants";

import type { HEX } from "./types";

Expand All @@ -10,6 +10,5 @@ export const TEST_ID_KEYBOARD_TOOLBAR_DONE = `${TEST_ID_KEYBOARD_TOOLBAR}.done`;

export const KEYBOARD_TOOLBAR_HEIGHT = 42;
export const DEFAULT_OPACITY: HEX = "FF";
export const KEYBOARD_HAS_ROUNDED_CORNERS =
Platform.OS === "ios" && parseInt(Platform.Version, 10) >= 26;
export const KEYBOARD_HAS_ROUNDED_CORNERS = KEYBOARD_BORDER_RADIUS > 0;
export const OPENED_OFFSET = KEYBOARD_HAS_ROUNDED_CORNERS ? -11 : 0;
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { KeyboardControllerNative } from "./bindings";

// copied from `android.view.WindowManager.LayoutParams`
export enum AndroidSoftInputModes {
SOFT_INPUT_ADJUST_NOTHING = 48,
Expand All @@ -17,3 +19,5 @@ export enum AndroidSoftInputModes {
SOFT_INPUT_STATE_UNSPECIFIED = 0,
SOFT_INPUT_STATE_VISIBLE = 4,
}
export const KEYBOARD_BORDER_RADIUS =
KeyboardControllerNative.getConstants().keyboardBorderRadius;
4 changes: 3 additions & 1 deletion src/specs/NativeKeyboardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { TurboModuleRegistry } from "react-native";
import type { TurboModule } from "react-native";

export interface Spec extends TurboModule {
readonly getConstants: () => {};
readonly getConstants: () => {
keyboardBorderRadius: number;
};

// methods
setInputMode(mode: number): void;
Expand Down
4 changes: 4 additions & 0 deletions src/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,8 @@ export type KeyboardControllerNativeModule = {
// native event module stuff
addListener: (eventName: string) => void;
removeListeners: (count: number) => void;
// constants
getConstants: () => {
keyboardBorderRadius: number;
};
};
Loading