diff --git a/RNTester/js/ViewExample.js b/RNTester/js/ViewExample.js index 1cc4ad686..ffa5bd3d2 100644 --- a/RNTester/js/ViewExample.js +++ b/RNTester/js/ViewExample.js @@ -10,110 +10,11 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {StyleSheet, Text, View} = ReactNative; -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); +/* eslint-disable react-native/no-inline-styles */ -var styles = StyleSheet.create({ - box: { - backgroundColor: '#527FE4', - borderColor: '#000033', - borderWidth: 1, - }, - zIndex: { - justifyContent: 'space-around', - width: 100, - height: 50, - marginTop: -10, - }, -}); - -class ViewBorderStyleExample extends React.Component<{}, $FlowFixMeState> { - state = { - showBorder: true, - }; - - render() { - return ( - - - - Dashed border style - - - Dotted border style - - - - ); - } - - _handlePress = () => { - this.setState({showBorder: !this.state.showBorder}); - }; -} - -class ZIndexExample extends React.Component<{}, $FlowFixMeState> { - state = { - flipped: false, - }; - - render() { - const indices = this.state.flipped ? [-1, 0, 1, 2] : [2, 1, 0, -1]; - return ( - - - Tap to flip sorting order - - ZIndex {indices[0]} - - - ZIndex {indices[1]} - - - ZIndex {indices[2]} - - - ZIndex {indices[3]} - - - - ); - } - - _handlePress = () => { - this.setState({flipped: !this.state.flipped}); - }; -} +const React = require('react'); +const {StyleSheet, Text, View} = require('react-native'); +const TouchableWithoutFeedback = require('TouchableWithoutFeedback'); exports.title = ''; exports.description = @@ -124,7 +25,7 @@ exports.displayName = 'ViewExample'; exports.examples = [ { title: 'Background Color', - render: function() { + render() { return ( Blue background @@ -134,7 +35,7 @@ exports.examples = [ }, { title: 'Border', - render: function() { + render() { return ( 5px blue border @@ -144,7 +45,14 @@ exports.examples = [ }, { title: 'Padding/Margin', - render: function() { + render() { + const styles = StyleSheet.create({ + box: { + backgroundColor: '#527FE4', + borderColor: '#000033', + borderWidth: 1, + }, + }); return ( @@ -167,7 +75,7 @@ exports.examples = [ }, { title: 'Border Radius', - render: function() { + render() { return ( @@ -180,13 +88,54 @@ exports.examples = [ }, { title: 'Border Style', - render: function() { + render() { + type Props = $ReadOnly<{||}>; + type State = {| + showBorder: boolean, + |}; + + class ViewBorderStyleExample extends React.Component { + state = { + showBorder: true, + }; + + render() { + return ( + + + + Dashed border style + + + Dotted border style + + + + ); + } + + _handlePress = () => { + this.setState({showBorder: !this.state.showBorder}); + }; + } return ; }, }, { title: 'Circle with Border Radius', - render: function() { + render() { return ( Overflow hidden + style={{ + borderWidth: 0.5, + height: 10, + marginBottom: 5, + marginRight: 10, + width: 95, + }}> Overflow visible @@ -224,7 +179,7 @@ exports.examples = [ }, { title: 'Opacity', - render: function() { + render() { return ( @@ -254,7 +209,87 @@ exports.examples = [ }, { title: 'ZIndex', - render: function() { + render() { + type Props = $ReadOnly<{||}>; + type State = {| + flipped: boolean, + |}; + + const styles = StyleSheet.create({ + zIndex: { + justifyContent: 'space-around', + width: 100, + height: 50, + marginTop: -10, + }, + }); + + class ZIndexExample extends React.Component { + state = { + flipped: false, + }; + + render() { + const indices = this.state.flipped ? [-1, 0, 1, 2] : [2, 1, 0, -1]; + return ( + + + + Tap to flip sorting order + + + ZIndex {indices[0]} + + + ZIndex {indices[1]} + + + ZIndex {indices[2]} + + + ZIndex {indices[3]} + + + + ); + } + + _handlePress = () => { + this.setState({flipped: !this.state.flipped}); + }; + } return ; }, },