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

Update header titles for DemoFeedScreen and DemoCaptureScreen Add demo mode UI changes with SkipDemoButton and demoMode prop #408

Merged
merged 5 commits into from
Feb 5, 2025
9 changes: 8 additions & 1 deletion apps/expo/src/app/(onboarding)/onboarding/demo-feed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useState } from "react";
import { Alert, View } from "react-native";
import { Alert, Text, View } from "react-native";
import * as Notifications from "expo-notifications";
import { Stack, useLocalSearchParams } from "expo-router";
import { toast } from "sonner-native";
Expand Down Expand Up @@ -160,6 +160,12 @@ export default function DemoFeedScreen() {
/>

<View className="flex-1">
<View className="absolute right-4 top-16 z-10 ">
<Text className="rounded-xl bg-accent-yellow px-3 py-1.5 text-center text-base font-medium text-neutral-1">
Press and hold for options 👇
</Text>
</View>

<UserEventsList
events={feedEvents}
showCreator="always"
Expand All @@ -168,6 +174,7 @@ export default function DemoFeedScreen() {
onEndReached={() => null}
isFetchingNextPage={false}
stats={stats}
demoMode
/>
</View>

Expand Down
14 changes: 10 additions & 4 deletions apps/expo/src/app/(onboarding)/onboarding/demo-intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Camera, ChevronDown, List, Plus, Sparkles } from "lucide-react-native";
import { toast } from "sonner-native";

import { DemoProgressBar } from "~/components/DemoProgressBar";
import { SkipDemoButton } from "~/components/SkipDemoButton";
import { TOTAL_ONBOARDING_STEPS } from "../_layout";

export default function DemoIntroScreen() {
Expand All @@ -41,7 +42,7 @@ export default function DemoIntroScreen() {
};
});

const handlePress = async () => {
const handlePress = () => {
if (isLoading) return;
setIsLoading(true);

Expand Down Expand Up @@ -144,9 +145,13 @@ export default function DemoIntroScreen() {
/>
</View>

<Text className="absolute bottom-48 left-1/2 w-min -translate-x-1/2 rounded-2xl bg-accent-yellow px-4 py-2 text-center text-2xl font-semibold text-neutral-1">
Try adding an event
</Text>
<View className="absolute bottom-48 left-1/2 flex -translate-x-1/2 flex-col items-center space-y-2">
<Text className="w-min rounded-2xl bg-accent-yellow px-4 py-2 text-center text-2xl font-semibold text-neutral-1">
Try adding an event
</Text>

<SkipDemoButton />
</View>

<TouchableOpacity
onPress={handlePress}
Expand All @@ -155,6 +160,7 @@ export default function DemoIntroScreen() {
>
<Plus size={28} color="#E0D9FF" />
</TouchableOpacity>

<Animated.View style={animatedStyle}>
<ChevronDown size={64} color="#5A32FB" strokeWidth={4} />
</Animated.View>
Expand Down
6 changes: 6 additions & 0 deletions apps/expo/src/components/EventMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface EventMenuProps {
isOwner: boolean;
isSaved: boolean;
menuType: "context" | "popup";
demoMode?: boolean;
children?: React.ReactNode;
onDelete?: () => Promise<void>;
}
Expand All @@ -81,6 +82,7 @@ export function EventMenu({
isOwner,
isSaved,
menuType,
demoMode = false,
children,
onDelete,
}: EventMenuProps) {
Expand Down Expand Up @@ -277,6 +279,10 @@ export function EventMenu({
};

const handleMenuSelect = (title: string) => {
if (demoMode) {
toast("Demo mode: action disabled");
return;
}
void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
switch (title) {
case "Share":
Expand Down
53 changes: 53 additions & 0 deletions apps/expo/src/components/SkipDemoButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { useState } from "react";
import { Pressable, Text } from "react-native";
import { useRouter } from "expo-router";
import { toast } from "sonner-native";

import { useRevenueCat } from "~/providers/RevenueCatProvider";
import { useAppStore } from "~/store";

interface SkipDemoButtonProps {
className?: string;
textClassName?: string;
}

export function SkipDemoButton({
className = "",
textClassName = "text-sm text-neutral-2",
}: SkipDemoButtonProps) {
const router = useRouter();
const { showProPaywallIfNeeded } = useRevenueCat();
const setHasCompletedOnboarding = useAppStore(
(state) => state.setHasCompletedOnboarding,
);
const [isLoading, setIsLoading] = useState(false);

const handlePress = async () => {
if (isLoading) return;
setIsLoading(true);

try {
setHasCompletedOnboarding(true);
await showProPaywallIfNeeded();
router.push("/feed");
} catch (error) {
toast.error("Something went wrong", {
description: "Please try again",
});
} finally {
setIsLoading(false);
}
};

return (
<Pressable
onPress={handlePress}
disabled={isLoading}
className={`py-2 ${className}`}
>
<Text className={textClassName}>
{isLoading ? "Loading..." : "or skip demo"}
</Text>
</Pressable>
);
}
6 changes: 6 additions & 0 deletions apps/expo/src/components/UserEventsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
showCreator: ShowCreatorOption;
isSaved: boolean;
similarEventsCount?: number;
demoMode: boolean;
}) {
const {
event,
Expand All @@ -68,6 +69,7 @@
showCreator,
isSaved,
similarEventsCount,
demoMode,
} = props;
const { fontScale } = useWindowDimensions();
const id = event.id;
Expand Down Expand Up @@ -130,6 +132,7 @@
isOwner={isOwner}
isSaved={isSaved}
menuType="context"
demoMode={demoMode}
>
<Pressable
onPress={() => {
Expand Down Expand Up @@ -326,6 +329,7 @@
allTimeEvents: number;
};
promoCard?: PromoCardProps;
demoMode: boolean;
}

export default function UserEventsList(props: UserEventsListProps) {
Expand All @@ -339,6 +343,7 @@
isFetchingNextPage,
stats,
promoCard,
demoMode,

Check failure on line 346 in apps/expo/src/components/UserEventsList.tsx

View workflow job for this annotation

GitHub Actions / lint

'demoMode' is assigned a value but never used. Allowed unused vars must match /^_/u
} = props;
const { user } = useUser();
const queryClient = useQueryClient();
Expand Down Expand Up @@ -452,6 +457,7 @@
similarEventsCount={
similarEventsCount > 0 ? similarEventsCount : undefined
}
demoMode
/>
);
}}
Expand Down
Loading