@widergy/mobile-ui 0.41.1 → 0.42.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.
@@ -1,20 +1,27 @@
1
- import React from 'react';
1
+ import React, { Fragment } from 'react';
2
2
  import { View, Animated } from 'react-native';
3
- import _ from 'lodash';
3
+ import merge from 'lodash/merge';
4
4
 
5
5
  import { useTheme } from '../../theming';
6
6
 
7
7
  import propTypes from './propTypes';
8
8
  import ownStyles from './styles';
9
+ import { generateBackgroundGradient } from './utils';
9
10
 
10
- const UTRoundView = ({ children, styles }) => {
11
+ const UTRoundView = ({ children, styles, startColor, endColor }) => {
11
12
  const theme = useTheme();
12
- const themedStyles = _.merge({}, theme?.roundView, styles);
13
+ const themedStyles = merge({}, theme?.roundView, styles);
14
+ const withBackgroundGradient = !!startColor && !!endColor;
13
15
 
14
16
  return (
15
- <Animated.View style={[ownStyles.container, themedStyles?.outerContainer]}>
16
- <View style={[ownStyles.innerContainer, themedStyles?.innerContainer]}>{children}</View>
17
- </Animated.View>
17
+ <Fragment>
18
+ {withBackgroundGradient && (
19
+ <View style={ownStyles.backgroundGradient}>{generateBackgroundGradient(startColor, endColor)}</View>
20
+ )}
21
+ <Animated.View style={[ownStyles.container, themedStyles?.outerContainer, withBackgroundGradient && ownStyles?.outerWithBackground]}>
22
+ <View style={[ownStyles.innerContainer, themedStyles?.innerContainer]}>{children}</View>
23
+ </Animated.View>
24
+ </Fragment>
18
25
  );
19
26
  };
20
27
 
@@ -1,9 +1,11 @@
1
1
  import { ViewPropTypes } from 'deprecated-react-native-prop-types';
2
- import { shape } from 'prop-types';
2
+ import { shape, string } from 'prop-types';
3
3
 
4
4
  export default {
5
5
  styles: shape({
6
6
  outerContainer: ViewPropTypes.style,
7
- innerContainer: ViewPropTypes.style
8
- })
7
+ innerContainer: ViewPropTypes.style,
8
+ }),
9
+ startColor: string,
10
+ endColor: string,
9
11
  };
@@ -3,8 +3,13 @@ import { StyleSheet } from 'react-native';
3
3
  export const ROUND_VIEW_BORDER_RADIUS = 25;
4
4
 
5
5
  const styles = StyleSheet.create({
6
+ backgroundGradient: {
7
+ height: '100%',
8
+ position: 'absolute',
9
+ width: '100%',
10
+ },
6
11
  container: {
7
- flex: 1
12
+ flex: 1,
8
13
  },
9
14
  innerContainer: {
10
15
  height: '100%',
@@ -12,8 +17,11 @@ const styles = StyleSheet.create({
12
17
  backgroundColor: 'white',
13
18
  borderTopLeftRadius: ROUND_VIEW_BORDER_RADIUS,
14
19
  borderTopRightRadius: ROUND_VIEW_BORDER_RADIUS,
15
- paddingTop: ROUND_VIEW_BORDER_RADIUS
16
- }
20
+ paddingTop: ROUND_VIEW_BORDER_RADIUS,
21
+ },
22
+ outerWithBackground: {
23
+ backgroundColor: 'transparent',
24
+ },
17
25
  });
18
26
 
19
27
  export default styles;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import Svg, { Rect, LinearGradient, Defs, Stop } from 'react-native-svg';
3
+
4
+ export const generateBackgroundGradient = (startColor, endColor) => (
5
+ <Svg height="100%" width="100%">
6
+ <Defs>
7
+ <LinearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="0%">
8
+ <Stop offset="0%" stopColor={startColor} stopOpacity="1" />
9
+ <Stop offset="100%" stopColor={endColor} stopOpacity="1" />
10
+ </LinearGradient>
11
+ </Defs>
12
+ <Rect x="0" y="0" width="100%" height="100%" fill="url(#gradient1)" />
13
+ </Svg>
14
+ );
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "0.41.1",
5
+ "version": "0.42.0",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [
@@ -38,7 +38,8 @@
38
38
  "numeral": "^2.0.6",
39
39
  "pdf-lib": "^1.14.1",
40
40
  "react-native-markdown-display": ">=6.1.6",
41
- "react-native-modal": "^11.5.6"
41
+ "react-native-modal": "^11.5.6",
42
+ "react-native-svg": "^12.1.0"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@babel/cli": "^7.4.4",