77 * @flow
88 * @format
99 */
10+
1011'use strict' ;
1112
1213const React = require ( 'react' ) ;
1314const ReactNative = require ( 'react-native' ) ;
14- const { CheckBox, Text, View} = ReactNative ;
15+ const { CheckBox, Text, View, StyleSheet } = ReactNative ;
1516
1617class BasicCheckBoxExample extends React . Component < { } , $FlowFixMeState > {
1718 state = {
@@ -24,7 +25,7 @@ class BasicCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
2425 < View >
2526 < CheckBox
2627 onValueChange = { value => this . setState ( { falseCheckBoxIsOn : value } ) }
27- style = { { marginBottom : 10 } }
28+ style = { styles . checkbox }
2829 value = { this . state . falseCheckBoxIsOn }
2930 />
3031 < CheckBox
@@ -40,7 +41,7 @@ class DisabledCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
4041 render ( ) {
4142 return (
4243 < View >
43- < CheckBox disabled = { true } style = { { marginBottom : 10 } } value = { true } />
44+ < CheckBox disabled = { true } style = { styles . checkbox } value = { true } />
4445 < CheckBox disabled = { true } value = { false } />
4546 </ View >
4647 ) ;
@@ -55,16 +56,16 @@ class EventCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
5556
5657 render ( ) {
5758 return (
58- < View style = { { flexDirection : 'row' , justifyContent : 'space-around' } } >
59+ < View style = { styles . container } >
5960 < View >
6061 < CheckBox
6162 onValueChange = { value => this . setState ( { eventCheckBoxIsOn : value } ) }
62- style = { { marginBottom : 10 } }
63+ style = { styles . checkbox }
6364 value = { this . state . eventCheckBoxIsOn }
6465 />
6566 < CheckBox
6667 onValueChange = { value => this . setState ( { eventCheckBoxIsOn : value } ) }
67- style = { { marginBottom : 10 } }
68+ style = { styles . checkbox }
6869 value = { this . state . eventCheckBoxIsOn }
6970 />
7071 < Text > { this . state . eventCheckBoxIsOn ? 'On' : 'Off' } </ Text >
@@ -74,14 +75,14 @@ class EventCheckBoxExample extends React.Component<{}, $FlowFixMeState> {
7475 onValueChange = { value =>
7576 this . setState ( { eventCheckBoxRegressionIsOn : value } )
7677 }
77- style = { { marginBottom : 10 } }
78+ style = { styles . checkbox }
7879 value = { this . state . eventCheckBoxRegressionIsOn }
7980 />
8081 < CheckBox
8182 onValueChange = { value =>
8283 this . setState ( { eventCheckBoxRegressionIsOn : value } )
8384 }
84- style = { { marginBottom : 10 } }
85+ style = { styles . checkbox }
8586 value = { this . state . eventCheckBoxRegressionIsOn }
8687 />
8788 < Text > { this . state . eventCheckBoxRegressionIsOn ? 'On' : 'Off' } </ Text >
@@ -122,3 +123,13 @@ exports.title = '<CheckBox>';
122123exports . displayName = 'CheckBoxExample' ;
123124exports . description = 'Native boolean input' ;
124125exports . examples = examples ;
126+
127+ const styles = StyleSheet . create ( {
128+ container : {
129+ flexDirection : 'row' ,
130+ justifyContent : 'space-around' ,
131+ } ,
132+ checkbox : {
133+ marginBottom : 10 ,
134+ } ,
135+ } ) ;
0 commit comments