-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31aa092
commit c9b3ba9
Showing
14 changed files
with
216 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
sidebar_position: 13 | ||
title: Custom Button | ||
--- | ||
|
||
import preview1 from '../../../assets/img/custom-button-preview-1.png' | ||
import preview2 from '../../../assets/img/custom-button-preview-2.png' | ||
import preview3 from '../../../assets/img/custom-button-preview-3.png' | ||
|
||
:::info | ||
To preview app with this example, clone [**github repo**](https://github.com/TheWidlarzGroup/rn-emoji-keyboard.git) and run `yarn example ios` or `yarn example android`. | ||
::: | ||
|
||
### Usage | ||
|
||
We've introduced a custom button feature to provide you with the flexibility to add your unique functionality to our interface. This feature allows you to, for example, add a function that deletes the previously used emoji, enhancing user interaction based on your application's specific needs. | ||
|
||
If you want to reveal the custom button, pass `enableCustomButton` prop. After that, use the `onCustomButtonPress` callback to define the specific action you want the custom button to perform. | ||
|
||
If search bar is enabled, custom button shows next to it. | ||
|
||
```jsx | ||
import EmojiPicker from 'rn-emoji-keyboard' | ||
|
||
const ExampleComponent = () => { | ||
// ... | ||
|
||
return ( | ||
<EmojiPicker | ||
open={isOpen} | ||
onClose={handleOnClose} | ||
onEmojiSelected={handleOnEmojiSelected} | ||
// add props below | ||
enableSearchBar | ||
enableCustomButton | ||
onCustomButtonPress={() => deleteLastEmoji()} | ||
/> | ||
) | ||
} | ||
``` | ||
|
||
<div className="gallery"> | ||
<img src={preview1} alt="First Image" /> | ||
<img src={preview2} alt="Second Image" /> | ||
<img src={preview3} alt="Third Image" /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Button } from 'example/src/components/Button' | ||
import React from 'react' | ||
import { Results } from 'example/src/components/Results' | ||
import EmojiPicker, { type EmojiType } from 'rn-emoji-keyboard' | ||
|
||
export default function () { | ||
const [result, setResult] = React.useState<string>() | ||
const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false) | ||
|
||
const handlePick = (emoji: EmojiType) => { | ||
console.log(emoji) | ||
setResult(emoji.emoji) | ||
setIsModalOpen((prev) => !prev) | ||
} | ||
|
||
const deleteLastEmoji = () => { | ||
if (result) { | ||
let arrayFromString = Array.from(result) | ||
arrayFromString.pop() | ||
setResult(arrayFromString.join('')) | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<Results label={result} /> | ||
<Button onPress={() => setIsModalOpen(true)} label="Open" /> | ||
|
||
<EmojiPicker | ||
onEmojiSelected={handlePick} | ||
open={isModalOpen} | ||
onClose={() => setIsModalOpen(false)} | ||
enableSearchBar | ||
enableCustomButton | ||
onCustomButtonPress={() => deleteLastEmoji()} | ||
allowMultipleSelections | ||
categoryPosition="bottom" | ||
/> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react' | ||
import { View, Pressable, StyleSheet } from 'react-native' | ||
import { KeyboardContext } from '../contexts/KeyboardContext' | ||
import { Icon } from './Icon' | ||
|
||
type CustomButtonType = { | ||
customButtonPressHandler: () => void | ||
} | ||
|
||
export const CustomButton = ({ customButtonPressHandler }: CustomButtonType) => { | ||
const { theme } = React.useContext(KeyboardContext) | ||
return ( | ||
<View style={styles.buttonContainer}> | ||
<Pressable | ||
onPress={customButtonPressHandler} | ||
style={({ pressed }) => [ | ||
{ | ||
backgroundColor: pressed | ||
? theme.customButton.backgroundPressed | ||
: theme.customButton.background, | ||
padding: 10, | ||
borderRadius: 100, | ||
}, | ||
styles.button, | ||
]} | ||
> | ||
{({ pressed }) => ( | ||
<Icon | ||
iconName={'Backspace'} | ||
isActive={pressed} | ||
normalColor={theme.customButton.icon} | ||
activeColor={theme.customButton.iconPressed} | ||
/> | ||
)} | ||
</Pressable> | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
buttonContainer: { | ||
marginTop: 16, | ||
marginHorizontal: 16, | ||
borderRadius: 100, | ||
flexDirection: 'row', | ||
justifyContent: 'flex-end', | ||
}, | ||
button: { | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
text: { | ||
color: 'white', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters