Skip to content

fix: 修复KeyboardControllerView注册2次重复的问题 #11

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

Merged
merged 1 commit into from
Oct 8, 2024
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
Binary file modified harmony/keyboard_controller.har
Binary file not shown.
6 changes: 0 additions & 6 deletions harmony/keyboard_controller/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion harmony/keyboard_controller/BuildProfile.ets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.12.17-0.0.1';
export const HAR_VERSION = '1.12.7-0.0.1';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
Expand Down
9 changes: 9 additions & 0 deletions harmony/keyboard_controller/ResourceTable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
string ReanimatedAbility_desc 0x02000001
string ReanimatedAbility_label 0x02000002
string WebviewAbility_desc 0x02000008
string WebviewAbility_label 0x02000009
string module_desc 0x02000003
string page_show 0x02000000
color start_window_background 0x02000004
media icon 0x02000005
profile main_pages 0x02000007
12 changes: 1 addition & 11 deletions harmony/keyboard_controller/oh-package.json5
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
{
"name": "@react-native-oh-tpl/react-native-keyboard-controller",
"version": "1.12.7-0.0.2",
"description": " control keyboard show or hide",
"main": "Index.ets",
"author": "",
"license": "MIT License",
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
}
}
{"name":"@react-native-oh-tpl/react-native-keyboard-controller","version":"1.12.7-0.0.3","description":" control keyboard show or hide","main":"Index.ets","author":"","license":"MIT License","dependencies":{"@rnoh/react-native-openharmony":"file:../react_native_openharmony"},"metadata":{"sourceRoots":["./src/main"],"useNormalizedOHMUrl":true},"compatibleSdkVersion":12,"compatibleSdkType":"HarmonyOS","obfuscated":false}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
namespace facebook {
namespace react {

inline const char KeyboardControllerViewName[] = "KeyboardControllerView";
inline const char KeyboardControllerViewName[] = "RNKeyboardControllerView";

class KeyboardControllerViewProps : public ViewProps {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void KeyboardControllerViewComponentInstance::keyboardHeightChangeHandle() {
if (rnInstancePtr != nullptr && this->enabled) {
if (this->keyboardStatus == KeyboardControllerStatus::HIDE) {
facebook::react::KeyboardControllerViewEventEmitter::MoveEvent start = {this->keyboardHeight, 0, 0, m_tag};
facebook::react::KeyboardControllerViewEventEmitter::MoveEvent end = {0, 0, 0, m_tag};
facebook::react::KeyboardControllerViewEventEmitter::MoveEvent end = {0, 1, 0, m_tag};
m_eventEmitter->onKeyboardMove(end);
m_eventEmitter->onKeyboardMoveEnd(end);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace facebook {
namespace react {

inline const char KeyboardGestureAreaComponentName[] = "KeyboardGestureArea";
inline const char KeyboardGestureAreaComponentName[] = "RNKeyboardGestureArea";

class KeyboardGestureAreaProps : public ViewProps {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ KeyboardControllerPackage::createComponentDescriptorProviders() {
facebook::react::KeyboardGestureAreaComponentDescriptor>()};
}
ComponentJSIBinderByString KeyboardControllerPackage::createComponentJSIBinderByName() {
return {{"KeyboardControllerView", std::make_shared<KeyboardControllerViewJSIBinder>()},
{"KeyboardGestureArea", std::make_shared<KeyboardGestureAreaJSIBinder>()}};
return {{"RNKeyboardControllerView", std::make_shared<KeyboardControllerViewJSIBinder>()},
{"RNKeyboardGestureArea", std::make_shared<KeyboardGestureAreaJSIBinder>()}};
}

std::unique_ptr<TurboModuleFactoryDelegate> KeyboardControllerPackage::createTurboModuleFactoryDelegate() {
Expand All @@ -30,10 +30,10 @@ ComponentInstanceFactoryDelegate::Shared KeyboardControllerPackage::createCompon
};

ComponentInstance::Shared KeyboardControllerPackage::createComponentInstance(const ComponentInstance::Context &ctx) {
if (ctx.componentName == "KeyboardControllerView") {
if (ctx.componentName == "RNKeyboardControllerView") {
return std::make_shared<KeyboardControllerViewComponentInstance>(ctx);
}
if (ctx.componentName == "KeyboardGestureArea") {
if (ctx.componentName == "RNKeyboardGestureArea") {
return std::make_shared<KeyboardGestureAreaComponentInstance>(ctx);
}
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ namespace rnoh {
class KeyboardControllerComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
public:
ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
if (ctx.componentName == "KeyboardControllerView") {
if (ctx.componentName == "RNKeyboardControllerView") {
return std::make_shared<KeyboardControllerViewComponentInstance>(ctx);
}
if (ctx.componentName == "KeyboardGestureArea") {
if (ctx.componentName == "RNKeyboardGestureArea") {
return std::make_shared<KeyboardGestureAreaComponentInstance>(ctx);
}
return nullptr;
Expand Down
29 changes: 29 additions & 0 deletions harmony/keyboard_controller/src/main/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"app": {
"bundleName": "com.rnoh.lhg.test",
"debug": true,
"versionCode": 1000000,
"versionName": "1.0.0",
"minAPIVersion": 50000012,
"targetAPIVersion": 50000012,
"apiReleaseType": "Beta5",
"compileSdkVersion": "5.0.0.60",
"compileSdkType": "HarmonyOS",
"appEnvironments": [],
"bundleType": "app"
},
"module": {
"name": "keyboard_controller",
"type": "har",
"deviceTypes": [
"default",
"tablet",
"2in1"
],
"packageName": "@react-native-oh-tpl/react-native-keyboard-controller",
"installationFree": false,
"virtualMachine": "ark12.0.2.0",
"compileMode": "esmodule",
"dependencies": []
}
}
11 changes: 0 additions & 11 deletions harmony/keyboard_controller/src/main/module.json5

This file was deleted.

35 changes: 0 additions & 35 deletions harmony/keyboard_controller/src/ohosTest/ets/test/Ability.test.ets

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions harmony/keyboard_controller/src/ohosTest/module.json5

This file was deleted.

5 changes: 0 additions & 5 deletions harmony/keyboard_controller/src/test/List.test.ets

This file was deleted.

33 changes: 0 additions & 33 deletions harmony/keyboard_controller/src/test/LocalUnit.test.ets

This file was deleted.

4 changes: 1 addition & 3 deletions src/animated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const KeyboardProvider = ({
const updateSharedValues = (event: NativeEvent, platforms: string[]) => {
"worklet";

if (platforms.includes(OS)||Platform.OS as string=='harmony') {
if (platforms.includes(OS)) {
// eslint-disable-next-line react-compiler/react-compiler
progressSV.value = event.progress;
heightSV.value = -event.height;
Expand All @@ -157,7 +157,6 @@ export const KeyboardProvider = ({
},
onKeyboardMoveEnd: (event: NativeEvent) => {
"worklet";

broadcastKeyboardEvents("onEnd", event);
updateSharedValues(event, ['harmony']);
},
Expand Down Expand Up @@ -198,7 +197,6 @@ export const KeyboardProvider = ({
{
onFocusedInputSelectionChanged: (e) => {
"worklet";

broadcastInputEvents("onSelectionChange", e);
},
},
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/components/KeyboardStickyView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const KeyboardStickyView = forwardRef<
ref,
) => {
const { height, progress } = useReanimatedKeyboardAnimation();

const stickyViewStyle = useAnimatedStyle(() => {
const offset = interpolate(progress.value, [0, 1], [closed, opened]);

Expand Down
2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const defaultContext: KeyboardAnimationContext = {
export const KeyboardContext = createContext(defaultContext);
export const useKeyboardContext = () => {
const context = useContext(KeyboardContext);

console.log('###KeyboardContext',context,context.animated.height);
if (__DEV__ && context === defaultContext) {
console.warn(
"Couldn't find real values for `KeyboardContext`. Please make sure you're inside of `KeyboardProvider` - otherwise functionality of `react-native-keyboard-controller` will not work.",
Expand Down
8 changes: 0 additions & 8 deletions src/event-handler.d.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/event-handler.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/event-handler.web.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/event-mappings.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/specs/KeyboardControllerViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ export interface NativeProps extends ViewProps {
}

export default codegenNativeComponent<NativeProps>(
"KeyboardControllerView",
"RNKeyboardControllerView",
) as HostComponent<NativeProps>;
2 changes: 1 addition & 1 deletion src/specs/KeyboardGestureAreaNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export interface NativeProps extends ViewProps {
enableSwipeToDismiss?: boolean;
}

export default codegenNativeComponent<NativeProps>("KeyboardGestureArea", {
export default codegenNativeComponent<NativeProps>("RNKeyboardGestureArea", {
excludedPlatforms: ["iOS"],
}) as HostComponent<NativeProps>;