unicorn-demo-app 7.3.6 → 7.4.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": "7.3.6",
3
+ "version": "7.4.0",
4
4
  "main": "src/index.js",
5
5
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
6
6
  "license": "MIT",
@@ -10,7 +10,6 @@ const reactions = ['❤️', '😮', '😔', '😂', '😡'];
10
10
  type HintScreenProps = {};
11
11
 
12
12
  export default class HintsScreen extends Component<HintScreenProps> {
13
-
14
13
  state = {
15
14
  showHint: true,
16
15
  useShortMessage: false,
@@ -134,6 +133,7 @@ export default class HintsScreen extends Component<HintScreenProps> {
134
133
  const message = useShortMessage
135
134
  ? 'Add other cool and useful stuff.'
136
135
  : 'Add other cool and useful stuff through adding apps to your visitors to enjoy.';
136
+ const color = !showCustomContent && showReactionStrip ? {color: Colors.$backgroundDefault} : undefined;
137
137
 
138
138
  return (
139
139
  <View flex>
@@ -178,7 +178,7 @@ export default class HintsScreen extends Component<HintScreenProps> {
178
178
  ? this.renderReactionStrip()
179
179
  : undefined
180
180
  }
181
- color={!showCustomContent && showReactionStrip ? Colors.$backgroundDefault : undefined}
181
+ {...color}
182
182
  removePaddings={!showCustomContent && showReactionStrip}
183
183
  enableShadow={enableShadow}
184
184
  testID={'Hint'}
@@ -63,6 +63,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
63
63
  <View bg-violet80 flex style={styles.page}>
64
64
  <Modal.TopBar
65
65
  title="another example"
66
+ subtitle="with a subtitle"
66
67
  onCancel={() => Alert.alert('cancel')}
67
68
  onDone={() => Alert.alert('done')}
68
69
  cancelIcon={null}
@@ -14,7 +14,7 @@ const segments = {
14
14
  },
15
15
  {label: 'Short'}
16
16
  ],
17
- forth: [{label: 'With'}, {label: 'Custom'}, {label: 'Colors'}],
17
+ forth: [{label: 'With'}, {label: 'Custom'}, {label: 'Style'}],
18
18
  fifth: [{label: 'Full'}, {label: 'Width'}],
19
19
  sixth: [{label: 'Full'}, {label: 'Width'}, {label: 'With'}, {label: 'A'}, {label: 'Very Long Segment'}]
20
20
  };
@@ -49,6 +49,8 @@ const SegmentedControlScreen = () => {
49
49
  backgroundColor={Colors.$backgroundInverted}
50
50
  activeBackgroundColor={Colors.$backgroundNeutralIdle}
51
51
  inactiveColor={Colors.$textDisabled}
52
+ style={styles.customStyle}
53
+ segmentsStyle={styles.customSegmentsStyle}
52
54
  />
53
55
  </View>
54
56
  <SegmentedControl
@@ -70,6 +72,13 @@ const SegmentedControlScreen = () => {
70
72
  const styles = StyleSheet.create({
71
73
  container: {
72
74
  marginTop: 20
75
+ },
76
+ customStyle: {
77
+ height: 50,
78
+ width: 300
79
+ },
80
+ customSegmentsStyle: {
81
+ height: 50
73
82
  }
74
83
  });
75
84
 
@@ -157,7 +157,13 @@ export default class SliderScreen extends Component<SliderScreenProps, SliderScr
157
157
  Disabled
158
158
  </Text>
159
159
  <Slider minimumValue={100} maximumValue={200} value={120} containerStyle={styles.slider} disabled/>
160
+ </Fragment>
161
+ );
162
+ }
160
163
 
164
+ renderCustomSlider() {
165
+ return (
166
+ <>
161
167
  <Text $textDefault text70BO marginT-15>
162
168
  Custom with Steps
163
169
  </Text>
@@ -174,7 +180,7 @@ export default class SliderScreen extends Component<SliderScreenProps, SliderScr
174
180
  minimumTrackTintColor={Colors.violet40}
175
181
  maximumTrackTintColor={Colors.violet70}
176
182
  />
177
- </Fragment>
183
+ </>
178
184
  );
179
185
  }
180
186
 
@@ -317,6 +323,7 @@ export default class SliderScreen extends Component<SliderScreenProps, SliderScr
317
323
  {this.renderDefaultSliderExample()}
318
324
  {this.renderNegativeSliderExample()}
319
325
  {this.renderDisabledSliderExample()}
326
+ {this.renderCustomSlider()}
320
327
  {this.renderRangeSliderExample()}
321
328
  {this.renderRangeSliderWithValuesExample()}
322
329
  {this.renderGradientSlidersExample()}
@@ -76,6 +76,7 @@ const SortableListScreen = () => {
76
76
  const Container = locked ? View : TouchableOpacity;
77
77
  return (
78
78
  <Container
79
+ // TODO: fix Android selection color
79
80
  style={[styles.itemContainer, isSelected && styles.selectedItemContainer]}
80
81
  onPress={() => toggleItemSelection(item)}
81
82
  // overriding the BG color to anything other than white will cause Android's elevation to fail
@@ -0,0 +1,22 @@
1
+ import _ from 'lodash';
2
+ import {data} from './MockData';
3
+
4
+ const PAGE_SIZE = 100;
5
+ const FAKE_FETCH_TIME = 1500;
6
+
7
+ class MockServer {
8
+ async getEvents(date: number): Promise<any[]> {
9
+ return new Promise(resolve => {
10
+ const eventIndexByDate = _.findIndex(data, event => {
11
+ return event.start > date;
12
+ });
13
+
14
+ setTimeout(() => {
15
+ const newEvents = _.slice(data, eventIndexByDate - PAGE_SIZE / 2, eventIndexByDate + PAGE_SIZE / 2);
16
+ resolve(newEvents);
17
+ }, FAKE_FETCH_TIME);
18
+ });
19
+ }
20
+ }
21
+
22
+ export default new MockServer();
@@ -1,27 +1,49 @@
1
+ import _ from 'lodash';
1
2
  import React, {Component} from 'react';
2
- import {View, Incubator} from 'react-native-ui-lib';
3
- import {data} from './MockData';
3
+ import {Incubator} from 'react-native-ui-lib';
4
+ import MockServer from './MockServer';
4
5
 
5
6
  export default class CalendarScreen extends Component {
6
- // constructor(props) {
7
- // super(props);
8
-
9
- // setTimeout(() => {
10
- // this.setState({date: 1676026748000});
11
- // }, 2000);
12
- // }
7
+ pageIndex = 0;
13
8
 
14
9
  state = {
15
- date: undefined
10
+ date: new Date().getTime(),
11
+ events: [] as any[],
12
+ showLoader: false
16
13
  };
17
-
14
+
15
+ componentDidMount(): void {
16
+ this.loadEvents(this.state.date);
17
+ }
18
+
19
+ loadEvents = async (date: number) => {
20
+ this.setState({showLoader: true});
21
+ const {events} = this.state;
22
+ const newEvents = await MockServer.getEvents(date);
23
+ this.pageIndex++;
24
+ this.setState({events: _.uniqBy([...events, ...newEvents], e => e.id), showLoader: false});
25
+ };
26
+
27
+ onChangeDate = (date: number) => {
28
+ console.log('Date change: ', date);
29
+ const {events} = this.state;
30
+ if (date < events[0]?.start || date > _.last(events)?.start) {
31
+ console.log('Load new events');
32
+ this.loadEvents(date);
33
+ }
34
+ };
35
+
36
+ onEndReached = (date: number) => {
37
+ console.log('Reached End: ', date);
38
+ this.loadEvents(date);
39
+ };
40
+
18
41
  render() {
42
+ const {date, events, showLoader} = this.state;
19
43
  return (
20
- <View flex>
21
- <Incubator.Calendar data={data} staticHeader initialDate={this.state.date}>
22
- <Incubator.Calendar.Agenda/>
23
- </Incubator.Calendar>
24
- </View>
44
+ <Incubator.Calendar data={events} initialDate={date} onChangeDate={this.onChangeDate} staticHeader>
45
+ <Incubator.Calendar.Agenda onEndReached={this.onEndReached} showLoader={showLoader}/>
46
+ </Incubator.Calendar>
25
47
  );
26
48
  }
27
49
  }
@@ -1,6 +1,6 @@
1
1
  import React, {useState, useRef, useCallback} from 'react';
2
2
  import {StyleSheet, ScrollView} from 'react-native';
3
- import {Constants, Colors, View, Text, Button, Incubator} from 'react-native-ui-lib'; //eslint-disable-line
3
+ import {Constants, Colors, View, Text, Button, Incubator, GradientSlider, ColorSliderGroup} from 'react-native-ui-lib'; //eslint-disable-line
4
4
  import {renderBooleanOption} from '../ExampleScreenPresenter';
5
5
 
6
6
  const VALUE = 20;
@@ -9,6 +9,7 @@ const MIN = 0;
9
9
  const MAX = Constants.screenWidth - 40; // horizontal margins 20
10
10
  const INITIAL_MIN = 30;
11
11
  const INITIAL_MAX = 270;
12
+ const COLOR = Colors.blue30;
12
13
 
13
14
  const IncubatorSliderScreen = () => {
14
15
  const [disableRTL, setDisableRTL] = useState<boolean>(false);
@@ -19,6 +20,9 @@ const IncubatorSliderScreen = () => {
19
20
  const [sliderMinValue, setSliderMinValue] = useState(INITIAL_MIN);
20
21
  const [sliderMaxValue, setSliderMaxValue] = useState(INITIAL_MAX);
21
22
 
23
+ const [color, setColor] = useState(COLOR);
24
+ const [alpha, setAlpha] = useState(1);
25
+
22
26
  const slider = useRef<typeof Incubator.Slider>();
23
27
  const customSlider = useRef<typeof Incubator.Slider>();
24
28
  const negativeSlider = useRef<typeof Incubator.Slider>();
@@ -48,6 +52,15 @@ const IncubatorSliderScreen = () => {
48
52
  setSliderMinValue(value.min);
49
53
  }, []);
50
54
 
55
+ const onGradientValueChange = useCallback((value: string, alpha: number) => {
56
+ setColor(value);
57
+ setAlpha(alpha);
58
+ }, []);
59
+
60
+ const onGroupValueChange = (value: string) => {
61
+ console.log('onGroupValueChange: ', value);
62
+ };
63
+
51
64
  const renderValuesBox = (min: number, max?: number) => {
52
65
  if (max !== undefined) {
53
66
  return (
@@ -179,6 +192,65 @@ const IncubatorSliderScreen = () => {
179
192
  );
180
193
  };
181
194
 
195
+ const renderGradientSlidersExample = () => {
196
+ return (
197
+ <View marginH-20>
198
+ <Text margin-10 text70BL $textDefault>
199
+ Gradient Sliders
200
+ </Text>
201
+ <View row centerV>
202
+ <Text text90 $textNeutral>
203
+ DEFAULT
204
+ </Text>
205
+ <GradientSlider
206
+ color={color}
207
+ containerStyle={styles.gradientSliderContainer}
208
+ onValueChange={onGradientValueChange}
209
+ // @ts-expect-error
210
+ ref={this.gradientSlider}
211
+ migrate
212
+ />
213
+ <View style={styles.box}>
214
+ <View style={{flex: 1, backgroundColor: color, opacity: alpha}}/>
215
+ </View>
216
+ </View>
217
+ <View row centerV>
218
+ <Text text90 $textNeutral>
219
+ HUE
220
+ </Text>
221
+ <GradientSlider
222
+ type={GradientSlider.types.HUE}
223
+ color={COLOR}
224
+ containerStyle={styles.gradientSliderContainer}
225
+ onValueChange={onGradientValueChange}
226
+ migrate
227
+ />
228
+ <View style={styles.box}>
229
+ <View style={{flex: 1, backgroundColor: color}}/>
230
+ </View>
231
+ </View>
232
+ </View>
233
+ );
234
+ };
235
+
236
+ const renderColorSliderGroupExample = () => {
237
+ return (
238
+ <>
239
+ <Text margin-10 text70BL $textDefault>
240
+ Color Slider Group
241
+ </Text>
242
+ <ColorSliderGroup
243
+ initialColor={color}
244
+ sliderContainerStyle={styles.slider}
245
+ containerStyle={styles.group}
246
+ showLabels
247
+ onValueChange={onGroupValueChange}
248
+ migrate
249
+ />
250
+ </>
251
+ );
252
+ };
253
+
182
254
  return (
183
255
  <ScrollView showsVerticalScrollIndicator={false} style={{backgroundColor: Colors.$backgroundDefault}}>
184
256
  <View row spread margin-20>
@@ -196,6 +268,8 @@ const IncubatorSliderScreen = () => {
196
268
  {renderCustomSliderExample()}
197
269
  {renderNegativeSliderExample()}
198
270
  {renderRangeSliderExample()}
271
+ {renderGradientSlidersExample()}
272
+ {renderColorSliderGroupExample()}
199
273
  </ScrollView>
200
274
  );
201
275
  };
@@ -221,5 +295,26 @@ const styles = StyleSheet.create({
221
295
  backgroundColor: Colors.red30,
222
296
  borderWidth: 2,
223
297
  borderColor: Colors.red70
298
+ },
299
+ gradientSliderContainer: {
300
+ flex: 1, // NOTE: to place a slider in a row layout you must set flex in its 'containerStyle'!!!
301
+ marginHorizontal: 20,
302
+ marginVertical: 10
303
+ },
304
+ box: {
305
+ width: 20,
306
+ height: 20,
307
+ borderRadius: 4,
308
+ borderWidth: 1,
309
+ borderColor: Colors.$outlineDefault
310
+ },
311
+ slider: {
312
+ marginVertical: 6
313
+ },
314
+ group: {
315
+ backgroundColor: Colors.$backgroundNeutralMedium,
316
+ padding: 20,
317
+ margin: 20,
318
+ borderRadius: 6
224
319
  }
225
320
  });