@momo-kits/foundation 0.109.1-beta.2 → 0.109.1-beta.4

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.
@@ -11,13 +11,16 @@ import {Colors} from '../../Consts';
11
11
  const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
12
12
  animatedValue,
13
13
  image,
14
+ useScale = true,
14
15
  children,
15
16
  }) => {
16
- const scale = animatedValue.interpolate({
17
- inputRange: [-300, 0, 300],
18
- outputRange: [4, 1, 1],
19
- extrapolate: 'clamp',
20
- });
17
+ const scale = useScale
18
+ ? animatedValue.interpolate({
19
+ inputRange: [-300, 0, 300],
20
+ outputRange: [4, 1, 1],
21
+ extrapolate: 'clamp',
22
+ })
23
+ : 1;
21
24
  const opacity = animatedValue.interpolate({
22
25
  inputRange: [0, 150, 300],
23
26
  outputRange: [1, 0.5, 0],
@@ -16,10 +16,14 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
16
16
  animatedValue,
17
17
  useGradient = true,
18
18
  useShadowHeader = true,
19
+ gradientColor,
20
+ headerBackground,
19
21
  }) => {
20
22
  const {theme} = useContext(ApplicationContext);
21
23
 
22
- let headerImage = theme.assets?.headerBackground;
24
+ const linearGradientColor = gradientColor ?? theme.colors.gradient;
25
+
26
+ let headerImage = headerBackground ?? theme.assets?.headerBackground;
23
27
  if (image === null) {
24
28
  headerImage = undefined;
25
29
  }
@@ -50,7 +54,7 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
50
54
  <View style={styles.gradientContainer}>
51
55
  {useGradient && (
52
56
  <LinearGradientAnimated
53
- colors={[theme.colors.gradient, theme.colors.gradient + '00']}
57
+ colors={[linearGradientColor, linearGradientColor + '00']}
54
58
  style={[styles.extendedHeader, {opacity: opacityGradient}]}>
55
59
  {!!headerImage && (
56
60
  <Image
@@ -27,6 +27,8 @@ const HeaderExtendHeader: React.FC<{
27
27
  inputSearchRef?: Ref<InputRef>;
28
28
  navigation?: Navigation;
29
29
  useShadowHeader?: boolean;
30
+ gradientColor?: string;
31
+ headerBackground?: string;
30
32
  }> = ({
31
33
  headerType = 'default',
32
34
  animatedValue,
@@ -35,10 +37,13 @@ const HeaderExtendHeader: React.FC<{
35
37
  inputSearchProps,
36
38
  inputSearchRef,
37
39
  useShadowHeader = true,
40
+ gradientColor: customGradientColor,
41
+ headerBackground: customBackground,
38
42
  }) => {
39
43
  const {theme} = useContext(ApplicationContext);
40
-
41
44
  const animated = useRef(new Animated.Value(0));
45
+ const gradientColor = customGradientColor ?? theme.colors.gradient;
46
+ const headerBackground = customBackground ?? theme.assets?.headerBackground;
42
47
 
43
48
  const opacityBackground = animatedValue?.interpolate({
44
49
  inputRange: [0, 52],
@@ -105,7 +110,7 @@ const HeaderExtendHeader: React.FC<{
105
110
  {height: headerType === 'extended' ? height : heightHeader},
106
111
  ]}>
107
112
  <LinearGradientAnimated
108
- colors={[theme.colors.gradient, theme.colors.gradient + '00']}
113
+ colors={[gradientColor, gradientColor + '00']}
109
114
  style={[styles.extendedHeader, {opacity: opacityGradient}]}>
110
115
  {!!theme.assets?.headerBackground && (
111
116
  <Image
@@ -169,12 +174,12 @@ const HeaderExtendHeader: React.FC<{
169
174
  ]}
170
175
  />
171
176
  <LinearGradientAnimated
172
- colors={[theme.colors.gradient, theme.colors.gradient + '00']}
177
+ colors={[gradientColor, gradientColor + '00']}
173
178
  style={[styles.extendedHeader, {opacity: opacityGradient}]}>
174
- {!!theme.assets?.headerBackground && (
179
+ {!!headerBackground && (
175
180
  <Image
176
181
  style={styles.headerBackground}
177
- source={{uri: theme.assets?.headerBackground}}
182
+ source={{uri: headerBackground}}
178
183
  loading={false}
179
184
  />
180
185
  )}
@@ -11,7 +11,7 @@ import {Colors, Spacing, Styles} from '../../Consts';
11
11
  import {PopupNotify} from '../../Popup';
12
12
  import {Tool} from '../types';
13
13
  import {Icon} from '../../Icon';
14
- import {scaleSize} from '../../Text';
14
+ import {scaleSize, Text} from '../../Text';
15
15
 
16
16
  const WHITE_LIST = [
17
17
  'vn.momo.appx',
@@ -25,7 +25,14 @@ const HELP_CENTER_ICON = 'help_center';
25
25
  * main component for header right
26
26
  */
27
27
  const HeaderRight: React.FC<any> = props => {
28
+ const {headerRight = {}} = props;
29
+ const {
30
+ useOnBoarding = false,
31
+ buttonOnBoarding,
32
+ onPressButtonOnBoarding,
33
+ } = headerRight;
28
34
  const context = useContext<any>(MiniAppContext);
35
+ const {translate} = useContext(ApplicationContext);
29
36
  if (
30
37
  WHITE_LIST.includes(context?.appId) &&
31
38
  typeof props.headerRight === 'function'
@@ -37,6 +44,18 @@ const HeaderRight: React.FC<any> = props => {
37
44
  return <View />;
38
45
  }
39
46
 
47
+ if (useOnBoarding && onPressButtonOnBoarding) {
48
+ return (
49
+ <TouchableOpacity
50
+ onPress={onPressButtonOnBoarding}
51
+ style={styles.onBoarding}>
52
+ <Text typography={'action_s_bold'}>
53
+ {buttonOnBoarding || translate?.('skip')}
54
+ </Text>
55
+ </TouchableOpacity>
56
+ );
57
+ }
58
+
40
59
  return (
41
60
  <View style={styles.headerRightButton}>
42
61
  <HeaderToolkitAction {...props.headerRight} tintColor={props.tintColor} />
@@ -177,14 +196,16 @@ const HeaderToolkitAction: React.FC<any> = ({
177
196
  <TouchableOpacity
178
197
  accessibilityLabel={'btn_navigation_help_center'}
179
198
  style={styles.toolkitButton}
180
- onPress={onPressHelpCenter}>
199
+ onPress={onPressHelpCenter}
200
+ hitSlop={{top: 7, bottom: 7, left: 7, right: 0}}>
181
201
  <Icon color={tintColor} source={HELP_CENTER_ICON} size={20} />
182
202
  </TouchableOpacity>
183
203
  <View style={[styles.divider, {backgroundColor: tintColor}]} />
184
204
  <TouchableOpacity
185
205
  accessibilityLabel={'btn_navigation_close'}
186
206
  onPress={onClose}
187
- style={styles.toolkitButton}>
207
+ style={styles.toolkitButton}
208
+ hitSlop={{top: 7, bottom: 7, left: 0, right: 7}}>
188
209
  <Icon
189
210
  color={tintColor}
190
211
  source="16_navigation_close_circle"
@@ -264,6 +285,7 @@ const styles = StyleSheet.create({
264
285
  },
265
286
  toolkitButton: {
266
287
  padding: 4,
288
+ backgroundColor: 'red',
267
289
  },
268
290
  divider: {
269
291
  width: 0.5,
@@ -334,6 +356,9 @@ const styles = StyleSheet.create({
334
356
  },
335
357
  }),
336
358
  },
359
+ onBoarding: {
360
+ marginRight: Spacing.M,
361
+ },
337
362
  });
338
363
 
339
364
  export {HeaderRight};
@@ -72,7 +72,10 @@ const TitleUser: React.FC<TitleUserProps> = ({
72
72
  onPress,
73
73
  }) => {
74
74
  return (
75
- <TouchableOpacity style={styles.headerTitleContainer} onPress={onPress}>
75
+ <TouchableOpacity
76
+ style={styles.headerTitleContainer}
77
+ onPress={onPress}
78
+ disabled={onPress === undefined}>
76
79
  <View style={Styles.row}>
77
80
  <View>
78
81
  <Image source={{uri: image}} style={styles.circle} />
@@ -140,7 +143,7 @@ const TitleLocation: React.FC<TitleLocationProps> = ({
140
143
  {location}
141
144
  </Text>
142
145
  <Icon
143
- source={'16_arrow_chevron_down'}
146
+ source={'16_arrow_chevron_down_small'}
144
147
  size={16}
145
148
  style={{marginHorizontal: Spacing.XS}}
146
149
  />
@@ -32,7 +32,8 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
32
32
  disabled={disabled}
33
33
  accessibilityLabel={accessibilityLabel}
34
34
  style={[styles.navigationButton, buttonStyle]}
35
- onPress={onPress}>
35
+ onPress={onPress}
36
+ hitSlop={{top: 7, bottom: 7, left: 7, right: 7}}>
36
37
  <Icon
37
38
  source={icon}
38
39
  color={tintColor ?? theme.colors.text.default}
@@ -16,9 +16,8 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
16
16
  (
17
17
  {
18
18
  animatedValue,
19
- headerRightWidth = 73,
20
19
  buttonText = 'Huỷ',
21
- showButtonText,
20
+ showButtonText = true,
22
21
  onPressButtonText,
23
22
  ...props
24
23
  },
@@ -68,7 +67,6 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
68
67
  <Text typography={'action_default_bold'}>{buttonText}</Text>
69
68
  </TouchableOpacity>
70
69
  )}
71
- <View style={{marginRight: headerRightWidth}} />
72
70
  </View>
73
71
  );
74
72
  }
@@ -154,9 +154,15 @@ export interface NavigationOptions
154
154
  onPressLeftHeader?: () => void;
155
155
  hiddenBack?: boolean;
156
156
  headerTitle?: HeaderTitleProps | string;
157
- headerRight?: HeaderRightToolkit | any;
157
+ headerRight?: OnBoarding | HeaderRightToolkit | any;
158
158
  }
159
159
 
160
+ export type OnBoarding = {
161
+ useOnBoarding?: boolean;
162
+ buttonText?: string;
163
+ onPressButtonOnBoarding?: () => void;
164
+ };
165
+
160
166
  export type HeaderRightToolkit = {
161
167
  useShortcut?: boolean;
162
168
  tools?: Tool[];
@@ -174,6 +180,8 @@ export type HeaderBackgroundProps = {
174
180
  useGradient?: boolean;
175
181
  useShadowHeader?: boolean;
176
182
  backgroundColor?: string;
183
+ gradientColor?: string;
184
+ headerBackground?: string;
177
185
  };
178
186
 
179
187
  export type TitleUserProps = {
@@ -212,6 +220,7 @@ export type HeaderToolkitProps = {
212
220
  export interface HeaderAnimatedProps extends ViewProps {
213
221
  animatedValue: Animated.Value;
214
222
  image: string;
223
+ useScale?: boolean;
215
224
  }
216
225
 
217
226
  export type BottomTabItemProps = {
@@ -97,7 +97,8 @@
97
97
  "information": "Thông tin chung",
98
98
  "tutorial": "Hướng dẫn sử dụng",
99
99
  "question": "Câu hỏi thường gặp",
100
- "support": "Trung tâm hỗ trợ"
100
+ "support": "Trung tâm hỗ trợ",
101
+ "skip": "Bỏ qua"
101
102
  },
102
103
  "en": {
103
104
  "seeMore": "See more",
@@ -197,6 +198,7 @@
197
198
  "tutorial": "Instruction",
198
199
  "question": "FAQ",
199
200
  "support": "Support center",
200
- "errorCode": "Error code: "
201
+ "errorCode": "Error code: ",
202
+ "skip": "Skip"
201
203
  }
202
204
  }
package/Layout/Screen.tsx CHANGED
@@ -136,6 +136,16 @@ export interface ScreenProps extends ViewProps {
136
136
  * Optional. If `true`, use shadow header.
137
137
  */
138
138
  useShadowHeader?: boolean;
139
+
140
+ /**
141
+ * Optional. Custom header Gradient Color.
142
+ */
143
+ gradientColor?: string;
144
+
145
+ /**
146
+ * Optional. Custom headerBackground Image
147
+ */
148
+ headerBackground?: string;
139
149
  }
140
150
 
141
151
  const Screen = forwardRef(
@@ -160,6 +170,8 @@ const Screen = forwardRef(
160
170
  inputSearchProps,
161
171
  inputSearchRef,
162
172
  animatedValue: customAnimatedValue,
173
+ headerBackground,
174
+ gradientColor,
163
175
  }: ScreenProps,
164
176
  ref: any
165
177
  ) => {
@@ -170,7 +182,7 @@ const Screen = forwardRef(
170
182
  const animatedValue = useRef<Animated.Value>(
171
183
  customAnimatedValue || new Animated.Value(0)
172
184
  );
173
- const currentTint = useRef<string>(Colors.black_17);
185
+ const currentTint = useRef<string | undefined>(undefined);
174
186
  const isTab = navigation?.instance?.getState?.()?.type === 'tab';
175
187
 
176
188
  let handleScroll;
@@ -233,6 +245,8 @@ const Screen = forwardRef(
233
245
  {...props}
234
246
  animatedValue={animatedValue.current}
235
247
  useShadowHeader={useShadowHeader}
248
+ headerBackground={headerBackground}
249
+ gradientColor={gradientColor}
236
250
  />
237
251
  ),
238
252
  headerTitle: (props: any) => <HeaderTitle {...props} />,
@@ -266,7 +280,10 @@ const Screen = forwardRef(
266
280
  */
267
281
  const setAnimatedHeader = (animatedHeader: AnimatedHeader) => {
268
282
  let options: StackNavigationOptions;
269
- currentTint.current = animatedHeader?.headerTintColor ?? Colors.black_17;
283
+ if (!currentTint.current) {
284
+ currentTint.current = animatedHeader?.headerTintColor;
285
+ }
286
+
270
287
  options = {
271
288
  headerTintColor: currentTint.current,
272
289
  headerTransparent: true,
@@ -276,6 +293,8 @@ const Screen = forwardRef(
276
293
  animatedValue={animatedValue.current}
277
294
  useGradient={false}
278
295
  useShadowHeader={useShadowHeader}
296
+ headerBackground={headerBackground}
297
+ gradientColor={gradientColor}
279
298
  />
280
299
  ),
281
300
  headerTitle: (props: any) => {
@@ -322,12 +341,12 @@ const Screen = forwardRef(
322
341
  */
323
342
  const setSearchHeader = (params: SearchHeaderProps) => {
324
343
  const options: StackNavigationOptions = {
344
+ headerRight: undefined,
325
345
  headerTitle: (props: any) => (
326
346
  <SearchHeader
327
347
  {...props}
328
348
  {...params}
329
349
  animatedValue={animatedValue.current}
330
- headerRightWidth={headerRightWidth}
331
350
  />
332
351
  ),
333
352
  };
@@ -487,6 +506,8 @@ const Screen = forwardRef(
487
506
  navigation={navigation}
488
507
  inputSearchRef={inputSearchRef}
489
508
  useShadowHeader={useShadowHeader}
509
+ gradientColor={gradientColor}
510
+ headerBackground={headerBackground}
490
511
  />
491
512
 
492
513
  <KeyboardAvoidingView
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.109.1-beta.2",
3
+ "version": "0.109.1-beta.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},