@momo-kits/foundation 0.162.3-test.1 → 0.162.3-test.2
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.
|
@@ -31,6 +31,27 @@ const Stack = createStackNavigator();
|
|
|
31
31
|
|
|
32
32
|
const FONT_SCALE_OBSERVER_KEY = 'font_scale_config';
|
|
33
33
|
|
|
34
|
+
// AI-GENERATED START: parse the font_scale_config first-frame seed read straight from async storage (string | {response} | object)
|
|
35
|
+
const parseSeedFontScaleConfig = (raw: any): FontScaleConfig | undefined => {
|
|
36
|
+
let data = raw;
|
|
37
|
+
if (typeof data === 'string') {
|
|
38
|
+
try {
|
|
39
|
+
data = JSON.parse(data);
|
|
40
|
+
} catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
data = data?.response ?? data;
|
|
45
|
+
if (!data || (data.useOSFontScale === undefined && data.userScaleRate === undefined)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
useOSFontScale: data.useOSFontScale,
|
|
50
|
+
userScaleRate: data.userScaleRate,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
// AI-GENERATED END: parse the font_scale_config first-frame seed read straight from async storage (string | {response} | object)
|
|
54
|
+
|
|
34
55
|
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
35
56
|
screen,
|
|
36
57
|
theme = defaultTheme,
|
|
@@ -47,9 +68,11 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
47
68
|
}) => {
|
|
48
69
|
const context = useContext<any>(MiniAppContext);
|
|
49
70
|
const [currentContext, setCurrentContext] = useState<any>({});
|
|
71
|
+
// AI-GENERATED START: self-seed first-frame font scale by reading font_scale_config straight from async storage
|
|
50
72
|
const [observerFontScaleConfig, setObserverFontScaleConfig] = useState<
|
|
51
73
|
FontScaleConfig | undefined
|
|
52
|
-
>(context?.fontScaleConfig);
|
|
74
|
+
>(() => parseSeedFontScaleConfig(maxApi?.getItem?.(FONT_SCALE_OBSERVER_KEY)) ?? context?.fontScaleConfig);
|
|
75
|
+
// AI-GENERATED END: self-seed first-frame font scale by reading font_scale_config straight from async storage
|
|
53
76
|
|
|
54
77
|
const mergedContext = {
|
|
55
78
|
...context,
|
package/Input/Input.tsx
CHANGED
|
@@ -77,8 +77,7 @@ const Input = forwardRef(
|
|
|
77
77
|
const scaledFontSize = useScaleSize(14);
|
|
78
78
|
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
|
|
79
79
|
const [focused, setFocused] = useState(false);
|
|
80
|
-
const
|
|
81
|
-
const haveValue = value !== undefined ? !!value : !!internalText;
|
|
80
|
+
const haveValue = !!value || !!defaultValue;
|
|
82
81
|
const inputRef = useRef<TextInput | null>(null);
|
|
83
82
|
const componentName = 'Input';
|
|
84
83
|
|
|
@@ -96,9 +95,6 @@ const Input = forwardRef(
|
|
|
96
95
|
};
|
|
97
96
|
|
|
98
97
|
const _onChangeText = (text: string) => {
|
|
99
|
-
if (value === undefined) {
|
|
100
|
-
setInternalText(text);
|
|
101
|
-
}
|
|
102
98
|
onChangeText?.(text);
|
|
103
99
|
};
|
|
104
100
|
|
|
@@ -69,8 +69,7 @@ const InputPhoneNumber = forwardRef(
|
|
|
69
69
|
const context = useContext<any>(MiniAppContext);
|
|
70
70
|
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
|
|
71
71
|
const [focused, setFocused] = useState(false);
|
|
72
|
-
const
|
|
73
|
-
const haveValue = value !== undefined ? !!value : !!internalText;
|
|
72
|
+
const haveValue = !!value || !!defaultValue;
|
|
74
73
|
const inputRef = useRef<TextInput | null>(null);
|
|
75
74
|
const componentName = 'InputPhoneNumber';
|
|
76
75
|
|
|
@@ -87,9 +86,6 @@ const InputPhoneNumber = forwardRef(
|
|
|
87
86
|
};
|
|
88
87
|
|
|
89
88
|
const _onChangeText = (text: string) => {
|
|
90
|
-
if (value === undefined) {
|
|
91
|
-
setInternalText(text);
|
|
92
|
-
}
|
|
93
89
|
onChangeText?.(text);
|
|
94
90
|
};
|
|
95
91
|
|