-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reactions): added add reaction button to message menu + emoji se…
…lector Signed-off-by: m-doescode <[email protected]>
- Loading branch information
1 parent
8b1129e
commit fb7cb63
Showing
10 changed files
with
444 additions
and
10 deletions.
There are no files selected for viewing
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,30 @@ | ||
diff --git a/node_modules/react-native-emoji-selector/index.js b/node_modules/react-native-emoji-selector/index.js | ||
index 0737acd..a1d1f2c 100644 | ||
--- a/node_modules/react-native-emoji-selector/index.js | ||
+++ b/node_modules/react-native-emoji-selector/index.js | ||
@@ -70,6 +70,7 @@ const categoryKeys = Object.keys(Categories); | ||
|
||
const TabBar = ({ theme, activeCategory, onPress, width }) => { | ||
const tabSize = width / categoryKeys.length; | ||
+ if (tabSize - 12 < 1) return; | ||
|
||
return categoryKeys.map(c => { | ||
const category = Categories[c]; | ||
@@ -80,7 +81,7 @@ const TabBar = ({ theme, activeCategory, onPress, width }) => { | ||
onPress={() => onPress(category)} | ||
style={{ | ||
flex: 1, | ||
- height: tabSize, | ||
+ height: tabSize + 12, | ||
borderColor: category === activeCategory ? theme : "#EEEEEE", | ||
borderBottomWidth: 2, | ||
alignItems: "center", | ||
@@ -91,7 +92,7 @@ const TabBar = ({ theme, activeCategory, onPress, width }) => { | ||
style={{ | ||
textAlign: "center", | ||
paddingBottom: 8, | ||
- fontSize: tabSize - 24 | ||
+ fontSize: tabSize - 12 | ||
}} | ||
> | ||
{category.symbol} |
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
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,67 @@ | ||
import { useContext, useRef, useState, useMemo } from 'react'; | ||
import { View, Text } from 'react-native'; | ||
import { observer } from 'mobx-react-lite'; | ||
import EmojiSelector from 'react-native-emoji-selector'; | ||
// import EmojiPicker from 'emoji-picker-react'; | ||
|
||
import type BottomSheetCore from '@gorhom/bottom-sheet'; | ||
|
||
import type { Message } from 'revolt.js'; | ||
|
||
import { client } from '@clerotri/lib/client'; | ||
import { showToast } from '@clerotri/lib/utils'; | ||
import { app, setFunction } from '@clerotri/Generic'; | ||
import { BottomSheet } from '@clerotri/components/common/BottomSheet'; | ||
import { ThemeContext } from '@clerotri/lib/themes'; | ||
import { useBackHandler } from '@clerotri/lib/ui'; | ||
|
||
export const AddReactionSheet = observer(() => { | ||
const { currentTheme } = useContext(ThemeContext); | ||
|
||
const [message, setMessage] = useState(null as Message | null); | ||
|
||
const sheetRef = useRef<BottomSheetCore>(null); | ||
|
||
useBackHandler(() => { | ||
if (message) { | ||
sheetRef.current?.close(); | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
setFunction('openAddReaction', async (m: Message | null) => { | ||
setMessage(m); | ||
m ? sheetRef.current?.expand() : sheetRef.current?.close(); | ||
}); | ||
|
||
function selectEmoji(emoji: string) { | ||
if (!message) return; | ||
|
||
const reaction = message.reactions.get(emoji) || []; | ||
|
||
message.channel?.havePermission('React') | ||
? !Array.from(reaction).includes(client.user?._id!) | ||
? message.react(emoji) | ||
: message.unreact(emoji) | ||
: showToast('You cannot react to this message.'); | ||
app.openAddReaction(null); | ||
} | ||
|
||
return ( | ||
// BottomSheet cannot wrap our children in a scroll view because it will | ||
// create a nested set of scroll views which causes issues | ||
<BottomSheet innerScroll={true} sheetRef={sheetRef}> | ||
<View style={{ paddingHorizontal: 16, flex: 1 }}> | ||
{!message ? ( | ||
<></> | ||
) : ( | ||
<EmojiSelector | ||
onEmojiSelected={selectEmoji} | ||
columns={8} /> | ||
)} | ||
</View> | ||
</BottomSheet> | ||
); | ||
}); |
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
Oops, something went wrong.