This repository has been archived on 2024-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
p61-project/app/application/habits/history.tsx

51 lines
1.2 KiB
TypeScript
Raw Normal View History

import { useMemo, useState } from "react"
import { View } from "react-native"
import { Agenda } from "react-native-calendars"
import { Text } from "react-native-paper"
import { SafeAreaView } from "react-native-safe-area-context"
2024-04-09 23:53:55 +02:00
import { getISODate, getNowDate } from "@/utils/dates"
2024-03-15 23:24:08 +01:00
const HistoryPage: React.FC = () => {
const today = useMemo(() => {
2024-04-09 23:53:55 +02:00
return getNowDate()
}, [])
const todayISO = getISODate(today)
const [selectedDate, setSelectedDate] = useState<Date>(today)
const selectedISODate = getISODate(selectedDate)
return (
2024-03-24 23:41:23 +01:00
<SafeAreaView
style={[
{
flex: 1,
backgroundColor: "white",
2024-03-24 23:41:23 +01:00
},
]}
>
<Agenda
firstDay={1}
showClosingKnob
showOnlySelectedDayItems
onDayPress={(date) => {
setSelectedDate(new Date(date.dateString))
}}
markedDates={{
[todayISO]: { marked: true },
}}
selected={selectedISODate}
renderList={() => {
return (
<View>
<Text>{selectedDate.toISOString()}</Text>
</View>
)
}}
/>
</SafeAreaView>
)
}
2024-03-15 23:24:08 +01:00
export default HistoryPage