e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { Text, Pressable, StyleSheet } from "react-native";
|
|
import {
|
|
ThreadListItemPrimitive,
|
|
useAui,
|
|
useAuiState,
|
|
} from "@assistant-ui/react-native";
|
|
import { useTheme } from "@/hooks/use-theme";
|
|
import { Radius } from "@/constants/theme";
|
|
import { haptics } from "@/lib/haptics";
|
|
|
|
export function ThreadListItem({ onSelect }: { onSelect: () => void }) {
|
|
const { colors } = useTheme();
|
|
const aui = useAui();
|
|
const isActive = useAuiState(
|
|
(s) => s.threads.mainThreadId === s.threadListItem.id,
|
|
);
|
|
|
|
return (
|
|
<ThreadListItemPrimitive.Root>
|
|
<Pressable
|
|
onPressIn={haptics.selection}
|
|
onPress={() => {
|
|
aui.threadListItem().switchTo();
|
|
onSelect();
|
|
}}
|
|
style={({ pressed }) => [
|
|
styles.item,
|
|
(isActive || pressed) && { backgroundColor: colors.muted },
|
|
]}
|
|
>
|
|
<Text
|
|
numberOfLines={1}
|
|
style={[
|
|
styles.title,
|
|
{
|
|
color: colors.foreground,
|
|
fontWeight: isActive ? "600" : "400",
|
|
},
|
|
]}
|
|
>
|
|
<ThreadListItemPrimitive.Title fallback="New chat" />
|
|
</Text>
|
|
</Pressable>
|
|
</ThreadListItemPrimitive.Root>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
item: {
|
|
height: 38,
|
|
justifyContent: "center",
|
|
paddingHorizontal: 12,
|
|
marginHorizontal: 8,
|
|
borderRadius: Radius.md,
|
|
},
|
|
title: {
|
|
fontSize: 15,
|
|
letterSpacing: -0.2,
|
|
},
|
|
});
|