unicorn-demo-app 6.22.3 → 6.23.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
|
@@ -43,7 +43,8 @@ export const navigationData = {
|
|
|
43
43
|
screen: 'unicorn.components.SharedTransitionScreen'
|
|
44
44
|
},
|
|
45
45
|
{title: 'Stack Aggregator', tags: 'stack aggregator', screen: 'unicorn.components.StackAggregatorScreen'},
|
|
46
|
-
{title: 'Wheel Picker Dialog', tags: 'wheel picker dialog', screen: 'unicorn.components.WheelPickerDialogScreen'}
|
|
46
|
+
{title: 'Wheel Picker Dialog', tags: 'wheel picker dialog', screen: 'unicorn.components.WheelPickerDialogScreen'},
|
|
47
|
+
{title: 'Marquee', tags: 'sliding text', screen: 'unicorn.components.MarqueeScreen'}
|
|
47
48
|
]
|
|
48
49
|
},
|
|
49
50
|
Form: {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import React, {Component} from 'react';
|
|
3
|
+
import {StyleSheet} from 'react-native';
|
|
4
|
+
import {Marquee, MarqueeDirections, Text, View, Spacings} from 'react-native-ui-lib';
|
|
5
|
+
import {renderBooleanOption, renderMultipleSegmentOptions} from '../ExampleScreenPresenter';
|
|
6
|
+
|
|
7
|
+
export default class MarqueeScreen extends Component<{}> {
|
|
8
|
+
state = {
|
|
9
|
+
duration: 5000,
|
|
10
|
+
directionHorizontal: true,
|
|
11
|
+
directionVertical: true,
|
|
12
|
+
numOfReps: -1
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
renderHorizontalSection = () => {
|
|
16
|
+
const {directionHorizontal, numOfReps, duration} = this.state;
|
|
17
|
+
return (
|
|
18
|
+
<View marginV-s3 center>
|
|
19
|
+
<Text h2 marginB-s2 $textDefault>
|
|
20
|
+
Horizontal
|
|
21
|
+
</Text>
|
|
22
|
+
<Text h3 marginV-s2 $textDefault>
|
|
23
|
+
Marquee: {directionHorizontal ? MarqueeDirections.LEFT : MarqueeDirections.RIGHT}
|
|
24
|
+
</Text>
|
|
25
|
+
<Marquee
|
|
26
|
+
key={`${directionHorizontal}-${duration}-${numOfReps}`}
|
|
27
|
+
label={'Hey there, this is the new Marquee component from UILIB!'}
|
|
28
|
+
direction={directionHorizontal ? MarqueeDirections.LEFT : MarqueeDirections.RIGHT}
|
|
29
|
+
duration={duration}
|
|
30
|
+
numberOfReps={numOfReps}
|
|
31
|
+
containerStyle={[styles.containerHorizontal, styles.horizontal]}
|
|
32
|
+
/>
|
|
33
|
+
</View>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
renderVerticalSection = () => {
|
|
38
|
+
const {directionVertical, numOfReps, duration} = this.state;
|
|
39
|
+
return (
|
|
40
|
+
<View marginV-s3 center>
|
|
41
|
+
<Text h2 marginB-s2 $textDefault>
|
|
42
|
+
Vertical
|
|
43
|
+
</Text>
|
|
44
|
+
<Text h3 marginV-s2 $textDefault>
|
|
45
|
+
Marquee: {directionVertical ? MarqueeDirections.UP : MarqueeDirections.DOWN}
|
|
46
|
+
</Text>
|
|
47
|
+
<Marquee
|
|
48
|
+
label={
|
|
49
|
+
'Hey there, this is the new Marquee! Hey there, this is the new Marquee! Hey there, this is the new Marquee! Hey there, this is the new Marquee!'
|
|
50
|
+
}
|
|
51
|
+
labelStyle={styles.label}
|
|
52
|
+
key={`${directionVertical}-${duration}-${numOfReps}`}
|
|
53
|
+
direction={directionVertical ? MarqueeDirections.UP : MarqueeDirections.DOWN}
|
|
54
|
+
duration={duration}
|
|
55
|
+
numberOfReps={numOfReps}
|
|
56
|
+
containerStyle={[styles.containerHorizontal, styles.vertical]}
|
|
57
|
+
/>
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
render() {
|
|
63
|
+
return (
|
|
64
|
+
<View flex padding-page>
|
|
65
|
+
<Text h1 center margin-20 $textDefault>
|
|
66
|
+
Marquee
|
|
67
|
+
</Text>
|
|
68
|
+
<View>
|
|
69
|
+
{renderMultipleSegmentOptions.call(this, 'Duration (optional)', 'duration', [
|
|
70
|
+
{label: '3000', value: 3000},
|
|
71
|
+
{label: '5000', value: 5000},
|
|
72
|
+
{label: '10000', value: 10000}
|
|
73
|
+
])}
|
|
74
|
+
{renderMultipleSegmentOptions.call(this, 'Number Of Reps', 'numOfReps', [
|
|
75
|
+
{label: 'Infinite', value: -1},
|
|
76
|
+
{label: '1', value: 1},
|
|
77
|
+
{label: '3', value: 3},
|
|
78
|
+
{label: '5', value: 5}
|
|
79
|
+
])}
|
|
80
|
+
<View marginV-s2>
|
|
81
|
+
{renderBooleanOption.call(this, 'Direction Horizontal: Left To Right/Right To Left', 'directionHorizontal')}
|
|
82
|
+
{renderBooleanOption.call(this, 'Direction Vertical: Bottom To Up/Up To Bottom', 'directionVertical')}
|
|
83
|
+
</View>
|
|
84
|
+
</View>
|
|
85
|
+
{this.renderHorizontalSection()}
|
|
86
|
+
{this.renderVerticalSection()}
|
|
87
|
+
</View>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
containerHorizontal: {
|
|
94
|
+
borderWidth: 1,
|
|
95
|
+
borderColor: 'black',
|
|
96
|
+
marginVertical: Spacings.s2
|
|
97
|
+
},
|
|
98
|
+
horizontal: {width: 200},
|
|
99
|
+
vertical: {width: 250, height: 100, alignItems: 'center'},
|
|
100
|
+
containerVertical: {borderWidth: 1, borderColor: 'black', marginVertical: Spacings.s2},
|
|
101
|
+
label: {alignSelf: 'center'}
|
|
102
|
+
});
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import React, {useCallback, useState, useRef} from 'react';
|
|
3
3
|
import {StyleSheet} from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
SortableList,
|
|
6
|
+
SortableListItemProps,
|
|
7
|
+
View,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
Text,
|
|
10
|
+
Icon,
|
|
11
|
+
Assets,
|
|
12
|
+
Colors,
|
|
13
|
+
Button
|
|
14
|
+
} from 'react-native-ui-lib';
|
|
5
15
|
import {renderHeader} from '../ExampleScreenPresenter';
|
|
6
16
|
|
|
7
|
-
interface Item {
|
|
8
|
-
|
|
9
|
-
id: string;
|
|
17
|
+
interface Item extends SortableListItemProps {
|
|
18
|
+
text: string;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
|
-
const data = _.times(30, index => {
|
|
21
|
+
const data: Item[] = _.times(30, index => {
|
|
22
|
+
let text = `${index}`;
|
|
23
|
+
if (index === 3) {
|
|
24
|
+
text = 'Locked item';
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
return {
|
|
14
|
-
|
|
15
|
-
id: `${index}
|
|
28
|
+
text,
|
|
29
|
+
id: `${index}`,
|
|
30
|
+
locked: index === 3
|
|
16
31
|
};
|
|
17
32
|
});
|
|
18
33
|
|
|
@@ -57,23 +72,26 @@ const SortableListScreen = () => {
|
|
|
57
72
|
|
|
58
73
|
const renderItem = useCallback(({item, index: _index}: {item: Item; index: number}) => {
|
|
59
74
|
const isSelected = selectedItems.includes(item);
|
|
75
|
+
const {locked} = item;
|
|
76
|
+
const Container = locked ? View : TouchableOpacity;
|
|
60
77
|
return (
|
|
61
|
-
<
|
|
78
|
+
<Container
|
|
62
79
|
style={[styles.itemContainer, isSelected && styles.selectedItemContainer]}
|
|
63
80
|
onPress={() => toggleItemSelection(item)}
|
|
64
81
|
// overriding the BG color to anything other than white will cause Android's elevation to fail
|
|
65
82
|
// backgroundColor={Colors.red30}
|
|
66
83
|
centerV
|
|
84
|
+
centerH={locked}
|
|
67
85
|
paddingH-page
|
|
68
86
|
>
|
|
69
87
|
<View flex row spread centerV>
|
|
70
|
-
<Icon source={Assets.icons.demo.drag} tintColor={Colors.$iconDisabled}/>
|
|
71
|
-
<Text center $textDefault>
|
|
72
|
-
{item.
|
|
88
|
+
{!locked && <Icon source={Assets.icons.demo.drag} tintColor={Colors.$iconDisabled}/>}
|
|
89
|
+
<Text center $textDefault={!locked} $textNeutralLight={locked}>
|
|
90
|
+
{item.text}
|
|
73
91
|
</Text>
|
|
74
|
-
<Icon source={Assets.icons.demo.chevronRight} tintColor={Colors.$iconDefault}/>
|
|
92
|
+
{!locked && <Icon source={Assets.icons.demo.chevronRight} tintColor={Colors.$iconDefault}/>}
|
|
75
93
|
</View>
|
|
76
|
-
</
|
|
94
|
+
</Container>
|
|
77
95
|
);
|
|
78
96
|
},
|
|
79
97
|
[selectedItems, toggleItemSelection]);
|
|
@@ -30,6 +30,7 @@ export function registerScreens(registrar) {
|
|
|
30
30
|
registrar('unicorn.components.GridViewScreen', () => require('./GridViewScreen').default);
|
|
31
31
|
registrar('unicorn.components.KeyboardAwareScrollViewScreen', () => require('./KeyboardAwareScrollViewScreen').default);
|
|
32
32
|
registrar('unicorn.components.MaskedInputScreen', () => require('./MaskedInputScreen').default);
|
|
33
|
+
registrar('unicorn.components.MarqueeScreen', () => require('./MarqueeScreen').default);
|
|
33
34
|
registrar('unicorn.components.OverlaysScreen', () => require('./OverlaysScreen').default);
|
|
34
35
|
registrar('unicorn.components.PageControlScreen', () => require('./PageControlScreen').default);
|
|
35
36
|
registrar('unicorn.components.PanDismissibleScreen', () => require('./PanDismissibleScreen').default);
|