Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions companion/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@
"image": "./assets/splash-icon.png",
"imageWidth": 200
}
],
[
"@react-native-community/datetimepicker",
{
"android": {
"datePicker": {
"colorAccent": {
"light": "#000000"
},
"textColorPrimary": {
"light": "#000000"
}
},
"timePicker": {
"background": { "light": "#ffffff" },
"numbersBackgroundColor": { "light": "#ffffff" },
"headerBackground": { "light": "#000000" },
"numbersSelectorColor": { "light": "#000000" }
}
}
}
]
],
"experiments": {
Expand Down
3 changes: 3 additions & 0 deletions companion/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useCallback, useMemo } from "react";
import { Pressable, Text } from "react-native";
import { DateTimePickerAndroid } from "@react-native-community/datetimepicker";

interface LimitsTabDatePickerProps {
value: string;
onChange: (value: string) => void;
placeholder?: string;
}

export function LimitsTabDatePicker({ value, onChange, placeholder }: LimitsTabDatePickerProps) {
// Parse value string to Date object
const dateValue = useMemo(() => {
if (!value) return new Date();
const parsed = new Date(`${value}T00:00:00`);
return Number.isNaN(parsed.getTime()) ? new Date() : parsed;
}, [value]);

// Format date for display (compact, human-readable)
const displayText = useMemo(() => {
if (!value) return placeholder || "Select date";
return dateValue.toLocaleDateString(undefined, {
month: "short",
day: "numeric",
year: "numeric",
});
}, [value, dateValue, placeholder]);

// Handle date selection - convert to YYYY-MM-DD format
const handleDateChange = useCallback(
(date: Date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
onChange(`${year}-${month}-${day}`);
},
[onChange]
);

// Open native Android date picker
const openDatePicker = useCallback(() => {
DateTimePickerAndroid.open({
value: dateValue,
mode: "date",
onChange: (event, date) => {
if (event.type === "set" && date) {
handleDateChange(date);
}
},
});
}, [dateValue, handleDateChange]);

return (
<Pressable onPress={openDatePicker} className="rounded-lg bg-[#F2F2F7] px-3 py-2">
<Text className={`text-[15px] ${value ? "text-black" : "text-[#8E8E93]"}`}>
{displayText}
</Text>
</Pressable>
);
}
Loading
Loading