import _ from 'lodash'; import React, {Component} from 'react'; import {AccessibilityInfo, findNodeHandle} from 'react-native'; import {Colors, Typography, View, Text, Button, FeatureHighlight} from 'react-native-ui-lib'; // eslint-disable-line const titles = [ 'Get Notified', 'Title two is a long title that will not get cut by default, but can be limited', 'Title number three', 'Title number four', 'Title number five', 'Welcome to Uilib demo!' ]; const messages = [ 'Important notifications appear right on your clubs and groups. Tap them to get more information about the most' + 'important things that you should pay attention to.', 'Short message with information about the above highlighted feature', 'A long message, that will not get cut (but can be limited) with information about the highlighted feature.' + ' Please note that if the message is too long and will cause the content box to render off screen, you will get a' + ' warning about it', 'Very short message', 'Short message with information about the below highlighted feature', 'Here is where you can view demos of all Uilib components' ]; interface State { currentTargetIndex: number; showFTE: boolean; } class FeatureHighlightScreen extends Component<{}, State> { viewRef: any; targets: {[key: string]: any} = {}; constructor(props: any) { super(props); this.state = { showFTE: false, currentTargetIndex: 0 }; } componentDidMount() { // setting timeout to allow Android's transition animation to complete setTimeout(() => { this.showHighlight(); }, 1000); } closeHighlight = () => { this.setState({showFTE: false}, () => { if (this.viewRef) { const reactTag = findNodeHandle(this.viewRef); reactTag && AccessibilityInfo.setAccessibilityFocus(reactTag); } }); }; showHighlight = () => { this.setState({showFTE: true}); }; addTarget(ref: any, id: string) { if (ref && !this.targets[id]) { this.targets[id] = ref; } } moveNext = () => { const {currentTargetIndex} = this.state; const newTargetIndex = currentTargetIndex + 1; this.moveToPage(newTargetIndex); }; moveToPage(index: number) { if (index < _.size(this.targets)) { this.setState({currentTargetIndex: index}); } else { this.closeHighlight(); } } getPageControlProps() { return { numOfPages: titles.length, currentPage: this.state.currentTargetIndex, onPagePress: this.onPagePress, color: Colors.grey30, inactiveColor: Colors.grey80, size: 8 }; } onPagePress = (index: number) => { this.moveToPage(index); }; renderHighlighterOverlay() { const {showFTE, currentTargetIndex} = this.state; const lastPage = titles.length - 1; return ( this.targets[currentTargetIndex]} // highlightFrame={{x: 30, y: 70, width: 150, height: 30}} // highlightFrame={{x: 160, y: 336, width: 150, height: 56}} borderRadius={_.includes([1, 2, 3, 4], currentTargetIndex) ? 4 : undefined} pageControlProps={currentTargetIndex < lastPage ? this.getPageControlProps() : undefined} /> ); } render() { return ( this.addTarget(r, '0')} /> this.addTarget(r, '1')}/> this.addTarget(r, '2')} /> this.addTarget(r, '3')} /> this.addTarget(r, '4')} /> (this.viewRef = r)}> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. this.addTarget(r, '5')}>