Skip to content

Commit

Permalink
fix(art-quiz): fix tabs issue (#8861)
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi authored Jun 12, 2023
1 parent cd0d3f6 commit fa9d0dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ArtQuizExploreArtworks = ({
<Tabs.ScrollView
contentContainerStyle={{
marginVertical: space(2),
paddingBottom: space(4),
paddingHorizontal: space(1),
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const ArtQuizLikedArtworks = ({
return (
<Tabs.ScrollView
contentContainerStyle={{
paddingBottom: space(4),
marginVertical: space(2),
paddingHorizontal: space(1),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ArtQuizExploreArtworks } from "app/Scenes/ArtQuiz/ArtQuizResults/ArtQui
import { ArtQuizLikedArtworks } from "app/Scenes/ArtQuiz/ArtQuizResults/ArtQuizResultsTabs/ArtQuizLikedArtworks"
import { ArtQuizResultsTabsHeader } from "app/Scenes/ArtQuiz/ArtQuizResults/ArtQuizResultsTabs/ArtQuizResultsTabsHeader"
import { navigate } from "app/system/navigation/navigate"
import { useState } from "react"
import React, { useState } from "react"
import { graphql, useFragment } from "react-relay"

type TabName = "worksYouLiked" | "exploreWorks" | "exploreArtists"
Expand All @@ -24,32 +24,14 @@ export const ArtQuizResultsTabs = ({ me }: { me: ArtQuizResultsQuery$data["me"]
return (
<Tabs.TabsWithHeader
title={title}
tabScrollEnabled
lazy
headerProps={{
onBack: () => navigate("/"),
}}
onTabPress={(tabName) => {
setActiveTab(tabName as TabName)
}}
onTabChange={({ tabName }) => {
setActiveTab(tabName as TabName)
}}
BelowTitleHeaderComponent={() => {
if (activeTab === "worksYouLiked") {
return (
<Flex mb={1}>
<ArtQuizResultsTabsHeader subtitle="We think you’ll enjoy these recommendations based on your likes. Keep saving and following to continue tailoring Artsy to you." />
</Flex>
)
}

return (
<Flex mb={1}>
<ArtQuizResultsTabsHeader subtitle="We think you’ll enjoy these recommendations based on your likes. To tailor Artsy to your art tastes, follow artists and save works you love." />
</Flex>
)
}}
BelowTitleHeaderComponent={() => <BelowHeaderComponent activeTab={activeTab} />}
>
<Tabs.Tab name="worksYouLiked" label="Works you liked">
<Tabs.Lazy>
Expand All @@ -70,6 +52,22 @@ export const ArtQuizResultsTabs = ({ me }: { me: ArtQuizResultsQuery$data["me"]
)
}

const BelowHeaderComponent: React.FC<{ activeTab: TabName }> = React.memo((props) => {
if (props.activeTab === "worksYouLiked") {
return (
<Flex mb={1}>
<ArtQuizResultsTabsHeader subtitle="We think you’ll enjoy these recommendations based on your likes. Keep saving and following to continue tailoring Artsy to you." />
</Flex>
)
}

return (
<Flex mb={1}>
<ArtQuizResultsTabsHeader subtitle="We think you’ll enjoy these recommendations based on your likes. To tailor Artsy to your art tastes, follow artists and save works you love." />
</Flex>
)
})

const artQuizResultsTabsFragment = graphql`
fragment ArtQuizResultsTabs_me on Me {
quiz {
Expand Down

0 comments on commit fa9d0dc

Please sign in to comment.