restyle reply prompt
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
import {useCallback, useMemo, useRef, useState} from 'react'
|
import {useCallback, useMemo, useRef, useState} from 'react'
|
||||||
import {useWindowDimensions, View} from 'react-native'
|
import {useWindowDimensions, View} from 'react-native'
|
||||||
import Animated from 'react-native-reanimated'
|
import Animated, {useAnimatedStyle} from 'react-native-reanimated'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
|
||||||
import {Trans} from '@lingui/macro'
|
import {Trans} from '@lingui/macro'
|
||||||
|
|
||||||
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
||||||
import {useMinimalShellFabTransform} from '#/lib/hooks/useMinimalShellTransform'
|
|
||||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||||
import {clamp} from '#/lib/numbers'
|
|
||||||
import {type ThreadViewOption} from '#/state/queries/preferences/useThreadPreferences'
|
import {type ThreadViewOption} from '#/state/queries/preferences/useThreadPreferences'
|
||||||
import {type ThreadItem, usePostThread} from '#/state/queries/usePostThread'
|
import {type ThreadItem, usePostThread} from '#/state/queries/usePostThread'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {type OnPostSuccessData} from '#/state/shell/composer'
|
import {type OnPostSuccessData} from '#/state/shell/composer'
|
||||||
|
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||||
import {PostThreadComposePrompt} from '#/view/com/post-thread/PostThreadComposePrompt'
|
import {PostThreadComposePrompt} from '#/view/com/post-thread/PostThreadComposePrompt'
|
||||||
import {List, type ListMethods} from '#/view/com/util/List'
|
import {List, type ListMethods} from '#/view/com/util/List'
|
||||||
import {HeaderDropdown} from '#/screens/PostThread/components/HeaderDropdown'
|
import {HeaderDropdown} from '#/screens/PostThread/components/HeaderDropdown'
|
||||||
@@ -533,20 +531,16 @@ export function PostThread({uri}: {uri: string | undefined}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function MobileComposePrompt({onPressReply}: {onPressReply: () => unknown}) {
|
function MobileComposePrompt({onPressReply}: {onPressReply: () => unknown}) {
|
||||||
const safeAreaInsets = useSafeAreaInsets()
|
const {footerHeight} = useShellLayout()
|
||||||
const fabMinimalShellTransform = useMinimalShellFabTransform()
|
|
||||||
|
const animatedStyle = useAnimatedStyle(() => {
|
||||||
|
return {
|
||||||
|
bottom: footerHeight.get(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View
|
<Animated.View style={[a.fixed, a.left_0, a.right_0, animatedStyle]}>
|
||||||
style={[
|
|
||||||
a.fixed,
|
|
||||||
fabMinimalShellTransform,
|
|
||||||
{
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: clamp(safeAreaInsets.bottom, 13, 60),
|
|
||||||
},
|
|
||||||
]}>
|
|
||||||
<PostThreadComposePrompt onPressCompose={onPressReply} />
|
<PostThreadComposePrompt onPressCompose={onPressReply} />
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import React, {memo, useRef, useState} from 'react'
|
import React, {memo, useRef, useState} from 'react'
|
||||||
import {StyleSheet, useWindowDimensions, View} from 'react-native'
|
import {useWindowDimensions, View} from 'react-native'
|
||||||
import {runOnJS} from 'react-native-reanimated'
|
import {runOnJS, useAnimatedStyle} from 'react-native-reanimated'
|
||||||
import Animated from 'react-native-reanimated'
|
import Animated from 'react-native-reanimated'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
|
||||||
import {
|
import {
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
type AppBskyFeedThreadgate,
|
type AppBskyFeedThreadgate,
|
||||||
@@ -13,11 +12,9 @@ import {useLingui} from '@lingui/react'
|
|||||||
|
|
||||||
import {HITSLOP_10} from '#/lib/constants'
|
import {HITSLOP_10} from '#/lib/constants'
|
||||||
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
||||||
import {useMinimalShellFabTransform} from '#/lib/hooks/useMinimalShellTransform'
|
|
||||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||||
import {useSetTitle} from '#/lib/hooks/useSetTitle'
|
import {useSetTitle} from '#/lib/hooks/useSetTitle'
|
||||||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
||||||
import {clamp} from '#/lib/numbers'
|
|
||||||
import {ScrollProvider} from '#/lib/ScrollContext'
|
import {ScrollProvider} from '#/lib/ScrollContext'
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
@@ -36,6 +33,7 @@ import {
|
|||||||
import {useSetThreadViewPreferencesMutation} from '#/state/queries/preferences'
|
import {useSetThreadViewPreferencesMutation} from '#/state/queries/preferences'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
|
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||||
import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
||||||
import {List, type ListMethods} from '#/view/com/util/List'
|
import {List, type ListMethods} from '#/view/com/util/List'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
@@ -715,17 +713,16 @@ let ThreadMenu = ({
|
|||||||
ThreadMenu = memo(ThreadMenu)
|
ThreadMenu = memo(ThreadMenu)
|
||||||
|
|
||||||
function MobileComposePrompt({onPressReply}: {onPressReply: () => unknown}) {
|
function MobileComposePrompt({onPressReply}: {onPressReply: () => unknown}) {
|
||||||
const safeAreaInsets = useSafeAreaInsets()
|
const {footerHeight} = useShellLayout()
|
||||||
const fabMinimalShellTransform = useMinimalShellFabTransform()
|
|
||||||
|
const animatedStyle = useAnimatedStyle(() => {
|
||||||
|
return {
|
||||||
|
bottom: footerHeight.get(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View
|
<Animated.View style={[a.fixed, a.left_0, a.right_0, animatedStyle]}>
|
||||||
style={[
|
|
||||||
styles.prompt,
|
|
||||||
fabMinimalShellTransform,
|
|
||||||
{
|
|
||||||
bottom: clamp(safeAreaInsets.bottom, 13, 60),
|
|
||||||
},
|
|
||||||
]}>
|
|
||||||
<PostThreadComposePrompt onPressCompose={onPressReply} />
|
<PostThreadComposePrompt onPressCompose={onPressReply} />
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)
|
)
|
||||||
@@ -890,12 +887,3 @@ function hasBranchingReplies(node?: ThreadNode) {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
prompt: {
|
|
||||||
// @ts-ignore web-only
|
|
||||||
position: isWeb ? 'fixed' : 'absolute',
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {LinearGradient} from 'expo-linear-gradient'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
@@ -7,7 +8,7 @@ import {useHaptics} from '#/lib/haptics'
|
|||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useProfileQuery} from '#/state/queries/profile'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, ios, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, ios, native, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
@@ -29,28 +30,46 @@ export function PostThreadComposePrompt({
|
|||||||
} = useInteractionState()
|
} = useInteractionState()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PressableScale
|
<View
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel={_(msg`Compose reply`)}
|
|
||||||
accessibilityHint={_(msg`Opens composer`)}
|
|
||||||
style={[
|
style={[
|
||||||
gtMobile ? a.py_xs : {paddingTop: 8, paddingBottom: 11},
|
gtMobile
|
||||||
a.px_sm,
|
? [
|
||||||
a.border_t,
|
a.py_xs,
|
||||||
t.atoms.border_contrast_low,
|
a.px_sm,
|
||||||
t.atoms.bg,
|
a.border_t,
|
||||||
]}
|
t.atoms.border_contrast_low,
|
||||||
onPress={() => {
|
t.atoms.bg,
|
||||||
onPressCompose()
|
]
|
||||||
playHaptic('Light')
|
: [a.px_md, a.pt_sm],
|
||||||
}}
|
]}>
|
||||||
onLongPress={ios(() => {
|
{!gtMobile && (
|
||||||
onPressCompose()
|
<LinearGradient
|
||||||
playHaptic('Heavy')
|
start={[0.5, 0]}
|
||||||
})}
|
end={[0.5, 1]}
|
||||||
onHoverIn={onHoverIn}
|
colors={[
|
||||||
onHoverOut={onHoverOut}>
|
// "white transparent" - the CSS transparent keyword
|
||||||
<View
|
// is black transparent
|
||||||
|
'rgba(255, 255, 255, 0)',
|
||||||
|
t.atoms.bg.backgroundColor,
|
||||||
|
]}
|
||||||
|
locations={[0.15, 0.4]}
|
||||||
|
style={[a.absolute, a.inset_0]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<PressableScale
|
||||||
|
accessibilityRole="button"
|
||||||
|
accessibilityLabel={_(msg`Compose reply`)}
|
||||||
|
accessibilityHint={_(msg`Opens composer`)}
|
||||||
|
onPress={() => {
|
||||||
|
onPressCompose()
|
||||||
|
playHaptic('Light')
|
||||||
|
}}
|
||||||
|
onLongPress={ios(() => {
|
||||||
|
onPressCompose()
|
||||||
|
playHaptic('Heavy')
|
||||||
|
})}
|
||||||
|
onHoverIn={onHoverIn}
|
||||||
|
onHoverOut={onHoverOut}
|
||||||
style={[
|
style={[
|
||||||
a.flex_row,
|
a.flex_row,
|
||||||
a.align_center,
|
a.align_center,
|
||||||
@@ -58,6 +77,7 @@ export function PostThreadComposePrompt({
|
|||||||
a.gap_sm,
|
a.gap_sm,
|
||||||
a.rounded_full,
|
a.rounded_full,
|
||||||
(!gtMobile || hovered) && t.atoms.bg_contrast_25,
|
(!gtMobile || hovered) && t.atoms.bg_contrast_25,
|
||||||
|
native([a.border, t.atoms.border_contrast_low]),
|
||||||
a.transition_color,
|
a.transition_color,
|
||||||
]}>
|
]}>
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
@@ -68,7 +88,7 @@ export function PostThreadComposePrompt({
|
|||||||
<Text style={[a.text_md, t.atoms.text_contrast_medium]}>
|
<Text style={[a.text_md, t.atoms.text_contrast_medium]}>
|
||||||
<Trans>Write your reply</Trans>
|
<Trans>Write your reply</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</PressableScale>
|
||||||
</PressableScale>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user