@momo-kits/foundation 0.77.1-optimize.3 → 0.77.1-optimzie.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.
@@ -46,8 +46,6 @@ type Options = {
46
46
  };
47
47
 
48
48
  const DEFAULT_MAX_TAB_ITEM_WIDTH = 125;
49
- const DEFAULT_TABBAR_HEIGHT = 49;
50
- const COMPACT_TABBAR_HEIGHT = 32;
51
49
 
52
50
  const shouldUseHorizontalLabels = ({
53
51
  state,
@@ -87,38 +85,6 @@ const shouldUseHorizontalLabels = ({
87
85
  const getPaddingBottom = (insets: EdgeInsets) =>
88
86
  Math.max(insets.bottom - Platform.select({ios: 4, default: 0}), 0);
89
87
 
90
- export const getTabBarHeight = ({
91
- dimensions,
92
- insets,
93
- style,
94
- ...rest
95
- }: Options & {
96
- insets: EdgeInsets;
97
- style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
98
- }) => {
99
- // @ts-ignore
100
- const customHeight = StyleSheet.flatten(style)?.height;
101
-
102
- if (typeof customHeight === 'number') {
103
- return customHeight;
104
- }
105
-
106
- const isLandscape = dimensions.width > dimensions.height;
107
- const horizontalLabels = shouldUseHorizontalLabels({dimensions, ...rest});
108
- const paddingBottom = getPaddingBottom(insets);
109
-
110
- if (
111
- Platform.OS === 'ios' &&
112
- !Platform.isPad &&
113
- isLandscape &&
114
- horizontalLabels
115
- ) {
116
- return COMPACT_TABBAR_HEIGHT + paddingBottom;
117
- }
118
-
119
- return DEFAULT_TABBAR_HEIGHT + paddingBottom;
120
- };
121
-
122
88
  export default function BottomTabBar({
123
89
  state,
124
90
  navigation,
@@ -409,7 +375,7 @@ export default function BottomTabBar({
409
375
  position: isTabBarHidden ? 'absolute' : (null as any),
410
376
  },
411
377
  {
412
- paddingBottom: paddingBottom - 0,
378
+ paddingBottom: paddingBottom,
413
379
  paddingHorizontal: Math.max(insets.left, insets.right),
414
380
  },
415
381
  style,
@@ -464,7 +430,6 @@ const styles = StyleSheet.create({
464
430
  justifyContent: 'center',
465
431
  height: 48,
466
432
  width: 48,
467
-
468
433
  borderRadius: 100,
469
434
  top: -12,
470
435
  },
@@ -75,7 +75,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
75
75
  )}
76
76
  tabBarOptions={{
77
77
  style: {
78
- height: 68 + Math.min(insets.bottom, 21),
78
+ height: 64 + Math.min(insets.bottom, 21),
79
79
  },
80
80
  tabStyle: {
81
81
  height: 68,
@@ -183,15 +183,18 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
183
183
 
184
184
  const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
185
185
  image,
186
- backgroundColor,
187
186
  animatedValue,
188
- useBorder = false,
187
+ useSurface = false,
189
188
  }) => {
190
189
  const {theme} = useContext(ApplicationContext);
191
190
  let headerImage = theme.assets?.headerBackground;
191
+ let backgroundColor;
192
192
  if (image === null) {
193
193
  headerImage = undefined;
194
194
  }
195
+ if (useSurface) {
196
+ backgroundColor = theme.colors.background.default;
197
+ }
195
198
  const opacity = animatedValue?.interpolate({
196
199
  inputRange: [0, 114],
197
200
  outputRange: [0, 1],
@@ -203,9 +206,9 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
203
206
  style={[
204
207
  Styles.flex,
205
208
  {
206
- backgroundColor: backgroundColor ?? theme.colors.background.default,
209
+ backgroundColor,
207
210
  overflow: 'hidden',
208
- borderBottomWidth: useBorder ? 1 : 0,
211
+ borderBottomWidth: useSurface ? 1 : 0,
209
212
  borderColor: theme.colors.border.default,
210
213
  opacity,
211
214
  },
@@ -90,6 +90,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
90
90
  options,
91
91
  footerComponent,
92
92
  flatListProps,
93
+ backgroundColor,
93
94
  }: BottomSheetParams = props.route.params;
94
95
 
95
96
  const navigation = new Navigation(props.navigation, theme);
@@ -127,6 +128,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
127
128
  options?.title ?? options?.customTitle?.title ?? '',
128
129
  handleClose,
129
130
  )}
131
+ modalStyle={{
132
+ backgroundColor: backgroundColor ?? theme.colors.background.surface,
133
+ }}
130
134
  FooterComponent={footerDefault(footerComponent)}>
131
135
  <View style={styles.bottomSheetContainer}>
132
136
  <Screen {...props} {...params} />
@@ -141,7 +145,7 @@ const headerDefault = (title: string, onClose: () => void) => {
141
145
  <View style={styles.header}>
142
146
  <Text
143
147
  style={styles.textOption}
144
- numberOfLines={2}
148
+ numberOfLines={1}
145
149
  typography="header_default_bold">
146
150
  {title ?? ''}
147
151
  </Text>
@@ -154,14 +158,18 @@ const headerDefault = (title: string, onClose: () => void) => {
154
158
 
155
159
  const footerDefault = (footerComponent: React.ReactNode) => {
156
160
  const insets = useSafeAreaInsets();
157
- if (!footerComponent) return;
158
161
  return (
159
162
  <View
160
163
  style={{
161
- marginBottom: Math.min(insets.bottom, 21) + Spacing.S,
164
+ marginBottom: Math.min(insets.bottom, 21),
162
165
  paddingHorizontal: 12,
163
166
  }}>
164
- {footerComponent}
167
+ {footerComponent && (
168
+ <>
169
+ {footerComponent}
170
+ <View style={{height: Spacing.S}} />
171
+ </>
172
+ )}
165
173
  </View>
166
174
  );
167
175
  };
@@ -204,9 +212,6 @@ const styles = StyleSheet.create({
204
212
  },
205
213
  bottomSheetContainer: {
206
214
  width: '100%',
207
- backgroundColor: 'white',
208
- borderTopRightRadius: 16,
209
- borderTopLeftRadius: 16,
210
215
  },
211
216
  header: {
212
217
  height: 50,
@@ -219,15 +224,9 @@ const styles = StyleSheet.create({
219
224
  color: '#303233',
220
225
  textAlign: 'center',
221
226
  fontWeight: 'bold',
222
- paddingHorizontal: 60,
223
- },
224
- imageOption: {
225
- height: 1,
226
- backgroundColor: '#ebebeb',
227
- width: '100%',
228
- position: 'absolute',
229
- bottom: 1,
227
+ paddingHorizontal: Spacing.L,
230
228
  },
229
+
231
230
  buttonClose: {
232
231
  padding: 12,
233
232
  position: 'absolute',
@@ -119,6 +119,7 @@ export interface ModalParams extends ScreenParams {
119
119
  export interface BottomSheetParams extends ScreenParams {
120
120
  [key: string]: any;
121
121
  onDismiss?: () => void;
122
+ backgroundColor?: string;
122
123
  footerComponent?: React.ReactNode;
123
124
  flatListProps?: FlatListProps<any>;
124
125
  }
@@ -165,9 +166,8 @@ export interface HeaderBackProps extends NavigationButtonProps {
165
166
 
166
167
  export type HeaderBackgroundProps = {
167
168
  image?: string | null;
168
- backgroundColor?: string | null;
169
169
  animatedValue?: Animated.Value;
170
- useBorder?: boolean;
170
+ useSurface?: boolean;
171
171
  };
172
172
 
173
173
  export type TitleCustomProps = {
@@ -223,4 +223,5 @@ export type FloatingButtonProps = {
223
223
  export type AnimatedHeader = {
224
224
  type: 'default' | 'surface';
225
225
  component?: (props?: any) => React.ReactElement;
226
+ headerTitle?: (props?: any) => React.ReactElement;
226
227
  };
@@ -100,11 +100,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
100
100
  ...options,
101
101
  headerTintColor: theme.colors.text.default,
102
102
  headerBackground: () => (
103
- <HeaderBackground
104
- image={null}
105
- backgroundColor={theme.colors.background.surface}
106
- useBorder={true}
107
- />
103
+ <HeaderBackground image={null} useSurface={true} />
108
104
  ),
109
105
  };
110
106
  } else {
package/Button/index.tsx CHANGED
@@ -58,7 +58,7 @@ export interface ButtonProps extends TouchableOpacityProps {
58
58
  /**
59
59
  * If true, the icon of button will use the tint color provided by its container.
60
60
  */
61
- useTintColor?: boolean;
61
+ tintColor?: string;
62
62
 
63
63
  /**
64
64
  * If true, the icon of button will use be show indicator loading.
@@ -76,7 +76,7 @@ export interface ButtonProps extends TouchableOpacityProps {
76
76
  const Button: FC<ButtonProps> = ({
77
77
  type = 'primary',
78
78
  size = 'large',
79
- useTintColor = true,
79
+ tintColor = null,
80
80
  full = true,
81
81
  iconRight,
82
82
  iconLeft,
@@ -231,7 +231,7 @@ const Button: FC<ButtonProps> = ({
231
231
  const renderLeading = () => {
232
232
  const iconSize = getIconSize();
233
233
  const marginRight = getIconSpace();
234
- const color = useTintColor ? getTextColor() : undefined;
234
+ const color = tintColor ?? getTextColor();
235
235
 
236
236
  if (loading) {
237
237
  return (
@@ -245,7 +245,7 @@ const Button: FC<ButtonProps> = ({
245
245
  borderRadius: Spacing.M,
246
246
  },
247
247
  ]}>
248
- <Loader type="spinner" color={color} />
248
+ <Loader type="spinner" color={getTextColor()} />
249
249
  </View>
250
250
  );
251
251
  }
@@ -266,7 +266,7 @@ const Button: FC<ButtonProps> = ({
266
266
  * render trailing
267
267
  */
268
268
  const renderTrailing = () => {
269
- const color = useTintColor ? getTextColor() : undefined;
269
+ const color = tintColor ?? getTextColor();
270
270
  const marginLeft = getIconSpace();
271
271
 
272
272
  if (iconRight) {
package/Input/Input.tsx CHANGED
@@ -169,7 +169,7 @@ const Input = forwardRef(
169
169
  <TextInput
170
170
  {...props}
171
171
  accessibilityLabel={accessibilityLabel}
172
- editable={editable || !disabled}
172
+ editable={editable && !disabled}
173
173
  secureTextEntry={secure}
174
174
  textAlignVertical="center"
175
175
  ref={inputRef}
@@ -76,7 +76,6 @@ const InputMoney = forwardRef(
76
76
  clear: onClearText,
77
77
  focus: () => inputRef.current?.focus(),
78
78
  blur: () => inputRef.current?.blur(),
79
- changeText: (text: string) => _onChangeText(text),
80
79
  setText: _onChangeText,
81
80
  };
82
81
  });
package/Input/common.tsx CHANGED
@@ -16,13 +16,6 @@ type FloatingViewProps = {
16
16
  style?: ViewStyle;
17
17
  };
18
18
 
19
- export interface InputRef {
20
- focus: () => void;
21
- blur: () => void;
22
- clear: () => void;
23
- setText: (text: string) => void;
24
- }
25
-
26
19
  export const DEFAULT_HEIGHT = scaleSize(104);
27
20
  export const MAX_LENGTH = 300;
28
21
 
package/Input/index.tsx CHANGED
@@ -6,6 +6,13 @@ import InputOTP from './InputOTP';
6
6
  import InputSearch from './InputSearch';
7
7
  import InputTextArea from './InputTextArea';
8
8
 
9
+ export interface InputRef {
10
+ focus: () => void;
11
+ blur: () => void;
12
+ clear: () => void;
13
+ setText: (text: string) => void;
14
+ }
15
+
9
16
  export interface InputProps extends TextInputProps {
10
17
  /**
11
18
  * Optional. Defines the size of the Input component.
@@ -45,22 +45,24 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
45
45
  if (!label) return;
46
46
 
47
47
  const listener = animatedValue?.addListener(({value}) => {
48
- const direction = value > lastOffset.current ? 'down' : 'up';
49
- lastOffset.current = value;
50
- if (lastDirection.current !== direction) {
51
- lastDirection.current = direction;
52
- if (direction === 'down') {
53
- Animated.timing(widthAnimated!, {
54
- toValue: minWidth,
55
- duration: 200,
56
- useNativeDriver: false,
57
- }).start(() => setShowText(false));
58
- } else {
59
- Animated.timing(widthAnimated!, {
60
- toValue: maxWidth.current,
61
- duration: 200,
62
- useNativeDriver: false,
63
- }).start(() => setShowText(true));
48
+ if (value !== lastOffset.current) {
49
+ const direction = value > lastOffset.current ? 'down' : 'up';
50
+ lastOffset.current = value;
51
+ if (lastDirection.current !== direction) {
52
+ lastDirection.current = direction;
53
+ if (direction === 'down') {
54
+ Animated.timing(widthAnimated!, {
55
+ toValue: minWidth,
56
+ duration: 200,
57
+ useNativeDriver: false,
58
+ }).start(() => setShowText(false));
59
+ } else {
60
+ Animated.timing(widthAnimated!, {
61
+ toValue: maxWidth.current,
62
+ duration: 200,
63
+ useNativeDriver: false,
64
+ }).start(() => setShowText(true));
65
+ }
64
66
  }
65
67
  }
66
68
  });
package/Layout/Screen.tsx CHANGED
@@ -89,6 +89,10 @@ export interface ScreenProps extends ViewProps {
89
89
  */
90
90
  floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
91
91
 
92
+ /**
93
+ * optional animated value
94
+ */
95
+ animatedValue?: Animated.Value;
92
96
  /**
93
97
  * Optional. If `true`, the screen content is using grid layout by span.
94
98
  */
@@ -111,10 +115,13 @@ const Screen = forwardRef(
111
115
  headerType = 'default',
112
116
  floatingButtonProps,
113
117
  useGridLayout = true,
118
+ animatedValue: animated,
114
119
  }: ScreenProps,
115
120
  ref,
116
121
  ) => {
117
- const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
122
+ const animatedValue = useRef<Animated.Value>(
123
+ animated ?? new Animated.Value(0),
124
+ );
118
125
  const {theme} = useContext(ApplicationContext);
119
126
  const insets = useSafeAreaInsets();
120
127
  const heightHeader = useHeaderHeight();
@@ -151,18 +158,27 @@ const Screen = forwardRef(
151
158
  };
152
159
  if (animatedHeader.type == 'surface') {
153
160
  styleAnimatedHeader = {
154
- headerTransparent: true,
161
+ ...styleAnimatedHeader,
155
162
  headerBackground: (props: any) => (
156
163
  <HeaderBackground
157
164
  {...props}
158
165
  image={null}
159
- backgroundColor={theme.colors.background.surface}
160
- useBorder={true}
166
+ useSurface={true}
161
167
  animatedValue={animatedValue.current}
162
168
  />
163
169
  ),
164
170
  };
165
171
  }
172
+ if (animatedHeader.headerTitle) {
173
+ styleAnimatedHeader = {
174
+ ...styleAnimatedHeader,
175
+ headerTitle: (props: any) =>
176
+ animatedHeader.headerTitle?.({
177
+ ...props,
178
+ animatedValue: animatedValue.current,
179
+ }),
180
+ };
181
+ }
166
182
  navigation?.setOptions(styleAnimatedHeader);
167
183
  }
168
184
  }, [animatedHeader]);
@@ -185,12 +201,7 @@ const Screen = forwardRef(
185
201
  headerShown: true,
186
202
  headerTintColor: theme.colors.text.default,
187
203
  headerBackground: (props: any) => (
188
- <HeaderBackground
189
- {...props}
190
- image={null}
191
- backgroundColor={theme.colors.background.surface}
192
- useBorder={true}
193
- />
204
+ <HeaderBackground {...props} image={null} useSurface={true} />
194
205
  ),
195
206
  headerTitle: (props: any) => <HeaderTitle {...props} />,
196
207
  };
@@ -236,6 +247,7 @@ const Screen = forwardRef(
236
247
  {
237
248
  useNativeDriver: true,
238
249
  listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
250
+ scrollViewProps?.onScroll?.(e);
239
251
  if (animatedHeader?.type == 'surface') {
240
252
  const offsetY = e.nativeEvent.contentOffset.y;
241
253
  let color = Colors.black_01;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.77.1-optimize.3",
3
+ "version": "0.77.1-optimzie.5",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},