unicorn-demo-app 7.43.0-snapshot.7147 → 7.43.0-snapshot.7148

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.43.0-snapshot.7147",
3
+ "version": "7.43.0-snapshot.7148",
4
4
  "main": "src/index.js",
5
5
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
6
6
  "license": "MIT",
@@ -17,11 +17,8 @@ const VERSION_INC = 'patch';
17
17
 
18
18
  function run() {
19
19
  if (!validateEnv()) {
20
- console.log('Do not release demo');
21
20
  return;
22
21
  }
23
-
24
- console.log('Release demo');
25
22
  createNpmRc();
26
23
  versionTagAndPublish();
27
24
  }
@@ -30,11 +27,7 @@ function validateEnv() {
30
27
  if (!process.env.CI) {
31
28
  throw new Error('releasing is only available from CI');
32
29
  }
33
- return (
34
- process.env.BUILDKITE_BRANCH === 'master' ||
35
- process.env.BUILDKITE_BRANCH === 'release' ||
36
- process.env.BUILDKITE_MESSAGE === 'snapshot'
37
- );
30
+ return true;
38
31
  }
39
32
 
40
33
  function createNpmRc() {
package/src/index.js CHANGED
@@ -87,15 +87,6 @@ module.exports = {
87
87
  get PageControlScreen() {
88
88
  return require('./screens/componentScreens/PageControlScreen').default;
89
89
  },
90
- get PanDismissibleScreen() {
91
- return require('./screens/componentScreens/PanDismissibleScreen').default;
92
- },
93
- get PanListenerScreen() {
94
- return require('./screens/componentScreens/PanListenerScreen').default;
95
- },
96
- get PanResponderScreen() {
97
- return require('./screens/componentScreens/PanResponderScreen').default;
98
- },
99
90
  get PickerScreen() {
100
91
  return require('./screens/componentScreens/PickerScreen').default;
101
92
  },
@@ -244,16 +235,13 @@ module.exports = {
244
235
  get SortableGridList() {
245
236
  return require('./screens/componentScreens/SortableGridListScreen').default;
246
237
  },
247
- // Incubator
248
238
  get PanViewScreen() {
249
- return require('./screens/incubatorScreens/PanViewScreen').default;
239
+ return require('./screens/componentScreens/PanViewScreen').default;
250
240
  },
241
+ // Incubator
251
242
  get IncubatorSlider() {
252
243
  return require('./screens/incubatorScreens/IncubatorSliderScreen').default;
253
244
  },
254
- get IncubatorDialog() {
255
- return require('./screens/incubatorScreens/IncubatorDialogScreen').default;
256
- },
257
245
  get IncubatorToast() {
258
246
  return require('./screens/incubatorScreens/IncubatorToastScreen').default;
259
247
  },
@@ -183,16 +183,14 @@ export const navigationData = {
183
183
  title: 'Animations & Gestures',
184
184
  screens: [
185
185
  {title: 'Animated Image', tags: 'animated image', screen: 'unicorn.components.AnimatedImageScreen'},
186
+ {title: 'Card Scanner', tags: 'card scanner process', screen: 'unicorn.animations.CardScannerScreen'},
186
187
  {title: 'Haptic feedback', tags: 'haptic feedback', screen: 'unicorn.components.HapticScreen'},
188
+ {title: 'PanView', tags: 'pan swipe drag', screen: 'unicorn.components.PanViewScreen'},
187
189
  {
188
190
  title: 'ProgressiveImage',
189
191
  tags: 'progressive image cover overlay',
190
192
  screen: 'unicorn.components.ProgressiveImageScreen'
191
- },
192
- {title: 'Card Scanner', tags: 'card scanner process', screen: 'unicorn.animations.CardScannerScreen'},
193
- {title: 'Pan Dismissible', tags: 'pan swipe drag dismiss', screen: 'unicorn.components.PanDismissibleScreen'},
194
- {title: 'Pan Listener', tags: 'pan swipe drag listener', screen: 'unicorn.components.PanListenerScreen'},
195
- {title: 'Pan Responder', tags: 'pan swipe drag responder', screen: 'unicorn.components.PanResponderScreen'}
193
+ }
196
194
  ]
197
195
  },
198
196
  Incubator: {
@@ -201,14 +199,12 @@ export const navigationData = {
201
199
  {title: 'Calendar', tags: 'calendar', screen: 'unicorn.components.IncubatorCalendarScreen'},
202
200
  {title: 'ChipsInput', tags: 'chips input', screen: 'unicorn.components.ChipsInputScreen'},
203
201
  {title: 'Native TouchableOpacity', tags: 'touchable native', screen: 'unicorn.incubator.TouchableOpacityScreen'},
204
- {title: 'Dialog (New)', tags: 'dialog modal popup alert', screen: 'unicorn.incubator.IncubatorDialogScreen'},
205
202
  {title: 'Toast (New)', tags: 'toast', screen: 'unicorn.components.IncubatorToastScreen'},
206
203
  {
207
204
  title: 'ExpandableOverlay',
208
205
  tags: 'text field expandable input picker',
209
206
  screen: 'unicorn.components.IncubatorExpandableOverlayScreen'
210
- },
211
- {title: 'PanView', tags: 'pan swipe drag', screen: 'unicorn.incubator.PanViewScreen'}
207
+ }
212
208
  ]
213
209
  },
214
210
  Inspirations: {
@@ -64,7 +64,6 @@ export default class ActionSheetScreen extends Component {
64
64
  cancelButtonIndex={3}
65
65
  destructiveButtonIndex={0}
66
66
  useNativeIOS={false}
67
- migrateDialog
68
67
  options={[
69
68
  {label: 'option 1', onPress: () => this.pickOption('option 1')},
70
69
  {label: 'option 2', onPress: () => this.pickOption('option 2')},
@@ -80,7 +79,6 @@ export default class ActionSheetScreen extends Component {
80
79
  message={'Message of action sheet'}
81
80
  cancelButtonIndex={3}
82
81
  destructiveButtonIndex={0}
83
- migrateDialog
84
82
  options={[
85
83
  {label: 'option 1', onPress: () => this.pickOption('option 1'), iconSource: collectionsIcon},
86
84
  {label: 'option 2', onPress: () => this.pickOption('option 2'), iconSource: shareIcon},
@@ -62,7 +62,6 @@ export default class DateTimePickerScreen extends Component<{}, State> {
62
62
  <View padding-page>
63
63
  <Text text40>Date Time Picker</Text>
64
64
  <DateTimePicker
65
- migrateDialog
66
65
  containerStyle={{marginVertical: 20}}
67
66
  label={'Date'}
68
67
  placeholder={'Select a date'}
@@ -72,7 +71,6 @@ export default class DateTimePickerScreen extends Component<{}, State> {
72
71
  // value={new Date('October 13, 2014')}
73
72
  />
74
73
  <DateTimePicker
75
- migrateDialog
76
74
  mode={'time'}
77
75
  label={'Time'}
78
76
  placeholder={'Select time'}
@@ -83,14 +81,12 @@ export default class DateTimePickerScreen extends Component<{}, State> {
83
81
  Disabled
84
82
  </Text>
85
83
  <DateTimePicker
86
- migrateDialog
87
84
  containerStyle={{marginBottom: 20}}
88
85
  editable={false}
89
86
  label={'Date'}
90
87
  placeholder={'Select a date'}
91
88
  />
92
89
  <DateTimePicker
93
- migrateDialog
94
90
  editable={false}
95
91
  mode={'time'}
96
92
  label={'Time'}
@@ -111,7 +107,6 @@ export default class DateTimePickerScreen extends Component<{}, State> {
111
107
  </View>
112
108
  </View>
113
109
  <DateTimePicker
114
- migrateDialog
115
110
  containerStyle={{marginVertical: 20}}
116
111
  renderInput={this.renderCustomInput}
117
112
  mode={mode}
@@ -1,7 +1,7 @@
1
1
  import React, {Component} from 'react';
2
2
  import {StyleSheet} from 'react-native';
3
3
  import {FlatList} from 'react-native-gesture-handler';
4
- import {View, Text, Card, Button, Incubator, Colors, Spacings, ModalProps} from 'react-native-ui-lib';
4
+ import {View, Text, Card, Button, Dialog, DialogHeaderProps, Colors, Spacings, ModalProps} from 'react-native-ui-lib';
5
5
 
6
6
  interface Item {
7
7
  value: string;
@@ -31,10 +31,10 @@ const colors: Item[] = [
31
31
  {value: Colors.yellow70, label: 'Yellow70'}
32
32
  ];
33
33
 
34
- export default class IncubatorDialogScreen extends Component {
34
+ export default class DialogScreen extends Component {
35
35
  state = {visible: false};
36
36
  modalProps: ModalProps = {supportedOrientations: ['portrait', 'landscape']};
37
- headerProps: Incubator.DialogHeaderProps = {title: 'Title (swipe here)'};
37
+ headerProps: DialogHeaderProps = {title: 'Title (swipe here)'};
38
38
 
39
39
  renderVerticalItem = ({item}: {item: Item}) => {
40
40
  return (
@@ -67,13 +67,13 @@ export default class IncubatorDialogScreen extends Component {
67
67
  <View bg-$backgroundNeutralLight flex padding-20>
68
68
  <Card height={100} center padding-20>
69
69
  <Text $textDefault text50>
70
- IncubatorDialogScreen
70
+ DialogScreen
71
71
  </Text>
72
72
  </Card>
73
73
  <View flex center>
74
74
  <Button marginV-s5 label="Open Dialog" onPress={this.openDialog}/>
75
75
  </View>
76
- <Incubator.Dialog
76
+ <Dialog
77
77
  useSafeArea
78
78
  visible={visible}
79
79
  onDismiss={this.onDismiss}
@@ -89,7 +89,7 @@ export default class IncubatorDialogScreen extends Component {
89
89
  renderItem={this.renderVerticalItem}
90
90
  keyExtractor={this.keyExtractor}
91
91
  />
92
- </Incubator.Dialog>
92
+ </Dialog>
93
93
  </View>
94
94
  );
95
95
  }
@@ -6,7 +6,7 @@ import {
6
6
  View,
7
7
  Text,
8
8
  Colors,
9
- Incubator,
9
+ PanView,
10
10
  Card,
11
11
  Constants,
12
12
  Modal,
@@ -14,7 +14,6 @@ import {
14
14
  Icon,
15
15
  TouchableOpacity
16
16
  } from 'react-native-ui-lib';
17
- const {PanView} = Incubator;
18
17
 
19
18
  interface Item {
20
19
  value: string;
@@ -5,14 +5,13 @@ import {
5
5
  Assets,
6
6
  Colors,
7
7
  Typography,
8
- Incubator,
8
+ Dialog,
9
9
  View,
10
10
  Text,
11
11
  Button,
12
12
  Icon,
13
13
  Avatar,
14
14
  Picker,
15
- PanningProvider,
16
15
  PickerProps,
17
16
  RenderCustomModalProps,
18
17
  PickerMethods,
@@ -130,7 +129,7 @@ export default class PickerScreen extends Component {
130
129
  renderDialog: PickerProps['renderOverlay'] = (modalProps: RenderCustomModalProps) => {
131
130
  const {visible, children, toggleModal, onDone} = modalProps;
132
131
  return (
133
- <Incubator.Dialog
132
+ <Dialog
134
133
  visible={visible}
135
134
  onDismiss={() => {
136
135
  onDone();
@@ -141,11 +140,11 @@ export default class PickerScreen extends Component {
141
140
  bottom
142
141
  useSafeArea
143
142
  containerStyle={{backgroundColor: Colors.$backgroundDefault}}
144
- direction={PanningProvider.Directions.DOWN}
143
+ direction={Dialog.directions.DOWN}
145
144
  headerProps={{title: 'Custom modal'}}
146
145
  >
147
146
  <ScrollView>{children}</ScrollView>
148
- </Incubator.Dialog>
147
+ </Dialog>
149
148
  );
150
149
  };
151
150
 
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import React, {useCallback, useState} from 'react';
3
- import {View, Text, Incubator, WheelPicker, WheelPickerAlign, Colors, Typography, Button} from 'react-native-ui-lib';
3
+ import {View, Text, Dialog, WheelPicker, WheelPickerAlign, Colors, Typography, Button} from 'react-native-ui-lib';
4
4
 
5
5
  const monthItems = _.map([
6
6
  'January',
@@ -88,7 +88,7 @@ export default () => {
88
88
  <View center marginT-40>
89
89
  <Text h3 marginB-20>Days</Text>
90
90
  <Button size={Button.sizes.small} label={'Pick Days'} onPress={onPickDaysPress}/>
91
- <Incubator.Dialog
91
+ <Dialog
92
92
  width={'90%'}
93
93
  bottom
94
94
  visible={showDialog}
@@ -96,7 +96,7 @@ export default () => {
96
96
  headerProps={{showKnob: false, showDivider: false}}
97
97
  >
98
98
  <WheelPicker initialValue={5} label={'Days'} items={dayItems}/>
99
- </Incubator.Dialog>
99
+ </Dialog>
100
100
  </View>
101
101
  </View>
102
102
  );
@@ -32,10 +32,8 @@ export function registerScreens(registrar) {
32
32
  registrar('unicorn.components.MarqueeScreen', () => require('./MarqueeScreen').default);
33
33
  registrar('unicorn.components.NumberInputScreen', () => require('./NumberInputScreen').default);
34
34
  registrar('unicorn.components.OverlaysScreen', () => require('./OverlaysScreen').default);
35
+ registrar('unicorn.components.PanViewScreen', () => require('./PanViewScreen').default);
35
36
  registrar('unicorn.components.PageControlScreen', () => require('./PageControlScreen').default);
36
- registrar('unicorn.components.PanDismissibleScreen', () => require('./PanDismissibleScreen').default);
37
- registrar('unicorn.components.PanListenerScreen', () => require('./PanListenerScreen').default);
38
- registrar('unicorn.components.PanResponderScreen', () => require('./PanResponderScreen').default);
39
37
  registrar('unicorn.components.PickerScreen', () => require('./PickerScreen').default);
40
38
  registrar('unicorn.animations.ProgressBarScreen', () => require('../componentScreens/ProgressBarScreen').default);
41
39
  registrar('unicorn.components.ProgressiveImageScreen', () => require('./ProgressiveImageScreen').default);
@@ -112,7 +112,6 @@ export default class TextFieldScreen extends Component {
112
112
  useDialog
113
113
  expandableContent={this.renderPickerContent()}
114
114
  dialogProps={{bottom: true, onDismiss: () => console.warn('Dialog is dismissed')}}
115
- migrateDialog
116
115
  >
117
116
  {this.renderColorRow(selectedColor)}
118
117
  </Incubator.ExpandableOverlay>
@@ -1,9 +1,7 @@
1
1
  export function registerScreens(registrar) {
2
2
  registrar('unicorn.components.IncubatorCalendarScreen', () => require('./IncubatorCalendarScreen').default);
3
3
  registrar('unicorn.incubator.TouchableOpacityScreen', () => require('./TouchableOpacityScreen').default);
4
- registrar('unicorn.incubator.IncubatorDialogScreen', () => require('./IncubatorDialogScreen').default);
5
4
  registrar('unicorn.components.IncubatorExpandableOverlayScreen', () => require('./IncubatorExpandableOverlayScreen').default);
6
5
  registrar('unicorn.components.IncubatorToastScreen', () => require('./IncubatorToastScreen').default);
7
- registrar('unicorn.incubator.PanViewScreen', () => require('./PanViewScreen').default);
8
6
  registrar('unicorn.components.IncubatorSliderScreen', () => require('./IncubatorSliderScreen').default);
9
7
  }
@@ -1,343 +0,0 @@
1
- import React, {Component} from 'react';
2
- import {FlatList, ScrollView, StyleSheet, Alert} from 'react-native';
3
- import {
4
- Text,
5
- View,
6
- Button,
7
- Dialog,
8
- Colors,
9
- PanningProvider,
10
- RadioGroup,
11
- RadioButton,
12
- Switch,
13
- Constants
14
- } from 'react-native-ui-lib'; // eslint-disable-line
15
-
16
- export default class DialogScreen extends Component {
17
- constructor(props) {
18
- super(props);
19
-
20
- this.SCROLL_TYPE = {
21
- NONE: 'none',
22
- VERTICAL: 'vertical',
23
- HORIZONTAL: 'horizontal'
24
- };
25
-
26
- this.pannableTitle = {title: 'This is a pannable header Dialog'};
27
- this.title = 'This is a Dialog';
28
- this.supportedOrientations = ['portrait', 'landscape'];
29
- this.colors = [
30
- {value: Colors.red10, label: 'Red10'},
31
- {value: Colors.red30, label: 'Red30'},
32
- {value: Colors.red50, label: 'Red50'},
33
- {value: Colors.red70, label: 'Red70'},
34
- {value: Colors.blue10, label: 'Blue10'},
35
- {value: Colors.blue30, label: 'Blue30'},
36
- {value: Colors.blue50, label: 'Blue50'},
37
- {value: Colors.blue70, label: 'Blue70'},
38
- {value: Colors.purple10, label: 'Purple10'},
39
- {value: Colors.purple30, label: 'Purple30'},
40
- {value: Colors.purple50, label: 'Purple50'},
41
- {value: Colors.purple70, label: 'Purple70'},
42
- {value: Colors.green10, label: 'Green10'},
43
- {value: Colors.green30, label: 'Green30'},
44
- {value: Colors.green50, label: 'Green50'},
45
- {value: Colors.green70, label: 'Green70'},
46
- {value: Colors.yellow10, label: 'Yellow10'},
47
- {value: Colors.yellow30, label: 'Yellow30'},
48
- {value: Colors.yellow50, label: 'Yellow50'},
49
- {value: Colors.yellow70, label: 'Yellow70'}
50
- ];
51
-
52
- this.state = {
53
- panDirection: Dialog.directions.DOWN,
54
- position: 'bottom',
55
- scroll: this.SCROLL_TYPE.NONE,
56
- showHeader: true,
57
- isRounded: true,
58
- showDialog: false,
59
- ignoreBackgroundPress: false
60
- };
61
- }
62
-
63
- titlePressed = ({title}) => {
64
- Alert.alert('Pressed on', title);
65
- };
66
-
67
- setPanDirection = panDirection => {
68
- if (panDirection !== this.state.panDirection) {
69
- this.setState({panDirection});
70
- }
71
- };
72
-
73
- setPosition = position => {
74
- if (position !== this.state.position) {
75
- this.setState({position});
76
- }
77
- };
78
-
79
- setScroll = scroll => {
80
- if (scroll !== this.state.scroll) {
81
- this.setState({scroll});
82
- }
83
- };
84
-
85
- toggleShowHeader = () => {
86
- this.setState({
87
- showHeader: !this.state.showHeader
88
- });
89
- };
90
-
91
- toggleIsRounded = () => {
92
- this.setState({
93
- isRounded: !this.state.isRounded
94
- });
95
- };
96
-
97
- toggleIgnoreBackgroundPress = () => {
98
- this.setState({
99
- ignoreBackgroundPress: !this.state.ignoreBackgroundPress
100
- });
101
- };
102
-
103
- showDialog = () => {
104
- this.setState({showDialog: true});
105
- };
106
-
107
- hideDialog = () => {
108
- this.setState({showDialog: false});
109
- };
110
-
111
- getWarning = () => {
112
- const {showHeader, scroll, panDirection} = this.state;
113
- if (!showHeader && scroll !== this.SCROLL_TYPE.NONE) {
114
- return (
115
- <Text color={Colors.$textDangerLight}>It is recommended to have pannable header with scrollable content</Text>
116
- );
117
- } else if (showHeader && panDirection !== Dialog.directions.DOWN) {
118
- return <Text color={Colors.$textDangerLight}>It is recommended to have pannable header with direction=down</Text>;
119
- }
120
- };
121
-
122
- getMessage = () => {
123
- const {panDirection, position, scroll} = this.state;
124
-
125
- return `Panning direction: ${panDirection ? panDirection : 'none'}
126
- Position: ${position ? position : 'center'}
127
- Scroll: ${scroll}`;
128
- };
129
-
130
- renderPannableHeader = props => {
131
- const {title} = props;
132
- return (
133
- <View>
134
- <View margin-20>
135
- <Text $textDefault>{title}</Text>
136
- </View>
137
- <View height={2} bg-grey70/>
138
- </View>
139
- );
140
- };
141
-
142
- renderPlainContent = () => {
143
- return (
144
- <View margin-20 right>
145
- <Button text60 label="Done" link onPress={this.hideDialog}/>
146
- </View>
147
- );
148
- };
149
-
150
- keyExtractor = item => {
151
- return item.value;
152
- };
153
-
154
- renderVerticalItem = ({item: color}) => {
155
- return (
156
- <Text $textDefault text50 margin-20 color={color.value}>
157
- {color.label}
158
- </Text>
159
- );
160
- };
161
-
162
- renderVerticalScroll = () => {
163
- return (
164
- <FlatList
165
- showsVerticalScrollIndicator={false}
166
- style={styles.verticalScroll}
167
- data={this.colors}
168
- renderItem={this.renderVerticalItem}
169
- keyExtractor={this.keyExtractor}
170
- />
171
- );
172
- };
173
-
174
- renderHorizontalItem = ({item: color}) => {
175
- return <View flex width={100} height={1000} style={{backgroundColor: color.value}}/>;
176
- };
177
-
178
- renderHorizontalScroll = () => {
179
- return (
180
- <View marginT-20 pointerEvents="box-none">
181
- <FlatList
182
- horizontal
183
- showsHorizontalScrollIndicator={false}
184
- data={this.colors}
185
- renderItem={this.renderHorizontalItem}
186
- keyExtractor={this.keyExtractor}
187
- />
188
- <View row pointerEvents="none" style={styles.horizontalTextContainer}>
189
- <Text>
190
- {'\u25c0'} Scroll me {'\u25b6'}
191
- </Text>
192
- </View>
193
- </View>
194
- );
195
- };
196
-
197
- renderContent = () => {
198
- const {scroll, showHeader} = this.state;
199
-
200
- let content;
201
- switch (scroll) {
202
- case this.SCROLL_TYPE.VERTICAL:
203
- content = this.renderVerticalScroll();
204
- break;
205
- case this.SCROLL_TYPE.HORIZONTAL:
206
- content = this.renderHorizontalScroll();
207
- break;
208
- case this.SCROLL_TYPE.NONE:
209
- default:
210
- content = this.renderPlainContent();
211
- break;
212
- }
213
-
214
- const data = (
215
- <View spread flex={scroll !== this.SCROLL_TYPE.NONE}>
216
- <View marginT-20 marginH-20>
217
- {!showHeader && <Text $textDefault text50>{this.title}</Text>}
218
- <Text $textDefault marginT-20={!showHeader}>{this.getMessage()}</Text>
219
- {this.getWarning()}
220
- </View>
221
- {content}
222
- </View>
223
- );
224
-
225
- return data;
226
- };
227
-
228
- getDialogKey = height => {
229
- const {position} = this.state;
230
- return `dialog-key-${position}-${height}`;
231
- };
232
-
233
- renderDialog = () => {
234
- const {showDialog, panDirection, position, scroll, showHeader, isRounded, ignoreBackgroundPress} = this.state;
235
- const renderPannableHeader = showHeader ? this.renderPannableHeader : undefined;
236
- const height = scroll !== this.SCROLL_TYPE.NONE ? '70%' : undefined;
237
-
238
- return (
239
- <Dialog
240
- useSafeArea
241
- key={this.getDialogKey(height)}
242
- top={position === 'top'}
243
- bottom={position === 'bottom'}
244
- height={height}
245
- panDirection={panDirection}
246
- containerStyle={isRounded ? styles.roundedDialog : styles.dialog}
247
- visible={showDialog}
248
- onDismiss={this.hideDialog}
249
- renderPannableHeader={renderPannableHeader}
250
- pannableHeaderProps={this.pannableTitle}
251
- supportedOrientations={this.supportedOrientations}
252
- ignoreBackgroundPress={ignoreBackgroundPress}
253
- >
254
- {this.renderContent()}
255
- </Dialog>
256
- );
257
- };
258
-
259
- render() {
260
- const {panDirection, position, scroll, showHeader, isRounded, ignoreBackgroundPress} = this.state;
261
-
262
- return (
263
- <ScrollView>
264
- <View flex padding-12>
265
- <Text $textDefault text30 marginB-20>
266
- Dialog
267
- </Text>
268
-
269
- <RadioGroup marginT-20 initialValue={panDirection} onValueChange={this.setPanDirection}>
270
- <Text $textDefault>Panning Direction:</Text>
271
- <View row marginV-10>
272
- <RadioButton value={null} label={'None'}/>
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
- </View>
278
- </RadioGroup>
279
-
280
- <RadioGroup marginT-20 initialValue={position} onValueChange={this.setPosition}>
281
- <Text $textDefault>Position:</Text>
282
- <View row marginV-10>
283
- <RadioButton value={'top'} label={'Top'}/>
284
- <RadioButton value={null} label={'Center'} marginL-10/>
285
- <RadioButton value={'bottom'} label={'Bottom'} marginL-10/>
286
- </View>
287
- </RadioGroup>
288
-
289
- <RadioGroup marginT-20 initialValue={scroll} onValueChange={this.setScroll}>
290
- <Text $textDefault>Scroll:</Text>
291
- <View row marginV-10>
292
- <RadioButton value={this.SCROLL_TYPE.NONE} label={'None'}/>
293
- <RadioButton value={this.SCROLL_TYPE.VERTICAL} label={'Vertical'} marginL-10/>
294
- <RadioButton value={this.SCROLL_TYPE.HORIZONTAL} label={'Horizontal'} marginL-10/>
295
- </View>
296
- </RadioGroup>
297
-
298
- <View row marginT-20 centerV>
299
- <Text $textDefault>Toggle pannable header:</Text>
300
- <Switch value={showHeader} onValueChange={this.toggleShowHeader} marginL-10/>
301
- </View>
302
-
303
- <View row marginT-20 centerV>
304
- <Text $textDefault>Add some style:</Text>
305
- <Switch value={isRounded} onValueChange={this.toggleIsRounded} marginL-10/>
306
- </View>
307
-
308
- <View row marginT-20 centerV>
309
- <Text $textDefault>Ignore Background Press:</Text>
310
- <Switch value={ignoreBackgroundPress} onValueChange={this.toggleIgnoreBackgroundPress} marginL-10/>
311
- </View>
312
-
313
- <Button marginT-50 label={'Show dialog'} onPress={this.showDialog}/>
314
-
315
- {this.renderDialog()}
316
- </View>
317
- </ScrollView>
318
- );
319
- }
320
- }
321
-
322
- const styles = StyleSheet.create({
323
- dialog: {
324
- backgroundColor: Colors.$backgroundDefault
325
- },
326
- roundedDialog: {
327
- backgroundColor: Colors.$backgroundDefault,
328
- marginBottom: Constants.isIphoneX ? 0 : 20,
329
- borderRadius: 12
330
- },
331
- button: {
332
- margin: 5,
333
- alignSelf: 'flex-start'
334
- },
335
- verticalScroll: {
336
- marginTop: 20
337
- },
338
- horizontalTextContainer: {
339
- alignSelf: 'center',
340
- position: 'absolute',
341
- top: 10
342
- }
343
- });
@@ -1,112 +0,0 @@
1
- import React, {Component} from 'react';
2
- import {StyleSheet} from 'react-native';
3
- import {
4
- Button,
5
- View,
6
- Text,
7
- Switch,
8
- Colors,
9
- Typography,
10
- PanListenerView,
11
- PanningProvider,
12
- PanDismissibleView
13
- } from 'react-native-ui-lib';
14
-
15
- const PAN_LISTENER_VIEW_HEIGHT = 100;
16
-
17
- export default class PanDismissibleScreen extends Component {
18
- state = {
19
- location: {left: 50, top: 50},
20
- isCoupled: true,
21
- key: false
22
- };
23
-
24
- switchExample = () => {
25
- const {isCoupled, location} = this.state;
26
- if (isCoupled) {
27
- this.setState({
28
- isCoupled: false,
29
- location: {left: location.left, top: location.top - PAN_LISTENER_VIEW_HEIGHT}
30
- });
31
- } else {
32
- this.setState({
33
- isCoupled: true,
34
- location: {left: location.left, top: location.top + PAN_LISTENER_VIEW_HEIGHT}
35
- });
36
- }
37
- };
38
-
39
- reset = () => {
40
- this.setState({key: !this.state.key});
41
- };
42
-
43
- renderPanListener = () => {
44
- return (
45
- <PanListenerView style={styles.panListener}>
46
- <Text style={styles.largeText}>Drag\Swipe here</Text>
47
- </PanListenerView>
48
- );
49
- };
50
-
51
- render() {
52
- const {isCoupled, key} = this.state;
53
- const panListener = this.renderPanListener();
54
-
55
- return (
56
- <View flex bg-grey80>
57
- <Text style={styles.largeText}>Pan Dismissible</Text>
58
- <View style={styles.container}>
59
- <Switch value={isCoupled} onValueChange={this.switchExample} style={styles.switch}/>
60
- <Text style={styles.smallText}>{isCoupled ? 'Coupled' : 'Uncoupled'}</Text>
61
- </View>
62
- <Button label="Reset" size={Button.sizes.medium} outline style={styles.button} onPress={this.reset}/>
63
- <View centerH>
64
- <PanningProvider>
65
- {!isCoupled && panListener}
66
- <PanDismissibleView
67
- key={key.toString()}
68
- style={[styles.panDismissible, {marginTop: isCoupled ? PAN_LISTENER_VIEW_HEIGHT : undefined}]}
69
- >
70
- {isCoupled && panListener}
71
- </PanDismissibleView>
72
- </PanningProvider>
73
- </View>
74
- </View>
75
- );
76
- }
77
- }
78
-
79
- const styles = StyleSheet.create({
80
- largeText: {
81
- ...Typography.text50,
82
- margin: 20
83
- },
84
- container: {
85
- flexDirection: 'row',
86
- marginBottom: 20,
87
- alignSelf: 'center'
88
- },
89
- panDismissible: {
90
- width: 250,
91
- height: 250,
92
- backgroundColor: Colors.blue30
93
- },
94
- panListener: {
95
- width: '100%',
96
- height: PAN_LISTENER_VIEW_HEIGHT,
97
- backgroundColor: Colors.blue60,
98
- justifyContent: 'center'
99
- },
100
- smallText: {
101
- ...Typography.text70,
102
- marginLeft: 20
103
- },
104
- switch: {
105
- marginLeft: 20,
106
- alignSelf: 'center'
107
- },
108
- button: {
109
- alignSelf: 'center',
110
- marginBottom: 20
111
- }
112
- });
@@ -1,63 +0,0 @@
1
- import React, {Component} from 'react';
2
- import {View, Text, PanListenerView, PanDirectionsProps, PanAmountsProps} from 'react-native-ui-lib';
3
-
4
- export default class PanListenerScreen extends Component {
5
- state = {
6
- locationText: '',
7
- endType: ''
8
- };
9
-
10
- onDrag = ({directions}: ({directions: PanDirectionsProps, deltas: PanAmountsProps})) => {
11
- this.setState({locationText: `Dragged: ${directions.x}, ${directions.y}`});
12
- };
13
-
14
- onSwipe = ({directions}: ({directions: PanDirectionsProps, velocities: PanAmountsProps})) => {
15
- this.setState({locationText: `Swiped: ${directions.x}, ${directions.y}`});
16
- };
17
-
18
- onPanStart = () => {
19
- this.setState({endType: 'Panning'});
20
- };
21
-
22
- onPanRelease = () => {
23
- this.setState({endType: 'Released'});
24
- };
25
-
26
- onPanTerminated = () => {
27
- this.setState({endType: 'Terminated'});
28
- };
29
-
30
- render() {
31
- const {locationText, endType} = this.state;
32
-
33
- return (
34
- <View flex bg-grey80>
35
- <Text text50 margin-40>
36
- Pan Listener
37
- </Text>
38
- <PanListenerView
39
- bg-grey70
40
- centerV
41
- height={300}
42
- width="100%"
43
- // directions={[PanningProvider.Directions.UP, PanningProvider.Directions.DOWN]}
44
- onDrag={this.onDrag}
45
- onSwipe={this.onSwipe}
46
- onPanStart={this.onPanStart}
47
- onPanRelease={this.onPanRelease}
48
- onPanTerminated={this.onPanTerminated}
49
- >
50
- <Text text50 margin-40>
51
- Drag\swipe here
52
- </Text>
53
- </PanListenerView>
54
- <Text text50 margin-40>
55
- {locationText}
56
- </Text>
57
- <Text text50 margin-40>
58
- {endType}
59
- </Text>
60
- </View>
61
- );
62
- }
63
- }
@@ -1,99 +0,0 @@
1
- import _ from 'lodash';
2
- import React, {Component} from 'react';
3
- import {StyleSheet} from 'react-native';
4
- import {
5
- View,
6
- Text,
7
- Switch,
8
- Colors,
9
- Typography,
10
- PanListenerView,
11
- PanningProvider,
12
- PanResponderView
13
- } from 'react-native-ui-lib';
14
-
15
- const PAN_LISTENER_VIEW_HEIGHT = 100;
16
-
17
- export default class PanResponderScreen extends Component {
18
- state = {
19
- location: {left: 50, top: 50},
20
- isCoupled: false
21
- };
22
-
23
- switchExample = () => {
24
- const {isCoupled, location} = this.state;
25
- if (isCoupled) {
26
- this.setState({
27
- isCoupled: false,
28
- location: {left: location.left, top: location.top - PAN_LISTENER_VIEW_HEIGHT}
29
- });
30
- } else {
31
- this.setState({
32
- isCoupled: true,
33
- location: {left: location.left, top: location.top + PAN_LISTENER_VIEW_HEIGHT}
34
- });
35
- }
36
- };
37
-
38
- renderPanListener = () => {
39
- return (
40
- <PanListenerView style={styles.panListener}>
41
- <Text style={styles.largeText}>Drag here</Text>
42
- </PanListenerView>
43
- );
44
- };
45
-
46
- render() {
47
- const {isCoupled} = this.state;
48
- const panListener = this.renderPanListener();
49
-
50
- return (
51
- <View flex bg-grey80>
52
- <View style={styles.container}>
53
- <Text style={styles.largeText}>Pan Responder</Text>
54
- <Switch value={isCoupled} onValueChange={this.switchExample} style={styles.switch} />
55
- <Text style={styles.smallText}>{isCoupled ? 'Coupled' : 'Uncoupled'}</Text>
56
- </View>
57
- <PanningProvider>
58
- {!isCoupled && panListener}
59
- <PanResponderView
60
- style={[styles.panResponder, {marginTop: isCoupled ? PAN_LISTENER_VIEW_HEIGHT : undefined}]}
61
- >
62
- {isCoupled && panListener}
63
- </PanResponderView>
64
- </PanningProvider>
65
- </View>
66
- );
67
- }
68
- }
69
-
70
- const styles = StyleSheet.create({
71
- container: {
72
- flexDirection: 'row',
73
- height: 50,
74
- alignItems: 'center'
75
- },
76
- panResponder: {
77
- width: 250,
78
- height: 250,
79
- backgroundColor: Colors.blue30
80
- },
81
- panListener: {
82
- width: '100%',
83
- height: PAN_LISTENER_VIEW_HEIGHT,
84
- backgroundColor: Colors.blue60,
85
- justifyContent: 'center'
86
- },
87
- largeText: {
88
- ...Typography.text50,
89
- marginLeft: 40
90
- },
91
- smallText: {
92
- ...Typography.text70,
93
- marginLeft: 20
94
- },
95
- switch: {
96
- marginLeft: 20,
97
- alignSelf: 'center'
98
- }
99
- });