Skip to content

Commit

Permalink
fix: large title on all tab screens now fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
thoreyjona committed Jul 11, 2024
1 parent 97f20ab commit 48a2155
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
12 changes: 12 additions & 0 deletions apps/native/app/src/screens/applications/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { useBrowser } from '../../lib/useBrowser'
import { getApplicationOverviewUrl } from '../../utils/applications-utils'
import { testIDs } from '../../utils/test-ids'
import { ApplicationsModule } from '../home/applications-module'
import { useNavigationComponentDidAppear } from 'react-native-navigation-hooks'
import { isIos } from '../../utils/devices'

type ListItem =
| { id: string; __typename: 'Skeleton' }
Expand Down Expand Up @@ -78,6 +80,7 @@ export const ApplicationsScreen: NavigationFunctionComponent = ({
const [refetching, setRefetching] = useState(false)
const intl = useIntl()
const scrollY = useRef(new Animated.Value(0)).current
const [hiddenContent, setHiddenContent] = useState(isIos)

const res = useListSearchQuery({
variables: {
Expand All @@ -99,6 +102,10 @@ export const ApplicationsScreen: NavigationFunctionComponent = ({
queryResult: [applicationsRes, res],
})

useNavigationComponentDidAppear(() => {
setHiddenContent(false)
}, componentId)

const data = useMemo<ListItem[]>(() => {
if (!res.data && res.loading) {
return Array.from({ length: 8 }).map((_, id) => ({
Expand Down Expand Up @@ -149,6 +156,11 @@ export const ApplicationsScreen: NavigationFunctionComponent = ({
}
}, [applicationsRes])

// Fix for a bug in react-native-navigation where the large title is not visible on iOS with bottom tabs https://github.com/wix/react-native-navigation/issues/6717
if (hiddenContent) {
return null
}

return (
<>
<Animated.FlatList
Expand Down
8 changes: 5 additions & 3 deletions apps/native/app/src/screens/inbox/inbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { useOrganizationsStore } from '../../stores/organizations-store'
import { useUiStore } from '../../stores/ui-store'
import { ComponentRegistry } from '../../utils/component-registry'
import { testIDs } from '../../utils/test-ids'
import { isIos } from '../../utils/devices'

type ListItem =
| { id: string; type: 'skeleton' | 'empty' }
Expand Down Expand Up @@ -273,7 +274,7 @@ export const InboxScreen: NavigationFunctionComponent<{
const [query, setQuery] = useState('')
const queryString = useThrottleState(query)
const theme = useTheme()
const [visible, setVisible] = useState(false)
const [hiddenContent, setHiddenContent] = useState(isIos)
const [refetching, setRefetching] = useState(false)

const res = useInboxQuery({
Expand Down Expand Up @@ -390,7 +391,7 @@ export const InboxScreen: NavigationFunctionComponent<{
}, [res.refetching, items, markAllAsReadLoading]) as ListItem[]

useNavigationComponentDidAppear(() => {
setVisible(true)
setHiddenContent(false)
}, componentId)

const onPressMarkAllAsRead = () => {
Expand Down Expand Up @@ -421,7 +422,8 @@ export const InboxScreen: NavigationFunctionComponent<{
)
}

if (!visible) {
// Fix for a bug in react-native-navigation where the large title is not visible on iOS with bottom tabs https://github.com/wix/react-native-navigation/issues/6717
if (hiddenContent) {
return null
}

Expand Down
13 changes: 12 additions & 1 deletion apps/native/app/src/screens/more/more.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FamilyMemberCard, ListButton } from '@ui'
import React from 'react'
import React, { useState } from 'react'
import { useIntl } from 'react-intl'
import {
Image,
Expand All @@ -23,6 +23,8 @@ import { formatNationalId } from '../../lib/format-national-id'
import { useAuthStore } from '../../stores/auth-store'
import { testIDs } from '../../utils/test-ids'
import { getRightButtons } from '../../utils/get-main-root'
import { useNavigationComponentDidAppear } from 'react-native-navigation-hooks'
import { isIos } from '../../utils/devices'

const Row = styled.View`
margin-top: ${({ theme }) => theme.spacing[2]}px;
Expand Down Expand Up @@ -75,6 +77,7 @@ export const MoreScreen: NavigationFunctionComponent = ({ componentId }) => {
const authStore = useAuthStore()
const intl = useIntl()
const theme = useTheme()
const [hiddenContent, setHiddenContent] = useState(isIos)
const showFinances = useFeatureFlag('isFinancesEnabled', false)
const showAirDiscount = useFeatureFlag('isAirDiscountEnabled', false)

Expand All @@ -83,6 +86,14 @@ export const MoreScreen: NavigationFunctionComponent = ({ componentId }) => {
componentId,
rightButtons: getRightButtons({ screen: 'More' }),
})
useNavigationComponentDidAppear(() => {
setHiddenContent(false)
}, componentId)

// Fix for a bug in react-native-navigation where the large title is not visible on iOS with bottom tabs https://github.com/wix/react-native-navigation/issues/6717
if (hiddenContent) {
return null
}

return (
<>
Expand Down
11 changes: 11 additions & 0 deletions apps/native/app/src/screens/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { getRightButtons } from '../../utils/get-main-root'
import { isDefined } from '../../utils/is-defined'
import { testIDs } from '../../utils/test-ids'
import { WalletItem } from './components/wallet-item'
import { useNavigationComponentDidAppear } from 'react-native-navigation-hooks'

type FlatListItem =
| GenericUserLicense
Expand Down Expand Up @@ -96,6 +97,7 @@ export const WalletScreen: NavigationFunctionComponent = ({ componentId }) => {
const intl = useIntl()
const scrollY = useRef(new Animated.Value(0)).current
const { dismiss, dismissed } = usePreferencesStore()
const [hiddenContent, setHiddenContent] = useState(isIos)

// Feature flags
const showPassport = useFeatureFlag('isPassportEnabled', false)
Expand Down Expand Up @@ -194,6 +196,10 @@ export const WalletScreen: NavigationFunctionComponent = ({ componentId }) => {
}
}, [])

useNavigationComponentDidAppear(() => {
setHiddenContent(false)
}, componentId)

const renderItem = useCallback(
({ item }: ListRenderItemInfo<FlatListItem>) => {
if (item.__typename === 'Skeleton') {
Expand Down Expand Up @@ -258,6 +264,11 @@ export const WalletScreen: NavigationFunctionComponent = ({ componentId }) => {
] as FlatListItem[]
}, [licenseItems, resPassport, showPassport, res.loading, res.data])

// Fix for a bug in react-native-navigation where the large title is not visible on iOS with bottom tabs https://github.com/wix/react-native-navigation/issues/6717
if (hiddenContent) {
return null
}

return (
<>
<Animated.FlatList
Expand Down

0 comments on commit 48a2155

Please sign in to comment.