@widergy/mobile-ui 0.34.3 → 0.35.0
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.
- package/CHANGELOG.md +20 -0
- package/lib/components/Button/index.js +1 -1
- package/lib/components/UTModal/constants.js +1 -0
- package/lib/components/UTModal/index.js +146 -0
- package/lib/components/UTModal/proptypes.js +35 -0
- package/lib/components/UTModal/styles.js +79 -0
- package/lib/index.js +1 -0
- package/lib/theming/DefaultTheme.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [0.35.0](https://github.com/widergy/mobile-ui/compare/v0.34.3...v0.35.0) (2022-06-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added opacity when disabled button ([6d75fdb](https://github.com/widergy/mobile-ui/commit/6d75fdb3023308ffaa6cbd5c70d88deb338440b6))
|
|
7
|
+
* adjusted loading in modal ([4b175e4](https://github.com/widergy/mobile-ui/commit/4b175e4b8f220444db5abebcee7b2a69c61f8eae))
|
|
8
|
+
* avoid falsy condition in buttons and adjusted its style ([1d83ab4](https://github.com/widergy/mobile-ui/commit/1d83ab4096418c678da0988b41ef2a1c691c5759))
|
|
9
|
+
* avoid falsy condition in title ([8a364dd](https://github.com/widergy/mobile-ui/commit/8a364dd3b61131ae64dca26153e79477658ded49))
|
|
10
|
+
* backgroundImg prop ([ea7d415](https://github.com/widergy/mobile-ui/commit/ea7d415a14a7960252fa1ef20a73e38a5b367e69))
|
|
11
|
+
* delete outsideContent prop ([5c2bbbc](https://github.com/widergy/mobile-ui/commit/5c2bbbc10057ad0ee3a4acc4c7c7acce92b70656))
|
|
12
|
+
* deleted withTheme hook and left useTheme hoc ([775ca6b](https://github.com/widergy/mobile-ui/commit/775ca6bd7ddb142be721b73868ca44776b87f306))
|
|
13
|
+
* separted img and backgound img styles ([e347885](https://github.com/widergy/mobile-ui/commit/e347885847883b5912624e1add844a630ab30c5b))
|
|
14
|
+
* UTModal and Modal components in mobile ui ([23dc89b](https://github.com/widergy/mobile-ui/commit/23dc89b26bd3776cb78206474b95ce7c01bbdb0b))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* add UTModal component ([8303a57](https://github.com/widergy/mobile-ui/commit/8303a5732600f21f600ebecbbe37dfcc321eab90))
|
|
20
|
+
|
|
1
21
|
## [0.34.3](https://github.com/widergy/mobile-ui/compare/v0.34.2...v0.34.3) (2022-05-19)
|
|
2
22
|
|
|
3
23
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CLOSE_ICON = 'close';
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, TouchableWithoutFeedback, Keyboard, Modal, ImageBackground } from 'react-native';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
|
|
5
|
+
import Label from '../Label';
|
|
6
|
+
import Button from '../Button';
|
|
7
|
+
import Touchable from '../Touchable';
|
|
8
|
+
import Icon from '../Icon';
|
|
9
|
+
import { useTheme } from '../../theming';
|
|
10
|
+
import UTLoading from '../UTLoading';
|
|
11
|
+
|
|
12
|
+
import ModalTypes from './proptypes';
|
|
13
|
+
import ownStyles from './styles';
|
|
14
|
+
import { CLOSE_ICON } from './constants';
|
|
15
|
+
|
|
16
|
+
const UTModal = ({
|
|
17
|
+
children,
|
|
18
|
+
onRequestClose,
|
|
19
|
+
acceptButton,
|
|
20
|
+
cancelButton,
|
|
21
|
+
visible,
|
|
22
|
+
title,
|
|
23
|
+
loading,
|
|
24
|
+
backgroundStyles,
|
|
25
|
+
imageStyles,
|
|
26
|
+
disableTouchable,
|
|
27
|
+
loadingText,
|
|
28
|
+
modalBackgroundColor,
|
|
29
|
+
color,
|
|
30
|
+
imageComponent,
|
|
31
|
+
labelProps,
|
|
32
|
+
modalStyles,
|
|
33
|
+
backgroundImg
|
|
34
|
+
}) => {
|
|
35
|
+
const theme = useTheme();
|
|
36
|
+
const themeStyles = theme.simpleButton;
|
|
37
|
+
const styles = _.merge({}, ownStyles, themeStyles);
|
|
38
|
+
|
|
39
|
+
const ParentView = disableTouchable ? View : TouchableWithoutFeedback;
|
|
40
|
+
return (
|
|
41
|
+
<Modal
|
|
42
|
+
animationType="fade"
|
|
43
|
+
transparent
|
|
44
|
+
visible={visible}
|
|
45
|
+
onRequestClose={loading ? () => {} : onRequestClose}
|
|
46
|
+
>
|
|
47
|
+
<ParentView onPress={() => Keyboard.dismiss()} style={[disableTouchable && styles.viewContainer]}>
|
|
48
|
+
<View style={styles.childView} forceInset={{ top: 'never' }}>
|
|
49
|
+
<View
|
|
50
|
+
style={[
|
|
51
|
+
styles.modalBackground,
|
|
52
|
+
modalBackgroundColor && { backgroundColor: modalBackgroundColor }
|
|
53
|
+
]}
|
|
54
|
+
>
|
|
55
|
+
<UTLoading
|
|
56
|
+
loading={loading}
|
|
57
|
+
style={[styles.innerContainer, styles.content, styles.loading]}
|
|
58
|
+
message={loadingText}
|
|
59
|
+
>
|
|
60
|
+
<View style={[styles.innerContainer, modalStyles?.innerContainer]}>
|
|
61
|
+
{!!backgroundImg && (
|
|
62
|
+
<ImageBackground source={backgroundImg} resizeMode="stretch" style={backgroundStyles} />
|
|
63
|
+
)}
|
|
64
|
+
{!!imageComponent && (
|
|
65
|
+
<View style={[styles.content, imageStyles]}>
|
|
66
|
+
<Touchable
|
|
67
|
+
borderless
|
|
68
|
+
style={styles.closeIcon}
|
|
69
|
+
onPress={onRequestClose || cancelButton.onPress}
|
|
70
|
+
>
|
|
71
|
+
<Icon name={CLOSE_ICON} color={color || 'black'} style={styles.iconSpacing} />
|
|
72
|
+
</Touchable>
|
|
73
|
+
<View style={styles.imageContainer}>{imageComponent}</View>
|
|
74
|
+
</View>
|
|
75
|
+
)}
|
|
76
|
+
<View style={styles.content}>
|
|
77
|
+
{!backgroundImg && !imageComponent && (
|
|
78
|
+
<Touchable borderless style={styles.closeIcon} onPress={onRequestClose}>
|
|
79
|
+
<Icon name={CLOSE_ICON} color={color || 'black'} style={styles.iconSpacing} />
|
|
80
|
+
</Touchable>
|
|
81
|
+
)}
|
|
82
|
+
|
|
83
|
+
{!!title && (
|
|
84
|
+
<Label bold center style={styles.title}>
|
|
85
|
+
{title}
|
|
86
|
+
</Label>
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
{children}
|
|
90
|
+
</View>
|
|
91
|
+
<View style={styles.buttonsContainer}>
|
|
92
|
+
{!!cancelButton && (
|
|
93
|
+
<Button
|
|
94
|
+
borderless
|
|
95
|
+
lowerCase
|
|
96
|
+
mode="text"
|
|
97
|
+
elevation={0}
|
|
98
|
+
containerStyle={[
|
|
99
|
+
styles.containerStyle,
|
|
100
|
+
{ backgroundColor: cancelButton.backgroundColor }
|
|
101
|
+
]}
|
|
102
|
+
title={cancelButton.text || 'Cancelar'}
|
|
103
|
+
onPress={cancelButton.onPress}
|
|
104
|
+
disabled={cancelButton.disabled || loading}
|
|
105
|
+
labelColor={cancelButton.textColor || theme.button.defaultButtonColor}
|
|
106
|
+
titleStyle={styles.buttonText}
|
|
107
|
+
/>
|
|
108
|
+
)}
|
|
109
|
+
{!!acceptButton && (
|
|
110
|
+
<Button
|
|
111
|
+
borderless
|
|
112
|
+
lowerCase
|
|
113
|
+
mode="text"
|
|
114
|
+
elevation={0}
|
|
115
|
+
outerContainerStyles={styles.outerContainerStyles}
|
|
116
|
+
containerStyle={[
|
|
117
|
+
styles.containerStyle,
|
|
118
|
+
{ backgroundColor: acceptButton.backgroundColor ?? theme.button.defaultButtonColor },
|
|
119
|
+
// eslint-disable-next-line react-native/no-inline-styles
|
|
120
|
+
acceptButton.disabled && { opacity: 0.5 }
|
|
121
|
+
]}
|
|
122
|
+
title={acceptButton.text || 'Aceptar'}
|
|
123
|
+
onPress={acceptButton.onPress}
|
|
124
|
+
disabled={acceptButton.disabled || loading}
|
|
125
|
+
labelColor={acceptButton.textColor || theme.colors.buttonLabelColor}
|
|
126
|
+
titleStyle={styles.buttonText}
|
|
127
|
+
labelProps={labelProps}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
</View>
|
|
131
|
+
</View>
|
|
132
|
+
</UTLoading>
|
|
133
|
+
</View>
|
|
134
|
+
</View>
|
|
135
|
+
</ParentView>
|
|
136
|
+
</Modal>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
UTModal.defaultProps = {
|
|
141
|
+
onRequestClose: () => {}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
UTModal.propTypes = ModalTypes;
|
|
145
|
+
|
|
146
|
+
export default UTModal;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { string, func, shape, number, bool, element } from 'prop-types';
|
|
2
|
+
import { ViewPropTypes } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { themeType } from '../../theming';
|
|
5
|
+
import { IS_ANDROID } from '../../utils/platformUtils/constants';
|
|
6
|
+
|
|
7
|
+
const buttonPropType = shape({
|
|
8
|
+
backgroundColor: string,
|
|
9
|
+
text: string,
|
|
10
|
+
onPress: func,
|
|
11
|
+
disabled: bool,
|
|
12
|
+
loadingText: string,
|
|
13
|
+
textColor: string
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
onRequestClose: IS_ANDROID ? func.isRequired : func,
|
|
18
|
+
cancelButton: buttonPropType,
|
|
19
|
+
acceptButton: buttonPropType,
|
|
20
|
+
visible: bool.isRequired,
|
|
21
|
+
loading: bool,
|
|
22
|
+
title: string,
|
|
23
|
+
disableTouchable: bool,
|
|
24
|
+
modalBackgroundColor: string,
|
|
25
|
+
onKeyboardDismiss: func,
|
|
26
|
+
loadingText: string,
|
|
27
|
+
fill: string,
|
|
28
|
+
imageStyles: ViewPropTypes.style,
|
|
29
|
+
backgroundStyles: ViewPropTypes.style,
|
|
30
|
+
modalStyles: ViewPropTypes.style,
|
|
31
|
+
image: element,
|
|
32
|
+
backgroundImg: number,
|
|
33
|
+
labelProps: shape(bool),
|
|
34
|
+
theme: themeType
|
|
35
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { verticalScale, moderateHorizontalScale, WINDOW_WIDTH, WINDOW_HEIGHT } from '../../utils/scaleUtils';
|
|
4
|
+
import { DEFAULT_ICON_SIZE } from '../Icon/constants';
|
|
5
|
+
import { ICON_MARGIN } from '../IconButton/styles';
|
|
6
|
+
|
|
7
|
+
export default StyleSheet.create({
|
|
8
|
+
container: {
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
marginVertical: verticalScale(4),
|
|
12
|
+
width: '95%'
|
|
13
|
+
},
|
|
14
|
+
modalBackground: {
|
|
15
|
+
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
16
|
+
flex: 1,
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
padding: 15
|
|
19
|
+
},
|
|
20
|
+
childView: {
|
|
21
|
+
flex: 1
|
|
22
|
+
},
|
|
23
|
+
innerContainer: {
|
|
24
|
+
backgroundColor: 'white',
|
|
25
|
+
borderRadius: 15,
|
|
26
|
+
alignItems: 'stretch',
|
|
27
|
+
alignSelf: 'center',
|
|
28
|
+
width: WINDOW_WIDTH * 0.78
|
|
29
|
+
},
|
|
30
|
+
buttonsContainer: {
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
justifyContent: 'flex-end',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
paddingVertical: 20,
|
|
35
|
+
paddingHorizontal: 15
|
|
36
|
+
},
|
|
37
|
+
viewContainer: {
|
|
38
|
+
flex: 1
|
|
39
|
+
},
|
|
40
|
+
loading: {
|
|
41
|
+
height: WINDOW_HEIGHT * 0.3,
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
alignItems: 'center'
|
|
44
|
+
},
|
|
45
|
+
title: {
|
|
46
|
+
marginBottom: 16
|
|
47
|
+
},
|
|
48
|
+
buttonText: {
|
|
49
|
+
fontWeight: 'normal',
|
|
50
|
+
padding: 0,
|
|
51
|
+
margin: 0
|
|
52
|
+
},
|
|
53
|
+
content: {
|
|
54
|
+
padding: 15
|
|
55
|
+
},
|
|
56
|
+
closeIcon: {
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
borderRadius: (DEFAULT_ICON_SIZE + ICON_MARGIN) / 2,
|
|
60
|
+
height: DEFAULT_ICON_SIZE + ICON_MARGIN,
|
|
61
|
+
width: DEFAULT_ICON_SIZE + ICON_MARGIN,
|
|
62
|
+
alignSelf: 'flex-end'
|
|
63
|
+
},
|
|
64
|
+
imageContainer: {
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
justifyContent: 'center',
|
|
67
|
+
marginBottom: verticalScale(25),
|
|
68
|
+
height: verticalScale(35)
|
|
69
|
+
},
|
|
70
|
+
iconSpacing: {
|
|
71
|
+
marginRight: moderateHorizontalScale(10)
|
|
72
|
+
},
|
|
73
|
+
containerStyle: {
|
|
74
|
+
borderRadius: 25,
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
marginHorizontal: moderateHorizontalScale(5)
|
|
77
|
+
},
|
|
78
|
+
disabledContainer: { opacity: 0.5 }
|
|
79
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { default as ActionButton } from './components/ActionButton';
|
|
|
7
7
|
export { default as UTSwitch } from './components/UTSwitch';
|
|
8
8
|
// Feedback
|
|
9
9
|
export { default as Modal } from './components/Modal';
|
|
10
|
+
export { default as UTModal } from './components/UTModal';
|
|
10
11
|
export { default as Snackbar } from './components/Snackbar';
|
|
11
12
|
// Forms
|
|
12
13
|
export { default as Checkbox } from './components/Checkbox';
|
package/package.json
CHANGED