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
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
// @flow

import React from 'react';
import { Image } from 'react-native';
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 }: Props) => {
const Flag = ({ size = 64, code, type = 'shiny', style, onPress }: Props) => {
const flag = flags[type][`icons${size}`][code];
const unknownFlag = flags[type][`icons${size}`]['unknown'];

return (
const flagImage =
<Image
source={flag || unknownFlag}
style={[{ width: size, height: size }, style]}
/>

if (!onPress) return flagImage;

return (
<TouchableOpacity onPress={onPress}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't suppose it's a good idea to wrap every flag into TouchableOpacity. It's a great redundant bias

{flagImage}
</TouchableOpacity>
);
};

Expand Down