@momo-kits/foundation 0.167.1-beta.2 → 0.167.1-beta.5
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/Application/BottomTab/BottomTabBar.tsx +3 -6
- package/Application/Components/HeaderExtendHeader.tsx +6 -7
- package/Application/Components/SearchHeader.tsx +8 -4
- package/Layout/Card.tsx +4 -6
- package/Layout/FloatingButton.tsx +2 -4
- package/Layout/Section.tsx +11 -7
- package/Layout/utils.ts +1 -16
- package/package.json +1 -1
|
@@ -58,13 +58,11 @@ export default function BottomTabBar({
|
|
|
58
58
|
const { theme } = useContext(ApplicationContext);
|
|
59
59
|
const { routes } = state;
|
|
60
60
|
const widthDevice = useWindowDimensions()?.width;
|
|
61
|
-
const insets = useSafeAreaInsets();
|
|
62
61
|
const useFloating = floatingButton && state.routes.length % 2 === 0;
|
|
63
|
-
const itemWidth =
|
|
64
|
-
(widthDevice - insets.left - insets.right) /
|
|
65
|
-
(state.routes.length + (useFloating ? 1 : 0));
|
|
62
|
+
const itemWidth = widthDevice / (state.routes.length + (useFloating ? 1 : 0));
|
|
66
63
|
// const buildLink = useLinkBuilder();
|
|
67
64
|
const indicatorAnimated = useSharedValue(0);
|
|
65
|
+
const insets = useSafeAreaInsets();
|
|
68
66
|
|
|
69
67
|
const indicatorStyle = useAnimatedStyle(() => ({
|
|
70
68
|
width: itemWidth,
|
|
@@ -248,8 +246,7 @@ export default function BottomTabBar({
|
|
|
248
246
|
},
|
|
249
247
|
{
|
|
250
248
|
paddingBottom: paddingBottom,
|
|
251
|
-
|
|
252
|
-
paddingRight: insets.right,
|
|
249
|
+
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
253
250
|
},
|
|
254
251
|
style,
|
|
255
252
|
]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Ref, useContext } from 'react';
|
|
2
2
|
import LinearGradient from 'react-native-linear-gradient';
|
|
3
|
-
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { Dimensions, Platform, StyleSheet, View } from 'react-native';
|
|
4
4
|
import Animated, {
|
|
5
5
|
Extrapolation,
|
|
6
6
|
interpolate,
|
|
@@ -18,11 +18,12 @@ import {
|
|
|
18
18
|
AnimatedCompatValue,
|
|
19
19
|
useNormalizedSharedValue,
|
|
20
20
|
} from '../utils';
|
|
21
|
-
import { useHorizontalLayout } from '../../Layout/utils';
|
|
22
21
|
|
|
23
22
|
const SCREEN_PADDING = 12;
|
|
24
23
|
const BACK_WIDTH = 28;
|
|
25
24
|
|
|
25
|
+
const { width: screenWidth } = Dimensions.get('window');
|
|
26
|
+
|
|
26
27
|
const HeaderExtendHeader: React.FC<{
|
|
27
28
|
headerType?: HeaderType;
|
|
28
29
|
animatedValue: AnimatedCompatValue;
|
|
@@ -51,8 +52,6 @@ const HeaderExtendHeader: React.FC<{
|
|
|
51
52
|
const gradientColor = customGradientColor ?? theme.colors.gradient;
|
|
52
53
|
const headerBackground = customBackground ?? theme.assets?.headerBackground;
|
|
53
54
|
const leftPosition = inputSearchProps?.leftPosition || BACK_WIDTH + 20;
|
|
54
|
-
const layout = useHorizontalLayout(SCREEN_PADDING);
|
|
55
|
-
const { insets } = layout;
|
|
56
55
|
|
|
57
56
|
let useShadowHeader = useShadowHeaderProp;
|
|
58
57
|
if (inputSearchProps && Platform.OS === 'android') {
|
|
@@ -80,7 +79,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
80
79
|
translateX: interpolate(
|
|
81
80
|
sharedValue.value,
|
|
82
81
|
[0, 100],
|
|
83
|
-
[
|
|
82
|
+
[SCREEN_PADDING, leftPosition],
|
|
84
83
|
Extrapolation.CLAMP,
|
|
85
84
|
),
|
|
86
85
|
},
|
|
@@ -89,8 +88,8 @@ const HeaderExtendHeader: React.FC<{
|
|
|
89
88
|
sharedValue.value,
|
|
90
89
|
[0, 100],
|
|
91
90
|
[
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
screenWidth - SCREEN_PADDING * 2,
|
|
92
|
+
screenWidth - leftPosition - 12 - headerRightWidth,
|
|
94
93
|
],
|
|
95
94
|
Extrapolation.CLAMP,
|
|
96
95
|
),
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Colors, Radius, Spacing, Styles } from '../../Consts';
|
|
2
2
|
import { InputRef, InputSearch } from '../../Input';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Dimensions,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
4
9
|
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
5
10
|
import React, { useContext } from 'react';
|
|
6
11
|
import { SearchHeaderProps } from '../types';
|
|
7
12
|
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
8
13
|
import { Text } from '../../Text';
|
|
9
14
|
import { useNormalizedSharedValue } from '../utils';
|
|
10
|
-
import { useHorizontalLayout } from '../../Layout/utils';
|
|
11
15
|
|
|
12
16
|
const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
13
17
|
(
|
|
@@ -23,7 +27,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
|
23
27
|
const { theme, navigator } = useContext(ApplicationContext);
|
|
24
28
|
const context = useContext<any>(MiniAppContext);
|
|
25
29
|
const BACK_WIDTH = 28;
|
|
26
|
-
const { width:
|
|
30
|
+
const { width: screenWidth } = Dimensions.get('window');
|
|
27
31
|
|
|
28
32
|
const sharedValue = useNormalizedSharedValue(animatedValue);
|
|
29
33
|
const leftPosition = props?.leftPosition ?? BACK_WIDTH + 20;
|
|
@@ -73,7 +77,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
|
|
|
73
77
|
style={[
|
|
74
78
|
Styles.flex,
|
|
75
79
|
renderButtons && {
|
|
76
|
-
maxWidth:
|
|
80
|
+
maxWidth: screenWidth - leftPosition - 12 - headerRightWidth,
|
|
77
81
|
},
|
|
78
82
|
]}
|
|
79
83
|
>
|
package/Layout/Card.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { View, ViewProps } from 'react-native';
|
|
3
|
-
import { useGridSystem
|
|
2
|
+
import { Dimensions, View, ViewProps } from 'react-native';
|
|
3
|
+
import { useGridSystem } from './utils';
|
|
4
4
|
import { GridContextProps } from './types';
|
|
5
5
|
import { GridContext, GridSystem } from './index';
|
|
6
6
|
import { Image } from '../Image';
|
|
@@ -32,8 +32,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
32
32
|
|
|
33
33
|
const gutterSize = 8;
|
|
34
34
|
const margin = 12;
|
|
35
|
-
const
|
|
36
|
-
const widthSection = layout.width;
|
|
35
|
+
const widthSection = Dimensions.get('window').width - margin * 2;
|
|
37
36
|
let sizePerSpan =
|
|
38
37
|
(widthSection - margin * 2 - gutterSize * (numberOfColumns - 1)) /
|
|
39
38
|
numberOfColumns -
|
|
@@ -77,8 +76,7 @@ const Card: React.FC<CardProps> = ({
|
|
|
77
76
|
styles.card,
|
|
78
77
|
{
|
|
79
78
|
width: widthSection,
|
|
80
|
-
|
|
81
|
-
marginRight: layout.marginRight,
|
|
79
|
+
marginHorizontal: margin,
|
|
82
80
|
gap: gutterSize,
|
|
83
81
|
},
|
|
84
82
|
!!backgroundImage && { backgroundColor: undefined },
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
AnimatedCompatValue,
|
|
20
20
|
useNormalizedSharedValue,
|
|
21
21
|
} from '../Application/utils';
|
|
22
|
-
import { useHorizontalLayout } from './utils';
|
|
23
22
|
|
|
24
23
|
export interface FloatingButtonProps {
|
|
25
24
|
label?: string;
|
|
@@ -57,7 +56,6 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
57
56
|
const lastOffset = useSharedValue(0);
|
|
58
57
|
const lastDirection = useSharedValue<string | null>(null);
|
|
59
58
|
const [showText, setShowText] = useState(true);
|
|
60
|
-
const { marginRight } = useHorizontalLayout(12);
|
|
61
59
|
|
|
62
60
|
useEffect(() => {
|
|
63
61
|
if (!label) return;
|
|
@@ -121,7 +119,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
121
119
|
style={[
|
|
122
120
|
styles.container,
|
|
123
121
|
{
|
|
124
|
-
right: position === 'right' ?
|
|
122
|
+
right: position === 'right' ? 12 : undefined,
|
|
125
123
|
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
126
124
|
bottom,
|
|
127
125
|
},
|
|
@@ -138,7 +136,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
138
136
|
style={[
|
|
139
137
|
styles.container,
|
|
140
138
|
{
|
|
141
|
-
right: position === 'right' ?
|
|
139
|
+
right: position === 'right' ? 12 : undefined,
|
|
142
140
|
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
143
141
|
height: size === 'small' ? 36 : 48,
|
|
144
142
|
backgroundColor: theme.colors.primary,
|
package/Layout/Section.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { useGridSystem
|
|
2
|
+
import { Dimensions, View, ViewProps } from 'react-native';
|
|
3
|
+
import { useGridSystem } from './utils';
|
|
4
4
|
import { GridContextProps } from './types';
|
|
5
5
|
import { GridContext } from './index';
|
|
6
6
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
@@ -38,9 +38,14 @@ const Section: React.FC<SectionProps> = ({
|
|
|
38
38
|
const { numberOfColumns } = useGridSystem();
|
|
39
39
|
|
|
40
40
|
const gutterSize = 12;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
let margin = 0;
|
|
42
|
+
if (useMargin) {
|
|
43
|
+
margin = 12;
|
|
44
|
+
}
|
|
45
|
+
let widthSection = Dimensions.get('window').width;
|
|
46
|
+
if (useMargin) {
|
|
47
|
+
widthSection = widthSection - margin * 2;
|
|
48
|
+
}
|
|
44
49
|
|
|
45
50
|
const sizePerSpan =
|
|
46
51
|
(widthSection - gutterSize * (numberOfColumns - 1)) / numberOfColumns -
|
|
@@ -72,8 +77,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
72
77
|
styles.protectedStyle,
|
|
73
78
|
{
|
|
74
79
|
width: widthSection,
|
|
75
|
-
|
|
76
|
-
marginRight: useMargin ? layout.marginRight : 0,
|
|
80
|
+
marginHorizontal: margin,
|
|
77
81
|
flexDirection: 'row',
|
|
78
82
|
flexWrap: 'wrap',
|
|
79
83
|
gap: gutterSize,
|
package/Layout/utils.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { Fragment, ReactElement } from 'react';
|
|
2
2
|
import { useWindowDimensions } from 'react-native';
|
|
3
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* validate children type
|
|
@@ -45,18 +44,4 @@ const useGridSystem = () => {
|
|
|
45
44
|
return { numberOfColumns };
|
|
46
45
|
};
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
const useHorizontalLayout = (margin: number) => {
|
|
50
|
-
const { width } = useWindowDimensions();
|
|
51
|
-
const insets = useSafeAreaInsets();
|
|
52
|
-
const marginLeft = margin + insets.left;
|
|
53
|
-
const marginRight = margin + insets.right;
|
|
54
|
-
return {
|
|
55
|
-
marginLeft,
|
|
56
|
-
marginRight,
|
|
57
|
-
width: width - marginLeft - marginRight,
|
|
58
|
-
insets,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export { useGridSystem, useHorizontalLayout, validateChildren };
|
|
47
|
+
export { useGridSystem, validateChildren };
|