@momo-kits/foundation 0.80.8-beta.10 → 0.80.8-beta.12

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.
@@ -1,11 +1,12 @@
1
- import React, {useContext, useEffect, useMemo, useRef} from 'react';
1
+ import React, {useContext, useEffect, useMemo, useRef, useState} from 'react';
2
2
  import {
3
+ Dimensions,
4
+ Keyboard,
3
5
  KeyboardAvoidingView,
4
6
  Platform,
5
7
  Pressable,
6
8
  StyleSheet,
7
9
  View,
8
- Keyboard,
9
10
  } from 'react-native';
10
11
  import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
11
12
  import {
@@ -90,6 +91,7 @@ const Modal: React.FC<ModalParams> = props => {
90
91
  const BottomSheet: React.FC<BottomSheetParams> = props => {
91
92
  const insets = useSafeAreaInsets();
92
93
  const {theme, navigator} = useContext(ApplicationContext);
94
+ const [keyboardSnap, setKeyboardSnap] = useState(0);
93
95
  const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
94
96
  const Component = useRef(screen).current;
95
97
  const navigation = new Navigation(props.navigation, theme);
@@ -102,28 +104,41 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
102
104
 
103
105
  const snapPoints = useMemo(() => {
104
106
  if (snapPoint) {
105
- return [snapPoint];
107
+ const current = parseInt(snapPoint) + keyboardSnap * 100;
108
+ return [`${current}%`];
106
109
  }
107
110
  return ['50%', '70%', '90%'];
108
- }, []);
111
+ }, [keyboardSnap]);
109
112
 
110
113
  const bottomSheetRef = useRef<any>(null);
111
114
  const mountedRef = useRef(true);
112
115
 
113
116
  let backgroundColor = theme.colors.background.default;
117
+ let bottomInset = keyboardSnap * Dimensions.get('window').height;
118
+ if (bottomInset > 16) {
119
+ bottomInset -= 16;
120
+ }
114
121
  if (options?.surface) {
115
122
  backgroundColor = theme.colors.background.surface;
116
123
  }
117
124
 
118
125
  useEffect(() => {
119
- const keyboardDidShow = Keyboard.addListener('keyboardDidShow', () =>
120
- bottomSheetRef.current?.expand(),
121
- );
126
+ const keyboardDidShow = Keyboard.addListener('keyboardDidShow', e => {
127
+ setKeyboardSnap(
128
+ e.endCoordinates.height / Dimensions.get('window').height,
129
+ );
130
+ bottomSheetRef.current?.expand();
131
+ });
132
+
133
+ const keyboardDidHide = Keyboard.addListener('keyboardDidHide', () => {
134
+ setKeyboardSnap(0);
135
+ });
122
136
 
123
137
  bottomSheetRef.current?.present();
124
138
  return () => {
125
139
  mountedRef.current = false;
126
140
  keyboardDidShow.remove();
141
+ keyboardDidHide.remove();
127
142
  };
128
143
  }, []);
129
144
 
@@ -145,6 +160,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
145
160
  navigator?.pop();
146
161
  }
147
162
  }}
163
+ bottomInset={bottomInset}
148
164
  handleComponent={null}
149
165
  backdropComponent={backdropComponent}>
150
166
  <BottomSheetView accessibilityLabel={'BottomSheet'}>
package/Layout/Card.tsx CHANGED
@@ -150,7 +150,7 @@ const Card: React.FC<CardProps> = ({
150
150
  width: widthSection,
151
151
  marginHorizontal: gridContext.margin,
152
152
  },
153
- Shadow.Light,
153
+ useShadow && Shadow.Light,
154
154
  ]}>
155
155
  {!!backgroundImage && (
156
156
  <Image
package/Layout/styles.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {StyleSheet} from 'react-native';
2
+ import {Spacing} from '../Consts';
2
3
 
3
4
  export default StyleSheet.create({
4
5
  boxGrid: {
@@ -47,7 +48,6 @@ export default StyleSheet.create({
47
48
  marginLeft: undefined,
48
49
  marginRight: undefined,
49
50
  marginVertical: undefined,
50
- overflow: 'hidden',
51
51
  },
52
52
  item: {
53
53
  overflow: 'hidden',
@@ -65,5 +65,6 @@ export default StyleSheet.create({
65
65
  bottom: 0,
66
66
  left: 0,
67
67
  right: 0,
68
+ borderRadius: Spacing.M,
68
69
  },
69
70
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.80.8-beta.10",
3
+ "version": "0.80.8-beta.12",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {