-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bottom sheet to infinite discovery
- Loading branch information
1 parent
06a164f
commit e80af24
Showing
34 changed files
with
1,249 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { FollowButton } from "@artsy/palette-mobile" | ||
import { ArtistFollowButtonQuery } from "__generated__/ArtistFollowButtonQuery.graphql" | ||
import { ArtistFollowButton_artist$key } from "__generated__/ArtistFollowButton_artist.graphql" | ||
import { useFollowArtist } from "app/utils/mutations/useFollowArtist" | ||
import { FC } from "react" | ||
import { useLazyLoadQuery, graphql, useFragment } from "react-relay" | ||
|
||
interface ArtistFollowButtonProps { | ||
artist: ArtistFollowButton_artist$key | ||
} | ||
|
||
export const ArtistFollowButton: FC<ArtistFollowButtonProps> = ({ artist }) => { | ||
const data = useFragment(fragment, artist) | ||
const [commitMutation, isInFlight] = useFollowArtist() | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const handleOnPress = () => { | ||
commitMutation({ | ||
variables: { input: { artistID: data.internalID, unfollow: data.isFollowed } }, | ||
updater: (store) => { | ||
store.get(data.internalID)?.setValue(!data.isFollowed, "isFollowed") | ||
}, | ||
}) | ||
} | ||
|
||
return <FollowButton isFollowed={data.isFollowed} onPress={handleOnPress} loading={isInFlight} /> | ||
} | ||
|
||
const fragment = graphql` | ||
fragment ArtistFollowButton_artist on Artist { | ||
internalID @required(action: NONE) | ||
isFollowed @required(action: NONE) | ||
} | ||
` | ||
|
||
interface ArtistFollowButtonQueryRendererProps { | ||
artistID: string | ||
} | ||
|
||
export const ArtistFollowButtonQueryRenderer: FC<ArtistFollowButtonQueryRendererProps> = ({ | ||
artistID, | ||
}) => { | ||
const data = useLazyLoadQuery<ArtistFollowButtonQuery>(query, { id: artistID }) | ||
|
||
if (!data.artist) { | ||
return <FollowButton isFollowed={false} /> | ||
} | ||
|
||
return <ArtistFollowButton artist={data.artist} /> | ||
} | ||
|
||
const query = graphql` | ||
query ArtistFollowButtonQuery($id: String!) { | ||
artist(id: $id) { | ||
...ArtistFollowButton_artist | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { EntityHeader, Flex, Touchable } from "@artsy/palette-mobile" | ||
import { ArtistListItemShortQuery } from "__generated__/ArtistListItemShortQuery.graphql" | ||
import { ArtistListItemShort_artist$key } from "__generated__/ArtistListItemShort_artist.graphql" | ||
import { ArtistFollowButtonQueryRenderer } from "app/Components/ArtistFollowButton" | ||
import { ReadMore } from "app/Components/ReadMore" | ||
import { navigate } from "app/system/navigation/navigate" | ||
import { truncatedTextLimit } from "app/utils/hardware" | ||
import { withSuspense } from "app/utils/hooks/withSuspense" | ||
import { FC } from "react" | ||
import { graphql, useFragment, useLazyLoadQuery } from "react-relay" | ||
|
||
interface ArtistListItemShortProps { | ||
artist: ArtistListItemShort_artist$key | ||
} | ||
|
||
export const ArtistListItemShort: FC<ArtistListItemShortProps> = ({ artist }) => { | ||
const data = useFragment(fragment, artist) | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const image = data.coverArtwork?.image?.cropped?.url ?? undefined | ||
const bio = data?.biographyBlurb?.text | ||
const bioTextLimit = truncatedTextLimit() | ||
|
||
const handleOnPress = () => { | ||
navigate(data.href) | ||
} | ||
|
||
return ( | ||
<> | ||
<Flex flexDirection="row" justifyContent="space-between" alignItems="center"> | ||
<Touchable onPress={handleOnPress} style={{ flex: 1 }}> | ||
<EntityHeader | ||
name={data.name} | ||
initials={data.initials} | ||
imageUrl={image} | ||
meta={data.formattedNationalityAndBirthday ?? undefined} | ||
RightButton={<ArtistFollowButtonQueryRenderer artistID={data.internalID} />} | ||
/> | ||
</Touchable> | ||
</Flex> | ||
|
||
{!!bio && ( | ||
<ReadMore content={bio} maxChars={bioTextLimit} textVariant="xs" linkTextVariant="xs" /> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const fragment = graphql` | ||
fragment ArtistListItemShort_artist on Artist { | ||
internalID @required(action: NONE) | ||
name @required(action: NONE) | ||
initials @required(action: NONE) | ||
href @required(action: NONE) | ||
formattedNationalityAndBirthday | ||
coverArtwork { | ||
image { | ||
cropped(height: 45, width: 45) { | ||
url | ||
} | ||
} | ||
} | ||
biographyBlurb { | ||
text | ||
} | ||
} | ||
` | ||
|
||
interface ArtworkListItemShortWithSuspenseProps { | ||
artistSlug: string | ||
} | ||
|
||
export const ArtworkListItemShortWithSuspense = withSuspense<ArtworkListItemShortWithSuspenseProps>( | ||
{ | ||
Component: ({ artistSlug }) => { | ||
const data = useLazyLoadQuery<ArtistListItemShortQuery>(query, { slug: artistSlug }) | ||
|
||
if (!data?.artist) { | ||
return null | ||
} | ||
|
||
return <ArtistListItemShort artist={data.artist} /> | ||
}, | ||
LoadingFallback: () => null, | ||
ErrorFallback: () => null, | ||
} | ||
) | ||
|
||
const query = graphql` | ||
query ArtistListItemShortQuery($slug: String!) { | ||
artist(id: $slug) { | ||
...ArtistListItemShort_artist | ||
name | ||
} | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { FollowButton } from "@artsy/palette-mobile" | ||
import { PartnerFollowButtonQuery } from "__generated__/PartnerFollowButtonQuery.graphql" | ||
import { PartnerFollowButton_partner$key } from "__generated__/PartnerFollowButton_partner.graphql" | ||
import { useFollowProfile } from "app/utils/mutations/useFollowProfile" | ||
import { FC } from "react" | ||
import { graphql, useFragment, useLazyLoadQuery } from "react-relay" | ||
|
||
interface PartnerFollowButtonProps { | ||
partner: PartnerFollowButton_partner$key | ||
} | ||
|
||
export const PartnerFollowButton: FC<PartnerFollowButtonProps> = ({ partner }) => { | ||
const data = useFragment(fragment, partner) | ||
const { followProfile, isInFlight } = useFollowProfile({ | ||
id: data?.profile.id ?? "", | ||
internalID: data?.profile.internalID ?? "", | ||
isFollowed: !!data?.profile.isFollowed, | ||
}) | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const handleOnPress = () => { | ||
followProfile() | ||
} | ||
|
||
return ( | ||
<FollowButton | ||
isFollowed={!!data.profile.isFollowed} | ||
onPress={handleOnPress} | ||
loading={isInFlight} | ||
/> | ||
) | ||
} | ||
|
||
const fragment = graphql` | ||
fragment PartnerFollowButton_partner on Partner { | ||
internalID @required(action: NONE) | ||
profile @required(action: NONE) { | ||
id @required(action: NONE) | ||
internalID @required(action: NONE) | ||
isFollowed | ||
} | ||
} | ||
` | ||
|
||
interface PartnerFollowButtonQueryRendererProps { | ||
partnerID: string | ||
} | ||
|
||
export const PartnerFollowButtonQueryRenderer: FC<PartnerFollowButtonQueryRendererProps> = ({ | ||
partnerID, | ||
}) => { | ||
const data = useLazyLoadQuery<PartnerFollowButtonQuery>(query, { id: partnerID }) | ||
|
||
if (!data.partner) { | ||
return <FollowButton isFollowed={false} /> | ||
} | ||
|
||
return <PartnerFollowButton partner={data.partner} /> | ||
} | ||
|
||
const query = graphql` | ||
query PartnerFollowButtonQuery($id: String!) { | ||
partner(id: $id) { | ||
...PartnerFollowButton_partner | ||
} | ||
} | ||
` |
Oops, something went wrong.