Skip to content
Draft
59 changes: 24 additions & 35 deletions example/src/Examples/ListItemExample.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { View, StyleSheet } from 'react-native';

import { List, Divider, Checkbox, Avatar, Switch } from 'react-native-paper';

import ScreenWrapper from '../ScreenWrapper';

const CenteredCheckbox = () => (
<View style={styles.centered}>
<Checkbox status="checked" />
</View>
);

const ListItemExample = () => {
return (
<ScreenWrapper>
Expand All @@ -21,16 +13,19 @@ const ListItemExample = () => {
description="Supporting text that is long enough to fill up multiple lines in the item"
/>
<Divider />
<List.Item title="Headline" right={() => <CenteredCheckbox />} />
<List.Item
title="Headline"
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text"
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text that is long enough to fill up multiple lines in the item"
right={() => <Checkbox status="checked" />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<Divider />
</List.Section>
Expand All @@ -54,19 +49,19 @@ const ListItemExample = () => {
<List.Item
title="Headline"
left={(props) => <List.Icon {...props} icon="account-outline" />}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text"
left={(props) => <List.Icon {...props} icon="account-outline" />}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text that is long enough to fill up multiple lines in the item"
left={(props) => <List.Icon {...props} icon="account-outline" />}
right={() => <Checkbox status="checked" />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<Divider />
</List.Section>
Expand Down Expand Up @@ -98,23 +93,23 @@ const ListItemExample = () => {
left={(props) => (
<Avatar.Text style={props.style} label="A" size={40} />
)}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text"
left={(props) => (
<Avatar.Text style={props.style} label="A" size={40} />
)}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text that is long enough to fill up multiple lines in the item"
left={(props) => (
<Avatar.Text style={props.style} label="A" size={40} />
)}
right={() => <Checkbox status="checked" />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<Divider />
</List.Section>
Expand Down Expand Up @@ -158,7 +153,7 @@ const ListItemExample = () => {
source={require('../../../example/assets/images/strawberries.jpg')}
/>
)}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
Expand All @@ -169,7 +164,7 @@ const ListItemExample = () => {
source={require('../../../example/assets/images/strawberries.jpg')}
/>
)}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
Expand All @@ -180,7 +175,7 @@ const ListItemExample = () => {
source={require('../../../example/assets/images/strawberries.jpg')}
/>
)}
right={() => <Checkbox status="checked" />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<Divider />
</List.Section>
Expand Down Expand Up @@ -228,7 +223,7 @@ const ListItemExample = () => {
source={require('../../../example/assets/images/strawberries.jpg')}
/>
)}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
Expand All @@ -240,7 +235,7 @@ const ListItemExample = () => {
source={require('../../../example/assets/images/strawberries.jpg')}
/>
)}
right={() => <CenteredCheckbox />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<List.Item
title="Headline"
Expand All @@ -252,56 +247,50 @@ const ListItemExample = () => {
source={require('../../../example/assets/images/strawberries.jpg')}
/>
)}
right={() => <Checkbox status="checked" />}
right={(props) => <Checkbox status="checked" style={props.style} />}
/>
<Divider />
</List.Section>

<List.Section title="With switch">
<List.Item
title="Headline"
right={() => <Switch disabled style={styles.centered} />}
right={(props) => <Switch disabled style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text"
right={() => <Switch disabled style={styles.centered} />}
right={(props) => <Switch disabled style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text that is long enough to fill up multiple lines in the item"
right={() => <Switch disabled />}
right={(props) => <Switch disabled style={props.style} />}
/>
<Divider />
<List.Item
title="Headline"
left={(props) => <List.Icon {...props} icon="account-outline" />}
right={() => <Switch disabled style={styles.centered} />}
right={(props) => <Switch disabled style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text"
left={(props) => <List.Icon {...props} icon="account-outline" />}
right={() => <Switch disabled style={styles.centered} />}
right={(props) => <Switch disabled style={props.style} />}
/>
<List.Item
title="Headline"
description="Supporting text that is long enough to fill up multiple lines in the item"
left={(props) => <List.Icon {...props} icon="account-outline" />}
right={() => <Switch disabled />}
right={(props) => <Switch disabled style={props.style} />}
/>
<Divider />
</List.Section>
</ScreenWrapper>
);
};

const styles = StyleSheet.create({
centered: {
alignSelf: 'center',
},
});

ListItemExample.title = 'List.Item';

export default ListItemExample;
Loading