From c7376788c0294294dec6d3e73d01fca6ed5808e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Kinsk=C3=BD?= Date: Wed, 29 Nov 2017 10:30:21 +0100 Subject: [PATCH] Extended Flag component to support `onPress` event --- index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 86940fe..0029ca7 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ // @flow import React from 'react'; -import { Image } from 'react-native'; +import { Image, TouchableOpacity } from 'react-native'; import * as flags from './flags'; type Props = { @@ -9,17 +9,25 @@ type Props = { 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 = + + if (!onPress) return flagImage; + + return ( + + {flagImage} + ); };