@momo-kits/foundation 0.81.1-optimize.18 → 0.81.1-optimize.19

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.
@@ -28,6 +28,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
28
28
  barrierDismissible = false,
29
29
  draggable = true,
30
30
  useBottomInset = true,
31
+ keyboardVerticalOffset,
31
32
  }: BottomSheetParams = props.route.params;
32
33
  const pan = useRef(
33
34
  new Animated.ValueXY({
@@ -83,7 +84,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
83
84
  /**
84
85
  * handler dismiss
85
86
  */
86
- const onDismiss = (force = false) => {
87
+ const onDismiss = (force = false, callback?: () => void) => {
87
88
  if (barrierDismissible && !force) {
88
89
  return;
89
90
  }
@@ -93,9 +94,20 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
93
94
  duration: 100,
94
95
  }).start(() => {
95
96
  navigator?.pop();
97
+ callback?.();
96
98
  });
97
99
  };
98
100
 
101
+ /**
102
+ * manual close
103
+ */
104
+ const requestClose = useCallback((callback?: () => void) => {
105
+ onDismiss(true, callback);
106
+ }, []);
107
+
108
+ /**
109
+ * render header
110
+ */
99
111
  const renderHeader = useCallback(() => {
100
112
  return (
101
113
  <View
@@ -137,7 +149,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
137
149
  <Modal transparent visible={true} onRequestClose={() => onDismiss()}>
138
150
  <KeyboardAvoidingView
139
151
  behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
140
- keyboardVerticalOffset={-20}
152
+ keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
141
153
  style={[Styles.flex, {justifyContent: 'flex-end'}]}>
142
154
  <TouchableOpacity
143
155
  style={Styles.flex}
@@ -147,7 +159,11 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
147
159
  <Animated.View style={{transform: pan.getTranslateTransform()}}>
148
160
  {renderHeader()}
149
161
  <View style={{backgroundColor: backgroundColor}}>
150
- <Screen {...props} {...props.route.params} />
162
+ <Screen
163
+ {...props}
164
+ {...props.route.params}
165
+ requestClose={requestClose}
166
+ />
151
167
  {useBottomInset && (
152
168
  <View style={{height: Math.min(insets.bottom, 21)}} />
153
169
  )}
@@ -157,6 +173,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
157
173
  </Modal>
158
174
  );
159
175
  };
176
+
160
177
  export default BottomSheet;
161
178
 
162
179
  const styles = StyleSheet.create({
@@ -50,10 +50,11 @@ const StackScreen: React.FC<ScreenParams> = props => {
50
50
  * tracking for screen
51
51
  */
52
52
  useEffect(() => {
53
- Alert.alert(screenName);
53
+ if (__DEV__ && (!screenName || screenName == 'Invalid')) {
54
+ Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
55
+ }
54
56
 
55
57
  navigator?.maxApi?.of?.({screenName});
56
-
57
58
  tracked.current.timeoutLoad = setTimeout(() => {
58
59
  onScreenLoad();
59
60
  }, 5000);
@@ -119,6 +119,7 @@ export type BottomSheetParams = {
119
119
  barrierDismissible?: boolean;
120
120
  draggable?: boolean;
121
121
  useBottomInset?: boolean;
122
+ keyboardVerticalOffset?: number;
122
123
  };
123
124
 
124
125
  export type NavigationButtonProps = {
package/Layout/Screen.tsx CHANGED
@@ -33,6 +33,9 @@ import styles from './styles';
33
33
  import {HeaderType} from './types';
34
34
 
35
35
  export interface ScreenProps extends ViewProps {
36
+ /**
37
+ * ReactNode representing the content of the screen.
38
+ */
36
39
  children: React.ReactNode;
37
40
  /**
38
41
  * Optional. Navigation object for handling navigation actions.
@@ -90,9 +93,10 @@ export interface ScreenProps extends ViewProps {
90
93
  floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
91
94
 
92
95
  /**
93
- * optional animated value
96
+ * Optional. Keyboard vertical offset.
94
97
  */
95
- animatedValue?: Animated.Value;
98
+ keyboardVerticalOffset?: number;
99
+
96
100
  /**
97
101
  * Optional. If `true`, the screen content is using grid layout by span.
98
102
  */
@@ -115,13 +119,11 @@ const Screen = forwardRef(
115
119
  headerType = 'default',
116
120
  floatingButtonProps,
117
121
  useGridLayout = true,
118
- animatedValue: animated,
122
+ keyboardVerticalOffset,
119
123
  }: ScreenProps,
120
124
  ref,
121
125
  ) => {
122
- const animatedValue = useRef<Animated.Value>(
123
- animated ?? new Animated.Value(0),
124
- );
126
+ const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
125
127
  const {theme} = useContext(ApplicationContext);
126
128
  const insets = useSafeAreaInsets();
127
129
  const heightHeader = useHeaderHeight();
@@ -132,10 +134,9 @@ const Screen = forwardRef(
132
134
  let handleScroll;
133
135
  let headerBackground: string | undefined = undefined;
134
136
  let Component: any = View;
135
- let keyboardVerticalOffset = heightHeader - 20;
136
-
137
+ let keyboardOffset = heightHeader - 20;
137
138
  if (headerType == 'extended' || animatedHeader) {
138
- keyboardVerticalOffset = -20;
139
+ keyboardOffset = -20;
139
140
  }
140
141
 
141
142
  if (headerType == 'extended') {
@@ -339,7 +340,7 @@ const Screen = forwardRef(
339
340
  <KeyboardAvoidingView
340
341
  style={Styles.flex}
341
342
  enabled={enableKeyboardAvoidingView}
342
- keyboardVerticalOffset={keyboardVerticalOffset}
343
+ keyboardVerticalOffset={keyboardVerticalOffset ?? keyboardOffset}
343
344
  behavior={Platform.select({
344
345
  ios: 'padding',
345
346
  android: undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.1-optimize.18",
3
+ "version": "0.81.1-optimize.19",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},