parent
cd5b8db8db
commit
2ba5602b27
@ -1,5 +1,31 @@ |
||||
import TodoList from "@/components/TodoList"; |
||||
import { Button, ButtonText } from "@/components/ui/button"; |
||||
import { GS } from "@/components/ui/gluestack-ui-provider/gluestack-ui-token"; |
||||
import { HStack } from "@/components/ui/hstack"; |
||||
import { Text } from "@/components/ui/text"; |
||||
import { VStack } from "@/components/ui/vstack"; |
||||
import { useTodosCtx } from "@/store/todoProvider"; |
||||
import { SafeAreaView } from "react-native-safe-area-context"; |
||||
|
||||
export default function DoneTab() { |
||||
return <SafeAreaView className="flex-1"></SafeAreaView>; |
||||
const { doneTodos, toggle, remove, clearDone } = useTodosCtx(); |
||||
|
||||
return ( |
||||
<SafeAreaView className="flex-1 bg-white dark:bg-neutral-900"> |
||||
<VStack className="flex-1 px-4 py-1 gap-3"> |
||||
<Text className="text-2xl font-bold">완료한 일</Text> |
||||
<TodoList data={doneTodos} onToggle={toggle} onRemove={remove} /> |
||||
<HStack className="justify-end"> |
||||
<Button |
||||
className="flex-1" |
||||
variant={GS.variant.outline} |
||||
action={GS.action.secondary} |
||||
onPress={clearDone} |
||||
> |
||||
<ButtonText>완료한 일 모두 지우기</ButtonText> |
||||
</Button> |
||||
</HStack> |
||||
</VStack> |
||||
</SafeAreaView> |
||||
); |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@ |
||||
import { createContext, useContext } from "react"; |
||||
import { type Todo, useTodos } from "./useTodos"; |
||||
|
||||
type TodosContextValue = ReturnType<typeof useTodos>; |
||||
|
||||
const TodosContext = createContext<TodosContextValue | null>(null); |
||||
|
||||
export function TodosProvider({ children }: { children: React.ReactNode }) { |
||||
const store = useTodos(); |
||||
return ( |
||||
<TodosContext.Provider value={store}>{children}</TodosContext.Provider> |
||||
); |
||||
} |
||||
|
||||
export function useTodosCtx(): TodosContextValue { |
||||
const ctx = useContext(TodosContext); |
||||
if (!ctx) { |
||||
throw new Error("use TodosCtx must be used within <TodosProvider>"); |
||||
} |
||||
return ctx; |
||||
} |
||||
|
||||
export type { Todo }; |
Loading…
Reference in new issue