sskhandek / react-native-emoji-input

A fully-featured emoji keyboard ⌨️ for React Native ⚛️
MIT License
71 stars 38 forks source link

[Feature] Add filterFunctions prop to enable emojis filtering #34

Closed darekg11 closed 5 years ago

darekg11 commented 5 years ago

Relate to any issue?

https://github.com/sskhandek/react-native-emoji-input/issues/5
It is a temporary workaround that would allow user of this library to avoid missing emojis being render as X

Breaking change?

Nope, by default all emojis will be rendered as before.

What this PR does?

Adds new filterFunctions prop allowing user to pass an array of functions used to filter emojis list before rendering it

Example of usage:

    filterFunctionByUnicode = emoji => {
        return emoji.lib.added_in === "6.0" || emoji.lib.added_in === "6.1"
    }

    <EmojiInput
        onEmojiSelected={this.handleEmojiSelected}
        ref={emojiInput => this._emojiInput = emojiInput}
        resetSearch={this.state.reset}
        loggingFunction={this.verboseLoggingFunction.bind(this)}
        verboseLoggingFunction={true}
        filterFunctions={[this.filterFunctionByUnicode]}
    />

Change Preview:

Before on my Huawei P8Lite running Android 6.0:
before

After enabling only 6.0 Unicode:
after

darekg11 commented 5 years ago

@rijn Let me know what You think : )

darekg11 commented 5 years ago

No problem 👌

sskhandek commented 5 years ago

Thank you for all the work here @rijn and @darekg11

darekg11 commented 5 years ago

No problem, glad to help.