Skip to content

How could a click event be implemented for the Flag? #4

Open

Description

@DenisTis
No description provided.

Activity

  1. filip-kinsky commented on Nov 29, 2017

    @filip-kinsky

    I tried to achieve this too, but got errors when I just wrapped the Flag component inside TouchableOpacity to attach onPress event handler. The easiest but little bit dirty solution I came up with is just omit the Flag component and build your own:

    import * as allFlags from 'react-native-flags/flags/flat/64'
    ...
    <TouchableOpacity onPress={() => console.log(countryCode)}>
       <Image source={allFlags[countryCode] || allFlags.unknown} style={{ width: 64, height: 64 }} />
    </TouchableOpacity>
    
  2. filip-kinsky commented on Nov 29, 2017

    @filip-kinsky

    I just submitted PR to support onPress event in the Flag component #5

  3. DenisTis commented on Nov 30, 2017

    @DenisTis
    Author

    Thank you for the proposal, I was able to implement it in the meantime:

              <TouchableOpacity onPress={this.onFlagClick.bind(this, 'de')}>
                <Flag style={styles.flagToolbar} code="DE" size={48} />
              </TouchableOpacity>
    

    But I like your way too and probably will switch to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions