[🐴] Remove keyboard controller lib (#4038)
* remove library * implement using just reanimated * always return false for `keyboardIsOpening` on web * undo comment * handle input focus scroll more elegantly * add back minimal shell toggle on mobile web * adjust initialnumtorender * oops * nit
This commit is contained in:
parent
da2bdf5d6f
commit
b15b49a48f
5 changed files with 89 additions and 74 deletions
|
|
@ -1,8 +1,5 @@
|
|||
import React, {useCallback} from 'react'
|
||||
import {TouchableOpacity, View} from 'react-native'
|
||||
import {KeyboardProvider} from 'react-native-keyboard-controller'
|
||||
import {KeyboardAvoidingView} from 'react-native-keyboard-controller'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {msg} from '@lingui/macro'
|
||||
|
|
@ -18,7 +15,7 @@ import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
|||
import {useProfileQuery} from '#/state/queries/profile'
|
||||
import {BACK_HITSLOP} from 'lib/constants'
|
||||
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
||||
import {isIOS, isNative, isWeb} from 'platform/detection'
|
||||
import {isWeb} from 'platform/detection'
|
||||
import {ConvoProvider, isConvoActive, useConvo} from 'state/messages/convo'
|
||||
import {ConvoStatus} from 'state/messages/convo/types'
|
||||
import {useSetMinimalShellMode} from 'state/shell'
|
||||
|
|
@ -39,8 +36,8 @@ type Props = NativeStackScreenProps<
|
|||
>
|
||||
export function MessagesConversationScreen({route}: Props) {
|
||||
const gate = useGate()
|
||||
const setMinimalShellMode = useSetMinimalShellMode()
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const setMinimalShellMode = useSetMinimalShellMode()
|
||||
|
||||
const convoId = route.params.conversation
|
||||
const {setCurrentConvoId} = useCurrentConvoId()
|
||||
|
|
@ -57,7 +54,7 @@ export function MessagesConversationScreen({route}: Props) {
|
|||
setCurrentConvoId(undefined)
|
||||
setMinimalShellMode(false)
|
||||
}
|
||||
}, [convoId, gtMobile, setCurrentConvoId, setMinimalShellMode]),
|
||||
}, [gtMobile, convoId, setCurrentConvoId, setMinimalShellMode]),
|
||||
)
|
||||
|
||||
if (!gate('dms')) return <ClipClopGate />
|
||||
|
|
@ -76,9 +73,6 @@ function Inner() {
|
|||
|
||||
const [hasInitiallyRendered, setHasInitiallyRendered] = React.useState(false)
|
||||
|
||||
const {bottom: bottomInset, top: topInset} = useSafeAreaInsets()
|
||||
const nativeBottomBarHeight = isIOS ? 42 : 60
|
||||
|
||||
// HACK: Because we need to scroll to the bottom of the list once initial items are added to the list, we also have
|
||||
// to take into account that scrolling to the end of the list on native will happen asynchronously. This will cause
|
||||
// a little flicker when the items are first renedered at the top and immediately scrolled to the bottom. to prevent
|
||||
|
|
@ -111,45 +105,33 @@ function Inner() {
|
|||
/*
|
||||
* Any other convo states (atm) are "ready" states
|
||||
*/
|
||||
|
||||
return (
|
||||
<KeyboardProvider>
|
||||
<KeyboardAvoidingView
|
||||
style={[
|
||||
a.flex_1,
|
||||
isNative && {marginBottom: bottomInset + nativeBottomBarHeight},
|
||||
]}
|
||||
keyboardVerticalOffset={isIOS ? topInset : 0}
|
||||
behavior="padding"
|
||||
contentContainerStyle={a.flex_1}>
|
||||
<CenteredView style={a.flex_1} sideBorders>
|
||||
<Header profile={convoState.recipients?.[0]} />
|
||||
<View style={[a.flex_1]}>
|
||||
{isConvoActive(convoState) ? (
|
||||
<MessagesList />
|
||||
) : (
|
||||
<ListMaybePlaceholder isLoading />
|
||||
)}
|
||||
{!hasInitiallyRendered && (
|
||||
<View
|
||||
style={[
|
||||
a.absolute,
|
||||
a.z_10,
|
||||
a.w_full,
|
||||
a.h_full,
|
||||
a.justify_center,
|
||||
a.align_center,
|
||||
t.atoms.bg,
|
||||
]}>
|
||||
<View style={[{marginBottom: 75}]}>
|
||||
<Loader size="xl" />
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
<CenteredView style={[a.flex_1]} sideBorders>
|
||||
<Header profile={convoState.recipients?.[0]} />
|
||||
<View style={[a.flex_1]}>
|
||||
{isConvoActive(convoState) ? (
|
||||
<MessagesList />
|
||||
) : (
|
||||
<ListMaybePlaceholder isLoading />
|
||||
)}
|
||||
{!hasInitiallyRendered && (
|
||||
<View
|
||||
style={[
|
||||
a.absolute,
|
||||
a.z_10,
|
||||
a.w_full,
|
||||
a.h_full,
|
||||
a.justify_center,
|
||||
a.align_center,
|
||||
t.atoms.bg,
|
||||
]}>
|
||||
<View style={[{marginBottom: 75}]}>
|
||||
<Loader size="xl" />
|
||||
</View>
|
||||
</View>
|
||||
</CenteredView>
|
||||
</KeyboardAvoidingView>
|
||||
</KeyboardProvider>
|
||||
)}
|
||||
</View>
|
||||
</CenteredView>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue