Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ const config = {
ProgressBar: 'ProgressBar',
RadioButton: {
RadioButton: 'RadioButton/RadioButton',
RadioButtonAndroid: 'RadioButton/RadioButtonAndroid',
RadioButtonGroup: 'RadioButton/RadioButtonGroup',
RadioButtonIOS: 'RadioButton/RadioButtonIOS',
RadioButtonItem: 'RadioButton/RadioButtonItem',
},
Searchbar: 'Searchbar',
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,6 @@ export default MyComponent;

<div>

### mode

</div>

<PropTable componentLink="RadioButton/RadioButtonItem" prop="mode" />

<div>

### position

</div>
Expand Down
46 changes: 30 additions & 16 deletions example/src/Examples/RadioButtonExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import ScreenWrapper from '../ScreenWrapper';

type State = 'normal' | 'normal-ios' | 'normal-item' | 'custom';
type State = 'normal' | 'normal-item' | 'custom';

const RadioButtonExample = () => {
const [checked, setChecked] = React.useState<State>('normal');
Expand All @@ -19,26 +19,15 @@ const RadioButtonExample = () => {
<ScreenWrapper style={styles.container}>
<TouchableRipple onPress={() => setChecked('normal')}>
<View style={styles.row}>
<Text>Normal - Material Design</Text>
<Text>Normal</Text>
<View pointerEvents="none">
<RadioButton.Android
<RadioButton
value="normal"
status={checked === 'normal' ? 'checked' : 'unchecked'}
/>
</View>
</View>
</TouchableRipple>
<TouchableRipple onPress={() => setChecked('normal-ios')}>
<View style={styles.row}>
<Text>Normal 2 - IOS</Text>
<View pointerEvents="none">
<RadioButton.IOS
value="normal-ios"
status={checked === 'normal-ios' ? 'checked' : 'unchecked'}
/>
</View>
</View>
</TouchableRipple>
<TouchableRipple onPress={() => setChecked('custom')}>
<View style={styles.row}>
<Text>Custom</Text>
Expand All @@ -58,11 +47,31 @@ const RadioButtonExample = () => {
onPress={() => setChecked('normal-item')}
/>
<View style={styles.row}>
<Text>Checked (Disabled)</Text>
<Text>Error (Checked)</Text>
<RadioButton value="error" status="checked" error />
</View>
<View style={styles.row}>
<Text>Error (Unchecked)</Text>
<RadioButton value="error-unchecked" status="unchecked" error />
</View>
<RadioButton.Item
label="Error - Item (Checked)"
value="error-item"
status="checked"
error
/>
<RadioButton.Item
label="Error - Item (Unchecked)"
value="error-item-unchecked"
status="unchecked"
error
/>
<View style={styles.row}>
<Text style={styles.disabledLabel}>Checked (Disabled)</Text>
<RadioButton value="first" status="checked" disabled />
</View>
<View style={styles.row}>
<Text>Unchecked (Disabled)</Text>
<Text style={styles.disabledLabel}>Unchecked (Disabled)</Text>
<RadioButton value="second" status="unchecked" disabled />
</View>
<RadioButton.Item
Expand Down Expand Up @@ -94,6 +103,11 @@ const styles = StyleSheet.create({
paddingVertical: 8,
paddingHorizontal: 16,
},
// Standalone RadioButton has no label of its own; dim the demo label to
// match the disabled control (RadioButton.Item dims its label for you).
disabledLabel: {
opacity: 0.38,
},
});

export default RadioButtonExample;
4 changes: 2 additions & 2 deletions example/src/Examples/RadioButtonGroupExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const RadioButtonGroupExample = () => {
</View>
<View style={styles.row}>
<Text>Second</Text>
<RadioButton.Android value="second" />
<RadioButton value="second" />
</View>
<View style={styles.row}>
<Text>Third</Text>
<RadioButton.IOS value="third" />
<RadioButton value="third" />
</View>
</RadioButton.Group>
</List.Section>
Expand Down
38 changes: 15 additions & 23 deletions example/src/Examples/RadioButtonItemExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,47 @@ import ScreenWrapper from '../ScreenWrapper';

const RadioButtonItemExample = () => {
const [checkedDefault, setCheckedDefault] = React.useState(true);
const [checkedAndroid, setCheckedAndroid] = React.useState(true);
const [checkedIOS, setCheckedIOS] = React.useState(true);
const [checkedLeadingControl, setCheckedLeadingControl] =
React.useState(true);
const [checkedDisabled, setCheckedDisabled] = React.useState<boolean>(true);
const [checkedError, setCheckedError] = React.useState(true);
const [checkedLabelVariant, setCheckedLabelVariant] = React.useState(true);

return (
<ScreenWrapper style={styles.container}>
<RadioButton.Item
label="Default (will look like whatever system this is running on)"
label="Default (trailing control)"
status={checkedDefault ? 'checked' : 'unchecked'}
onPress={() => setCheckedDefault(!checkedDefault)}
value="default"
/>
<RadioButton.Item
label="Material Design"
mode="android"
status={checkedAndroid ? 'checked' : 'unchecked'}
onPress={() => setCheckedAndroid(!checkedAndroid)}
value="android"
/>
<RadioButton.Item
label="iOS"
mode="ios"
status={checkedIOS ? 'checked' : 'unchecked'}
onPress={() => setCheckedIOS(!checkedIOS)}
value="iOS"
/>
<RadioButton.Item
label="Default with leading control"
label="Leading control"
status={checkedLeadingControl ? 'checked' : 'unchecked'}
onPress={() => setCheckedLeadingControl(!checkedLeadingControl)}
value="iOS"
value="leading"
position="leading"
/>
<RadioButton.Item
label="Disabled checkbox"
label="Error"
status={checkedError ? 'checked' : 'unchecked'}
onPress={() => setCheckedError(!checkedError)}
value="error"
error
/>
<RadioButton.Item
label="Disabled"
status={checkedDisabled ? 'checked' : 'unchecked'}
onPress={() => setCheckedDisabled(!checkedDisabled)}
value="iOS"
value="disabled"
disabled
/>
<RadioButton.Item
label="Default with titleLarge title variant"
label="titleLarge label variant"
labelVariant="titleLarge"
status={checkedLabelVariant ? 'checked' : 'unchecked'}
onPress={() => setCheckedLabelVariant(!checkedLabelVariant)}
value="default"
value="variant"
/>
</ScreenWrapper>
);
Expand Down
Loading
Loading