change approach for keeping tab highlit
This commit is contained in:
@@ -46,7 +46,11 @@ export function isTab(current: string, route: string) {
|
|||||||
// our tab routes can be variously referenced by 3 different names
|
// our tab routes can be variously referenced by 3 different names
|
||||||
// this helper deals with that weirdness
|
// this helper deals with that weirdness
|
||||||
// -prf
|
// -prf
|
||||||
return current.startsWith(route)
|
return (
|
||||||
|
current === route ||
|
||||||
|
current === `${route}Tab` ||
|
||||||
|
current === `${route}Inner`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum TabState {
|
export enum TabState {
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ function SwitcherMenuProfileLink() {
|
|||||||
return isTab(currentRouteInfo.name, pathName)
|
return isTab(currentRouteInfo.name, pathName)
|
||||||
}
|
}
|
||||||
}, [currentAccount?.handle, currentRouteInfo, pathName])
|
}, [currentAccount?.handle, currentRouteInfo, pathName])
|
||||||
|
|
||||||
const onProfilePress = useCallback(
|
const onProfilePress = useCallback(
|
||||||
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||||
if (e.ctrlKey || e.metaKey || e.altKey) {
|
if (e.ctrlKey || e.metaKey || e.altKey) {
|
||||||
@@ -411,6 +412,7 @@ function NavItem({
|
|||||||
(currentRouteInfo.params as CommonNavigatorParams['Profile']).name ===
|
(currentRouteInfo.params as CommonNavigatorParams['Profile']).name ===
|
||||||
currentAccount?.handle
|
currentAccount?.handle
|
||||||
: isTab(currentRouteInfo.name, pathName)
|
: isTab(currentRouteInfo.name, pathName)
|
||||||
|
const isRelated = currentRouteInfo.name.startsWith(pathName)
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const onPressWrapped = useCallback(
|
const onPressWrapped = useCallback(
|
||||||
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
(e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||||
@@ -461,7 +463,7 @@ function NavItem({
|
|||||||
height: 30,
|
height: 30,
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
{isCurrent ? iconFilled : icon}
|
{isCurrent || isRelated ? iconFilled : icon}
|
||||||
{typeof count === 'string' && count ? (
|
{typeof count === 'string' && count ? (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
|||||||
Reference in New Issue
Block a user