1
1
mirror of https://github.com/theoludwig/p61-project.git synced 2024-07-17 07:00:12 +02:00
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-05-02 01:08:27 +02:00
import { getISODate, getNowDateUTC } from "@/utils/dates"
2024-03-15 23:24:08 +01:00
const HistoryPage: React.FC = () => {
const today = useMemo(() => {
2024-05-02 01:08:27 +02:00
return getNowDateUTC()
}, [])
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