mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Allow custom exit
This commit is contained in:
@ -1,20 +1,12 @@
|
||||
import EmojisButton from '@components/Emojis/Button'
|
||||
import EmojisList from '@components/Emojis/List'
|
||||
import { PasteInputRef } from '@mattermost/react-native-paste-input'
|
||||
import { useAccessibility } from '@utils/accessibility/AccessibilityManager'
|
||||
import { useEmojisQuery } from '@utils/queryHooks/emojis'
|
||||
import { getInstanceFrequentEmojis } from '@utils/slices/instancesSlice'
|
||||
import { chunk, forEach, groupBy, sortBy } from 'lodash'
|
||||
import React, {
|
||||
createRef,
|
||||
PropsWithChildren,
|
||||
RefObject,
|
||||
useEffect,
|
||||
useReducer,
|
||||
useState
|
||||
} from 'react'
|
||||
import React, { createRef, PropsWithChildren, useEffect, useReducer, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Keyboard, KeyboardAvoidingView, TextInput, View } from 'react-native'
|
||||
import { Keyboard, KeyboardAvoidingView, View } from 'react-native'
|
||||
import FastImage from 'react-native-fast-image'
|
||||
import { Edge, SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { useSelector } from 'react-redux'
|
||||
@ -49,7 +41,6 @@ const prefetchEmojis = (
|
||||
|
||||
export type Props = {
|
||||
inputProps: EmojisState['inputProps']
|
||||
focusRef?: RefObject<TextInput | PasteInputRef>
|
||||
customButton?: boolean
|
||||
customEdges?: Edge[]
|
||||
customBehavior?: 'height' | 'padding' | 'position'
|
||||
@ -60,7 +51,6 @@ export const emojis: Emojis = createRef()
|
||||
const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
|
||||
children,
|
||||
inputProps,
|
||||
focusRef,
|
||||
customButton = false,
|
||||
customEdges = ['bottom'],
|
||||
customBehavior
|
||||
@ -79,14 +69,14 @@ const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
|
||||
if (data && data.length) {
|
||||
let sortedEmojis: NonNullable<Emojis['current']> = []
|
||||
forEach(groupBy(sortBy(data, ['category', 'shortcode']), 'category'), (value, key) =>
|
||||
sortedEmojis.push({ title: key, data: chunk(value, 4) })
|
||||
sortedEmojis.push({ title: key, data: chunk(value, 5) })
|
||||
)
|
||||
if (frequentEmojis.length) {
|
||||
sortedEmojis.unshift({
|
||||
title: t('componentEmojis:frequentUsed'),
|
||||
data: chunk(
|
||||
frequentEmojis.map(e => e.emoji),
|
||||
4
|
||||
5
|
||||
),
|
||||
type: 'frequent'
|
||||
})
|
||||
@ -115,11 +105,6 @@ const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
|
||||
hideSubscription.remove()
|
||||
}
|
||||
}, [inputProps])
|
||||
useEffect(() => {
|
||||
if (focusRef) {
|
||||
setTimeout(() => focusRef.current?.focus(), 500)
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView style={{ flex: 1 }} behavior={customBehavior}>
|
||||
@ -129,7 +114,7 @@ const ComponentEmojis: React.FC<Props & PropsWithChildren> = ({
|
||||
{children}
|
||||
<View
|
||||
style={[
|
||||
keyboardShown ? { position: 'absolute', bottom: 0, width: '100%' } : null,
|
||||
{ position: 'absolute', bottom: 0, width: '100%' },
|
||||
{
|
||||
marginBottom: keyboardShown && emojisState.targetIndex === -1 ? insets.bottom : 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user