@momo-kits/foundation 0.92.6-rc.27 → 0.92.6-rc.29

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.
@@ -84,7 +84,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
84
84
  },
85
85
  tabStyle: {
86
86
  height: 68,
87
- paddingVertical: 8,
87
+ paddingVertical: 10,
88
88
  },
89
89
  }}>
90
90
  {tabs.map(item => {
@@ -122,7 +122,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
122
122
  fontFamily: `${theme.font}-Bold`,
123
123
  left: isDot ? 8 : 4,
124
124
  top: isDot ? -2 : -6,
125
- backgroundColor: isNum ? Colors.orange_03 : Colors.red_03,
125
+ backgroundColor: isNum ? Colors.red_03 : Colors.orange_03,
126
126
  },
127
127
  tabBarIcon: ({color}) => (
128
128
  <Icon source={item.icon} color={color} size={28} />
@@ -193,7 +193,7 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
193
193
  headerImage = undefined;
194
194
  }
195
195
  if (useSurface) {
196
- backgroundColor = theme.colors.background.default;
196
+ backgroundColor = theme.colors.background.surface;
197
197
  }
198
198
  const opacity = animatedValue?.interpolate({
199
199
  inputRange: [0, 114],
@@ -85,11 +85,13 @@ const Modal: React.FC<ModalParams> = props => {
85
85
 
86
86
  const BottomSheet: React.FC<BottomSheetParams> = props => {
87
87
  const {theme, navigator} = useContext(ApplicationContext);
88
+ const insets = useSafeAreaInsets();
89
+
88
90
  const {
89
91
  screen: Screen,
90
92
  options,
91
93
  footerComponent,
92
- flatListProps,
94
+ scrollViewProps,
93
95
  backgroundColor,
94
96
  }: BottomSheetParams = props.route.params;
95
97
 
@@ -101,14 +103,59 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
101
103
  };
102
104
 
103
105
  delete params.screen;
104
- const modalizeRef = useRef<Modalize>(null);
106
+ const modalRef = useRef<Modalize>(null);
105
107
 
106
108
  useEffect(() => {
107
- modalizeRef.current?.open();
109
+ modalRef.current?.open();
108
110
  }, []);
109
111
 
110
112
  const handleClose = () => {
111
- modalizeRef?.current?.close();
113
+ modalRef?.current?.close();
114
+ };
115
+
116
+ /**
117
+ * build header
118
+ * @param title
119
+ * @param onClose
120
+ */
121
+ const headerDefault = (title: string, onClose: () => void) => {
122
+ return (
123
+ <View
124
+ style={[
125
+ styles.header,
126
+ {borderBottomColor: theme.colors.border.default},
127
+ ]}>
128
+ <View style={styles.iconButton} />
129
+ <Text
130
+ style={styles.textOption}
131
+ numberOfLines={1}
132
+ typography="header_default_bold">
133
+ {title ?? ''}
134
+ </Text>
135
+ <TouchableOpacity style={styles.iconButton} onPress={onClose}>
136
+ <Icon source="navigation_close" />
137
+ </TouchableOpacity>
138
+ </View>
139
+ );
140
+ };
141
+
142
+ /**
143
+ * build footer
144
+ * @param footerComponent
145
+ */
146
+ const footerDefault = (footerComponent: React.ReactNode) => {
147
+ if (footerComponent) {
148
+ return (
149
+ <View
150
+ style={{
151
+ marginBottom: Math.min(insets.bottom, 21),
152
+ paddingHorizontal: Spacing.M,
153
+ paddingVertical: Spacing.S,
154
+ }}>
155
+ {footerComponent}
156
+ </View>
157
+ );
158
+ }
112
159
  };
113
160
 
114
161
  return (
@@ -121,9 +168,12 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
121
168
  onClosed={() => {
122
169
  navigator?.pop();
123
170
  }}
124
- ref={modalizeRef}
125
- withHandle={false}
126
- flatListProps={flatListProps}
171
+ handlePosition="inside"
172
+ withHandle={true}
173
+ disableScrollIfPossible={true}
174
+ modalTopOffset={insets.top}
175
+ ref={modalRef}
176
+ scrollViewProps={scrollViewProps}
127
177
  HeaderComponent={headerDefault(
128
178
  options?.title ?? options?.customTitle?.title ?? '',
129
179
  handleClose,
@@ -140,38 +190,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
140
190
  );
141
191
  };
142
192
 
143
- const headerDefault = (title: string, onClose: () => void) => {
144
- return (
145
- <View style={styles.header}>
146
- <Text
147
- style={styles.textOption}
148
- numberOfLines={1}
149
- typography="header_default_bold">
150
- {title ?? ''}
151
- </Text>
152
- <TouchableOpacity style={styles.buttonClose} onPress={onClose}>
153
- <Icon source="navigation_close" />
154
- </TouchableOpacity>
155
- </View>
156
- );
157
- };
158
-
159
- const footerDefault = (footerComponent: React.ReactNode) => {
160
- const insets = useSafeAreaInsets();
161
- if (footerComponent) {
162
- return (
163
- <View
164
- style={{
165
- marginBottom: Math.min(insets.bottom, 21),
166
- paddingHorizontal: Spacing.M,
167
- paddingVertical: Spacing.S,
168
- }}>
169
- {footerComponent}
170
- </View>
171
- );
172
- }
173
- };
174
-
175
193
  const styles = StyleSheet.create({
176
194
  container: {flex: 1, flexDirection: 'row'},
177
195
  modalContent: {
@@ -212,10 +230,12 @@ const styles = StyleSheet.create({
212
230
  width: '100%',
213
231
  },
214
232
  header: {
215
- height: 50,
233
+ marginTop: 10,
234
+ height: 56,
216
235
  width: '100%',
217
236
  alignItems: 'center',
218
- justifyContent: 'center',
237
+ flexDirection: 'row',
238
+ borderBottomWidth: 1,
219
239
  },
220
240
  textOption: {
221
241
  fontSize: 16,
@@ -223,12 +243,14 @@ const styles = StyleSheet.create({
223
243
  textAlign: 'center',
224
244
  fontWeight: 'bold',
225
245
  paddingHorizontal: Spacing.L,
246
+ flex: 1,
226
247
  },
227
-
228
- buttonClose: {
229
- padding: 12,
230
- position: 'absolute',
231
- right: 0,
248
+ iconButton: {
249
+ width: 24,
250
+ height: 24,
251
+ alignItems: 'center',
252
+ justifyContent: 'center',
253
+ marginHorizontal: Spacing.M,
232
254
  },
233
255
  icon: {
234
256
  width: 24,
@@ -1,6 +1,6 @@
1
1
  import {StackNavigationOptions} from '@react-navigation/stack';
2
2
  import React from 'react';
3
- import {Animated, FlatListProps, ViewProps} from 'react-native';
3
+ import {Animated, ScrollViewProps, ViewProps} from 'react-native';
4
4
  import {PopupNotifyProps} from '../Popup/types';
5
5
  import Navigation from './Navigation';
6
6
  import Navigator from './Navigator';
@@ -121,7 +121,7 @@ export interface BottomSheetParams extends ScreenParams {
121
121
  onDismiss?: () => void;
122
122
  backgroundColor?: string;
123
123
  footerComponent?: React.ReactNode;
124
- flatListProps?: FlatListProps<any>;
124
+ scrollViewProps?: ScrollViewProps;
125
125
  }
126
126
 
127
127
  export type NavigationButtonProps = {
@@ -8,7 +8,6 @@ import {
8
8
  } from 'react-native';
9
9
  import {ApplicationContext} from '../Application';
10
10
  import {Icon} from '../Icon';
11
- import {Text} from '../Text';
12
11
 
13
12
  export interface FloatingButtonProps {
14
13
  label?: string;
@@ -36,6 +35,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
36
35
  const {theme} = useContext(ApplicationContext);
37
36
  const maxWidth = useRef(0);
38
37
  const minWidth = size == 'small' ? 36 : 48;
38
+ const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
39
39
  const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
40
40
  const lastOffset = useRef(0);
41
41
  const lastDirection = useRef<string>();
@@ -44,6 +44,12 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
44
44
  useEffect(() => {
45
45
  if (!label) return;
46
46
 
47
+ Animated.timing(opacityAnimated, {
48
+ toValue: 1,
49
+ duration: 100,
50
+ useNativeDriver: true,
51
+ }).start();
52
+
47
53
  const listener = animatedValue?.addListener(({value}) => {
48
54
  if (value !== lastOffset.current && value > 0) {
49
55
  const direction = value > lastOffset.current ? 'down' : 'up';
@@ -51,15 +57,25 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
51
57
  if (lastDirection.current !== direction) {
52
58
  lastDirection.current = direction;
53
59
  if (direction === 'down') {
60
+ Animated.timing(opacityAnimated, {
61
+ toValue: 0,
62
+ duration: 100,
63
+ useNativeDriver: true,
64
+ }).start();
54
65
  Animated.timing(widthAnimated!, {
55
66
  toValue: minWidth,
56
- duration: 200,
67
+ duration: 100,
57
68
  useNativeDriver: false,
58
69
  }).start(() => setShowText(false));
59
70
  } else {
71
+ Animated.timing(opacityAnimated, {
72
+ toValue: 1,
73
+ duration: 100,
74
+ useNativeDriver: true,
75
+ }).start();
60
76
  Animated.timing(widthAnimated!, {
61
77
  toValue: maxWidth.current,
62
- duration: 200,
78
+ duration: 100,
63
79
  useNativeDriver: false,
64
80
  }).start(() => setShowText(true));
65
81
  }
@@ -121,13 +137,11 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
121
137
  color={iconColor}
122
138
  />
123
139
  {showText && !!label && (
124
- <Text
125
- style={styles.label}
126
- color="white"
127
- numberOfLines={1}
128
- typography="action_default_bold">
140
+ <Animated.Text
141
+ style={[styles.label, {opacity: opacityAnimated, color: 'white'}]}
142
+ numberOfLines={1}>
129
143
  {label}
130
- </Text>
144
+ </Animated.Text>
131
145
  )}
132
146
  </TouchableOpacity>
133
147
  </Animated.View>
@@ -147,5 +161,8 @@ const styles = StyleSheet.create({
147
161
  },
148
162
  label: {
149
163
  marginLeft: 8,
164
+ fontSize: 16,
165
+ lineHeight: 22,
166
+ fontWeight: '700',
150
167
  },
151
168
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.6-rc.27",
3
+ "version": "0.92.6-rc.29",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},