Skip to content
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

Feat RN KeyboardAvoidingView #1857

Merged
merged 18 commits into from
Feb 28, 2025
Merged

Feat RN KeyboardAvoidingView #1857

merged 18 commits into from
Feb 28, 2025

Conversation

WX-DongXing
Copy link
Collaborator

No description provided.

@@ -0,0 +1,83 @@
import React, { ReactNode, useContext, useEffect } from 'react'
import { EmitterSubscription, Keyboard, Platform, View, ViewStyle } from 'react-native'
import Animted, { useSharedValue, useAnimatedStyle, withTiming } from 'react-native-reanimated'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Animated

cursorSpacing: 0,
ref: null
})
bottom.value = withTiming(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

动画曲线得配置一下

} else {
subscriptions = [
Keyboard.addListener('keyboardDidShow', (evt: any) => {
if (!keyboardAvoid) return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios和安卓这块的区别是啥,除了事件名不同

if (adjustPosition && keyboardAvoid) {
Object.assign(keyboardAvoid, {
cursorSpacing,
ref: nodeRef.current
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个ref直接透传nodeRef好一点吧,这样可能能规避一些边界条件

const animatedStyle = useAnimatedStyle(() => ({ transform: [{ translateY: -bottom.value }] }))

const resetKeyboard = () => {
keyboardAvoid && Object.assign(keyboardAvoid, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.assign替换为utils中的extendObject

@@ -37,9 +37,8 @@
* ✘ bind:keyboardcompositionend
* ✘ bind:onkeyboardheightchange
*/
import { JSX, forwardRef, useMemo, useRef, useState, useContext, useEffect, createElement } from 'react'
import { JSX, forwardRef, useRef, useState, useContext, useEffect, createElement } from 'react'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textarea也需要支持adjust-position

@hiyuki hiyuki merged commit c9a50f7 into master Feb 28, 2025
6 checks passed
@hiyuki hiyuki deleted the feat-rn-keyboard-avoid-view branch February 28, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants