unicorn-demo-app 6.15.2 → 6.16.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.15.2",
3
+ "version": "6.16.0",
4
4
  "main": "src/index.js",
5
5
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
6
6
  "license": "MIT",
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -3,10 +3,12 @@ import {Assets, Colors, Typography, Spacings, Incubator} from 'react-native-ui-l
3
3
  export const loadDemoConfigurations = () => {
4
4
  Assets.loadAssetsGroup('icons.demo', {
5
5
  chevronDown: require('./assets/icons/chevronDown.png'),
6
+ chevronRight: require('./assets/icons/chevronRight.png'),
6
7
  add: require('./assets/icons/add.png'),
7
8
  camera: require('./assets/icons/cameraSelected.png'),
8
9
  close: require('./assets/icons/close.png'),
9
10
  dashboard: require('./assets/icons/dashboard.png'),
11
+ drag: require('./assets/icons/drag.png'),
10
12
  image: require('./assets/icons/image.png'),
11
13
  plus: require('./assets/icons/plus.png'),
12
14
  refresh: require('./assets/icons/refresh.png'),
package/src/index.js CHANGED
@@ -111,6 +111,9 @@ module.exports = {
111
111
  get SkeletonViewScreen() {
112
112
  return require('./screens/componentScreens/SkeletonViewScreen').default;
113
113
  },
114
+ get SortableListScreen() {
115
+ return require('./screens/componentScreens/SortableListScreen').default;
116
+ },
114
117
  get StepperScreen() {
115
118
  return require('./screens/componentScreens/StepperScreen').default;
116
119
  },
@@ -83,7 +83,8 @@ export const navigationData = {
83
83
  {title: 'Basic List', tags: 'basic list', screen: 'unicorn.lists.BasicListScreen'},
84
84
  {title: 'Contacts List', tags: 'list contacts', screen: 'unicorn.lists.ContactsListScreen'},
85
85
  {title: 'Conversation List', tags: 'list conversation', screen: 'unicorn.lists.ConversationListScreen'},
86
- {title: 'Drawer', tags: 'drawer', screen: 'unicorn.components.DrawerScreen'}
86
+ {title: 'Drawer', tags: 'drawer', screen: 'unicorn.components.DrawerScreen'},
87
+ {title: 'SortableList', tags: 'sortable list drag', screen: 'unicorn.components.SortableListScreen'}
87
88
  ]
88
89
  },
89
90
  LayoutsAndTemplates: {
@@ -96,6 +97,7 @@ export const navigationData = {
96
97
  {title: 'Modal', tags: 'modal topbar screen', screen: 'unicorn.screens.ModalScreen'},
97
98
  {title: 'StateScreen', tags: 'empty state screen', screen: 'unicorn.screens.EmptyStateScreen'},
98
99
  {title: 'TabController', tags: 'tabbar controller native', screen: 'unicorn.components.TabControllerScreen'},
100
+ {title: 'Timeline', tags: 'timeline', screen: 'unicorn.components.TimelineScreen'},
99
101
  {
100
102
  title: 'withScrollEnabler',
101
103
  tags: 'scroll enabled withScrollEnabler',
@@ -50,7 +50,7 @@ export default class DialogScreen extends Component {
50
50
  ];
51
51
 
52
52
  this.state = {
53
- panDirection: PanningProvider.Directions.DOWN,
53
+ panDirection: Dialog.directions.DOWN,
54
54
  position: 'bottom',
55
55
  scroll: this.SCROLL_TYPE.NONE,
56
56
  showHeader: true,
@@ -114,7 +114,7 @@ export default class DialogScreen extends Component {
114
114
  return (
115
115
  <Text color={Colors.$textDangerLight}>It is recommended to have pannable header with scrollable content</Text>
116
116
  );
117
- } else if (showHeader && panDirection !== PanningProvider.Directions.DOWN) {
117
+ } else if (showHeader && panDirection !== Dialog.directions.DOWN) {
118
118
  return <Text color={Colors.$textDangerLight}>It is recommended to have pannable header with direction=down</Text>;
119
119
  }
120
120
  };
@@ -270,10 +270,10 @@ Scroll: ${scroll}`;
270
270
  <Text $textDefault>Panning Direction:</Text>
271
271
  <View row marginV-10>
272
272
  <RadioButton value={null} label={'None'}/>
273
- <RadioButton value={PanningProvider.Directions.UP} label={'Up'} marginL-10/>
274
- <RadioButton value={PanningProvider.Directions.DOWN} label={'Down'} marginL-10/>
275
- <RadioButton value={PanningProvider.Directions.LEFT} label={'Left'} marginL-10/>
276
- <RadioButton value={PanningProvider.Directions.RIGHT} label={'Right'} marginL-10/>
273
+ <RadioButton value={Dialog.directions.UP} label={'Up'} marginL-10/>
274
+ <RadioButton value={Dialog.directions.DOWN} label={'Down'} marginL-10/>
275
+ <RadioButton value={Dialog.directions.LEFT} label={'Left'} marginL-10/>
276
+ <RadioButton value={Dialog.directions.RIGHT} label={'Right'} marginL-10/>
277
277
  </View>
278
278
  </RadioGroup>
279
279
 
@@ -22,6 +22,7 @@ import {longOptions} from './PickerScreenLongOptions';
22
22
 
23
23
  const tagIcon = require('../../assets/icons/tags.png');
24
24
  const dropdown = require('../../assets/icons/chevronDown.png');
25
+ const dropdownIcon = <Icon source={dropdown} tintColor={Colors.$iconDefault}/>;
25
26
 
26
27
  const contacts = _.map(contactsData, (c, index) => ({...c, value: index, label: c.name}));
27
28
 
@@ -56,7 +57,7 @@ export default class PickerScreen extends Component {
56
57
  dialogHeader: DialogProps['renderPannableHeader'] = props => {
57
58
  const {title} = props;
58
59
  return (
59
- <Text margin-15 text60>
60
+ <Text margin-15 text60 $textDefault>
60
61
  {title}
61
62
  </Text>
62
63
  );
@@ -76,7 +77,7 @@ export default class PickerScreen extends Component {
76
77
  height="45%"
77
78
  bottom
78
79
  useSafeArea
79
- containerStyle={{backgroundColor: Colors.white}}
80
+ containerStyle={{backgroundColor: Colors.$backgroundDefault}}
80
81
  renderPannableHeader={this.dialogHeader}
81
82
  panDirection={PanningProvider.Directions.DOWN}
82
83
  pannableHeaderProps={{title: 'Custom modal'}}
@@ -90,7 +91,9 @@ export default class PickerScreen extends Component {
90
91
  return (
91
92
  <ScrollView keyboardShouldPersistTaps="always">
92
93
  <View flex padding-20>
93
- <Text text40>Picker</Text>
94
+ <Text text40 $textDefault>
95
+ Picker
96
+ </Text>
94
97
  <Picker
95
98
  placeholder="Favorite Language"
96
99
  floatingPlaceholder
@@ -103,6 +106,7 @@ export default class PickerScreen extends Component {
103
106
  searchPlaceholder={'Search a language'}
104
107
  searchStyle={{color: Colors.blue30, placeholderTextColor: Colors.grey50}}
105
108
  // onSearchChange={value => console.warn('value', value)}
109
+ migrateTextField
106
110
  >
107
111
  {_.map(longOptions, option => (
108
112
  <Picker.Item key={option.value} value={option} label={''} disabled={option.disabled}/>
@@ -115,7 +119,8 @@ export default class PickerScreen extends Component {
115
119
  onChange={items => this.setState({languages: items})}
116
120
  mode={Picker.modes.MULTI}
117
121
  selectionLimit={3}
118
- rightIconSource={dropdown}
122
+ trailingAccessory={dropdownIcon}
123
+ migrateTextField
119
124
  >
120
125
  {_.map(options, option => (
121
126
  <Picker.Item key={option.value} value={option} label={''} disabled={option.disabled}/>
@@ -152,12 +157,13 @@ export default class PickerScreen extends Component {
152
157
  </Picker>
153
158
 
154
159
  <Picker
155
- title="Custom modal"
160
+ label="Custom modal"
156
161
  placeholder="Pick multiple Languages"
157
162
  value={this.state.customModalValues}
158
163
  onChange={items => this.setState({customModalValues: items})}
159
164
  mode={Picker.modes.MULTI}
160
- rightIconSource={dropdown}
165
+ trailingAccessory={dropdownIcon}
166
+ migrateTextField
161
167
  renderCustomModal={this.renderDialog}
162
168
  >
163
169
  {_.map(options, option => (
@@ -171,7 +177,7 @@ export default class PickerScreen extends Component {
171
177
  ))}
172
178
  </Picker>
173
179
 
174
- <Text marginB-10 text70>
180
+ <Text marginB-10 text70 $textDefault>
175
181
  Custom Picker:
176
182
  </Text>
177
183
  <Picker
@@ -180,8 +186,12 @@ export default class PickerScreen extends Component {
180
186
  renderPicker={(_value?: any, label?: string) => {
181
187
  return (
182
188
  <View row>
183
- <Icon style={{marginRight: 1, height: 16, resizeMode: 'contain'}} source={tagIcon}/>
184
- <Text grey10 text80>
189
+ <Icon
190
+ style={{marginRight: 1, height: 16, resizeMode: 'contain'}}
191
+ source={tagIcon}
192
+ tintColor={Colors.$iconDefault}
193
+ />
194
+ <Text $textDefault text80>
185
195
  {label} Posts
186
196
  </Text>
187
197
  </View>
@@ -193,11 +203,11 @@ export default class PickerScreen extends Component {
193
203
  ))}
194
204
  </Picker>
195
205
 
196
- <Text text60 marginT-s5>
206
+ <Text text60 marginT-s5 $textDefault>
197
207
  Migrated Pickers
198
208
  </Text>
199
209
 
200
- <Text marginT-20 marginB-10 text70>
210
+ <Text marginT-20 marginB-10 text70 $textDefault>
201
211
  Custom Picker Items:
202
212
  </Text>
203
213
  <Picker
@@ -214,12 +224,12 @@ export default class PickerScreen extends Component {
214
224
  {contact ? (
215
225
  <>
216
226
  <Avatar size={30} source={{uri: contact?.thumbnail}}/>
217
- <Text text70 marginL-10>
227
+ <Text text70 marginL-10 $textDefault>
218
228
  {contact?.name}
219
229
  </Text>
220
230
  </>
221
231
  ) : (
222
- <Text text70 grey30>
232
+ <Text text70 $textNeutral>
223
233
  Pick a contact
224
234
  </Text>
225
235
  )}
@@ -239,7 +249,7 @@ export default class PickerScreen extends Component {
239
249
  style={{
240
250
  height: 56,
241
251
  borderBottomWidth: 1,
242
- borderColor: Colors.grey80
252
+ borderColor: Colors.$backgroundNeutral
243
253
  }}
244
254
  paddingH-15
245
255
  row
@@ -248,11 +258,11 @@ export default class PickerScreen extends Component {
248
258
  >
249
259
  <View row centerV>
250
260
  <Avatar size={35} source={{uri: contact?.thumbnail}}/>
251
- <Text marginL-10 text70 grey10>
261
+ <Text marginL-10 text70 $textDefault>
252
262
  {contact?.name}
253
263
  </Text>
254
264
  </View>
255
- {props.isSelected && <Icon source={Assets.icons.check}/>}
265
+ {props.isSelected && <Icon source={Assets.icons.check} tintColor={Colors.$iconDefault}/>}
256
266
  </View>
257
267
  );
258
268
  }}
@@ -0,0 +1,64 @@
1
+ import _ from 'lodash';
2
+ import React, {useCallback} from 'react';
3
+ import {StyleSheet} from 'react-native';
4
+ import {SortableList, View, TouchableOpacity, Text, Icon, Assets, Colors} from 'react-native-ui-lib';
5
+ import {renderHeader} from '../ExampleScreenPresenter';
6
+
7
+ interface Item {
8
+ originalIndex: number;
9
+ }
10
+
11
+ const data = _.times(30, index => {
12
+ return {
13
+ originalIndex: index
14
+ };
15
+ });
16
+
17
+ const SortableListScreen = () => {
18
+ const keyExtractor = useCallback((item: Item) => {
19
+ return `${item.originalIndex}`;
20
+ }, []);
21
+
22
+ const onOrderChange = useCallback((newData: Item[]) => {
23
+ console.log('New order:', newData);
24
+ }, []);
25
+
26
+ const renderItem = useCallback(({item, index: _index}: {item: Item; index: number}) => {
27
+ return (
28
+ <TouchableOpacity
29
+ style={styles.itemContainer}
30
+ onPress={() => console.log('Original index is', item.originalIndex)}
31
+ // overriding the BG color to anything other than white will cause Android's elevation to fail
32
+ // backgroundColor={Colors.red30}
33
+ centerV
34
+ marginH-page
35
+ >
36
+ <View flex row spread centerV>
37
+ <Icon source={Assets.icons.demo.drag} tintColor={Colors.$iconDisabled}/>
38
+ <Text center $textDefault>
39
+ {item.originalIndex}
40
+ </Text>
41
+ <Icon source={Assets.icons.demo.chevronRight} tintColor={Colors.$iconDefault}/>
42
+ </View>
43
+ </TouchableOpacity>
44
+ );
45
+ }, []);
46
+
47
+ return (
48
+ <View flex bg-$backgroundDefault>
49
+ {renderHeader('Sortable List', {'margin-10': true})}
50
+ <View flex useSafeArea>
51
+ <SortableList data={data} renderItem={renderItem} keyExtractor={keyExtractor} onOrderChange={onOrderChange}/>
52
+ </View>
53
+ </View>
54
+ );
55
+ };
56
+
57
+ export default SortableListScreen;
58
+ const styles = StyleSheet.create({
59
+ itemContainer: {
60
+ height: 52,
61
+ borderColor: Colors.$outlineDefault,
62
+ borderBottomWidth: 1
63
+ }
64
+ });
@@ -174,7 +174,7 @@ class TabControllerScreen extends Component<{}, State> {
174
174
  // iconColor={'green'}
175
175
  // selectedIconColor={'blue'}
176
176
  enableShadow
177
- activeBackgroundColor={Colors.$backgroundGeneralLight}
177
+ activeBackgroundColor={Colors.$backgroundPrimaryLight}
178
178
  centerSelected={centerSelected}
179
179
  >
180
180
  {/* {this.renderTabItems()} */}
@@ -0,0 +1,143 @@
1
+ import React, {useCallback, useRef, useState} from 'react';
2
+ import {StyleSheet, ScrollView} from 'react-native';
3
+ import {Assets, Colors, Timeline, View, Card, Text, Button} from 'react-native-ui-lib';
4
+
5
+ const contents = [
6
+ 'CURRENT (default) state with dashed line.\nAligned to title',
7
+ 'SUCCESS state with label.',
8
+ 'ERROR state with icon.',
9
+ 'Custom color with icon and outline.\nAligned to title',
10
+ 'NEXT state with outline.',
11
+ 'NEXT state with circle point and entry point.'
12
+ ];
13
+
14
+ const TimelineScreen = () => {
15
+ const [anchorIndex, setAnchorIndex] = useState(0);
16
+ const [expand, setExpand] = useState(false);
17
+ const anchor = useRef();
18
+
19
+ const onPress = useCallback(() => {
20
+ setAnchorIndex(anchorIndex === 0 ? 1 : 0);
21
+ }, [anchorIndex]);
22
+
23
+ const onPressExpand = useCallback(() => {
24
+ setExpand(!expand);
25
+ }, [expand]);
26
+
27
+ const renderContent = (index = 0, anchorRef?: any) => {
28
+ return (
29
+ <Card padding-page>
30
+ <Text text70BO ref={anchorRef}>
31
+ Step {index + 1}
32
+ </Text>
33
+ <View marginT-5 padding-8 bg-grey70 br30>
34
+ <Text>{contents[index]}</Text>
35
+ <Button marginT-10 size={'small'} label={!expand ? 'Expand' : 'Close'} onPress={onPressExpand}/>
36
+ {expand && <View style={{height: 100, marginTop: 10, backgroundColor: 'red'}}/>}
37
+ </View>
38
+ </Card>
39
+ );
40
+ };
41
+
42
+ return (
43
+ <>
44
+ <View row margin-20 spread>
45
+ <Text h1 $textDefault margin-20>
46
+ Timeline
47
+ </Text>
48
+ <Button margin-20 link size={'small'} label={'Change Points Anchor'} onPress={onPress}/>
49
+ </View>
50
+ <ScrollView contentContainerStyle={styles.container}>
51
+ <Timeline
52
+ // key={String(expand)}
53
+ // topLine={{
54
+ // type: Timeline.lineTypes.DASHED,
55
+ // entry: true
56
+ // }}
57
+ bottomLine={{type: Timeline.lineTypes.DASHED}}
58
+ // bottomLine={{state: Timeline.states.SUCCESS}}
59
+ point={{anchorRef: anchorIndex === 0 ? anchor : undefined}}
60
+ >
61
+ {renderContent(0, anchorIndex === 0 ? anchor : undefined)}
62
+ </Timeline>
63
+ <Timeline
64
+ topLine={{type: Timeline.lineTypes.DASHED}}
65
+ bottomLine={{state: Timeline.states.SUCCESS}}
66
+ point={{
67
+ state: Timeline.states.SUCCESS,
68
+ label: 2,
69
+ anchorRef: anchorIndex === 1 ? anchor : undefined
70
+ }}
71
+ >
72
+ {renderContent(1, anchorIndex === 1 ? anchor : undefined)}
73
+ </Timeline>
74
+
75
+ <Timeline
76
+ topLine={{state: Timeline.states.SUCCESS}}
77
+ bottomLine={{state: Timeline.states.ERROR}}
78
+ point={{
79
+ state: Timeline.states.ERROR,
80
+ icon: Assets.icons.demo.settings
81
+ }}
82
+ >
83
+ {renderContent(2)}
84
+ </Timeline>
85
+ <Timeline
86
+ topLine={{state: Timeline.states.ERROR}}
87
+ bottomLine={{
88
+ type: Timeline.lineTypes.DASHED,
89
+ color: Colors.orange40
90
+ }}
91
+ point={{
92
+ type: Timeline.pointTypes.OUTLINE,
93
+ color: Colors.orange40,
94
+ icon: Assets.icons.demo.camera
95
+ }}
96
+ >
97
+ {renderContent(3)}
98
+ </Timeline>
99
+ <Timeline
100
+ topLine={{
101
+ type: Timeline.lineTypes.DASHED,
102
+ color: Colors.orange40
103
+ }}
104
+ bottomLine={{
105
+ state: Timeline.states.NEXT,
106
+ type: Timeline.lineTypes.DASHED
107
+ }}
108
+ point={{
109
+ state: Timeline.states.NEXT,
110
+ type: Timeline.pointTypes.OUTLINE
111
+ }}
112
+ >
113
+ {renderContent(4)}
114
+ </Timeline>
115
+
116
+ <Timeline
117
+ topLine={{
118
+ state: Timeline.states.NEXT,
119
+ type: Timeline.lineTypes.DASHED
120
+ }}
121
+ bottomLine={{
122
+ state: Timeline.states.NEXT,
123
+ entry: true
124
+ }}
125
+ point={{
126
+ state: Timeline.states.NEXT,
127
+ type: Timeline.pointTypes.CIRCLE
128
+ }}
129
+ >
130
+ {renderContent(5)}
131
+ </Timeline>
132
+ </ScrollView>
133
+ </>
134
+ );
135
+ };
136
+
137
+ export default TimelineScreen;
138
+
139
+ const styles = StyleSheet.create({
140
+ container: {
141
+ paddingBottom: 20
142
+ }
143
+ });
@@ -46,6 +46,7 @@ export function registerScreens(registrar) {
46
46
  registrar('unicorn.components.SkeletonViewScreen', () => require('./SkeletonViewScreen').default);
47
47
  registrar('unicorn.components.SliderScreen', () => require('./SliderScreen').default);
48
48
  registrar('unicorn.components.SortableGridListScreen', () => require('./SortableGridListScreen').default);
49
+ registrar('unicorn.components.SortableListScreen', () => require('./SortableListScreen').default);
49
50
  registrar('unicorn.components.StackAggregatorScreen', () => require('./StackAggregatorScreen').default);
50
51
  registrar('unicorn.components.StepperScreen', () => require('./StepperScreen').default);
51
52
  registrar('unicorn.components.SwitchScreen', () => require('./SwitchScreen').default);
@@ -62,6 +63,7 @@ export function registerScreens(registrar) {
62
63
  registrar('unicorn.lists.BasicListScreen', () => require('./BasicListScreen').default);
63
64
  registrar('unicorn.lists.ContactsListScreen', () => require('./ContactsListScreen').default);
64
65
  registrar('unicorn.lists.ConversationListScreen', () => require('./ConversationListScreen').default);
66
+ registrar('unicorn.components.TimelineScreen', () => require('./TimelineScreen').default);
65
67
  // Full Screen components
66
68
  registrar('unicorn.screens.EmptyStateScreen', () => require('./EmptyStateScreen').default);
67
69
  registrar('unicorn.components.FaderScreen', () => require('./FaderScreen').default);
@@ -206,6 +206,7 @@ export default class KeyboardAccessoryViewScreen extends PureComponent {
206
206
  revealKeyboardInteractive
207
207
  onRequestShowKeyboard={this.onRequestShowKeyboard}
208
208
  useSafeArea={useSafeArea}
209
+ addBottomView={useSafeArea}
209
210
  // usesBottomTabs={!isModal}
210
211
  />
211
212
  </View>