Skip to content
Open
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
21 changes: 9 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@ import PropTypes from 'prop-types';
import { Image } from 'react-native';
import * as flags from './src';

const Flag = props => {
const flag = flags[props.type][`icons${props.size}`][props.code];
const unknownFlag = flags[props.type][`icons${props.size}`]['unknown'];
const Flag = ({ size = 64, type = "shiny", code, style }) => {
const flag = flags[type][`icons${size}`][code];
const unknownFlag = flags[type][`icons${size}`]['unknown'];

return (
<Image
source={flag || unknownFlag}
style={[{ width: props.size, height: props.size }, props.style]}
/>
<Image
source={flag || unknownFlag}
style={[{ width: size, height: size }, style]}
/>
);
};

Flag.propTypes = {
size: PropTypes.number,
type: PropTypes.string,
};

Flag.defaultProps = {
size: 64,
type: "shiny",
code: PropTypes.string.isRequired,
style: PropTypes.object,
};

export default Flag;