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

feat: context menu [anyone can take this over] #7704

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
wip
  • Loading branch information
pvinis committed Dec 25, 2022
commit 510f1347663a4face4c1936162997591e3fad277
36 changes: 11 additions & 25 deletions src/app/Components/Artist/ArtistHeaderFloatingButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ContextModule, OwnerType } from "@artsy/cohesion"
import { ArtistHeaderFloatingButtons_artist$data } from "__generated__/ArtistHeaderFloatingButtons_artist.graphql"
import { HeaderButton } from "app/Components/HeaderButton"
import { ShareSheet } from "app/Components/ShareSheet/ShareSheet"
import { useStickyTabPageContext } from "app/Components/StickyTabPage/StickyTabPageContext"
import { goBack } from "app/navigation/navigate"
import { ChevronIcon, ShareIcon } from "palette"
import React, { Fragment, useRef, useState } from "react"
import React, { useRef, useState } from "react"
import Animated, { block, call, cond, onChange, set, useCode } from "react-native-reanimated"
import { createFragmentContainer, graphql } from "react-relay"
import { useCustomShareSheet } from "../CustomShareSheet/atoms"

interface ArtistHeaderFloatingButtonsProps {
artist: ArtistHeaderFloatingButtons_artist$data
Expand All @@ -20,7 +19,7 @@ const SHARE_ICON_SIZE = 23
export const ArtistHeaderFloatingButtons: React.FC<ArtistHeaderFloatingButtonsProps> = ({
artist,
}) => {
const [shareSheetVisible, setShareSheetVisible] = useState(false)
const sharesheet = useCustomShareSheet()
const [hideButton, setHideButton] = useState(false)
const { headerOffsetY } = useStickyTabPageContext()

Expand All @@ -41,12 +40,8 @@ export const ArtistHeaderFloatingButtons: React.FC<ArtistHeaderFloatingButtonsPr
[]
)

const handleSharePress = () => {
setShareSheetVisible(true)
}

return (
<Fragment>
<>
<HeaderButton
shouldHide={hideButton}
position="left"
Expand All @@ -58,27 +53,18 @@ export const ArtistHeaderFloatingButtons: React.FC<ArtistHeaderFloatingButtonsPr

<HeaderButton
shouldHide={hideButton}
onPress={handleSharePress}
onPress={() =>
sharesheet.show({
type: "artist",
slug: artist.slug,
})
}
position="right"
applySafeAreaTopInsets={false}
>
<ShareIcon width={SHARE_ICON_SIZE} height={SHARE_ICON_SIZE} />
</HeaderButton>

<ShareSheet
entry={{
internalID: artist.internalID,
slug: artist.slug,
href: artist.href!,
artistNames: [artist.name!],
imageURL: artist.image?.url ?? undefined,
}}
ownerType={OwnerType.artist}
contextModule={ContextModule.artistHeader}
visible={shareSheetVisible}
setVisible={setShareSheetVisible}
/>
</Fragment>
</>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { renderWithWrappers } from "app/tests/renderWithWrappers"
import { useCanOpenURL } from "app/utils/useCanOpenURL"
import Share from "react-native-share"
import * as helpers from "./helpers"
import { ShareSheet, ShareSheetProps } from "./ShareSheet"

// TODO: these tests need some rewriting

const setVisibleMock = jest.fn()

Expand Down
15 changes: 15 additions & 0 deletions src/app/Components/CustomShareSheet/CustomShareSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const CustomShareSheet = () => {
const toast = useToast()
const shotRef = useRef<ViewShot>(null)
const { trackEvent } = useTracking()
// TODO: we need to handle thr artist and the sale case
const data = useLazyLoadQuery<CustomShareSheet_ArtworkQuery>(artworkQuery, {
slug: item?.slug ?? "",
skip: !item,
Expand Down Expand Up @@ -234,6 +235,20 @@ const artworkQuery = graphql`
}
`

const artistQuery = graphql`
query CustomShareSheet_ArtistQuery($slug: String!, $skip: Boolean!) {
artist(id: $slug) @skip(if: $skip) {
internalID
slug
href
name
image {
url(version: "large")
}
}
}
`
// TODO: needs the other stuff, like sale and artist
export const tracks = {
customShare: (service: string, id: string, slug?: string): ShareType => ({
action: ActionType.share,
Expand Down
5 changes: 1 addition & 4 deletions src/app/Components/CustomShareSheet/atoms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { atom, useAtom } from "jotai"

type Item =
| { type: "artwork"; slug: string; currentImageIndex?: number }
| { type: "sale"; slug: string }
import { Item } from "./types"

const visibleAtom = atom(false)
const itemAtom = atom<Item | null>(null)
Expand Down
4 changes: 4 additions & 0 deletions src/app/Components/CustomShareSheet/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type Item =
| { type: "artwork"; slug: string; currentImageIndex?: number }
| { type: "sale"; slug: string }
| { type: "artist"; slug: string }
181 changes: 0 additions & 181 deletions src/app/Components/ShareSheet/ShareSheet.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/Scenes/ViewingRoom/ViewingRoom.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ViewingRoom_viewingRoom$data } from "__generated__/ViewingRoom_viewingRoom.graphql"
import { ViewingRoomQuery } from "__generated__/ViewingRoomQuery.graphql"
import { getShareURL } from "app/Components/ShareSheet/helpers"
import { getShareURL } from "app/Components/CustomShareSheet/helpers"
import { navigate } from "app/navigation/navigate"
import { defaultEnvironment } from "app/relay/createEnvironment"
import renderWithLoadProgress from "app/utils/renderWithLoadProgress"
Expand Down