|
| 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 | +}); |
0 commit comments