@momo-kits/foundation 0.77.2-beta.1 → 0.77.2-beta.3

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.
@@ -77,7 +77,7 @@ const styles = StyleSheet.create({
77
77
  },
78
78
  });
79
79
 
80
- const HeaderTitle: React.FC<any> = props => {
80
+ const HeaderTitle: React.FC<any> = ({accessibilityLabel = '', ...props}) => {
81
81
  const {theme} = useContext(ApplicationContext);
82
82
  const opacity = props.animatedValue?.interpolate({
83
83
  inputRange: [0, 200],
@@ -88,7 +88,7 @@ const HeaderTitle: React.FC<any> = props => {
88
88
  return (
89
89
  <Animated.Text
90
90
  {...props}
91
- accessibilityLabel={`HeaderTitle/${props.children}`}
91
+ accessibilityLabel={`HeaderTitle/${accessibilityLabel}${props.children}`}
92
92
  style={[
93
93
  styles.title,
94
94
  {fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
@@ -102,6 +102,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
102
102
  preventBack,
103
103
  useBorder,
104
104
  backgroundColor,
105
+ accessibilityLabel = '',
105
106
  }) => {
106
107
  const {navigator} = useContext(ApplicationContext);
107
108
  const goBack = () => {
@@ -138,7 +139,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
138
139
  icon="ic_back"
139
140
  tintColor={tintColor}
140
141
  onPress={goBack}
141
- accessibilityLabel={'Back'}
142
+ accessibilityLabel={`${accessibilityLabel}Back`}
142
143
  useBorder={useBorder}
143
144
  backgroundColor={backgroundColor}
144
145
  />
@@ -18,7 +18,7 @@ import {
18
18
  NavigationButton,
19
19
  NavigationContainer,
20
20
  } from './index';
21
- import {HeaderBackground, HeaderLeft} from './Components';
21
+ import {HeaderBackground, HeaderLeft, HeaderTitle} from './Components';
22
22
 
23
23
  const ModalScreen: React.FC<any> = props => {
24
24
  useEffect(() => {
@@ -160,10 +160,19 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
160
160
  {...props}
161
161
  useBorder={false}
162
162
  backgroundColor="transparent"
163
+ accessibilityLabel={'BottomSheet/'}
163
164
  />
164
165
  );
165
166
  }
166
167
  },
168
+ headerTitle: (props: any) => {
169
+ return (
170
+ <HeaderTitle
171
+ {...props}
172
+ accessibilityLabel={'BottomSheet/'}
173
+ />
174
+ );
175
+ },
167
176
  headerBackground: () => (
168
177
  <HeaderBackground backgroundColor={backgroundColor} />
169
178
  ),
@@ -178,6 +187,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
178
187
  backgroundColor="transparent"
179
188
  useBorder={false}
180
189
  onPress={bottomSheetRef.current?.dismiss}
190
+ accessibilityLabel={'BottomSheet/Close'}
181
191
  />
182
192
  </HeaderRightAction>
183
193
  ),
@@ -1,4 +1,4 @@
1
- import React, {useRef} from 'react';
1
+ import React, {useEffect, useRef, useState} from 'react';
2
2
  import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
3
3
  import {SafeAreaProvider} from 'react-native-safe-area-context';
4
4
  import {
@@ -10,10 +10,9 @@ import StackScreen from './StackScreen';
10
10
  import ModalScreen from './ModalScreen';
11
11
  import Navigator from './Navigator';
12
12
  import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
13
- import {GridSystem} from '../Layout';
14
- import {GRIDVIEW} from '../Consts';
15
13
  import {NavigationContainerProps} from './types';
16
14
  import {ApplicationContext} from './index';
15
+ import {DeviceEventEmitter} from 'react-native';
17
16
 
18
17
  const Stack = createStackNavigator();
19
18
 
@@ -25,13 +24,27 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
25
24
  }) => {
26
25
  const navigationRef = React.useRef<NavigationContainerRef>(null);
27
26
  const navigator = useRef(new Navigator(navigationRef));
27
+ const [showGrid, setShowGrid] = useState(false);
28
+
29
+ useEffect(() => {
30
+ const subscription = DeviceEventEmitter.addListener(
31
+ 'onChangeGrid',
32
+ enable => {
33
+ setShowGrid(!!enable);
34
+ },
35
+ );
36
+ return () => {
37
+ subscription.remove();
38
+ };
39
+ }, []);
40
+
28
41
  navigator.current.maxApi = maxApi;
29
42
 
30
43
  return (
31
44
  <SafeAreaProvider>
32
45
  <BottomSheetModalProvider>
33
46
  <ApplicationContext.Provider
34
- value={{theme, navigator: navigator.current}}>
47
+ value={{theme, navigator: navigator.current, showGrid}}>
35
48
  <ReactNavigationContainer
36
49
  theme={{
37
50
  ...theme,
@@ -69,7 +82,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
69
82
  </ReactNavigationContainer>
70
83
  </ApplicationContext.Provider>
71
84
  </BottomSheetModalProvider>
72
- {GRIDVIEW && <GridSystem />}
73
85
  </SafeAreaProvider>
74
86
  );
75
87
  };
@@ -2,10 +2,11 @@ import React, {useContext, useEffect} from 'react';
2
2
  import {ScreenParams} from './types';
3
3
  import Navigation from './Navigation';
4
4
  import {ApplicationContext} from './index';
5
+ import {GridSystem} from '../Layout';
5
6
 
6
7
  const StackScreen: React.FC<ScreenParams> = props => {
7
8
  const {screen: Component, options}: ScreenParams = props.route.params;
8
- const {theme, navigator} = useContext(ApplicationContext);
9
+ const {theme, showGrid, navigator} = useContext(ApplicationContext);
9
10
  const navigation = new Navigation(props.navigation, theme);
10
11
 
11
12
  const params = {
@@ -21,7 +22,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
21
22
  }
22
23
  }, [options]);
23
24
 
24
- return <Component {...params} />;
25
+ return (
26
+ <>
27
+ <Component {...params} />
28
+ {showGrid && <GridSystem />}
29
+ </>
30
+ );
25
31
  };
26
32
 
27
33
  export default StackScreen;
@@ -64,6 +64,7 @@ export type Theme = {
64
64
  export type Context = {
65
65
  theme: Theme;
66
66
  navigator?: Navigator;
67
+ showGrid?: boolean;
67
68
  };
68
69
 
69
70
  export type NavigationContainerProps = {
@@ -131,6 +132,7 @@ export type NavigationOptions = {
131
132
 
132
133
  export interface HeaderBackProps extends NavigationButtonProps {
133
134
  preventBack?: PopupNotifyProps;
135
+ accessibilityLabel?: string;
134
136
  }
135
137
 
136
138
  export type HeaderBackgroundProps = {
package/Consts/theme.ts CHANGED
@@ -116,6 +116,7 @@ const defaultDarkTheme: Theme = {
116
116
  const defaultContext: Context = {
117
117
  theme: defaultTheme,
118
118
  navigator: undefined,
119
+ showGrid: false,
119
120
  };
120
121
 
121
122
  export {defaultContext, defaultTheme, defaultDarkTheme};
package/Input/Input.tsx CHANGED
@@ -124,7 +124,7 @@ const Input: FC<InputProps> = ({
124
124
  };
125
125
 
126
126
  return (
127
- <View style={styles.wrapper} accessibilityLabel={`Input`}>
127
+ <View style={styles.wrapper} accessibilityLabel={`Input/${floatingValue}`}>
128
128
  {renderInputView()}
129
129
  <ErrorView errorMessage={errorMessage} />
130
130
  </View>
@@ -123,7 +123,9 @@ const InputMoney: FC<InputMoneyProps> = ({
123
123
  };
124
124
 
125
125
  return (
126
- <View style={styles.wrapper} accessibilityLabel={`InputMoney`}>
126
+ <View
127
+ style={styles.wrapper}
128
+ accessibilityLabel={`InputMoney/${floatingValue}`}>
127
129
  {renderInputView()}
128
130
  <ErrorView errorMessage={errorMessage} />
129
131
  </View>
@@ -132,7 +132,7 @@ const InputSearch: FC<InputSearchProps> = ({
132
132
  return (
133
133
  <View
134
134
  style={[style, styles.searchInputContainer]}
135
- accessibilityLabel={`InputSearch`}>
135
+ accessibilityLabel={`InputSearch/${placeholder}`}>
136
136
  <View
137
137
  style={[
138
138
  getBorderColor(),
@@ -139,7 +139,9 @@ const InputTextArea: FC<InputTextAreaProps> = ({
139
139
  };
140
140
 
141
141
  return (
142
- <View style={styles.wrapper} accessibilityLabel={`InputTextArea`}>
142
+ <View
143
+ style={styles.wrapper}
144
+ accessibilityLabel={`InputTextArea/${floatingValue}`}>
143
145
  {renderInputView()}
144
146
  <ErrorView errorMessage={errorMessage} />
145
147
  </View>
package/Layout/Card.tsx CHANGED
@@ -1,12 +1,13 @@
1
- import React from 'react';
1
+ import React, {useContext} from 'react';
2
2
  import {Dimensions, View} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
4
  import {CardProps, GridContextProps} from './types';
5
5
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
7
6
  import Item from './Item';
7
+ import {ApplicationContext} from '../Application';
8
8
 
9
9
  const Card: React.FC<CardProps> = ({children, style}) => {
10
+ const {showGrid} = useContext(ApplicationContext);
10
11
  const {numberOfColumns} = useGridSystem();
11
12
 
12
13
  const gutterSize = 8;
@@ -131,7 +132,7 @@ const Card: React.FC<CardProps> = ({children, style}) => {
131
132
  },
132
133
  ]}>
133
134
  {renderView(validateChildren(children, [Item]))}
134
- {GRIDVIEW && renderOverlay()}
135
+ {showGrid && renderOverlay()}
135
136
  </View>
136
137
  </GridContext.Provider>
137
138
  );
@@ -42,6 +42,7 @@ const GridSystem: React.FC = () => {
42
42
  {
43
43
  borderColor: theme.colors.error.primary,
44
44
  marginHorizontal: grid.margin,
45
+ top: Spacing.M,
45
46
  },
46
47
  ]}>
47
48
  {list.map((i, index) => {
@@ -66,7 +67,7 @@ const GridSystem: React.FC = () => {
66
67
  <View pointerEvents="none" style={styles.dangerRightContainer} />
67
68
  <View
68
69
  pointerEvents="none"
69
- style={[styles.dangerTopContainer, {height: insets.top}]}
70
+ style={[styles.dangerTopContainer, {height: Spacing.M}]}
70
71
  />
71
72
  <View
72
73
  pointerEvents="none"
package/Layout/Item.tsx CHANGED
@@ -3,7 +3,7 @@ import {View} from 'react-native';
3
3
 
4
4
  import {ItemProps} from './types';
5
5
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
6
+ import {ApplicationContext} from '../Application';
7
7
 
8
8
  const Item: React.FC<ItemProps> = ({
9
9
  widthSpan,
@@ -11,6 +11,7 @@ const Item: React.FC<ItemProps> = ({
11
11
  children,
12
12
  style,
13
13
  }) => {
14
+ const {showGrid} = useContext(ApplicationContext);
14
15
  const grid = useContext(GridContext);
15
16
 
16
17
  /**
@@ -50,7 +51,7 @@ const Item: React.FC<ItemProps> = ({
50
51
  },
51
52
  ]}>
52
53
  {children}
53
- {GRIDVIEW && renderOverlay()}
54
+ {showGrid && renderOverlay()}
54
55
  </View>
55
56
  );
56
57
  };
@@ -1,16 +1,17 @@
1
- import React from 'react';
1
+ import React, {useContext} from 'react';
2
2
  import {Dimensions, View} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
4
  import {GridContextProps, SectionProps} from './types';
5
5
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
7
6
  import Item from './Item';
7
+ import {ApplicationContext} from '../Application';
8
8
 
9
9
  const Section: React.FC<SectionProps> = ({
10
10
  children,
11
11
  useMargin = true,
12
12
  backgroundColor,
13
13
  }) => {
14
+ const {showGrid} = useContext(ApplicationContext);
14
15
  const {numberOfColumns} = useGridSystem();
15
16
 
16
17
  const gutterSize = 12;
@@ -136,7 +137,7 @@ const Section: React.FC<SectionProps> = ({
136
137
  backgroundColor: backgroundColor,
137
138
  }}>
138
139
  {renderView(validateChildren(children, [Item]))}
139
- {GRIDVIEW && renderOverlay()}
140
+ {showGrid && renderOverlay()}
140
141
  </View>
141
142
  </GridContext.Provider>
142
143
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.77.2-beta.01",
3
+ "version": "0.77.2-beta.03",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {