@momo-kits/foundation 0.79.5 → 0.79.6-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.
@@ -1,11 +1,4 @@
1
- import React, {
2
- useCallback,
3
- useContext,
4
- useEffect,
5
- useMemo,
6
- useRef,
7
- useState,
8
- } from 'react';
1
+ import React, {useContext, useEffect, useMemo, useRef} from 'react';
9
2
  import {
10
3
  KeyboardAvoidingView,
11
4
  Platform,
@@ -14,7 +7,11 @@ import {
14
7
  View,
15
8
  } from 'react-native';
16
9
  import {SafeAreaView} from 'react-native-safe-area-context';
17
- import {BottomSheetBackdrop, BottomSheetModal} from '@gorhom/bottom-sheet';
10
+ import {
11
+ BottomSheetBackdrop,
12
+ BottomSheetModal,
13
+ BottomSheetView,
14
+ } from '@gorhom/bottom-sheet';
18
15
  import Navigation from './Navigation';
19
16
  import {BottomSheetParams, ModalParams} from './types';
20
17
  import {Radius, Spacing, Styles} from '../Consts';
@@ -91,11 +88,7 @@ const Modal: React.FC<ModalParams> = props => {
91
88
 
92
89
  const BottomSheet: React.FC<BottomSheetParams> = props => {
93
90
  const {theme, navigator} = useContext(ApplicationContext);
94
- const {
95
- screen,
96
- options,
97
- useSnap = true,
98
- }: BottomSheetParams = props.route.params;
91
+ const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
99
92
  const Component = useRef(screen).current;
100
93
  const navigation = new Navigation(props.navigation, theme);
101
94
  const params = {
@@ -105,31 +98,16 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
105
98
 
106
99
  delete params.screen;
107
100
 
108
- const [contentHeight, setContentHeight] = useState(undefined);
109
101
  const snapPoints = useMemo(() => {
110
- if (useSnap) {
111
- return ['50%', '90%'];
102
+ if (snapPoint) {
103
+ return [snapPoint];
112
104
  }
113
- return [contentHeight ?? '50%'];
114
- }, [contentHeight]);
105
+ return ['50%', '90%'];
106
+ }, []);
115
107
 
116
108
  const bottomSheetRef = useRef<any>(null);
117
109
  const mountedRef = useRef(true);
118
110
 
119
- let handleOnLayout;
120
- if (!useSnap) {
121
- handleOnLayout = useCallback(
122
- ({
123
- nativeEvent: {
124
- layout: {height},
125
- },
126
- }) => {
127
- setContentHeight(height);
128
- },
129
- [],
130
- );
131
- }
132
-
133
111
  let backgroundColor = theme.colors.background.default;
134
112
  if (options?.surface) {
135
113
  backgroundColor = theme.colors.background.surface;
@@ -162,7 +140,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
162
140
  }}
163
141
  handleComponent={null}
164
142
  backdropComponent={backdropComponent}>
165
- <View onLayout={handleOnLayout} accessibilityLabel={'BottomSheet'}>
143
+ <BottomSheetView accessibilityLabel={'BottomSheet'}>
166
144
  <View style={[styles.sheetContainer, {backgroundColor}]}>
167
145
  <View style={styles.indicatorContainer}>
168
146
  <View
@@ -222,7 +200,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
222
200
  }}
223
201
  />
224
202
  </View>
225
- </View>
203
+ </BottomSheetView>
226
204
  </BottomSheetModal>
227
205
  </SafeAreaView>
228
206
  );
@@ -107,7 +107,7 @@ export interface ModalParams extends ScreenParams {
107
107
  export interface BottomSheetParams extends ScreenParams {
108
108
  [key: string]: any;
109
109
  onDismiss?: () => void;
110
- useSnap?: boolean;
110
+ snapPoint?: '30%' | '50%' | '70%' | '90%';
111
111
  }
112
112
 
113
113
  export type NavigationButtonProps = {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.79.5",
3
+ "version": "0.79.6-beta.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "postinstall": "node verify.js"
8
8
  },
9
9
  "keywords": [
10
10
  "@momo-kits/foundation"
@@ -42,4 +42,4 @@
42
42
  },
43
43
  "author": "@momo-kits/foundation",
44
44
  "license": "ISC"
45
- }
45
+ }
package/verify.js ADDED
@@ -0,0 +1,12 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ console.log(`App Info`);
5
+ const main = async () => {
6
+ const appJson = path.join(__dirname, 'app.json');
7
+ const app = JSON.parse(fs.readFileSync(appJson, 'utf8'));
8
+
9
+ console.log(`App Info: ${app}`);
10
+ };
11
+
12
+ main().catch(console.error);