forked from frostney/react-native-flags
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 629 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// @flow
import React from 'react';
import { Image } from 'react-native';
import * as flags from './flags';
type Props = {
code: string,
style?: any,
};
const rectangle = { width: 40, height: 25, borderRadius: 2 };
const square = { marginLeft: 7.5, width: 25, height: 25, borderRadius: 2 };
const squareFlags = ['CH', 'NE', 'NP', 'VA'];
const Flag = ({ code, style }: Props) => {
const flag = flags[code];
const unknownFlag = flags['unknown'];
return (
<Image
source={flag || unknownFlag}
style={[squareFlags.find(i => i === code) ? square : rectangle, style]}
/>
);
};
export default Flag;