import _ from 'lodash'; import React, {Component} from 'react'; import {Alert, ScrollView, StyleSheet} from 'react-native'; import { Avatar, BorderRadiuses, Button, Constants, Image, ListItem, SkeletonView, Spacings, Text, View, Colors } from 'react-native-ui-lib'; import * as ExampleScreenPresenter from '../ExampleScreenPresenter'; const AVATAR_SIZE = 48; const IMAGE_URIS = [ 'https://static.wixstatic.com/media/17db2bb89a1d405886bf6c5f90c776e8.jpg', 'https://static.wixstatic.com/media/ed8de924f9a04bc1b7f43137378d696e.jpg', 'https://static.wixstatic.com/media/ea3157fe992346728dd08cc2e4560e1c.jpg' ]; const NUMBER_OF_ITEMS_TO_SHOW = 10; const DATA_TYPE = { List: 'list', Content: 'content', Images: 'images', Avatars: 'avatars', Custom: 'custom' }; const LIST_TYPE = { Regular: 'regular', Avatar: 'avatar', Thumbnail: 'thumbnail' }; export default class SkeletonViewScreen extends Component { state = { isDataAvailable: false, dataType: DATA_TYPE.List, listType: LIST_TYPE.Regular, isLarge: false, showEndContent: true, key: 1 }; increaseKey = () => { const {key} = this.state; this.setState({isDataAvailable: false, key: key + 1}); }; toggleVisibility = () => { const {isDataAvailable} = this.state; if (isDataAvailable) { this.increaseKey(); } else { this.setState({isDataAvailable: true}); } }; setSize = () => { const {isLarge, key} = this.state; this.setState({isLarge: !isLarge, key: key + 1, isDataAvailable: false}); }; setEndContent = () => { const {showEndContent, key} = this.state; this.setState({showEndContent: !showEndContent, key: key + 1, isDataAvailable: false}); }; renderEndContent = () => { const {showEndContent} = this.state; if (showEndContent) { return ( ); } }; renderTopSection = () => { const {isDataAvailable, isLarge, showEndContent, dataType} = this.state; return ( {ExampleScreenPresenter.renderHeader.call(this, 'Skeleton')} {ExampleScreenPresenter.renderRadioGroup.call(this, 'Data type', 'dataType', DATA_TYPE, { isRow: true, afterValueChanged: this.increaseKey })} {dataType === DATA_TYPE.List && ExampleScreenPresenter.renderRadioGroup.call(this, 'List type', 'listType', LIST_TYPE, { isRow: true, afterValueChanged: this.increaseKey })}