@momo-kits/foundation 0.161.2-beta.15 → 0.161.2-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Layout/Screen.tsx +46 -2
- package/package.json +1 -1
package/Layout/Screen.tsx
CHANGED
|
@@ -10,9 +10,11 @@ import React, {
|
|
|
10
10
|
useEffect,
|
|
11
11
|
useImperativeHandle,
|
|
12
12
|
useRef,
|
|
13
|
+
useState,
|
|
13
14
|
} from 'react';
|
|
14
15
|
import {
|
|
15
16
|
Animated,
|
|
17
|
+
Keyboard,
|
|
16
18
|
KeyboardAvoidingView,
|
|
17
19
|
NativeScrollEvent,
|
|
18
20
|
NativeSyntheticEvent,
|
|
@@ -201,6 +203,31 @@ const Screen = forwardRef(
|
|
|
201
203
|
const currentTint = useRef<string | undefined>(undefined);
|
|
202
204
|
const isTab = navigation?.instance?.getState?.()?.type === 'tab';
|
|
203
205
|
|
|
206
|
+
// AI-GENERATED START: track keyboard height (Android tự đẩy; footer bỏ safe-area khi hiện)
|
|
207
|
+
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
208
|
+
const isKeyboardVisible = keyboardHeight > 0;
|
|
209
|
+
// Chỉ can thiệp trên Android 16+ (API 36): edge-to-edge -> window KHÔNG resize cho bàn phím.
|
|
210
|
+
// Android <16 (window tự resize) và iOS giữ NGUYÊN behavior cũ -> không impact.
|
|
211
|
+
const useManualKeyboardAvoid =
|
|
212
|
+
Platform.OS === 'android' &&
|
|
213
|
+
Number(Platform.Version) >= 36 &&
|
|
214
|
+
enableKeyboardAvoidingView;
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
const showEvent =
|
|
217
|
+
Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
|
|
218
|
+
const hideEvent =
|
|
219
|
+
Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
|
220
|
+
const showSub = Keyboard.addListener(showEvent, e =>
|
|
221
|
+
setKeyboardHeight(e.endCoordinates?.height ?? 0),
|
|
222
|
+
);
|
|
223
|
+
const hideSub = Keyboard.addListener(hideEvent, () => setKeyboardHeight(0));
|
|
224
|
+
return () => {
|
|
225
|
+
showSub.remove();
|
|
226
|
+
hideSub.remove();
|
|
227
|
+
};
|
|
228
|
+
}, []);
|
|
229
|
+
// AI-GENERATED END: track keyboard height
|
|
230
|
+
|
|
204
231
|
let handleScroll;
|
|
205
232
|
let Component: any = View;
|
|
206
233
|
|
|
@@ -587,13 +614,25 @@ const Screen = forwardRef(
|
|
|
587
614
|
/>
|
|
588
615
|
|
|
589
616
|
<KeyboardAvoidingView
|
|
590
|
-
|
|
617
|
+
// AI-GENERATED START: Android tự đẩy bằng keyboardHeight (KAV behavior để lại padding dư)
|
|
618
|
+
style={[
|
|
619
|
+
Styles.flex,
|
|
620
|
+
// height (Android) chưa gồm nav bar -> cộng insets.bottom để đẩy đủ qua bàn phím
|
|
621
|
+
useManualKeyboardAvoid
|
|
622
|
+
? {
|
|
623
|
+
paddingBottom: isKeyboardVisible
|
|
624
|
+
? keyboardHeight + insets.bottom
|
|
625
|
+
: 0,
|
|
626
|
+
}
|
|
627
|
+
: null,
|
|
628
|
+
]}
|
|
591
629
|
enabled={enableKeyboardAvoidingView}
|
|
592
630
|
keyboardVerticalOffset={keyboardVerticalOffset ?? keyboardOffset}
|
|
593
631
|
behavior={Platform.select({
|
|
594
632
|
ios: 'padding',
|
|
595
633
|
android: undefined,
|
|
596
634
|
})}
|
|
635
|
+
// AI-GENERATED END: Android tự đẩy bằng keyboardHeight
|
|
597
636
|
>
|
|
598
637
|
{Header}
|
|
599
638
|
|
|
@@ -628,7 +667,12 @@ const Screen = forwardRef(
|
|
|
628
667
|
style={[
|
|
629
668
|
styles.shadow,
|
|
630
669
|
{
|
|
631
|
-
|
|
670
|
+
// AI-GENERATED START: bàn phím hiện -> bỏ safe-area, chỉ chừa Spacing.S (như StackScreen)
|
|
671
|
+
paddingBottom:
|
|
672
|
+
(isKeyboardVisible && useManualKeyboardAvoid
|
|
673
|
+
? 0
|
|
674
|
+
: bottomInset) + Spacing.S,
|
|
675
|
+
// AI-GENERATED END: bàn phím hiện -> bỏ safe-area, chỉ chừa Spacing.S
|
|
632
676
|
backgroundColor: theme.colors.background.surface,
|
|
633
677
|
},
|
|
634
678
|
]}
|