mirror of
https://github.com/zhigang1992/react-native-paper.git
synced 2026-06-15 10:28:13 +08:00
feat: add <RadioButton /> component. fixes #13
This commit is contained in:
67
example/src/RadioButtonExample.js
Normal file
67
example/src/RadioButtonExample.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/* @flow */
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
View,
|
||||
StyleSheet,
|
||||
} from 'react-native';
|
||||
import {
|
||||
Paragraph,
|
||||
RadioButton,
|
||||
Colors,
|
||||
} from 'react-native-paper';
|
||||
|
||||
export default class RadioButtonExample extends Component {
|
||||
|
||||
static title = 'Radio button';
|
||||
|
||||
state = {
|
||||
checkedNormal: true,
|
||||
checkedCustom: true,
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View style={styles.row}>
|
||||
<Paragraph>Normal</Paragraph>
|
||||
<RadioButton
|
||||
checked={this.state.checkedNormal}
|
||||
onPress={() => this.setState(state => ({ checkedNormal: !state.checkedNormal }))}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.row}>
|
||||
<Paragraph>Custom</Paragraph>
|
||||
<RadioButton
|
||||
color={Colors.pink500}
|
||||
checked={this.state.checkedCustom}
|
||||
onPress={() => this.setState(state => ({ checkedCustom: !state.checkedCustom }))}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.row}>
|
||||
<Paragraph>Checked (Disabled)</Paragraph>
|
||||
<RadioButton checked disabled />
|
||||
</View>
|
||||
<View style={styles.row}>
|
||||
<Paragraph>Unchecked (Disabled)</Paragraph>
|
||||
<RadioButton checked={false} disabled />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: Colors.white,
|
||||
padding: 8,
|
||||
},
|
||||
|
||||
row: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
padding: 8,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user