Fix Profile link from drawer on Mobile Web (#1437)
* 🗺️ fix an issue where web devices that see the Drawer couldn't access Profile from said Drawer
* fix routes on web
* handle profile button active state
* add hack for web navigation
* fix comment
---------
Co-authored-by: Micah Maligie <kerosuppi@gmail.com>
zio/stable
parent
e643c43459
commit
50f811666a
|
@ -348,7 +348,6 @@ const MyProfileTabNavigator = observer(function MyProfileTabNavigatorImpl() {
|
||||||
component={ProfileScreen}
|
component={ProfileScreen}
|
||||||
initialParams={{
|
initialParams={{
|
||||||
name: store.me.did,
|
name: store.me.did,
|
||||||
hideBackButton: true,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{commonScreens(MyProfileTab as typeof HomeTab)}
|
{commonScreens(MyProfileTab as typeof HomeTab)}
|
||||||
|
@ -362,7 +361,9 @@ const MyProfileTabNavigator = observer(function MyProfileTabNavigatorImpl() {
|
||||||
*/
|
*/
|
||||||
const FlatNavigator = observer(function FlatNavigatorImpl() {
|
const FlatNavigator = observer(function FlatNavigatorImpl() {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const unreadCountLabel = useStores().me.notifications.unreadCountLabel
|
const store = useStores()
|
||||||
|
const unreadCountLabel = store.me.notifications.unreadCountLabel
|
||||||
|
|
||||||
const title = (page: string) => bskyTitle(page, unreadCountLabel)
|
const title = (page: string) => bskyTitle(page, unreadCountLabel)
|
||||||
return (
|
return (
|
||||||
<Flat.Navigator
|
<Flat.Navigator
|
||||||
|
|
|
@ -64,8 +64,13 @@ export const DrawerContent = observer(function DrawerContentImpl() {
|
||||||
const state = navigation.getState()
|
const state = navigation.getState()
|
||||||
store.shell.closeDrawer()
|
store.shell.closeDrawer()
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
|
// hack because we have flat navigator for web and MyProfile does not exist on the web navigator -ansh
|
||||||
|
if (tab === 'MyProfile') {
|
||||||
|
navigation.navigate('Profile', {name: store.me.handle})
|
||||||
|
} else {
|
||||||
// @ts-ignore must be Home, Search, Notifications, or MyProfile
|
// @ts-ignore must be Home, Search, Notifications, or MyProfile
|
||||||
navigation.navigate(tab)
|
navigation.navigate(tab)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const tabState = getTabState(state, tab)
|
const tabState = getTabState(state, tab)
|
||||||
if (tabState === TabState.InsideAtRoot) {
|
if (tabState === TabState.InsideAtRoot) {
|
||||||
|
|
|
@ -18,10 +18,12 @@ import {
|
||||||
SatelliteDishIcon,
|
SatelliteDishIcon,
|
||||||
SatelliteDishIconSolid,
|
SatelliteDishIconSolid,
|
||||||
UserIcon,
|
UserIcon,
|
||||||
|
UserIconSolid,
|
||||||
} from 'lib/icons'
|
} from 'lib/icons'
|
||||||
import {Link} from 'view/com/util/Link'
|
import {Link} from 'view/com/util/Link'
|
||||||
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
|
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
|
||||||
import {makeProfileLink} from 'lib/routes/links'
|
import {makeProfileLink} from 'lib/routes/links'
|
||||||
|
import {CommonNavigatorParams} from 'lib/routes/types'
|
||||||
|
|
||||||
export const BottomBarWeb = observer(function BottomBarWebImpl() {
|
export const BottomBarWeb = observer(function BottomBarWebImpl() {
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
|
@ -89,13 +91,16 @@ export const BottomBarWeb = observer(function BottomBarWebImpl() {
|
||||||
}}
|
}}
|
||||||
</NavItem>
|
</NavItem>
|
||||||
<NavItem routeName="Profile" href={makeProfileLink(store.me)}>
|
<NavItem routeName="Profile" href={makeProfileLink(store.me)}>
|
||||||
{() => (
|
{({isActive}) => {
|
||||||
<UserIcon
|
const Icon = isActive ? UserIconSolid : UserIcon
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
size={28}
|
size={28}
|
||||||
strokeWidth={1.5}
|
strokeWidth={1.5}
|
||||||
style={[styles.ctrlIcon, pal.text, styles.profileIcon]}
|
style={[styles.ctrlIcon, pal.text, styles.profileIcon]}
|
||||||
/>
|
/>
|
||||||
)}
|
)
|
||||||
|
}}
|
||||||
</NavItem>
|
</NavItem>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)
|
)
|
||||||
|
@ -107,7 +112,14 @@ const NavItem: React.FC<{
|
||||||
routeName: string
|
routeName: string
|
||||||
}> = ({children, href, routeName}) => {
|
}> = ({children, href, routeName}) => {
|
||||||
const currentRoute = useNavigationState(getCurrentRoute)
|
const currentRoute = useNavigationState(getCurrentRoute)
|
||||||
const isActive = isTab(currentRoute.name, routeName)
|
const store = useStores()
|
||||||
|
const isActive =
|
||||||
|
currentRoute.name === 'Profile'
|
||||||
|
? isTab(currentRoute.name, routeName) &&
|
||||||
|
(currentRoute.params as CommonNavigatorParams['Profile']).name ===
|
||||||
|
store.me.handle
|
||||||
|
: isTab(currentRoute.name, routeName)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={href} style={styles.ctrl}>
|
<Link href={href} style={styles.ctrl}>
|
||||||
{children({isActive})}
|
{children({isActive})}
|
||||||
|
|
Loading…
Reference in New Issue