Skip to content

Commit

Permalink
add lang select to right nav if left nav is minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius committed Feb 8, 2025
1 parent 6f5e55f commit 1dd65ab
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/view/shell/desktop/RightNav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import {useEffect, useState} from 'react'
import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
Expand All @@ -17,23 +17,23 @@ import {
useTheme,
web,
} from '#/alf'
import {AppLanguageDropdown} from '#/components/AppLanguageDropdown'
import {Divider} from '#/components/Divider'
import {InlineLinkText} from '#/components/Link'
import {ProgressGuideList} from '#/components/ProgressGuide/List'
import {Text} from '#/components/Typography'

function useWebQueryParams() {
const navigation = useNavigation()
const [params, setParams] = React.useState<Record<string, string>>({})
const [params, setParams] = useState<Record<string, string>>({})

React.useEffect(() => {
useEffect(() => {
return navigation.addListener('state', e => {
try {
const {state} = e.data
const lastRoute = state.routes[state.routes.length - 1]
const {params} = lastRoute
setParams(params)
} catch (e) {}
setParams(lastRoute.params)
} catch (err) {}
})
}, [navigation, setParams])

Expand All @@ -50,7 +50,8 @@ export function DesktopRightNav({routeName}: {routeName: string}) {
const webqueryParams = useWebQueryParams()
const searchQuery = webqueryParams?.q
const showTrending = !isSearchScreen || (isSearchScreen && !!searchQuery)
const {rightNavVisible, centerColumnOffset} = useLayoutBreakpoints()
const {rightNavVisible, centerColumnOffset, leftNavMinimal} =
useLayoutBreakpoints()

if (!rightNavVisible) {
return null
Expand Down Expand Up @@ -128,6 +129,12 @@ export function DesktopRightNav({routeName}: {routeName: string}) {
</Trans>
</Text>
)}

{!hasSession && leftNavMinimal && (
<View style={[a.w_full, {height: 32}]}>
<AppLanguageDropdown style={{marginTop: 0}} />
</View>
)}
</View>
)
}

0 comments on commit 1dd65ab

Please sign in to comment.