-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (27 loc) · 735 Bytes
/
index.js
File metadata and controls
34 lines (27 loc) · 735 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
29
30
31
32
33
34
// @flow
import React from 'react';
import { Image, TouchableOpacity } from 'react-native';
import * as flags from './flags';
type Props = {
size: 16 | 24 | 32 | 48 | 64,
code: string,
type?: 'flat' | 'shiny',
style?: any,
onPress: void
};
const Flag = ({ size = 64, code, type = 'shiny', style, onPress }: Props) => {
const flag = flags[type][`icons${size}`][code];
const unknownFlag = flags[type][`icons${size}`]['unknown'];
const flagImage =
<Image
source={flag || unknownFlag}
style={[{ width: size, height: size }, style]}
/>
if (!onPress) return flagImage;
return (
<TouchableOpacity onPress={onPress}>
{flagImage}
</TouchableOpacity>
);
};
export default Flag;