Profile back button tweaks for web (#8795)

* Profile back button tweaks

* apply review feedback - remove StyleSheet

* Update src/screens/Profile/Header/Shell.tsx

---------

Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
Bartosz Kaszubowski
2025-08-14 19:54:27 +02:00
committed by GitHub
parent 7b2e61bf4d
commit 9440068b69
+41 -55
View File
@@ -1,5 +1,5 @@
import {memo, useCallback, useEffect, useMemo} from 'react' import {memo, useCallback, useEffect, useMemo} from 'react'
import {StyleSheet, TouchableWithoutFeedback, View} from 'react-native' import {TouchableWithoutFeedback, View} from 'react-native'
import Animated, { import Animated, {
measure, measure,
type MeasuredDimensions, type MeasuredDimensions,
@@ -26,6 +26,8 @@ import {LoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserAvatar} from '#/view/com/util/UserAvatar'
import {UserBanner} from '#/view/com/util/UserBanner' import {UserBanner} from '#/view/com/util/UserBanner'
import {atoms as a, platform, useTheme} from '#/alf' import {atoms as a, platform, useTheme} from '#/alf'
import {transparentifyColor} from '#/alf/util/colorGeneration'
import {Button} from '#/components/Button'
import {useDialogControl} from '#/components/Dialog' import {useDialogControl} from '#/components/Dialog'
import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeftIcon} from '#/components/icons/Arrow' import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeftIcon} from '#/components/icons/Arrow'
import {EditLiveDialog} from '#/components/live/EditLiveDialog' import {EditLiveDialog} from '#/components/live/EditLiveDialog'
@@ -148,30 +150,46 @@ let ProfileHeaderShell = ({
<StatusBarShadow /> <StatusBarShadow />
<GrowableBanner <GrowableBanner
backButton={ backButton={
<> !hideBackButton && (
{!hideBackButton && ( <Button
<TouchableWithoutFeedback testID="profileHeaderBackBtn"
testID="profileHeaderBackBtn" onPress={onPressBack}
onPress={onPressBack} hitSlop={BACK_HITSLOP}
hitSlop={BACK_HITSLOP} label={_(msg`Back`)}
accessibilityRole="button" style={[
accessibilityLabel={_(msg`Back`)} a.absolute,
accessibilityHint=""> a.pointer,
{
top: platform({
web: 10,
default: topInset,
}),
left: platform({
web: 18,
default: 12,
}),
},
]}>
{({hovered}) => (
<View <View
style={[ style={[
styles.backBtnWrapper, a.align_center,
a.justify_center,
a.rounded_sm,
{ {
top: platform({ width: 31,
web: 10, height: 31,
default: topInset, backgroundColor: transparentifyColor('#000', 0.5),
}), },
hovered && {
backgroundColor: transparentifyColor('#000', 0.75),
}, },
]}> ]}>
<ArrowLeftIcon size="lg" fill="white" /> <ArrowLeftIcon size="lg" fill="white" />
</View> </View>
</TouchableWithoutFeedback> )}
)} </Button>
</> )
}> }>
{isPlaceholderProfile ? ( {isPlaceholderProfile ? (
<LoadingPlaceholder <LoadingPlaceholder
@@ -203,7 +221,7 @@ let ProfileHeaderShell = ({
</View> </View>
)} )}
<GrowableAvatar style={styles.aviPosition}> <GrowableAvatar style={[a.absolute, {top: 104, left: 10}]}>
<TouchableWithoutFeedback <TouchableWithoutFeedback
testID="profileHeaderAviButton" testID="profileHeaderAviButton"
onPress={onPressAvi} onPress={onPressAvi}
@@ -215,13 +233,14 @@ let ProfileHeaderShell = ({
t.atoms.bg, t.atoms.bg,
a.rounded_full, a.rounded_full,
{ {
width: 94,
height: 94,
borderWidth: live.isActive ? 3 : 2, borderWidth: live.isActive ? 3 : 2,
borderColor: live.isActive borderColor: live.isActive
? t.palette.negative_500 ? t.palette.negative_500
: t.atoms.bg.backgroundColor, : t.atoms.bg.backgroundColor,
}, },
styles.avi, profile.associated?.labeler && a.rounded_md,
profile.associated?.labeler && styles.aviLabeler,
]}> ]}>
<Animated.View ref={aviRef} collapsable={false}> <Animated.View ref={aviRef} collapsable={false}>
<UserAvatar <UserAvatar
@@ -255,39 +274,6 @@ let ProfileHeaderShell = ({
</View> </View>
) )
} }
ProfileHeaderShell = memo(ProfileHeaderShell) ProfileHeaderShell = memo(ProfileHeaderShell)
export {ProfileHeaderShell} export {ProfileHeaderShell}
const styles = StyleSheet.create({
backBtnWrapper: {
position: 'absolute',
left: 12,
width: 30,
height: 30,
overflow: 'hidden',
borderRadius: 15,
cursor: 'pointer',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
alignItems: 'center',
justifyContent: 'center',
},
backBtn: {
width: 30,
height: 30,
borderRadius: 15,
alignItems: 'center',
justifyContent: 'center',
},
aviPosition: {
position: 'absolute',
top: 104,
left: 10,
},
avi: {
width: 94,
height: 94,
},
aviLabeler: {
borderRadius: 10,
},
})