@momo-kits/foundation 0.161.2-beta.14 → 0.161.2-beta.16
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.
|
@@ -37,7 +37,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
37
37
|
const action = useRef<undefined | string>(undefined);
|
|
38
38
|
const insets = useSafeAreaInsets();
|
|
39
39
|
const heightHeader = useHeaderHeight();
|
|
40
|
-
const
|
|
40
|
+
const bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
41
|
+
const keyboardOffset = heightHeader - bottomInset;
|
|
41
42
|
|
|
42
43
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
43
44
|
|
|
@@ -311,7 +312,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
311
312
|
{useBottomInset && (
|
|
312
313
|
<View
|
|
313
314
|
style={{
|
|
314
|
-
height:
|
|
315
|
+
height: bottomInset,
|
|
315
316
|
backgroundColor: backgroundColor,
|
|
316
317
|
}}
|
|
317
318
|
/>
|
|
@@ -320,7 +320,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
320
320
|
activeTintColor={theme.colors.primary}
|
|
321
321
|
style={[
|
|
322
322
|
{
|
|
323
|
-
height: 64 + Math.min(insets.bottom, 21),
|
|
323
|
+
height: 64 + (Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom),
|
|
324
324
|
},
|
|
325
325
|
]}
|
|
326
326
|
/>
|
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,12 +203,38 @@ 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 15+ (API 35): edge-to-edge -> window KHÔNG resize cho bàn phím.
|
|
210
|
+
// Android <15 (window tự resize) và iOS giữ NGUYÊN behavior cũ -> không impact.
|
|
211
|
+
const useManualKeyboardAvoid =
|
|
212
|
+
Platform.OS === 'android' &&
|
|
213
|
+
Number(Platform.Version) >= 35 &&
|
|
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
|
|
|
207
|
-
|
|
234
|
+
const bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
235
|
+
let keyboardOffset = heightHeader - bottomInset;
|
|
208
236
|
if (headerType === 'extended' || animatedHeader || inputSearchProps) {
|
|
209
|
-
keyboardOffset = -
|
|
237
|
+
keyboardOffset = -bottomInset;
|
|
210
238
|
}
|
|
211
239
|
|
|
212
240
|
/**
|
|
@@ -586,13 +614,25 @@ const Screen = forwardRef(
|
|
|
586
614
|
/>
|
|
587
615
|
|
|
588
616
|
<KeyboardAvoidingView
|
|
589
|
-
|
|
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
|
+
]}
|
|
590
629
|
enabled={enableKeyboardAvoidingView}
|
|
591
630
|
keyboardVerticalOffset={keyboardVerticalOffset ?? keyboardOffset}
|
|
592
631
|
behavior={Platform.select({
|
|
593
632
|
ios: 'padding',
|
|
594
633
|
android: undefined,
|
|
595
634
|
})}
|
|
635
|
+
// AI-GENERATED END: Android tự đẩy bằng keyboardHeight
|
|
596
636
|
>
|
|
597
637
|
{Header}
|
|
598
638
|
|
|
@@ -616,7 +656,7 @@ const Screen = forwardRef(
|
|
|
616
656
|
{...floatingButtonProps}
|
|
617
657
|
animatedValue={animatedValue.current}
|
|
618
658
|
bottom={
|
|
619
|
-
Footer || isTab ? 12 :
|
|
659
|
+
Footer || isTab ? 12 : bottomInset + Spacing.S
|
|
620
660
|
}
|
|
621
661
|
/>
|
|
622
662
|
</View>
|
|
@@ -627,7 +667,12 @@ const Screen = forwardRef(
|
|
|
627
667
|
style={[
|
|
628
668
|
styles.shadow,
|
|
629
669
|
{
|
|
630
|
-
|
|
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
|
|
631
676
|
backgroundColor: theme.colors.background.surface,
|
|
632
677
|
},
|
|
633
678
|
]}
|