|
| 1 | +import React, {Component} from 'react'; |
| 2 | +import {StyleSheet} from 'react-native'; |
| 3 | +import {FlatList} from 'react-native-gesture-handler'; |
| 4 | +import {View, Text, Card, Button, Incubator, Colors, BorderRadiuses} from 'react-native-ui-lib'; //eslint-disable-line |
| 5 | + |
| 6 | +interface Item { |
| 7 | + value: string; |
| 8 | + label: string; |
| 9 | +} |
| 10 | + |
| 11 | +const colors: Item[] = [ |
| 12 | + {value: Colors.red10, label: 'Red10'}, |
| 13 | + {value: Colors.red30, label: 'Red30'}, |
| 14 | + {value: Colors.red50, label: 'Red50'}, |
| 15 | + {value: Colors.red70, label: 'Red70'}, |
| 16 | + {value: Colors.blue10, label: 'Blue10'}, |
| 17 | + {value: Colors.blue30, label: 'Blue30'}, |
| 18 | + {value: Colors.blue50, label: 'Blue50'}, |
| 19 | + {value: Colors.blue70, label: 'Blue70'}, |
| 20 | + {value: Colors.purple10, label: 'Purple10'}, |
| 21 | + {value: Colors.purple30, label: 'Purple30'}, |
| 22 | + {value: Colors.purple50, label: 'Purple50'}, |
| 23 | + {value: Colors.purple70, label: 'Purple70'}, |
| 24 | + {value: Colors.green10, label: 'Green10'}, |
| 25 | + {value: Colors.green30, label: 'Green30'}, |
| 26 | + {value: Colors.green50, label: 'Green50'}, |
| 27 | + {value: Colors.green70, label: 'Green70'}, |
| 28 | + {value: Colors.yellow10, label: 'Yellow10'}, |
| 29 | + {value: Colors.yellow30, label: 'Yellow30'}, |
| 30 | + {value: Colors.yellow50, label: 'Yellow50'}, |
| 31 | + {value: Colors.yellow70, label: 'Yellow70'} |
| 32 | +]; |
| 33 | + |
| 34 | +export default class IncubatorDialogScreen extends Component { |
| 35 | + state = {visible: false}; |
| 36 | + |
| 37 | + renderVerticalItem = ({item}: {item: Item}) => { |
| 38 | + return ( |
| 39 | + <Text text50 margin-20 color={item.value}> |
| 40 | + {item.label} |
| 41 | + </Text> |
| 42 | + ); |
| 43 | + }; |
| 44 | + |
| 45 | + keyExtractor = (item: Item) => { |
| 46 | + return item.value; |
| 47 | + }; |
| 48 | + |
| 49 | + openDialog = () => { |
| 50 | + this.setState({visible: true}); |
| 51 | + }; |
| 52 | + |
| 53 | + closeDialog = () => { |
| 54 | + this.setState({visible: false}); |
| 55 | + }; |
| 56 | + |
| 57 | + render() { |
| 58 | + const {visible} = this.state; |
| 59 | + |
| 60 | + return ( |
| 61 | + <View bg-dark80 flex padding-20> |
| 62 | + <Card height={100} center padding-20> |
| 63 | + <Text text50>IncubatorDialogScreen</Text> |
| 64 | + </Card> |
| 65 | + <View flex center> |
| 66 | + <Button marginV-20 label="Open Dialog" onPress={this.openDialog}/> |
| 67 | + </View> |
| 68 | + <Incubator.Dialog visible={visible} onDismiss={this.closeDialog} bottom containerStyle={styles.dialogContainer}> |
| 69 | + <View style={styles.dialog}> |
| 70 | + <Text text60 margin-s2> |
| 71 | + Title (swipe here) |
| 72 | + </Text> |
| 73 | + <View height={1} bg-grey40/> |
| 74 | + <FlatList |
| 75 | + showsVerticalScrollIndicator={false} |
| 76 | + style={styles.verticalScroll} |
| 77 | + data={colors} |
| 78 | + renderItem={this.renderVerticalItem} |
| 79 | + keyExtractor={this.keyExtractor} |
| 80 | + /> |
| 81 | + </View> |
| 82 | + </Incubator.Dialog> |
| 83 | + </View> |
| 84 | + ); |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +const styles = StyleSheet.create({ |
| 89 | + dialogContainer: { |
| 90 | + bottom: 20, |
| 91 | + alignSelf: 'center' |
| 92 | + }, |
| 93 | + dialog: { |
| 94 | + backgroundColor: Colors.white, |
| 95 | + width: 200, |
| 96 | + height: 300, |
| 97 | + borderRadius: BorderRadiuses.br20 |
| 98 | + }, |
| 99 | + verticalScroll: { |
| 100 | + marginTop: 20 |
| 101 | + } |
| 102 | +}); |
0 commit comments