Skip to content

Commit

Permalink
Merge branch 'main' into rohan/lightbox-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan-cp authored May 11, 2024
2 parents 0c777ba + 5ae8213 commit 7dc7cfe
Show file tree
Hide file tree
Showing 46 changed files with 1,311 additions and 142 deletions.
Empty file added .env.sample
Empty file.
2 changes: 1 addition & 1 deletion apps/mobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
orientation: 'portrait',
icon: './assets/icon.png',
userInterfaceStyle: 'automatic',
version: '1.0.61',
version: '1.0.63',
updates: {
fallbackToCacheTimeout: 0,
},
Expand Down
46 changes: 26 additions & 20 deletions apps/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { CheckMaintenanceOnAppForeground, MaintenanceScreen } from './components
import SearchProvider from './components/Search/SearchContext';
import BottomSheetModalProvider from './contexts/BottomSheetModalContext';
import ManageWalletProvider from './contexts/ManageWalletContext';
import { SanityAnnouncementProvider } from './contexts/SanityAnnouncementContext';
import SanityDataProvider from './contexts/SanityDataContext';
import SyncTokensProvider from './contexts/SyncTokensContext';
import ToastProvider from './contexts/ToastContext';
import { TokenStateManagerProvider } from './contexts/TokenStateManagerContext';
Expand Down Expand Up @@ -156,26 +158,30 @@ export default function App() {
<magic.Relayer />
<SearchProvider>
<NavigationContainer ref={navigationRef}>
<ToastProvider>
<TokenStateManagerProvider>
<PortalProvider>
<BottomSheetModalProvider>
<SyncTokensProvider>
<ManageWalletProvider>
{/* Register the user's push token if one exists (does not prompt the user) */}
<NotificationRegistrar />
<DevMenuItems />
<DeepLinkRegistrar />
<RootStackNavigator
navigationContainerRef={navigationRef}
/>
</ManageWalletProvider>
</SyncTokensProvider>
<PortalHost name="app-context" />
</BottomSheetModalProvider>
</PortalProvider>
</TokenStateManagerProvider>
</ToastProvider>
<SanityDataProvider>
<ToastProvider>
<TokenStateManagerProvider>
<PortalProvider>
<BottomSheetModalProvider>
<SyncTokensProvider>
<ManageWalletProvider>
<SanityAnnouncementProvider>
{/* Register the user's push token if one exists (does not prompt the user) */}
<NotificationRegistrar />
<DevMenuItems />
<DeepLinkRegistrar />
<RootStackNavigator
navigationContainerRef={navigationRef}
/>
</SanityAnnouncementProvider>
</ManageWalletProvider>
</SyncTokensProvider>
<PortalHost name="app-context" />
</BottomSheetModalProvider>
</PortalProvider>
</TokenStateManagerProvider>
</ToastProvider>
</SanityDataProvider>
</NavigationContainer>
</SearchProvider>
</SafeAreaProvider>
Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/src/components/AnimatedRefreshIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback } from 'react';
import { ViewProps } from 'react-native';
import { RefreshIcon } from 'src/icons/RefreshIcon';

import { IconContainer } from '~/components/IconContainer';
Expand All @@ -9,13 +10,15 @@ type AnimatedRefreshIconProps = {
isSyncing: boolean;
eventElementId: string;
eventName: string;
style?: ViewProps['style'];
};

export function AnimatedRefreshIcon({
onSync,
isSyncing,
eventElementId,
eventName,
style,
}: AnimatedRefreshIconProps) {
const handleSync = useCallback(async () => {
if (isSyncing) return;
Expand All @@ -30,7 +33,7 @@ export function AnimatedRefreshIcon({
eventElementId={eventElementId}
eventName={eventName}
eventContext={contexts.Posts}
style={{ opacity: isSyncing ? 0.3 : 1 }}
style={[{ opacity: isSyncing ? 0.3 : 1 }, style]}
/>
);
}
8 changes: 6 additions & 2 deletions apps/mobile/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Typography } from './Typography';
type Variant = 'primary' | 'secondary' | 'danger' | 'disabled' | 'blue';
type FontWeight = 'Medium' | 'Regular' | 'Bold';
type Size = 'xs' | 'sm' | 'md';
type TextTransform = 'uppercase' | 'capitalize' | 'lowercase';

export type ButtonProps = {
style?: GalleryTouchableOpacityProps['style'];
Expand All @@ -24,6 +25,7 @@ export type ButtonProps = {
textClassName?: string;
containerClassName?: string;
fontWeight?: FontWeight;
textTransform?: TextTransform;
size?: Size;
DO_NOT_USE_OR_YOU_WILL_BE_FIRED_colorScheme?: 'light' | 'dark';
} & GalleryTouchableOpacityProps;
Expand Down Expand Up @@ -179,6 +181,7 @@ export function Button({
size = 'md',
fontWeight = 'Medium',
footerElement,
textTransform = 'uppercase',
DO_NOT_USE_OR_YOU_WILL_BE_FIRED_colorScheme,
...props
}: ButtonProps) {
Expand Down Expand Up @@ -226,9 +229,10 @@ export function Button({
<Typography
font={{ family: 'ABCDiatype', weight: fontWeight }}
className={clsx(
'text-xs uppercase text-center',
'text-xs text-center',
variantClassNames.textClassName,
textClassName
textClassName,
textTransform
)}
>
{text}
Expand Down
26 changes: 18 additions & 8 deletions apps/mobile/src/components/ClaimMintUpsellBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useCallback } from 'react';
import { View } from 'react-native';
import { graphql, useFragment } from 'react-relay';
import { MCHX_CLAIM_CODE_KEY } from 'src/constants/storageKeys';
import usePersistedState from 'src/hooks/usePersistedState';
import { XMarkIcon } from 'src/icons/XMarkIcon';

import { useBottomSheetModalActions } from '~/contexts/BottomSheetModalContext';
import { useSanityAnnouncementContext } from '~/contexts/SanityAnnouncementContext';
import { ClaimMintUpsellBannerFragment$key } from '~/generated/ClaimMintUpsellBannerFragment.graphql';
import { contexts } from '~/shared/analytics/constants';
import colors from '~/shared/theme/colors';
Expand All @@ -17,9 +17,10 @@ import { Typography } from './Typography';

type Props = {
queryRef: ClaimMintUpsellBannerFragment$key;
projectInternalId: string;
};

export function ClaimMintUpsellBanner({ queryRef }: Props) {
export function ClaimMintUpsellBanner({ queryRef, projectInternalId }: Props) {
const query = useFragment(
graphql`
fragment ClaimMintUpsellBannerFragment on Query {
Expand All @@ -37,10 +38,10 @@ export function ClaimMintUpsellBanner({ queryRef }: Props) {

const { showBottomSheetModal, hideBottomSheetModal } = useBottomSheetModalActions();

const [claimCode] = usePersistedState(MCHX_CLAIM_CODE_KEY, '');
const [claimCode] = usePersistedState(`${projectInternalId}-claim-code`, '');

const [isUpsellMintBannerDismissed, setIsUpsellMintBannerDismissed] = usePersistedState(
'isUpsellMintBannerDismissed',
`${projectInternalId}-isUpsellMintBannerDismissed`,
false
);

Expand All @@ -49,12 +50,21 @@ export function ClaimMintUpsellBanner({ queryRef }: Props) {
}, [setIsUpsellMintBannerDismissed]);

const handleClaimPress = useCallback(() => {
showBottomSheetModal({ content: <MintCampaignBottomSheet onClose={hideBottomSheetModal} /> });
}, [hideBottomSheetModal, showBottomSheetModal]);
showBottomSheetModal({
content: (
<MintCampaignBottomSheet
onClose={hideBottomSheetModal}
projectInternalId={projectInternalId}
/>
),
});
}, [hideBottomSheetModal, projectInternalId, showBottomSheetModal]);

const { announcement } = useSanityAnnouncementContext();

const user = query.viewer?.user;

if (!user || claimCode || isUpsellMintBannerDismissed) {
if (!user || !announcement || claimCode || isUpsellMintBannerDismissed) {
return <View className="bg-white dark:bg-black-900" />;
}

Expand All @@ -71,7 +81,7 @@ export function ClaimMintUpsellBanner({ queryRef }: Props) {
font={{ family: 'ABCDiatype', weight: 'Regular' }}
className="text-offWhite text-xs"
>
Claim your free generative work by MCHX
{announcement.description}
</Typography>
</View>
<View className="flex-row items-center space-x-2">
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/components/GalleryTouchableOpacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GalleryElementTrackingProps, useTrack } from '~/shared/contexts/Analyti

export type GalleryTouchableOpacityProps = {
withoutFeedback?: boolean;
activeOpacity?: number;
} & GalleryElementTrackingProps &
TouchableOpacityProps;

Expand All @@ -25,6 +26,7 @@ export function GalleryTouchableOpacity({
onPress,
properties,
withoutFeedback,
activeOpacity = 0.2,
...props
}: GalleryTouchableOpacityProps) {
const track = useTrack();
Expand Down Expand Up @@ -62,7 +64,7 @@ export function GalleryTouchableOpacity({
}

return (
<TouchableOpacity {...props} onPress={handlePress}>
<TouchableOpacity {...props} onPress={handlePress} activeOpacity={activeOpacity}>
{children}
</TouchableOpacity>
);
Expand Down
5 changes: 3 additions & 2 deletions apps/mobile/src/components/IconContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type IconContainerProps = {
onPress: () => void;
size?: 'xs' | 'sm' | 'md';
border?: boolean;
color?: 'default' | 'white' | 'black' | 'faint';
color?: 'default' | 'white' | 'black' | 'faint' | 'active';
} & GalleryTouchableOpacityProps;

export function IconContainer({
Expand All @@ -28,11 +28,12 @@ export function IconContainer({
md: 'h-8 w-8',
};

const colorVariants: { [color in 'default' | 'white' | 'black' | 'faint']: string } = {
const colorVariants: { [color in 'default' | 'white' | 'black' | 'faint' | 'active']: string } = {
default: 'bg-faint dark:bg-black-500',
white: 'bg-white dark:bg-black-900',
black: 'bg-black-900 dark:bg-white',
faint: 'bg-black-700',
active: 'bg-porcelain dark:bg-white',
};

return (
Expand Down
3 changes: 1 addition & 2 deletions apps/mobile/src/components/Login/SignInBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ function SignInBottomSheet({ onQrCodePress, openManageWallet }: Props) {
}, [hideBottomSheetModal, navigation]);

const handleConnectWallet = useCallback(() => {
hideBottomSheetModal();
openManageWallet({ method: 'auth' });
}, [hideBottomSheetModal, openManageWallet]);
}, [openManageWallet]);

return (
<View className="flex flex-col space-y-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function WalletSelectorBottomSheet({

return (
<>
<View style={{ paddingBottom: bottom }} className="p-4 flex flex-col space-y-6">
<View style={{ paddingBottom: bottom }} className="flex flex-col space-y-6">
{isSigningIn ? (
<SignedInWalletMessage />
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
import { MCHX_CLAIM_CODE_KEY } from 'src/constants/storageKeys';
import { useMemo } from 'react';
import usePersistedState from 'src/hooks/usePersistedState';

import { useSanityDataContext } from '~/contexts/SanityDataContext';

import MintCampaignPostTransaction from './MintCampaignPostTransaction';
import MintCampaignPreTransaction from './MintCampaignPreTransaction';

export default function MintCampaignBottomSheet({ onClose }: { onClose: () => void }) {
type Props = {
onClose?: () => void;
projectInternalId: string;
};

export default function MintCampaignBottomSheet({ onClose, projectInternalId }: Props) {
// claimCode is the identifer used to poll for the status of the mint
// Once we kick off the mint, the backend returns a claim code from Highlight that we can use to check the status of the mint

const [claimCode, setClaimCode] = usePersistedState(MCHX_CLAIM_CODE_KEY, '');
const [claimCode, setClaimCode] = usePersistedState(`${projectInternalId}_claim_code`, '');

const { data } = useSanityDataContext();
const projectData = useMemo(() => {
return data?.mintProjects.find((document) => document.internalId === projectInternalId);
}, [data, projectInternalId]);

if (!projectData) {
// TODO decide best way to handle missing data
return null;
}

if (claimCode) {
return <MintCampaignPostTransaction claimCode={claimCode} onClose={onClose} />;
return (
<MintCampaignPostTransaction
claimCode={claimCode}
onClose={onClose}
projectData={projectData}
/>
);
}

return <MintCampaignPreTransaction setClaimCode={setClaimCode} />;
return (
<MintCampaignPreTransaction
setClaimCode={setClaimCode}
projectInternalId={projectInternalId}
projectData={projectData}
/>
);
}
Loading

0 comments on commit 7dc7cfe

Please sign in to comment.