unicorn-demo-app 7.46.2-snapshot.7306 → 7.46.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unicorn-demo-app",
3
- "version": "7.46.2-snapshot.7306",
3
+ "version": "7.46.2",
4
4
  "main": "src/index.js",
5
5
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -263,9 +263,6 @@ module.exports = {
263
263
  get IncubatorCalendarScreen() {
264
264
  return require('./screens/incubatorScreens/IncubatorCalendarScreen').default;
265
265
  },
266
- get IncubatorGradient() {
267
- return require('./screens/incubatorScreens/IncubatorGradientScreen').default;
268
- },
269
266
  // realExamples
270
267
  get AppleMusic() {
271
268
  return require('./screens/realExamples/AppleMusic').default;
@@ -16,22 +16,12 @@ import {
16
16
  View
17
17
  } from 'react-native-ui-lib';
18
18
 
19
- interface StateOptions {
20
- state?: string;
21
- setState?: React.Dispatch<React.SetStateAction<any /** no suitable solution for enum */>>;
22
- }
23
-
24
- interface RadioGroupBaseOptions {
19
+ interface RadioGroupOptions {
25
20
  isRow?: boolean;
21
+ afterValueChanged?: () => void;
26
22
  useValueAsLabel?: boolean;
27
23
  }
28
24
 
29
- type RadioGroupOptions =
30
- | (RadioGroupBaseOptions & {
31
- afterValueChanged?: () => void;
32
- })
33
- | (RadioGroupBaseOptions & StateOptions);
34
-
35
25
  interface BooleanGroupOptions {
36
26
  spread?: boolean;
37
27
  afterValueChanged?: () => void;
@@ -39,6 +29,11 @@ interface BooleanGroupOptions {
39
29
  setState?: React.Dispatch<React.SetStateAction<boolean>>;
40
30
  }
41
31
 
32
+ interface SegmentsExtraOptions {
33
+ state?: string;
34
+ setState?: React.Dispatch<React.SetStateAction<any /** no suitable solution for enum */>>;
35
+ }
36
+
42
37
  export function renderHeader(title: string, others?: TextProps) {
43
38
  return (
44
39
  <Text text30 $textDefault {...others}>
@@ -108,10 +103,9 @@ export function renderBooleanGroup(title: string, options: string[]) {
108
103
  export function renderRadioGroup(title: string,
109
104
  key: string,
110
105
  options: object,
106
+ {isRow, afterValueChanged, useValueAsLabel}: RadioGroupOptions = {}) {
111
107
  // @ts-ignore
112
- {isRow, afterValueChanged, useValueAsLabel, state, setState}: RadioGroupOptions = {}) {
113
- // @ts-ignore
114
- const value = state ?? this.state[key];
108
+ const value = this.state[key];
115
109
  return (
116
110
  <View marginB-s2>
117
111
  {!_.isUndefined(title) && (
@@ -124,18 +118,7 @@ export function renderRadioGroup(title: string,
124
118
  style={isRow && styles.rowWrap}
125
119
  initialValue={value}
126
120
  // @ts-ignore
127
- onValueChange={value => {
128
- if (setState) {
129
- setState(value);
130
- if (afterValueChanged) {
131
- // eslint-disable-next-line no-restricted-syntax
132
- console.error('afterValueChanged is not supported together with the state option');
133
- }
134
- } else {
135
- // @ts-ignore
136
- this.setState({[key]: value}, afterValueChanged);
137
- }
138
- }}
121
+ onValueChange={value => this.setState({[key]: value}, afterValueChanged)}
139
122
  >
140
123
  {_.map(options, (value, key) => {
141
124
  return (
@@ -176,25 +159,9 @@ export function renderColorOption(title: string,
176
159
 
177
160
  export function renderSliderOption(title: string,
178
161
  key: string,
179
- {
180
- min = 0,
181
- max = 10,
182
- step = 1,
183
- initial = 0,
184
- sliderText = '',
185
- state,
186
- setState
187
- }: {
188
- min?: number;
189
- max?: number;
190
- step?: number;
191
- initial?: number;
192
- sliderText?: string;
193
- state?: number;
194
- setState?: React.Dispatch<React.SetStateAction<number>>;
195
- }) {
162
+ {min = 0, max = 10, step = 1, initial = 0, sliderText = ''}) {
196
163
  // @ts-ignore
197
- const value = state ?? this.state[key] ?? initial;
164
+ const value = this.state[key] || initial;
198
165
  return (
199
166
  <View marginV-s2>
200
167
  <Text marginB-s1 text70M $textDefault>
@@ -210,14 +177,7 @@ export function renderSliderOption(title: string,
210
177
  maximumValue={max}
211
178
  step={step}
212
179
  // @ts-ignore
213
- onValueChange={value => {
214
- if (setState) {
215
- setState(value);
216
- } else {
217
- // @ts-ignore
218
- this.setState({[key]: value});
219
- }
220
- }}
180
+ onValueChange={value => this.setState({[key]: value})}
221
181
  />
222
182
  <Text marginL-s4 text70 $textDefault style={styles.text}>
223
183
  {sliderText}
@@ -231,7 +191,7 @@ export function renderSliderOption(title: string,
231
191
  export function renderMultipleSegmentOptions(title: string,
232
192
  key: string,
233
193
  options: (SegmentedControlItemProps & {value: any})[],
234
- {state, setState}: StateOptions = {}) {
194
+ {state, setState}: SegmentsExtraOptions = {}) {
235
195
  // @ts-ignore
236
196
  const value = state ?? this.state[key];
237
197
  const index = _.findIndex(options, {value});
@@ -208,8 +208,7 @@ export const navigationData = {
208
208
  tags: 'text field expandable input picker',
209
209
  screen: 'unicorn.components.IncubatorExpandableOverlayScreen'
210
210
  },
211
- {title: 'PanView', tags: 'pan swipe drag', screen: 'unicorn.incubator.PanViewScreen'},
212
- {title: 'Gradient', tags: 'gradient', screen: 'unicorn.components.IncubatorGradientScreen'}
211
+ {title: 'PanView', tags: 'pan swipe drag', screen: 'unicorn.incubator.PanViewScreen'}
213
212
  ]
214
213
  },
215
214
  Inspirations: {
@@ -6,5 +6,4 @@ export function registerScreens(registrar) {
6
6
  registrar('unicorn.components.IncubatorToastScreen', () => require('./IncubatorToastScreen').default);
7
7
  registrar('unicorn.incubator.PanViewScreen', () => require('./PanViewScreen').default);
8
8
  registrar('unicorn.components.IncubatorSliderScreen', () => require('./IncubatorSliderScreen').default);
9
- registrar('unicorn.components.IncubatorGradientScreen', () => require('./IncubatorGradientScreen').default);
10
9
  }
@@ -1,114 +0,0 @@
1
- import React, {useEffect, useMemo, useState} from 'react';
2
- import {Assets, View, Text, Incubator, Icon, Colors} from 'react-native-ui-lib';
3
- import {renderRadioGroup, renderSliderOption} from '../ExampleScreenPresenter';
4
-
5
- const {Gradient} = Incubator;
6
-
7
- const COLORS = [Colors.$backgroundPrimaryHeavy, Colors.$backgroundPrimaryHeavy, Colors.$backgroundPrimaryMedium];
8
-
9
- const GradientScreen = () => {
10
- const [type, setType] = useState('rectangle');
11
- const [children, setChildren] = useState('none');
12
- const [alignment, setAlignment] = useState('none');
13
- const [size, setSize] = useState('fixed');
14
- const [error, setError] = useState('');
15
- const [angle, setAngle] = useState(0);
16
-
17
- const gradientProps = useMemo(() => {
18
- switch (type) {
19
- case 'rectangle':
20
- return size === 'fixed' ? {type: 'rectangle', width: 100, height: 100} : {type: 'rectangle'};
21
- case 'circle':
22
- return size === 'fixed' ? {type: 'circle', radius: 50} : {type: 'circle'};
23
- case 'border':
24
- return size === 'fixed' ? {type: 'border', width: 100, height: 100} : {type: 'border'};
25
- }
26
- }, [type, size]);
27
-
28
- const childrenProps = useMemo(() => {
29
- switch (children) {
30
- case 'shortText':
31
- return <Text>Lorem ipsum dolor sit amet.</Text>;
32
- case 'text':
33
- return (
34
- <Text>
35
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
36
- dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
37
- ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
38
- nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
39
- anim id est laborum.
40
- </Text>
41
- );
42
- case 'icon':
43
- return <Icon source={Assets.icons.demo.search}/>;
44
- }
45
- }, [children]);
46
-
47
- const alignmentProp = useMemo(() => {
48
- switch (alignment) {
49
- case 'none':
50
- return undefined;
51
- case 'center':
52
- return {center: true};
53
- case 'centerH':
54
- return {centerH: true};
55
- case 'centerV':
56
- return {centerV: true};
57
- }
58
- }, [alignment]);
59
-
60
- useEffect(() => {
61
- if (children === 'none' && size === 'flex' && type !== 'border') {
62
- setError('No children + flex gives no gradient');
63
- } else if (size === 'flex' && type === 'circle') {
64
- setError('flex size will result with an ellipse instead of a circle');
65
- } else {
66
- setError('');
67
- }
68
- }, [children, size, type]);
69
-
70
- return (
71
- <View padding-page>
72
- {renderRadioGroup('Select type',
73
- 'type',
74
- {Rectangle: 'rectangle', Circle: 'circle', Border: 'border'},
75
- {isRow: true, state: type, setState: setType})}
76
- {renderRadioGroup('Select children',
77
- 'children',
78
- {No: 'none', 'Short text': 'shortText', Text: 'text', Icon: 'icon'},
79
- {isRow: true, state: children, setState: setChildren})}
80
- {renderRadioGroup('Select children`s alignment',
81
- 'alignment',
82
- {None: 'none', Center: 'center', CenterH: 'centerH', CenterV: 'centerV'},
83
- {isRow: true, state: alignment, setState: setAlignment})}
84
- {renderRadioGroup('Select size',
85
- 'size',
86
- {Fixed: 'fixed', Flex: 'flex'},
87
- {isRow: true, state: size, setState: setSize})}
88
- <View marginH-s10>
89
- {renderSliderOption('Angle', 'angle', {
90
- min: 0,
91
- max: 360,
92
- step: 1,
93
- state: angle,
94
- setState: setAngle
95
- })}
96
- </View>
97
- <Gradient
98
- colors={COLORS}
99
- // @ts-expect-error
100
- type={type}
101
- {...gradientProps}
102
- {...alignmentProp}
103
- angle={angle}
104
- >
105
- {childrenProps}
106
- </Gradient>
107
- <Text marginT-s10 center $textDangerLight>
108
- {error}
109
- </Text>
110
- </View>
111
- );
112
- };
113
-
114
- export default GradientScreen;