From 5f5fb1b2e532cb7df94031288bfc4c4ab48216f1 Mon Sep 17 00:00:00 2001
From: h0lybyte <5599058+h0lybyte@users.noreply.github.com>
Date: Thu, 14 Nov 2024 13:35:25 -0500
Subject: [PATCH] feat(expo-bbq): added a general user profile card with
optimization tweaks.
---
apps/expo-lcagents/src/app/_layout.tsx | 2 +-
apps/expo-lcagents/src/app/users.tsx | 115 ++++++++++++++++++
apps/kbve.com/src/content/journal/11-14.mdx | 8 ++
.../src/components/card/TamaProfileCard.tsx | 66 ++++++++++
.../container/TamaProfileContainer.tsx | 50 ++++++++
packages/expo-bbq/src/core/useMemory.tsx | 10 +-
packages/expo-bbq/src/index.ts | 6 +
packages/expo-bbq/src/type.ts | 7 ++
8 files changed, 258 insertions(+), 6 deletions(-)
create mode 100644 apps/expo-lcagents/src/app/users.tsx
create mode 100644 packages/expo-bbq/src/components/card/TamaProfileCard.tsx
create mode 100644 packages/expo-bbq/src/components/container/TamaProfileContainer.tsx
create mode 100644 packages/expo-bbq/src/type.ts
diff --git a/apps/expo-lcagents/src/app/_layout.tsx b/apps/expo-lcagents/src/app/_layout.tsx
index f6dd1ce23..07c8a0cc8 100644
--- a/apps/expo-lcagents/src/app/_layout.tsx
+++ b/apps/expo-lcagents/src/app/_layout.tsx
@@ -63,7 +63,7 @@ function RootLayoutNav() {
-
+
diff --git a/apps/expo-lcagents/src/app/users.tsx b/apps/expo-lcagents/src/app/users.tsx
new file mode 100644
index 000000000..b323de41d
--- /dev/null
+++ b/apps/expo-lcagents/src/app/users.tsx
@@ -0,0 +1,115 @@
+import React, { useMemo, useCallback, useEffect } from 'react';
+import { YStack, XStack, SizableText, Separator, ScrollView } from 'tamagui';
+import {
+ TamaUserCard,
+ LottieAnimation,
+ createSupabaseClient,
+ TamaProfileContainer,
+} from '@kbve/expo-bbq';
+import { useNavigation, useLocalSearchParams } from 'expo-router';
+
+const Users = () => {
+ const navigation = useNavigation();
+
+ const { username = 'h0lybyte' } = useLocalSearchParams<{
+ username?: string;
+ }>();
+
+ const supabaseUrl = 'https://supabase.kbve.com';
+ const supabaseAnonKey =
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICJyb2xlIjogImFub24iLAogICJpc3MiOiAic3VwYWJhc2UiLAogICJpYXQiOiAxNzI0NTM2ODAwLAogICJleHAiOiAxODgyMzAzMjAwCn0._fmEmblm0afeLoPXxt8wP2mYpa9gzU-ufx3v8oRTFGg';
+
+ const supabase = useMemo(
+ () => createSupabaseClient(supabaseUrl, supabaseAnonKey),
+ [supabaseUrl, supabaseAnonKey],
+ );
+
+ const lottieProfileAnimation = useMemo(
+ () => require('../../assets/json/profile.json'),
+ [],
+ );
+
+ const updateNavigationOptions = useCallback(() => {
+ navigation.setOptions({
+ title: 'KBVE Users',
+ headerBackTitle: 'Back',
+ });
+ }, [navigation]);
+
+ useEffect(() => {
+ updateNavigationOptions();
+ }, [updateNavigationOptions]);
+
+ const MemoizedLottieAnimation = React.memo(LottieAnimation);
+
+ return (
+
+
+
+
+
+
+
+
+ KBVE Users
+
+
+
+
+
+
+
+ );
+};
+
+export default Users;
diff --git a/apps/kbve.com/src/content/journal/11-14.mdx b/apps/kbve.com/src/content/journal/11-14.mdx
index 784bc8a9c..c4597097b 100644
--- a/apps/kbve.com/src/content/journal/11-14.mdx
+++ b/apps/kbve.com/src/content/journal/11-14.mdx
@@ -21,3 +21,11 @@ import { Adsense, Tasks } from '@kbve/astropad';
The `useMemory` hook is almost done, but we still need to fix the offscreen integration and maybe even utilize the `useIdleCallback`.
Let me get this all pushed out and I will enter the testing realm again tonight.
+ After making the hook, we can test it out with a profile component?
+ The idea would be to create two files for us to use, the general profile container and then a wrapper around that said container for the rendering and caching.
+ The first file would be the Profile itself and the second would be a contaijner that would hold the profile and add the useMemory hook around it?
+
+ I am wondering what would be the best way to handle this without causing too many renders but also making it super fast to load and unload profiles.
+ I am also thinking that after we get the useMemory hook to work, we can add another hook that would help us create a pool of the objects that we could render offscreen and then transition them in.
+ In theory we would be creating one of those infinite scrolling situations but having it render as they scroll through the application.
+ The goal would also be to make sure that it does not pull any additional data, by having it cache the results and then use the cache to help build the profiles.
\ No newline at end of file
diff --git a/packages/expo-bbq/src/components/card/TamaProfileCard.tsx b/packages/expo-bbq/src/components/card/TamaProfileCard.tsx
new file mode 100644
index 000000000..8c151045a
--- /dev/null
+++ b/packages/expo-bbq/src/components/card/TamaProfileCard.tsx
@@ -0,0 +1,66 @@
+import React, { memo } from 'react';
+import {
+ YStack,
+ XStack,
+ SizableText,
+ Avatar,
+ Button,
+ Separator,
+} from 'tamagui';
+import { MessageCircle, Heart, MoreVertical } from '@tamagui/lucide-icons';
+import { type IUserCardsPublic } from '../../type';
+
+
+
+interface TamaProfileCardProps {
+ data: IUserCardsPublic;
+ loading: boolean;
+ onAction: (actionState: string, content: string) => void;
+}
+
+export const TamaProfileCard = memo(function TamaProfileCard({
+ data,
+ loading,
+ onAction,
+}: TamaProfileCardProps) {
+ if (loading) {
+ return