Skip to content

Commit

Permalink
adding rn-primitives for ui and calendar component
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorpfiz committed Aug 6, 2024
1 parent cc766a9 commit 4a15da4
Show file tree
Hide file tree
Showing 42 changed files with 875 additions and 1,952 deletions.
12 changes: 12 additions & 0 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@
"@gorhom/bottom-sheet": "^4.6.4",
"@hookform/resolvers": "^3.9.0",
"@hyper/validators": "workspace:*",
"@marceloterreiro/flash-calendar": "^1.0.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-google-signin/google-signin": "^12.2.1",
"@react-navigation/drawer": "^6.7.2",
"@react-navigation/native": "^6.1.18",
"@rn-primitives/avatar": "^1.0.3",
"@rn-primitives/dialog": "^1.0.3",
"@rn-primitives/hooks": "^1.0.3",
"@rn-primitives/label": "^1.0.3",
"@rn-primitives/portal": "^1.0.3",
"@rn-primitives/progress": "^1.0.3",
"@rn-primitives/slot": "^1.0.3",
"@rn-primitives/tooltip": "^1.0.3",
"@rn-primitives/types": "^1.0.3",
"@rn-primitives/utils": "^1.0.3",
"@shopify/flash-list": "1.7.0",
"@shopify/react-native-skia": "^1.3.9",
"@supabase/auth-helpers-react": "catalog:supabase",
Expand All @@ -44,6 +55,7 @@
"aes-js": "^3.1.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"expo": "^51.0.24",
"expo-apple-authentication": "~6.4.2",
"expo-av": "~14.0.6",
Expand Down
58 changes: 58 additions & 0 deletions apps/expo/src/app/(app)/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { TouchableOpacity, View } from "react-native";
import { Tabs } from "expo-router";
import colors from "tailwindcss/colors";

import { CircleUserRound } from "~/lib/icons/circle-user-round";
import { House } from "~/lib/icons/house";
import { Plus } from "~/lib/icons/plus";

const TabsLayout = () => {
return (
<Tabs>
<Tabs.Screen
name="index"
options={{
headerShown: false,
title: "Home",
tabBarButton: (props) => <TouchableOpacity {...props} />,
tabBarIcon: ({ size, color }) => <House size={size} color={color} />,
}}
/>
<Tabs.Screen
name="log"
options={{
title: "Log",
tabBarLabel: "",
tabBarButton: (props) => <TouchableOpacity {...props} />,
tabBarIcon: ({ size }) => (
<View
style={{
width: size + 10,
height: size + 10,
borderRadius: 9999,
backgroundColor: colors.blue[600],
justifyContent: "center",
alignItems: "center",
top: 10,
}}
>
<Plus size={size} color="white" />
</View>
),
}}
/>
<Tabs.Screen
name="account"
options={{
title: "Account",
tabBarButton: (props) => <TouchableOpacity {...props} />,
tabBarIcon: ({ size, color }) => (
<CircleUserRound size={size} color={color} />
),
}}
/>
</Tabs>
);
};

export default TabsLayout;
42 changes: 42 additions & 0 deletions apps/expo/src/app/(app)/(tabs)/account.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { View } from "react-native";
import {
useSessionContext,
useSupabaseClient,
useUser,
} from "@supabase/auth-helpers-react";

import { ThemeToggle } from "~/components/theme-toggle";
import { Button } from "~/components/ui/button";
import { Text } from "~/components/ui/text";

export default function AccountScreen() {
const user = useUser();

const SignOut = () => {
const { isLoading } = useSessionContext();
const supabase = useSupabaseClient();

if (isLoading) {
return null;
}
return (
<View className="flex-row items-center justify-between gap-2 p-4">
<Button
onPress={async () => {
await supabase.auth.signOut();
}}
>
<Text>Sign Out</Text>
</Button>
<ThemeToggle />
</View>
);
};

return (
<View>
<Text>Account Screen</Text>
{user?.id && <SignOut />}
</View>
);
}
13 changes: 13 additions & 0 deletions apps/expo/src/app/(app)/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SafeAreaView } from "react-native-safe-area-context";

import { Button } from "~/components/ui/button";
import { Text } from "~/components/ui/text";

export default function HomeScreen() {
return (
<SafeAreaView>
<Text>Home Screen</Text>
<Button />
</SafeAreaView>
);
}
11 changes: 11 additions & 0 deletions apps/expo/src/app/(app)/(tabs)/log.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { View } from "react-native";

import { Text } from "~/components/ui/text";

export default function LogScreen() {
return (
<View>
<Text>Log Screen</Text>
</View>
);
}
6 changes: 6 additions & 0 deletions apps/expo/src/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import { LogOut } from "~/lib/icons/log-out";
const Layout = () => {
return (
<Stack>
<Stack.Screen
name="(tabs)"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="sandbox"
options={{
Expand Down
86 changes: 43 additions & 43 deletions apps/expo/src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { SplashScreen, Stack, useRouter, useSegments } from "expo-router";
import { StatusBar } from "expo-status-bar";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { ThemeProvider } from "@react-navigation/native";
import { PortalHost } from "@rn-primitives/portal";
import { SessionContextProvider } from "@supabase/auth-helpers-react";

// import * as SystemUI from "expo-system-ui";
Expand Down Expand Up @@ -76,58 +77,57 @@ const InitialLayout = () => {

const inAppGroup = segments[0] === "(app)";

console.log("inAppGroup", inAppGroup, "isSignedIn", isSignedIn);

if (isSignedIn && !inAppGroup) {
console.log("replace", isSignedIn);

router.replace("/sandbox");
} else if (!isSignedIn) {
router.replace("/(tabs)");
} else if (!isSignedIn && inAppGroup) {
router.replace("/");
}
}, [isSignedIn]);
}, [isLoaded, isSignedIn, segments, router]);

if (!isLoaded) {
return null;
}

return (
<Stack>
<Stack.Screen
name="index"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="(auth)/signup"
options={{
presentation: "modal",
title: "Sign Up",
headerTitle: "",
headerLeft: HeaderCloseButton,
}}
/>
<Stack.Screen
name="(auth)/signin"
options={{
presentation: "modal",
title: "Sign In",
headerTitle: "",
headerLeft: HeaderCloseButton,
}}
/>
<Stack.Screen
name="(auth)/reset-password"
options={{
presentation: "modal",
title: "Reset Password",
headerTitle: "",
headerLeft: HeaderCloseButton,
}}
/>
<Stack.Screen name="(app)" options={{ headerShown: false }} />
</Stack>
<>
<Stack>
<Stack.Screen
name="index"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="(auth)/signup"
options={{
presentation: "modal",
title: "Sign Up",
headerTitle: "",
headerLeft: HeaderCloseButton,
}}
/>
<Stack.Screen
name="(auth)/signin"
options={{
presentation: "modal",
title: "Sign In",
headerTitle: "",
headerLeft: HeaderCloseButton,
}}
/>
<Stack.Screen
name="(auth)/reset-password"
options={{
presentation: "modal",
title: "Reset Password",
headerTitle: "",
headerLeft: HeaderCloseButton,
}}
/>
<Stack.Screen name="(app)" options={{ headerShown: false }} />
</Stack>
<PortalHost />
</>
);
};

Expand Down
24 changes: 24 additions & 0 deletions apps/expo/src/components/calendar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useState } from "react";
import { Text, View } from "react-native";
import { Calendar, toDateId } from "@marceloterreiro/flash-calendar";

const today = toDateId(new Date());

export function BasicCalendar() {
const [selectedDate, setSelectedDate] = useState(today);
return (
<View>
<Text>Selected date: {selectedDate}</Text>
<Calendar
calendarActiveDateRanges={[
{
startId: selectedDate,
endId: selectedDate,
},
]}
calendarMonthId={today}
onCalendarDayPress={setSelectedDate}
/>
</View>
);
}
Loading

0 comments on commit 4a15da4

Please sign in to comment.