mirror of
https://github.com/zhigang1992/react-native-paper.git
synced 2026-06-15 10:28:13 +08:00
feat: add Chip component
This commit is contained in:
committed by
Satyajit Sahoo
parent
9fd6db4ec7
commit
b9aa79503c
56
example/src/ChipExample.js
Normal file
56
example/src/ChipExample.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/* @flow */
|
||||
|
||||
import * as React from 'react';
|
||||
import { View, StyleSheet, Image } from 'react-native';
|
||||
import { Chip, withTheme } from 'react-native-paper';
|
||||
import type { Theme } from 'react-native-paper/types';
|
||||
|
||||
type Props = {
|
||||
theme: Theme,
|
||||
};
|
||||
|
||||
class ChipExample extends React.Component<Props> {
|
||||
static title = 'Chip';
|
||||
|
||||
render() {
|
||||
const {
|
||||
theme: {
|
||||
colors: { background },
|
||||
},
|
||||
} = this.props;
|
||||
return (
|
||||
<View style={[styles.container, { backgroundColor: background }]}>
|
||||
<View style={styles.row}>
|
||||
<Chip onPress={() => {}}>Simple Chip</Chip>
|
||||
<Chip onDelete={() => {}}>Chip with delete button</Chip>
|
||||
<Chip icon="info">Chip with icon</Chip>
|
||||
<Chip
|
||||
icon={({ size }) => (
|
||||
<Image
|
||||
source={require('../assets/avatar.jpg')}
|
||||
style={{ height: size, width: size, borderRadius: size / 2 }}
|
||||
/>
|
||||
)}
|
||||
onDelete={() => {}}
|
||||
>
|
||||
Chip with image
|
||||
</Chip>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
padding: 4,
|
||||
},
|
||||
|
||||
row: {
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
},
|
||||
});
|
||||
|
||||
export default withTheme(ChipExample);
|
||||
@@ -7,6 +7,7 @@ import BottomNavigationExample from './BottomNavigationExample';
|
||||
import ButtonExample from './ButtonExample';
|
||||
import CardExample from './CardExample';
|
||||
import CheckboxExample from './CheckboxExample';
|
||||
import ChipExample from './ChipExample';
|
||||
import DialogExample from './DialogExample';
|
||||
import DividerExample from './DividerExample';
|
||||
import FABExample from './FABExample';
|
||||
@@ -35,6 +36,7 @@ export const examples = {
|
||||
button: ButtonExample,
|
||||
card: CardExample,
|
||||
checkbox: CheckboxExample,
|
||||
chip: ChipExample,
|
||||
dialog: DialogExample,
|
||||
divider: DividerExample,
|
||||
fab: FABExample,
|
||||
|
||||
Reference in New Issue
Block a user