mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { View } from "react-native";
|
|
import { Text } from "../common/Text";
|
|
|
|
export const HourHeader = ({ height }: { height: number }) => {
|
|
const now = new Date();
|
|
const currentHour = now.getHours();
|
|
const hoursRemaining = 24 - currentHour;
|
|
const hours = generateHours(currentHour, hoursRemaining);
|
|
|
|
return (
|
|
<View
|
|
className='flex flex-row'
|
|
style={{
|
|
height,
|
|
}}
|
|
>
|
|
{hours.map((hour, index) => (
|
|
<HourCell key={index} hour={hour} />
|
|
))}
|
|
</View>
|
|
);
|
|
};
|
|
|
|
const HourCell = ({ hour }: { hour: Date }) => (
|
|
<View className='w-[200px] flex items-center justify-center bg-neutral-800'>
|
|
<Text className='text-xs text-gray-600'>
|
|
{hour.toLocaleTimeString([], {
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
})}
|
|
</Text>
|
|
</View>
|
|
);
|
|
|
|
const generateHours = (startHour: number, count: number): Date[] => {
|
|
const now = new Date();
|
|
return Array.from({ length: count }, (_, i) => {
|
|
const hour = new Date(now);
|
|
hour.setHours(startHour + i, 0, 0, 0);
|
|
return hour;
|
|
});
|
|
};
|