@widergy/mobile-ui 0.40.1 → 1.1.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +921 -0
  2. package/lib/components/Button/index.js +10 -6
  3. package/lib/components/Button/styles.js +5 -5
  4. package/lib/components/Capture/index.js +3 -3
  5. package/lib/components/Carousel/components/CarouselComponent/index.js +2 -0
  6. package/lib/components/Carousel/components/CarouselContainer/index.js +2 -10
  7. package/lib/components/CheckList/components/CheckBoxRenderer/index.js +1 -0
  8. package/lib/components/CheckList/index.js +5 -3
  9. package/lib/components/CheckList/proptypes.js +2 -2
  10. package/lib/components/Checkbox/styles.js +3 -3
  11. package/lib/components/Dropdown/index.js +12 -10
  12. package/lib/components/FilePicker/utils.js +2 -2
  13. package/lib/components/Icon/constants.js +1 -0
  14. package/lib/components/Icon/index.js +11 -1
  15. package/lib/components/ImageIcon/index.js +8 -1
  16. package/lib/components/ImageRadio/index.js +21 -12
  17. package/lib/components/Loading/index.js +1 -0
  18. package/lib/components/Overlay/index.js +2 -10
  19. package/lib/components/PhotoAlbum/index.js +8 -9
  20. package/lib/components/Picker/index.js +2 -2
  21. package/lib/components/Portal/components/Manager/index.js +7 -4
  22. package/lib/components/RadioGroup/components/RadioButton/index.js +5 -5
  23. package/lib/components/RateChart/components/RateStagesGraph/components/Indicator/index.js +3 -3
  24. package/lib/components/RateChart/components/RateStagesGraph/components/Indicator/utils.js +1 -1
  25. package/lib/components/TransformView/constants.js +1 -1
  26. package/lib/components/TransformView/utils.js +674 -0
  27. package/lib/components/UTAutocomplete/index.js +4 -4
  28. package/lib/components/UTBanner/index.js +42 -0
  29. package/lib/components/UTBanner/styles.js +14 -0
  30. package/lib/components/UTCBUInput/index.js +2 -2
  31. package/lib/components/UTHeader/index.js +56 -0
  32. package/lib/components/UTHeader/styles.js +16 -0
  33. package/lib/components/UTMenu/components/ListView/index.js +4 -2
  34. package/lib/components/UTMenu/components/MenuOption/index.js +1 -0
  35. package/lib/components/UTMenu/index.js +3 -3
  36. package/lib/components/UTMenu/proptypes.js +2 -2
  37. package/lib/components/UTOnBoarding/components/CardContent/index.js +3 -3
  38. package/lib/components/UTOnBoarding/index.js +4 -4
  39. package/lib/components/UTPasswordField/components/PasswordValidations/index.js +2 -6
  40. package/lib/components/UTSelect/componentes/MultipleItem/index.js +1 -0
  41. package/lib/components/UTSelect/proptypes.js +1 -0
  42. package/lib/components/UTStepFeedback/components/CircleNumber/index.js +12 -10
  43. package/lib/components/UTStepFeedback/index.js +36 -37
  44. package/lib/components/UTStepper/components/Connectors/index.js +33 -0
  45. package/lib/components/UTStepper/components/Connectors/styles.js +26 -0
  46. package/lib/components/UTStepper/components/Step/index.js +50 -0
  47. package/lib/components/UTStepper/components/Step/styles.js +47 -0
  48. package/lib/components/UTStepper/index.js +34 -0
  49. package/lib/components/UTStepper/styles.js +12 -0
  50. package/lib/components/UTStepper/types.js +3 -0
  51. package/lib/components/UTSwitch/proptypes.js +1 -0
  52. package/lib/components/UTTextInput/components/BaseInput/index.js +10 -12
  53. package/lib/components/UTTextInput/proptypes.js +1 -0
  54. package/lib/components/UTTopbar/index.js +64 -0
  55. package/lib/components/UTTopbar/styles.js +16 -0
  56. package/lib/components/UTTopbar/types.js +8 -0
  57. package/lib/components/UTWorkflowContainer/index.js +10 -102
  58. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/BottomStepHandler/index.js +4 -4
  59. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/BottomStepHandler/styles.js +3 -3
  60. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/index.js +9 -9
  61. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/styles.js +3 -3
  62. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/index.js +2 -2
  63. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/styles.js +12 -12
  64. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/types.js +9 -9
  65. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/index.js +6 -6
  66. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/styles.js +3 -3
  67. package/lib/components/UTWorkflowContainer/versions/V0/index.js +108 -0
  68. package/lib/components/UTWorkflowContainer/{styles.js → versions/V0/styles.js} +4 -4
  69. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/index.js +35 -0
  70. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/styles.js +13 -0
  71. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/types.js +9 -0
  72. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/constants.js +2 -0
  73. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/index.js +110 -0
  74. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/styles.js +75 -0
  75. package/lib/components/UTWorkflowContainer/versions/V1/index.js +94 -0
  76. package/lib/components/UTWorkflowContainer/versions/V1/styles.js +14 -0
  77. package/lib/components/UTWorkflowContainer/versions/V1/types.js +24 -0
  78. package/lib/theming/DefaultTheme.js +1 -0
  79. package/lib/utils/fileUtils.js/index.js +20 -5
  80. package/package.json +47 -71
  81. /package/lib/components/UTWorkflowContainer/{README.md → versions/V0/README.md} +0 -0
  82. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/utils.js +0 -0
  83. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/constants.js +0 -0
  84. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/utils.js +0 -0
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { shape, string } from 'prop-types';
4
+ import _ from 'lodash';
5
+
6
+ import Icon from '../Icon';
7
+ import Label from '../Label';
8
+ import { useTheme } from '../../theming';
9
+
10
+ import ownStyles from './styles';
11
+
12
+ const UTBanner = ({ text, icon, style }) => {
13
+ const theme = useTheme();
14
+
15
+ const ICON_SIZE = 24;
16
+
17
+ const themedStyles = _.merge({}, ownStyles, theme?.UTBanner, style);
18
+
19
+ return (
20
+ <View style={themedStyles.banner}>
21
+ {icon && (
22
+ <Icon
23
+ name={icon.name}
24
+ type={icon.type}
25
+ size={ICON_SIZE}
26
+ height={ICON_SIZE}
27
+ width={ICON_SIZE}
28
+ color={theme.UTBanner?.iconColor}
29
+ style={ownStyles.icon}
30
+ />
31
+ )}
32
+ <Label>{text}</Label>
33
+ </View>
34
+ );
35
+ };
36
+
37
+ UTBanner.propTypes = {
38
+ icon: shape({ name: string, type: string }),
39
+ text: string
40
+ };
41
+
42
+ export default UTBanner;
@@ -0,0 +1,14 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export default StyleSheet.create({
4
+ banner: {
5
+ backgroundColor: '#F4F5F7',
6
+ borderRadius: 8,
7
+ display: 'flex',
8
+ flexDirection: 'row',
9
+ padding: 16
10
+ },
11
+ icon: {
12
+ marginRight: 16
13
+ }
14
+ });
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
2
  import React from 'react';
3
- import { shape, func, any, elementType } from 'prop-types';
3
+ import { shape, func, any, elementType, oneOfType, number, string } from 'prop-types';
4
4
 
5
5
  import UTTextInput from '../UTTextInput';
6
6
 
@@ -38,7 +38,7 @@ const UTCBUInput = ({ input, configuration, ...props }) => {
38
38
  };
39
39
 
40
40
  UTCBUInput.propTypes = {
41
- input: shape({ onChange: func.isRequired, value: any }),
41
+ input: shape({ onChange: func.isRequired, value: oneOfType([number, string]) }),
42
42
  InputComponent: elementType,
43
43
  // eslint-disable-next-line react/forbid-prop-types
44
44
  configuration: any
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { string, bool, shape, element } from 'prop-types';
4
+
5
+ import Label from '../Label';
6
+ import UTBanner from '../UTBanner';
7
+
8
+ import ownStyles from './styles';
9
+
10
+ const Header = ({ tagline, title, subtitle, requiredFieldInfo, helpText, useMarkdown, banner }) => {
11
+ return (
12
+ <View style={ownStyles.header}>
13
+ {tagline && (
14
+ <Label disabled bold useMarkdown={useMarkdown} style={ownStyles.child}>
15
+ {tagline.toUpperCase()}
16
+ </Label>
17
+ )}
18
+ <View>
19
+ <Label big bold style={ownStyles.title} useMarkdown={useMarkdown}>
20
+ {title}
21
+ </Label>
22
+ {subtitle && (
23
+ <Label disabled useMarkdown={useMarkdown} style={ownStyles.child}>
24
+ {subtitle}
25
+ </Label>
26
+ )}
27
+ </View>
28
+ {requiredFieldInfo && (
29
+ <Label disabled useMarkdown={useMarkdown} style={ownStyles.child}>
30
+ {requiredFieldInfo}
31
+ </Label>
32
+ )}
33
+ {helpText && (
34
+ <Label disabled useMarkdown={useMarkdown} style={ownStyles.child}>
35
+ {helpText}
36
+ </Label>
37
+ )}
38
+ {banner?.text && <UTBanner text={banner.text} icon={banner.icon} style={{ banner: ownStyles.child }} />}
39
+ </View>
40
+ );
41
+ };
42
+
43
+ Header.propTypes = {
44
+ banner: shape({
45
+ Icon: element,
46
+ text: string
47
+ }),
48
+ helpText: string,
49
+ requiredFieldInfo: string,
50
+ subtitle: string,
51
+ tagline: string,
52
+ title: string,
53
+ useMarkdown: bool
54
+ };
55
+
56
+ export default Header;
@@ -0,0 +1,16 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export default StyleSheet.create({
4
+ child: {
5
+ marginBottom: 16
6
+ },
7
+ header: {
8
+ display: 'flex',
9
+ flexDirection: 'column',
10
+ paddingBottom: 16,
11
+ paddingTop: 24
12
+ },
13
+ title: {
14
+ marginBottom: 12
15
+ }
16
+ });
@@ -1,9 +1,13 @@
1
+ /* eslint-disable react/sort-comp */
2
+ /* eslint-disable class-methods-use-this */
1
3
  import React, { PureComponent } from 'react';
2
4
  import { FlatList } from 'react-native';
3
5
 
4
6
  import propTypes from './proptypes';
5
7
 
6
8
  class ListView extends PureComponent {
9
+ keyExtractor = (option, index) => option.id?.toString() || index.toString();
10
+
7
11
  constructor(props) {
8
12
  super(props);
9
13
  this.state = {
@@ -41,8 +45,6 @@ class ListView extends PureComponent {
41
45
  );
42
46
  };
43
47
 
44
- keyExtractor = (option, index) => option.id?.toString() || index.toString();
45
-
46
48
  render() {
47
49
  const { filteredOptions, ItemSeparatorComponent } = this.props;
48
50
  const { style } = this.state;
@@ -24,6 +24,7 @@ MenuOption.propTypes = {
24
24
  label: string,
25
25
  selected: bool,
26
26
  styles: ViewPropTypes.style,
27
+ // eslint-disable-next-line react/forbid-prop-types
27
28
  item: shape(any)
28
29
  };
29
30
 
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react';
1
+ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Dimensions, Keyboard, KeyboardAvoidingView, Modal, TouchableOpacity, View } from 'react-native';
3
3
 
4
4
  import useKeyboardHeight from '../../hooks/useKeyboardHeight';
@@ -98,7 +98,7 @@ const UTMenu = ({
98
98
  const focusSearchInput = () => withAutocomplete && searchTextInputRef.current?.focus();
99
99
 
100
100
  return (
101
- <Fragment>
101
+ <>
102
102
  <TouchableOpacity
103
103
  disabled={disabled}
104
104
  onPress={isOpen ? closeMenu : openMenu}
@@ -156,7 +156,7 @@ const UTMenu = ({
156
156
  </KeyboardAvoidingView>
157
157
  </View>
158
158
  </Modal>
159
- </Fragment>
159
+ </>
160
160
  );
161
161
  };
162
162
 
@@ -1,10 +1,10 @@
1
- import { any, arrayOf, bool, func, number, shape, string } from 'prop-types';
1
+ import { arrayOf, bool, func, number, oneOfType, shape, string } from 'prop-types';
2
2
 
3
3
  const optionType = shape({
4
4
  label: string.isRequired,
5
5
  id: string.isRequired,
6
6
  action: func,
7
- value: any.isRequired
7
+ value: oneOfType([number, string])
8
8
  });
9
9
 
10
10
  export default {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react-native/no-inline-styles */
2
- import React, { Fragment } from 'react';
2
+ import React from 'react';
3
3
  import { Animated } from 'react-native';
4
4
 
5
5
  import Label from '../../../Label';
@@ -9,7 +9,7 @@ import propTypes from './propTypes';
9
9
  import ownStyles from './styles';
10
10
 
11
11
  const CardContent = ({ onPress, currentPage, opacity, styles, buttonTitle = '', disabled }) => (
12
- <Fragment>
12
+ <>
13
13
  <Animated.View style={[styles?.textContainer, { opacity }]}>
14
14
  <Label big bold style={styles?.title}>
15
15
  {currentPage?.title || ''}
@@ -26,7 +26,7 @@ const CardContent = ({ onPress, currentPage, opacity, styles, buttonTitle = '',
26
26
  {...styles?.buttonProps}
27
27
  disabled={disabled}
28
28
  />
29
- </Fragment>
29
+ </>
30
30
  );
31
31
 
32
32
  CardContent.propTypes = propTypes;
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useRef } from 'react';
2
2
  import { View, ImageBackground, Animated } from 'react-native';
3
- // eslint-disable-next-line import/no-unresolved
4
- import ViewPager from '@react-native-community/viewpager';
3
+ // // eslint-disable-next-line import/no-unresolved
4
+ import PagerView from 'react-native-pager-view';
5
5
 
6
6
  import UTRoundView from '../UTRoundView';
7
7
  import useEffectOnlyOnUpdates from '../../hooks/useEffectOnlyOnUpdates';
@@ -89,7 +89,7 @@ const UTOnBoarding = ({
89
89
 
90
90
  return (
91
91
  <View style={ownStyles.expand}>
92
- <ViewPager style={ownStyles.expand} ref={viewPagerRef} scrollEnabled={false}>
92
+ <PagerView style={ownStyles.expand} ref={viewPagerRef} scrollEnabled={false}>
93
93
  {pages.map(page => (
94
94
  <ImageBackground
95
95
  key={`${page?.title} - ${page?.description}`}
@@ -97,7 +97,7 @@ const UTOnBoarding = ({
97
97
  source={page.image?.source}
98
98
  />
99
99
  ))}
100
- </ViewPager>
100
+ </PagerView>
101
101
  <UTRoundView
102
102
  styles={{
103
103
  outerContainer: [
@@ -21,12 +21,8 @@ const PasswordValidations = ({ passwordValidations, value, style, shouldShowErro
21
21
 
22
22
  const validations = validatedRegExps.filter(({ requirement }) => requirement);
23
23
  const errors = validatedRegExps.filter(({ requirement }) => !requirement);
24
- const {
25
- ValidationFailedIcon,
26
- ValidationPassedIcon,
27
- ErrorIcon,
28
- NoValueIcon
29
- } = theme.UTPasswordField.passwordIcons;
24
+ const { ValidationFailedIcon, ValidationPassedIcon, ErrorIcon, NoValueIcon } =
25
+ theme.UTPasswordField.passwordIcons;
30
26
  const showErrors = errors.some(({ assertion }) => !assertion);
31
27
 
32
28
  return (
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react/forbid-prop-types */
1
2
  import { any, bool, func, shape, string } from 'prop-types';
2
3
  import React, { memo } from 'react';
3
4
 
@@ -4,6 +4,7 @@ const optionType = shape({
4
4
  label: string.isRequired,
5
5
  id: string.isRequired,
6
6
  action: func,
7
+ // eslint-disable-next-line react/forbid-prop-types
7
8
  value: any.isRequired
8
9
  });
9
10
 
@@ -16,16 +16,18 @@ const CircleNumber = ({ index, step, themedStyles, status, hideStepNumber }) =>
16
16
 
17
17
  return (
18
18
  <View style={{ ...themedStyles.step, ...complementaryStyle }}>
19
- {!hideStepNumber && <Label
20
- color={
21
- (status.isComplete && themedStyles.stepLabel.complete) ||
22
- (status.isActive && themedStyles.stepLabel.active) ||
23
- (status.isFuture && themedStyles.stepLabel.future)
24
- }
25
- bold
26
- >
27
- {step.stepShortLabel || index + 1}
28
- </Label>}
19
+ {!hideStepNumber && (
20
+ <Label
21
+ color={
22
+ (status.isComplete && themedStyles.stepLabel.complete) ||
23
+ (status.isActive && themedStyles.stepLabel.active) ||
24
+ (status.isFuture && themedStyles.stepLabel.future)
25
+ }
26
+ bold
27
+ >
28
+ {step.stepShortLabel || index + 1}
29
+ </Label>
30
+ )}
29
31
  {status.isComplete && (
30
32
  <View style={themedStyles.checkContainer}>
31
33
  <Icon name="check" color={themedStyles.checkIcon.color} size={CHECK_ICON_SIZE} />
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
- import React, { Fragment, useEffect, useRef, useState } from 'react';
2
+ import React, { useEffect, useRef, useState } from 'react';
3
3
  import { Animated, TouchableOpacity, View } from 'react-native';
4
4
  import _ from 'lodash';
5
5
 
@@ -16,6 +16,19 @@ import ownStyles, {
16
16
  } from './styles';
17
17
  import stepFeedbackProptypes from './proptypes';
18
18
 
19
+ const Wrapper = ({ children, onStepPress, status, step }) =>
20
+ onStepPress ? (
21
+ <TouchableOpacity
22
+ onPress={() => {
23
+ if (!status.isActive && !status.isFuture) onStepPress(step.step);
24
+ }}
25
+ >
26
+ {children}
27
+ </TouchableOpacity>
28
+ ) : (
29
+ children
30
+ );
31
+
19
32
  const StepFeedback = ({
20
33
  currentStep,
21
34
  disableTriangle,
@@ -72,27 +85,25 @@ const StepFeedback = ({
72
85
  const isFirst = index === 0;
73
86
  const centerLabel = isLast || isFirst;
74
87
  return (
75
- <Fragment>
76
- <View style={styles.centerLabelContainer}>
77
- <Label
78
- center={labelsCentered || !centerLabel}
79
- small
80
- style={[
81
- styles.title,
82
- isFirst && !labelsCentered && styles.textAlignFirst,
83
- isLast && !labelsCentered && styles.textAlingLast
84
- ]}
85
- textProps={{ numberOfLines: 2 }}
86
- color={
87
- (status.isComplete && styles.titleLabel.complete) ||
88
- (status.isActive && styles.titleLabel.active) ||
89
- (status.isFuture && styles.titleLabel.future)
90
- }
91
- >
92
- {step.stepDescription}
93
- </Label>
94
- </View>
95
- </Fragment>
88
+ <View style={styles.centerLabelContainer}>
89
+ <Label
90
+ center={labelsCentered || !centerLabel}
91
+ small
92
+ style={[
93
+ styles.title,
94
+ isFirst && !labelsCentered && styles.textAlignFirst,
95
+ isLast && !labelsCentered && styles.textAlingLast
96
+ ]}
97
+ textProps={{ numberOfLines: 2 }}
98
+ color={
99
+ (status.isComplete && styles.titleLabel.complete) ||
100
+ (status.isActive && styles.titleLabel.active) ||
101
+ (status.isFuture && styles.titleLabel.future)
102
+ }
103
+ >
104
+ {step.stepDescription}
105
+ </Label>
106
+ </View>
96
107
  );
97
108
  };
98
109
 
@@ -102,23 +113,11 @@ const StepFeedback = ({
102
113
  isComplete: index < currentIndex,
103
114
  isFuture: index > currentIndex
104
115
  };
105
- const Wrapper = ({ children }) =>
106
- onStepPress ? (
107
- <TouchableOpacity
108
- onPress={() => {
109
- if (!status.isActive && !status.isFuture) onStepPress(step.step);
110
- }}
111
- >
112
- {children}
113
- </TouchableOpacity>
114
- ) : (
115
- children
116
- );
117
116
 
118
117
  return (
119
- <Fragment>
118
+ <>
120
119
  <View style={styles.stepContainer}>
121
- <Wrapper>
120
+ <Wrapper onStepPress={onStepPress} status={status} step={step}>
122
121
  <View style={styles.centerStepContainer}>
123
122
  <CircleNumber
124
123
  hideStepNumber={hideStepNumber}
@@ -134,7 +133,7 @@ const StepFeedback = ({
134
133
  {index < steps.length - 1 && (
135
134
  <View style={[styles.stepSeparator, status.isComplete && styles.stepSeparatorComplete]} />
136
135
  )}
137
- </Fragment>
136
+ </>
138
137
  );
139
138
  };
140
139
 
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { func, number } from 'prop-types';
4
+
5
+ import ownStyles from './styles';
6
+
7
+ const Connectors = ({ isCompleted, numberOfStages, theme = {} }) => {
8
+ const connectors = Array.from(Array(numberOfStages - 1), (_, index) => ({ key: index })).map(
9
+ ({ key }, index) => (
10
+ <View
11
+ key={key}
12
+ style={[
13
+ ownStyles.connector,
14
+ theme.connector,
15
+ isCompleted(index + 1) && [ownStyles.coloredProgress, theme.coloredProgress]
16
+ ]}
17
+ />
18
+ )
19
+ );
20
+
21
+ return (
22
+ <View style={ownStyles.wrapper}>
23
+ <View style={ownStyles.container}>{connectors}</View>
24
+ </View>
25
+ );
26
+ };
27
+
28
+ Connectors.propTypes = {
29
+ isCompleted: func,
30
+ numberOfStages: number
31
+ };
32
+
33
+ export default Connectors;
@@ -0,0 +1,26 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ import { OVAL_SIZE } from '../../styles';
4
+
5
+ export default StyleSheet.create({
6
+ coloredProgress: {
7
+ backgroundColor: 'blue'
8
+ },
9
+ connector: {
10
+ backgroundColor: 'gray',
11
+ flexGrow: 1,
12
+ height: 2
13
+ },
14
+ container: {
15
+ display: 'flex',
16
+ flexDirection: 'row',
17
+ justifyContent: 'space-around'
18
+ },
19
+ wrapper: {
20
+ left: 0,
21
+ paddingHorizontal: OVAL_SIZE,
22
+ paddingTop: OVAL_SIZE,
23
+ position: 'absolute',
24
+ width: '100%'
25
+ }
26
+ });
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { func, number, shape } from 'prop-types';
3
+ import { View } from 'react-native';
4
+
5
+ import Icon from '../../../Icon';
6
+ import { OVAL_SIZE } from '../../styles';
7
+
8
+ import ownStyles, { ICON_OFFSET } from './styles';
9
+
10
+ const Step = ({ isCompleted, isActive, stage, theme = {} }) => {
11
+ const stageCompleted = isCompleted(stage.id);
12
+ const stageActive = isActive(stage.id);
13
+
14
+ return (
15
+ <View
16
+ style={[
17
+ [ownStyles.stepContainer, theme.stepContainer],
18
+ stageCompleted && [ownStyles.completedContainer, theme.completeStepContainer],
19
+ stageActive && [ownStyles.activeContainer, theme.activeStepContainer]
20
+ ]}
21
+ >
22
+ <View style={ownStyles.checkContainer}>
23
+ <View
24
+ style={[
25
+ [ownStyles.stepInnerContainer, theme.stepInnerContainer],
26
+ stageCompleted && [ownStyles.completedInnerContainer, theme.completeStepInnerContainer],
27
+ stageActive && [ownStyles.activeInnerContainer, theme.activeStepInnerContainer]
28
+ ]}
29
+ />
30
+ {stageCompleted && (
31
+ <Icon
32
+ name="check"
33
+ type="feather"
34
+ size={OVAL_SIZE - ICON_OFFSET}
35
+ color="white"
36
+ style={ownStyles.checkIcon}
37
+ />
38
+ )}
39
+ </View>
40
+ </View>
41
+ );
42
+ };
43
+
44
+ Step.propTypes = {
45
+ isActive: func,
46
+ isCompleted: func,
47
+ stage: shape({ id: number })
48
+ };
49
+
50
+ export default Step;
@@ -0,0 +1,47 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ import { OVAL_SIZE } from '../../styles';
4
+
5
+ export const ICON_OFFSET = OVAL_SIZE / 4;
6
+
7
+ export default StyleSheet.create({
8
+ checkContainer: {
9
+ alignItems: 'center',
10
+ display: 'flex',
11
+ justifyContent: 'center'
12
+ },
13
+ checkIcon: {
14
+ left: ICON_OFFSET / 2,
15
+ position: 'absolute',
16
+ top: ICON_OFFSET / 2
17
+ },
18
+
19
+ activeContainer: {
20
+ backgroundColor: 'blue'
21
+ },
22
+ completedContainer: {
23
+ backgroundColor: 'blue'
24
+ },
25
+ stepContainer: {
26
+ backgroundColor: 'white',
27
+ borderRadius: OVAL_SIZE / 2,
28
+ height: OVAL_SIZE,
29
+ margin: OVAL_SIZE / 2,
30
+ width: OVAL_SIZE
31
+ },
32
+
33
+ activeInnerContainer: {
34
+ backgroundColor: 'white'
35
+ },
36
+ completedInnerContainer: {
37
+ backgroundColor: 'blue'
38
+ },
39
+ stepInnerContainer: {
40
+ backgroundColor: 'gray',
41
+ borderRadius: OVAL_SIZE / 2,
42
+ height: OVAL_SIZE / 2,
43
+ position: 'absolute',
44
+ top: OVAL_SIZE / 4,
45
+ width: OVAL_SIZE / 2
46
+ }
47
+ });
@@ -0,0 +1,34 @@
1
+ import { number } from 'prop-types';
2
+ import React from 'react';
3
+ import { View } from 'react-native';
4
+
5
+ import { useTheme } from '../../theming';
6
+
7
+ import ownStyles from './styles';
8
+ import Step from './components/Step';
9
+ import Connectors from './components/Connectors';
10
+ import { StagesPropTypes } from './types';
11
+
12
+ const UTStepper = ({ currentStage, stages }) => {
13
+ const isCompleted = stageNumber => stageNumber < currentStage;
14
+ const isActive = stageNumber => stageNumber === currentStage;
15
+ const numberOfStages = stages.length;
16
+
17
+ const theme = useTheme().UTStepper;
18
+
19
+ return (
20
+ <View style={ownStyles.container}>
21
+ <Connectors {...{ isCompleted, numberOfStages, theme }} />
22
+ {stages.map(stage => (
23
+ <Step key={stage.id} {...{ isActive, isCompleted, stage, theme }} />
24
+ ))}
25
+ </View>
26
+ );
27
+ };
28
+
29
+ UTStepper.propTypes = {
30
+ currentStage: number,
31
+ stages: StagesPropTypes
32
+ };
33
+
34
+ export default UTStepper;
@@ -0,0 +1,12 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const OVAL_SIZE = 16;
4
+
5
+ export default StyleSheet.create({
6
+ container: {
7
+ display: 'flex',
8
+ flexDirection: 'row',
9
+ flexGrow: 1,
10
+ justifyContent: 'space-between'
11
+ }
12
+ });
@@ -0,0 +1,3 @@
1
+ import { arrayOf, number, shape } from 'prop-types';
2
+
3
+ export const StagesPropTypes = arrayOf(shape({ id: number }));
@@ -13,6 +13,7 @@ export default {
13
13
  trackSize: number,
14
14
  thumbSize: number,
15
15
  theme: number,
16
+ // eslint-disable-next-line react/forbid-prop-types
16
17
  input: shape({ onChange: func.isRequired, value: any }),
17
18
  hitSlop: shape({
18
19
  bottom: number,