Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tab bar layout on ipad #2

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions packages/legacy/core/App/navigators/TabStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { useNetwork } from '../contexts/network'
import { useTheme } from '../contexts/theme'
import { Screens, Stacks, TabStackParams, TabStacks } from '../types/navigators'
import { TourID } from '../types/tour'
import { isTablet, orientation, Orientation } from '../utils/helpers'
import { testIdWithKey } from '../utils/testable'

import CredentialStack from './CredentialStack'
import HomeStack from './HomeStack'

const TabStack: React.FC = () => {
const { width, height } = useWindowDimensions()
const { useCustomNotifications } = useConfiguration()
const { total } = useCustomNotifications()
const { t } = useTranslation()
Expand All @@ -31,6 +33,14 @@ const TabStack: React.FC = () => {
},
})

const leftMarginForDevice = (width: number, height: number) => {
if (isTablet(width, height)) {
return orientation(width, height) === Orientation.Portrait ? 130 : 170
}

return 0
}

return (
<SafeAreaView style={{ flex: 1, backgroundColor: ColorPallet.brand.primary }}>
<Tab.Navigator
Expand All @@ -53,11 +63,11 @@ const TabStack: React.FC = () => {
<AttachTourStep tourID={TourID.HomeTour} index={1}>
<View style={{ ...TabTheme.tabBarContainerStyle, justifyContent: showLabels ? 'flex-end' : 'center' }}>
<Icon name={focused ? 'message-text' : 'message-text-outline'} color={color} size={30} />

{showLabels && (
<Text
style={{
...TabTheme.tabBarTextStyle,
color: focused ? TabTheme.tabBarActiveTintColor : TabTheme.tabBarInactiveTintColor,
fontWeight: focused ? 'bold' : 'normal',
}}
>
Expand All @@ -68,12 +78,15 @@ const TabStack: React.FC = () => {
</AttachTourStep>
),
tabBarShowLabel: false,
tabBarBadge: total || undefined,
tabBarBadgeStyle: { backgroundColor: ColorPallet.semantic.error },
tabBarAccessibilityLabel: `${t('TabStack.Home')} (${
total === 1 ? t('Home.OneNotification') : t('Home.CountNotifications', { count: total || 0 })
})`,
tabBarTestID: testIdWithKey(t('TabStack.Home')),
tabBarBadge: total || undefined,
tabBarBadgeStyle: {
marginLeft: leftMarginForDevice(width, height),
backgroundColor: ColorPallet.semantic.error,
},
}}
/>
<Tab.Screen
Expand Down