unicorn-demo-app 6.4.3 → 6.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unicorn-demo-app",
3
- "version": "6.4.3",
3
+ "version": "6.5.0",
4
4
  "main": "src/index.js",
5
5
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
6
6
  "license": "MIT",
@@ -10,11 +10,19 @@ import {
10
10
  RadioGroup,
11
11
  Slider,
12
12
  SegmentedControl,
13
+ SegmentedControlItemProps,
13
14
  Text,
15
+ TextProps,
14
16
  View
15
17
  } from 'react-native-ui-lib';
16
18
 
17
- export function renderHeader(title, others) {
19
+ interface RadioGroupOptions {
20
+ isRow?: boolean;
21
+ afterValueChanged?: () => void;
22
+ useValueAsLabel?: boolean;
23
+ }
24
+
25
+ export function renderHeader(title: string, others: TextProps) {
18
26
  return (
19
27
  <Text text30 grey10 {...others}>
20
28
  {title}
@@ -22,25 +30,25 @@ export function renderHeader(title, others) {
22
30
  );
23
31
  }
24
32
 
25
- export function renderBooleanOption(title, key) {
33
+ export function renderBooleanOption(title: string, key: string) {
34
+ // @ts-ignore
26
35
  const value = this.state[key];
27
36
  return (
28
37
  <View row centerV spread marginB-s4 key={key}>
29
- <Text flex>
30
- {title}
31
- </Text>
38
+ <Text flex>{title}</Text>
32
39
  <Switch
33
40
  useCustomTheme
34
41
  key={key}
35
- textID={key}
42
+ testID={key}
36
43
  value={value}
44
+ // @ts-ignore
37
45
  onValueChange={value => this.setState({[key]: value})}
38
46
  />
39
47
  </View>
40
48
  );
41
49
  }
42
50
 
43
- export function renderBooleanGroup(title, options) {
51
+ export function renderBooleanGroup(title: string, options: string[]) {
44
52
  return (
45
53
  <View marginB-s2>
46
54
  <Text text70M marginB-s2>
@@ -48,6 +56,7 @@ export function renderBooleanGroup(title, options) {
48
56
  </Text>
49
57
  <View row style={styles.rowWrap}>
50
58
  {_.map(options, key => {
59
+ // @ts-ignore
51
60
  const value = this.state[key];
52
61
  return (
53
62
  <View spread centerH row key={key}>
@@ -57,6 +66,7 @@ export function renderBooleanGroup(title, options) {
57
66
  key={key}
58
67
  testID={key}
59
68
  value={value}
69
+ // @ts-ignore
60
70
  onValueChange={value => this.setState({[key]: value})}
61
71
  />
62
72
  <Text text70 marginR-s3 marginB-s2>
@@ -70,7 +80,11 @@ export function renderBooleanGroup(title, options) {
70
80
  );
71
81
  }
72
82
 
73
- export function renderRadioGroup(title, key, options, {isRow, afterValueChanged, useValueAsLabel} = {}) {
83
+ export function renderRadioGroup(title: string,
84
+ key: string,
85
+ options: object,
86
+ {isRow, afterValueChanged, useValueAsLabel}: RadioGroupOptions = {}) {
87
+ // @ts-ignore
74
88
  const value = this.state[key];
75
89
  return (
76
90
  <View marginB-s2>
@@ -83,6 +97,7 @@ export function renderRadioGroup(title, key, options, {isRow, afterValueChanged,
83
97
  row={isRow}
84
98
  style={isRow && styles.rowWrap}
85
99
  initialValue={value}
100
+ // @ts-ignore
86
101
  onValueChange={value => this.setState({[key]: value}, afterValueChanged)}
87
102
  >
88
103
  {_.map(options, (value, key) => {
@@ -103,9 +118,10 @@ export function renderRadioGroup(title, key, options, {isRow, afterValueChanged,
103
118
  );
104
119
  }
105
120
 
106
- export function renderColorOption(title,
107
- key,
121
+ export function renderColorOption(title: string,
122
+ key: string,
108
123
  colors = ['transparent', Colors.blue30, Colors.grey10, Colors.yellow30, Colors.green30, Colors.purple30]) {
124
+ // @ts-ignore
109
125
  const value = this.state[key];
110
126
  return (
111
127
  <View marginV-s2>
@@ -113,13 +129,17 @@ export function renderColorOption(title,
113
129
  <ColorPalette
114
130
  value={value}
115
131
  colors={colors}
132
+ // @ts-ignore
116
133
  onValueChange={value => this.setState({[key]: value === 'transparent' ? undefined : value})}
117
134
  />
118
135
  </View>
119
136
  );
120
137
  }
121
138
 
122
- export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, initial = 0, sliderText = ''}) {
139
+ export function renderSliderOption(title: string,
140
+ key: string,
141
+ {min = 0, max = 10, step = 1, initial = 0, sliderText = ''}) {
142
+ // @ts-ignore
123
143
  const value = this.state[key] || initial;
124
144
  return (
125
145
  <View marginV-s2>
@@ -134,6 +154,7 @@ export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, ini
134
154
  minimumValue={min}
135
155
  maximumValue={max}
136
156
  step={step}
157
+ // @ts-ignore
137
158
  onValueChange={value => this.setState({[key]: value})}
138
159
  />
139
160
  <Text marginL-s4 text70 style={styles.text}>
@@ -145,16 +166,18 @@ export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, ini
145
166
  );
146
167
  }
147
168
 
148
- export function renderMultipleSegmentOptions(title, key, options) {
169
+ export function renderMultipleSegmentOptions(title: string, key: string, options: (SegmentedControlItemProps & {value: any})[]) {
170
+ // @ts-ignore
149
171
  const value = this.state[key];
150
172
  const index = _.findIndex(options, {value});
151
173
 
152
174
  return (
153
175
  <View row centerV spread marginB-s4 key={key}>
154
- <Text marginR-s2>{title}</Text>
176
+ {!!title && <Text marginR-s2>{title}</Text>}
155
177
  <SegmentedControl
156
178
  initialIndex={index}
157
179
  segments={options}
180
+ // @ts-ignore
158
181
  onChangeIndex={index => this.setState({[key]: options[index].value})}
159
182
  />
160
183
  </View>
@@ -153,6 +153,7 @@ export const navigationData = {
153
153
  Incubator: {
154
154
  title: 'Incubator (Experimental)',
155
155
  screens: [
156
+ {title: '(New) ChipsInput', tags: 'chips input', screen: 'unicorn.components.IncubatorChipsInputScreen'},
156
157
  {title: 'Native TouchableOpacity', tags: 'touchable native', screen: 'unicorn.incubator.TouchableOpacityScreen'},
157
158
  {title: '(New) Dialog', tags: 'dialog modal popup alert', screen: 'unicorn.incubator.IncubatorDialogScreen'},
158
159
  {title: '(New) TextField', tags: 'text field input', screen: 'unicorn.components.IncubatorTextFieldScreen'},
@@ -179,8 +179,11 @@ class GridViewScreen extends Component {
179
179
  <GridView items={pairs} numColumns={2}/>
180
180
  <Text marginV-s5 text60BO>
181
181
  Dynamic itemSize
182
+ <Text text90>
183
+ {' '} (Using maxItemWidth)
184
+ </Text>
182
185
  </Text>
183
- <GridView items={dynamicLayout} numColumns={3}/>
186
+ <GridView items={dynamicLayout} maxItemWidth={120}/>
184
187
  <Text marginV-s5 text60BO>
185
188
  OverlayText
186
189
  </Text>
@@ -2,7 +2,6 @@ import _ from 'lodash';
2
2
  import React, {Component} from 'react';
3
3
  import {Alert} from 'react-native';
4
4
  import {Colors, View, Text, Hint, Button, Assets, Incubator} from 'react-native-ui-lib';
5
- // @ts-expect-error
6
5
  import {renderMultipleSegmentOptions, renderBooleanOption} from '../ExampleScreenPresenter';
7
6
 
8
7
  const settingsIcon = require('../../assets/icons/settings.png');
@@ -119,7 +119,7 @@ class TabControllerScreen extends Component<{}, State> {
119
119
  }
120
120
 
121
121
  renderTabPages() {
122
- const {asCarousel} = this.state;
122
+ const {asCarousel, fewItems} = this.state;
123
123
  const Container = asCarousel ? TabController.PageCarousel : View;
124
124
  const containerProps = asCarousel ? {} : {flex: true};
125
125
  return (
@@ -134,7 +134,7 @@ class TabControllerScreen extends Component<{}, State> {
134
134
  <Tab3/>
135
135
  </TabController.TabPage>
136
136
 
137
- {_.map(_.takeRight(TABS, TABS.length - 3), (title, index) => {
137
+ {!fewItems && _.map(_.takeRight(TABS, TABS.length - 3), (title, index) => {
138
138
  return (
139
139
  <TabController.TabPage key={title} index={index + 3}>
140
140
  <View padding-s5>
@@ -5,6 +5,7 @@ import {Card, Avatar, View, Text} from 'react-native-ui-lib';
5
5
 
6
6
  class Tab2 extends Component {
7
7
  state = {
8
+ counter: 0,
8
9
  loading: true
9
10
  };
10
11
 
@@ -13,7 +14,17 @@ class Tab2 extends Component {
13
14
  this.setState({loading: false});
14
15
  }, 1200);
15
16
 
16
- // this.slow();
17
+ /* Uncomment to test TabPage freeze functionality when the page lose focus */
18
+ // setInterval(() => {
19
+ // this.setState({counter: this.state.counter + 1});
20
+ // }, 1000);
21
+ }
22
+
23
+ componentDidUpdate() {
24
+ /* Uncomment to test TabPage freeze functionality when the page lose focus */
25
+ // if (this.state.counter % 3 === 0) {
26
+ // console.warn('freeze counter', this.state.counter);
27
+ // }
17
28
  }
18
29
 
19
30
  slow(iterations = 10) {
@@ -13,16 +13,20 @@ export function registerScreens(registrar) {
13
13
  registrar('unicorn.components.CarouselVerticalScreen', () => require('./CarouselVerticalScreen').default);
14
14
  registrar('unicorn.components.CheckboxScreen', () => require('./CheckboxScreen').default);
15
15
  registrar('unicorn.components.ChipScreen', () => require('./ChipScreen').default);
16
+ registrar('unicorn.components.ChipsInputScreen', () => require('./ChipsInputScreen').default);
17
+ registrar('unicorn.components.ColorPickerScreen', () => require('./ColorPickerScreen').default);
18
+ registrar('unicorn.components.ColorSwatchScreen', () => require('./ColorSwatchScreen').default);
16
19
  registrar('unicorn.components.ConnectionStatusBar', () => require('./ConnectionStatusBarScreen').default);
20
+ registrar('unicorn.components.DateTimePickerScreen', () => require('./DateTimePickerScreen').default);
17
21
  registrar('unicorn.components.DialogScreen', () => require('./DialogScreen').default);
18
22
  registrar('unicorn.components.DrawerScreen', () => require('./DrawerScreen').default);
19
23
  registrar('unicorn.components.ExpandableSectionScreen', () => require('./ExpandableSectionScreen').default);
20
- registrar('unicorn.components.ChipsInputScreen', () => require('./ChipsInputScreen').default);
24
+ registrar('unicorn.components.FloatingButtonScreen', () => require('./FloatingButtonScreen').default);
21
25
  registrar('unicorn.components.HapticScreen', () => require('./HapticScreen').default);
22
26
  registrar('unicorn.components.HintsScreen', () => require('./HintsScreen').default);
23
27
  registrar('unicorn.components.IconScreen', () => require('./IconScreen').default);
24
28
  registrar('unicorn.components.ImageScreen', () => require('./ImageScreen').default);
25
- registrar('unicorn.components.ProgressiveImageScreen', () => require('./ProgressiveImageScreen').default);
29
+ registrar('unicorn.components.GridViewScreen', () => require('./GridViewScreen').default);
26
30
  registrar('unicorn.components.KeyboardAwareScrollViewScreen', () => require('./KeyboardAwareScrollViewScreen').default);
27
31
  registrar('unicorn.components.MaskedInputScreen', () => require('./MaskedInputScreen').default);
28
32
  registrar('unicorn.components.OverlaysScreen', () => require('./OverlaysScreen').default);
@@ -32,41 +36,37 @@ export function registerScreens(registrar) {
32
36
  registrar('unicorn.components.PanResponderScreen', () => require('./PanResponderScreen').default);
33
37
  registrar('unicorn.components.PickerScreen', () => require('./PickerScreen').default);
34
38
  registrar('unicorn.animations.ProgressBarScreen', () => require('../componentScreens/ProgressBarScreen').default);
39
+ registrar('unicorn.components.ProgressiveImageScreen', () => require('./ProgressiveImageScreen').default);
35
40
  registrar('unicorn.components.RadioButtonScreen', () => require('./RadioButtonScreen').default);
36
41
  registrar('unicorn.components.ScrollBarScreen', () => require('./ScrollBarScreen').default);
37
42
  registrar('unicorn.components.SectionsWheelPickerScreen', () => require('./SectionsWheelPickerScreen').default);
38
43
  registrar('unicorn.components.SegmentedControlScreen', () => require('./SegmentedControlScreen').default);
39
44
  registrar('unicorn.components.SharedTransitionScreen', () => require('./SharedTransitionScreen').default);
40
45
  registrar('unicorn.components.SkeletonViewScreen', () => require('./SkeletonViewScreen').default);
46
+ registrar('unicorn.components.SliderScreen', () => require('./SliderScreen').default);
47
+ registrar('unicorn.components.StackAggregatorScreen', () => require('./StackAggregatorScreen').default);
41
48
  registrar('unicorn.components.StepperScreen', () => require('./StepperScreen').default);
42
49
  registrar('unicorn.components.SwitchScreen', () => require('./SwitchScreen').default);
43
- registrar('unicorn.components.ToastsScreen', () => require('./ToastsScreen').default);
44
50
  registrar('unicorn.components.TabControllerScreen', () => require('./TabControllerScreen').default);
45
- registrar('unicorn.components.TextScreen', () => require('./TextScreen').default);
46
51
  registrar('unicorn.components.TextFieldScreen', () => require('./TextFieldScreen').default);
52
+ registrar('unicorn.components.TextScreen', () => require('./TextScreen').default);
53
+ registrar('unicorn.components.ToastsScreen', () => require('./ToastsScreen').default);
47
54
  registrar('unicorn.wrappers.TouchableOpacityScreen', () => require('./TouchableOpacityScreen').default);
48
55
  registrar('unicorn.components.TourScreen', () => require('./TourScreen').default);
49
- registrar('unicorn.components.FeatureHighlightScreen', () => require('./FeatureHighlightScreen').default);
50
- registrar('unicorn.components.WheelPickerDialogScreen', () => require('./WheelPickerDialogScreen').default);
51
- registrar('unicorn.components.SliderScreen', () => require('./SliderScreen').default);
52
- registrar('unicorn.components.FloatingButtonScreen', () => require('./FloatingButtonScreen').default);
53
- registrar('unicorn.components.ColorPickerScreen', () => require('./ColorPickerScreen').default);
54
- registrar('unicorn.components.ColorSwatchScreen', () => require('./ColorSwatchScreen').default);
55
- registrar('unicorn.components.StackAggregatorScreen', () => require('./StackAggregatorScreen').default);
56
- registrar('unicorn.components.DateTimePickerScreen', () => require('./DateTimePickerScreen').default);
57
56
  registrar('unicorn.components.ViewScreen', () => require('./ViewScreen').default);
57
+ registrar('unicorn.components.WheelPickerDialogScreen', () => require('./WheelPickerDialogScreen').default);
58
58
  registrar('unicorn.components.WizardScreen', () => require('./WizardScreen').default);
59
- registrar('unicorn.components.GridViewScreen', () => require('./GridViewScreen').default);
60
59
  // List Components
61
60
  registrar('unicorn.lists.BasicListScreen', () => require('./BasicListScreen').default);
62
61
  registrar('unicorn.lists.ContactsListScreen', () => require('./ContactsListScreen').default);
63
62
  registrar('unicorn.lists.ConversationListScreen', () => require('./ConversationListScreen').default);
64
63
  // Full Screen components
65
64
  registrar('unicorn.screens.EmptyStateScreen', () => require('./EmptyStateScreen').default);
65
+ registrar('unicorn.components.FaderScreen', () => require('./FaderScreen').default);
66
+ registrar('unicorn.components.FeatureHighlightScreen', () => require('./FeatureHighlightScreen').default);
66
67
  registrar('unicorn.screens.LoadingScreen', () => require('./LoadingScreen').default);
67
68
  registrar('unicorn.screens.ModalScreen', () => require('./ModalScreen').default);
68
69
  registrar('unicorn.components.WithScrollEnablerScreen', () => require('./WithScrollEnablerScreen').default);
69
70
  registrar('unicorn.components.WithScrollReachedScreen', () => require('./WithScrollReachedScreen').default);
70
- registrar('unicorn.components.FaderScreen', () => require('./FaderScreen').default);
71
71
  }
72
72
 
@@ -0,0 +1,41 @@
1
+ import React, {Component} from 'react';
2
+ import {View, Text, Card, TextField, Button, Colors, Incubator} from 'react-native-ui-lib'; //eslint-disable-line
3
+
4
+ export default class ChipsInputScreen extends Component {
5
+ state = {
6
+ chips: [{label: 'one'}, {label: 'two'}],
7
+ chips2: []
8
+ };
9
+
10
+ render() {
11
+ return (
12
+ <View flex padding-20>
13
+ <Text h1 marginB-s4>
14
+ ChipsInput
15
+ </Text>
16
+ <Incubator.ChipsInput
17
+ placeholder="Enter chips"
18
+ defaultChipProps={{
19
+ backgroundColor: Colors.primary,
20
+ labelStyle: {color: Colors.white},
21
+ containerStyle: {borderWidth: 0},
22
+ dismissColor: Colors.white
23
+ }}
24
+ chips={this.state.chips}
25
+ leadingAccessory={<Text>TO: </Text>}
26
+ onChange={newChips => {
27
+ this.setState({chips: newChips});
28
+ }}
29
+ />
30
+
31
+ <Incubator.ChipsInput
32
+ label="Max 3 chips"
33
+ placeholder="Enter chips..."
34
+ chips={this.state.chips2}
35
+ onChange={newChips => this.setState({chips2: newChips})}
36
+ maxChips={3}
37
+ />
38
+ </View>
39
+ );
40
+ }
41
+ }
@@ -98,9 +98,10 @@ export default class TextFieldScreen extends Component {
98
98
  <TextField
99
99
  ref={this.input2}
100
100
  placeholder="Enter URL"
101
+ floatingPlaceholder
101
102
  text70
102
103
  leadingAccessory={
103
- <Text text70 blue30>
104
+ <Text text70 blue30 marginR-2>
104
105
  Https://
105
106
  </Text>
106
107
  }
@@ -214,7 +215,7 @@ export default class TextFieldScreen extends Component {
214
215
  label="Label"
215
216
  placeholder="Enter text..."
216
217
  preset={preset}
217
- fieldStyle={(_state, {preset}) => (preset === 'withUnderline' ? styles.withUnderline : styles.withFrame)}
218
+ dynamicFieldStyle={(_state, {preset}) => (preset === 'withUnderline' ? styles.withUnderline : styles.withFrame)}
218
219
  editable={!shouldDisable}
219
220
  />
220
221
 
@@ -1,6 +1,7 @@
1
1
  import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
2
2
 
3
3
  export function registerScreens(registrar) {
4
+ registrar('unicorn.components.IncubatorChipsInputScreen', () => require('./IncubatorChipsInputScreen').default);
4
5
  registrar('unicorn.incubator.TouchableOpacityScreen', () =>
5
6
  gestureHandlerRootHOC(require('./TouchableOpacityScreen').default));
6
7
  registrar('unicorn.incubator.IncubatorDialogScreen', () => require('./IncubatorDialogScreen').default);