@momo-kits/foundation 0.162.1-beta.1 → 0.162.2-beta.1

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,8 +37,7 @@ 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 bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
41
- const keyboardOffset = heightHeader - bottomInset;
40
+ const keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
42
41
 
43
42
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
44
43
 
@@ -312,7 +311,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
312
311
  {useBottomInset && (
313
312
  <View
314
313
  style={{
315
- height: bottomInset,
314
+ height: Math.min(insets.bottom, 21),
316
315
  backgroundColor: backgroundColor,
317
316
  }}
318
317
  />
@@ -296,7 +296,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
296
296
  activeTintColor={theme.colors.primary}
297
297
  style={[
298
298
  {
299
- height: 64 + (Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom),
299
+ height: 64 + Math.min(insets.bottom, 21),
300
300
  },
301
301
  ]}
302
302
  />
@@ -86,7 +86,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
86
86
 
87
87
  const styles = StyleSheet.create({
88
88
  headerLeft: {
89
- marginLeft: 12,
89
+ marginLeft: 8,
90
90
  },
91
91
  });
92
92
 
@@ -19,7 +19,7 @@ import Navigator from './Navigator';
19
19
  import ScaleSizeProvider from './ScaleSizeProvider';
20
20
  import { getModalOptions, getStackOptions } from './utils';
21
21
  import { NavigationContainerProps } from './types';
22
- import { ApplicationContext, FontScaleConfig, MiniAppContext } from '../Context';
22
+ import { ApplicationContext, MiniAppContext } from '../Context';
23
23
  import Localize from './Localize';
24
24
  import { Colors, defaultTheme } from '../Consts';
25
25
  import { HeaderLeft } from './Components/HeaderLeft';
@@ -29,8 +29,6 @@ import { HeaderBackground } from './Components/HeaderBackground';
29
29
 
30
30
  const Stack = createStackNavigator();
31
31
 
32
- const FONT_SCALE_OBSERVER_KEY = 'font_scale_config';
33
-
34
32
  const NavigationContainer: React.FC<NavigationContainerProps> = ({
35
33
  screen,
36
34
  theme = defaultTheme,
@@ -47,9 +45,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
47
45
  }) => {
48
46
  const context = useContext<any>(MiniAppContext);
49
47
  const [currentContext, setCurrentContext] = useState<any>({});
50
- const [observerFontScaleConfig, setObserverFontScaleConfig] = useState<
51
- FontScaleConfig | undefined
52
- >(context?.fontScaleConfig);
53
48
 
54
49
  const mergedContext = {
55
50
  ...context,
@@ -60,24 +55,10 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
60
55
  },
61
56
  };
62
57
 
63
- useEffect(() => {
64
- const sub = maxApi?.observer?.(
65
- FONT_SCALE_OBSERVER_KEY,
66
- (data: FontScaleConfig) => {
67
- setObserverFontScaleConfig(data ?? undefined);
68
- },
69
- );
70
- return () => {
71
- sub?.remove?.();
72
- };
73
- }, [maxApi]);
74
-
75
58
  return (
76
59
  <SafeAreaProvider>
77
60
  <MiniAppContext.Provider value={mergedContext}>
78
- <ScaleSizeProvider
79
- fontScaleConfig={observerFontScaleConfig}
80
- >
61
+ <ScaleSizeProvider scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}>
81
62
  <Navigation
82
63
  screen={screen}
83
64
  theme={theme}
@@ -1,15 +1,13 @@
1
- import React, { FC, useContext } from 'react';
1
+ import React, { FC } from 'react';
2
2
  import { ScaleSizeContext } from '../Context';
3
3
  import { ScaleSizeProviderProps } from './types';
4
4
 
5
5
  const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
6
- fontScaleConfig,
6
+ scaleSizeMaxRate,
7
7
  children,
8
8
  }) => {
9
- // Inherit the config from an upper layer (e.g. app root) when the host doesn't set it via MiniAppContext.
10
- const parent = useContext(ScaleSizeContext);
11
9
  return (
12
- <ScaleSizeContext.Provider value={fontScaleConfig ?? parent}>
10
+ <ScaleSizeContext.Provider value={{ scaleSizeMaxRate }}>
13
11
  {children}
14
12
  </ScaleSizeContext.Provider>
15
13
  );
@@ -78,7 +78,7 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
78
78
  <SafeAreaProvider>
79
79
  <MiniAppContext.Provider value={mergedContext}>
80
80
  <ScaleSizeProvider
81
- fontScaleConfig={mergedContext?.fontScaleConfig}
81
+ scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}
82
82
  >
83
83
  <ApplicationContext.Provider
84
84
  value={{
@@ -10,7 +10,6 @@ import {
10
10
  import type { SharedValue } from 'react-native-reanimated';
11
11
  import { PopupNotifyProps } from '../Popup/types';
12
12
  import { InputRef, InputSearchProps } from '../Input';
13
- import { FontScaleConfig } from '../Context';
14
13
  import Navigation from './Navigation';
15
14
 
16
15
  export type NavigationProps = {
@@ -110,7 +109,7 @@ export type Theme = {
110
109
  };
111
110
 
112
111
  export type ScaleSizeProviderProps = {
113
- fontScaleConfig?: FontScaleConfig;
112
+ scaleSizeMaxRate?: number;
114
113
  children: ViewProps['children'];
115
114
  };
116
115
 
package/Context/index.ts CHANGED
@@ -9,12 +9,9 @@ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
9
9
  const ScreenContext = (Platform as any).ScreenContext ?? Context;
10
10
  const ComponentContext = (Platform as any).ComponentContext ?? Context;
11
11
  const SkeletonContext = createContext({ loading: false });
12
- // Single source of truth: holds both the OS flag and the user-adjusted rate.
13
- export type FontScaleConfig = {
14
- useOSFontScale?: boolean;
15
- userScaleRate?: number;
16
- };
17
- const ScaleSizeContext = createContext<FontScaleConfig>({});
12
+ const ScaleSizeContext = createContext<{ scaleSizeMaxRate?: number }>({
13
+ scaleSizeMaxRate: undefined,
14
+ });
18
15
  const TrackingScopeContext = createContext<{ scopeName?: string }>({
19
16
  scopeName: undefined,
20
17
  });
package/Layout/Screen.tsx CHANGED
@@ -240,10 +240,9 @@ const Screen = forwardRef(
240
240
  let handleScroll;
241
241
  let Component: any = View;
242
242
 
243
- const bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
244
- let keyboardOffset = heightHeader - bottomInset;
243
+ let keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
245
244
  if (headerType === 'extended' || animatedHeader || inputSearchProps) {
246
- keyboardOffset = -bottomInset;
245
+ keyboardOffset = -Math.min(insets.bottom, 21);
247
246
  }
248
247
 
249
248
  /**
@@ -663,7 +662,7 @@ const Screen = forwardRef(
663
662
  {...floatingButtonProps}
664
663
  animatedValue={sharedValue}
665
664
  bottom={
666
- Footer || isTab ? 12 : bottomInset + Spacing.S
665
+ Footer || isTab ? 12 : Math.min(insets.bottom, 21) + Spacing.S
667
666
  }
668
667
  />
669
668
  </View>
@@ -674,7 +673,7 @@ const Screen = forwardRef(
674
673
  style={[
675
674
  styles.shadow,
676
675
  {
677
- paddingBottom: bottomInset + Spacing.S,
676
+ paddingBottom: Math.min(insets.bottom, 21) + Spacing.S,
678
677
  backgroundColor: theme.colors.background.surface,
679
678
  },
680
679
  ]}
package/Text/utils.ts CHANGED
@@ -7,18 +7,13 @@ const DEFAULT_SCREEN_SIZE = 375;
7
7
  const MAX_FONT_SCALE = 1.5;
8
8
  const MAX_DEVICE_SCALE = 5;
9
9
 
10
- const useScaleSize = (size: number, userScaleRate?: number) => {
11
- const { useOSFontScale = true, userScaleRate: ctxRate } =
12
- useContext(ScaleSizeContext);
10
+ const useScaleSize = (size: number, scaleRate?: number) => {
11
+ const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
13
12
  const fontScale = PixelRatio.getFontScale();
14
13
  const { width } = useWindowDimensions();
15
14
  const deviceScale = width / DEFAULT_SCREEN_SIZE;
16
15
 
17
- const customRate = userScaleRate ?? ctxRate ?? 1;
18
-
19
- if (!useOSFontScale) {
20
- return customRate > 1 ? customRate * size : size;
21
- }
16
+ const maxScaleRate = scaleRate ?? scaleSizeMaxRate;
22
17
 
23
18
  let fontSizeDeviceScale = size;
24
19
  let fontSizeOSScale = size;
@@ -32,8 +27,8 @@ const useScaleSize = (size: number, userScaleRate?: number) => {
32
27
 
33
28
  if (fontScale > 1) {
34
29
  fontSizeOSScale = Math.min(
35
- fontScale * fontSizeOSScale,
36
- fontSizeOSScale * MAX_FONT_SCALE,
30
+ fontSizeOSScale * fontScale,
31
+ fontSizeOSScale * maxScaleRate,
37
32
  );
38
33
  }
39
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.162.1-beta.1",
3
+ "version": "0.162.2-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},