Skip to content

Commit 4b9f11b

Browse files
Picker example for the webDemo (#2622)
* Picker exmaple for the webDemo * new picker dialog example * Fix svg example * fixed review comments --------- Co-authored-by: lidord-wix <[email protected]>
1 parent fd15874 commit 4b9f11b

File tree

2 files changed

+106
-28
lines changed

2 files changed

+106
-28
lines changed

webDemo/src/App.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ function App() {
358358
return (
359359
<View flex>
360360
<ScrollView>
361-
<View style={styles.header}>
361+
<View padding-page>
362362
<Text style={styles.title}>Welcome to react-native-ui-lib for Web</Text>
363363
</View>
364364

365365
{
366366
itemsToRender.map(({title, FC}: ItemToRender) =>
367367
(
368-
<View style={styles.componentContainer} key={'component_' + title}>
368+
<View bg-grey80 paddingT-s5 paddingB-s5 center style={styles.componentContainer} key={'component_' + title}>
369369
<Text style={styles.compTitle}> {title} </Text>
370370
<FC/>
371371
</View>
@@ -387,14 +387,9 @@ const styles = StyleSheet.create({
387387
padding: 20
388388
},
389389
componentContainer: {
390-
backgroundColor: '#F5FCFF',
391390
width: '100%',
392-
alignItems: 'center',
393-
justifyContent: 'center',
394391
borderColor: 'white',
395-
borderBottomWidth: 5,
396-
paddingBottom: 20,
397-
paddingTop: 20
392+
borderBottomWidth: 5
398393
},
399394
compTitle: {
400395
fontWeight: 'bold',
@@ -409,4 +404,5 @@ const styles = StyleSheet.create({
409404
textAlign: 'center'
410405
}
411406
});
407+
412408
export default App;

webDemo/src/examples/Picker.tsx

Lines changed: 102 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useState} from 'react';
2-
import Picker from 'react-native-ui-lib/Picker';
3-
import {Colors} from 'react-native-ui-lib/style';
2+
import {ScrollView} from 'react-native-gesture-handler';
3+
import {Picker, Colors, View, Text, Incubator, PickerProps, PanningProvider} from 'react-native-ui-lib';
44

55
const options = [
66
{label: 'JavaScript', value: 'js'},
@@ -10,28 +10,110 @@ const options = [
1010
{label: 'Perl', value: 'perl'}
1111
];
1212

13-
const PickerWrapper = () => {
13+
const filters = [
14+
{value: 1, label: 'All'},
15+
{value: 2, label: 'Accessories'},
16+
{value: 3, label: 'Outwear'},
17+
{value: 4, label: 'Footwear'},
18+
{value: 5, label: 'Swimwear'},
19+
{value: 6, label: 'Tops'}
20+
];
21+
22+
const schemes = [
23+
{label: 'Default', value: 1},
24+
{label: 'Light', value: 2},
25+
{label: 'Dark', value: 3}
26+
];
1427

28+
const PickerWrapper = () => {
1529
const [language, setLanguage] = useState(undefined);
30+
const [filter, setFilter] = useState(undefined);
31+
const [customModalValues, setCustomModalValues] = useState(undefined);
32+
const renderDialog: PickerProps['renderCustomModal'] = (modalProps: any) => {
33+
const {visible, children, toggleModal, onDone} = modalProps;
34+
35+
return (
36+
<Incubator.Dialog
37+
visible={visible}
38+
onDismiss={() => {
39+
onDone();
40+
toggleModal(false);
41+
}}
42+
width="40%"
43+
height="45%"
44+
bottom
45+
useSafeArea
46+
containerStyle={{backgroundColor: Colors.$backgroundDefault}}
47+
direction={PanningProvider.Directions.DOWN}
48+
headerProps={{title: 'Custom modal'}}
49+
>
50+
<ScrollView>{children}</ScrollView>
51+
</Incubator.Dialog>
52+
);
53+
};
1654

1755
return (
18-
<Picker
19-
placeholder="Favorite Language"
20-
floatingPlaceholder
21-
value={language}
22-
enableModalBlur={false}
23-
onChange={setLanguage}
24-
topBarProps={{title: 'Languages'}}
25-
showSearch
26-
fieldType={Picker.fieldTypes.filter}
27-
searchPlaceholder={'Search a language'}
28-
searchStyle={{color: Colors.blue30, placeholderTextColor: Colors.grey50}}
29-
migrateTextField
30-
>
31-
{options.map(option => (
32-
<Picker.Item key={option.value} value={option} label={''} disabled={option.disabled}/>
33-
))}
34-
</Picker>
56+
<View marginT-s2>
57+
<Text text80BO marginT-s1 center>
58+
Single Value Picker
59+
</Text>
60+
<View marginB-s2>
61+
<Picker
62+
placeholder="Favorite Language"
63+
floatingPlaceholder
64+
value={language}
65+
enableModalBlur={false}
66+
onChange={setLanguage}
67+
topBarProps={{title: 'Languages'}}
68+
showSearch
69+
searchPlaceholder={'Search a language'}
70+
searchStyle={{color: Colors.blue30, placeholderTextColor: Colors.grey50}}
71+
migrateTextField
72+
>
73+
{options.map(option => (
74+
<Picker.Item key={option.value} value={option.value} label={option.label} disabled={option.disabled}/>
75+
))}
76+
</Picker>
77+
</View>
78+
<Text text80BO center>
79+
Multi Value Picker
80+
</Text>
81+
<View>
82+
<Picker
83+
placeholder="Favorite Filters"
84+
floatingPlaceholder
85+
value={filter}
86+
enableModalBlur={false}
87+
onChange={setFilter}
88+
topBarProps={{title: 'Filters'}}
89+
mode={Picker.modes.MULTI}
90+
showSearch
91+
searchPlaceholder={'Search a filter'}
92+
searchStyle={{color: Colors.blue30, placeholderTextColor: Colors.grey50}}
93+
migrateTextField
94+
>
95+
{filters.map(filter => (
96+
<Picker.Item key={filter.value} value={filter.value} label={filter.label} disabled={filter.disabled}/>
97+
))}
98+
</Picker>
99+
</View>
100+
<Text text80BO center>
101+
Dialog Picker
102+
</Text>
103+
<View>
104+
<Picker
105+
placeholder="Pick multiple schemes"
106+
value={customModalValues}
107+
onChange={items => setCustomModalValues(items)}
108+
mode={Picker.modes.MULTI}
109+
renderCustomModal={renderDialog}
110+
>
111+
{schemes.map(option => (
112+
<Picker.Item key={option.value} value={option.value} label={option.label} disabled={option.disabled}/>
113+
))}
114+
</Picker>
115+
</View>
116+
</View>
35117
);
36118
};
37119

0 commit comments

Comments
 (0)