mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
Co-authored-by: Alex Kim <alexkim@Alexs-MacBook-Pro.local> Co-authored-by: Fredrik Burmester <fredrik.burmester@gmail.com> Co-authored-by: Simon-Eklundh <simon.eklundh@proton.me>
32 lines
914 B
TypeScript
32 lines
914 B
TypeScript
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client/models";
|
|
import type React from "react";
|
|
import { useCallback } from "react";
|
|
import { View, type ViewProps } from "react-native";
|
|
import { useMarkAsPlayed } from "@/hooks/useMarkAsPlayed";
|
|
import { RoundButton } from "./RoundButton";
|
|
|
|
interface Props extends ViewProps {
|
|
items: BaseItemDto[];
|
|
size?: "default" | "large";
|
|
}
|
|
|
|
export const PlayedStatus: React.FC<Props> = ({ items, ...props }) => {
|
|
const allPlayed = items.every((item) => item.UserData?.Played);
|
|
const toggle = useMarkAsPlayed(items);
|
|
|
|
const handlePress = useCallback(() => {
|
|
void toggle(!allPlayed);
|
|
}, [allPlayed, toggle]);
|
|
|
|
return (
|
|
<View {...props}>
|
|
<RoundButton
|
|
color={allPlayed ? "purple" : "white"}
|
|
icon={allPlayed ? "checkmark" : "checkmark"}
|
|
onPress={handlePress}
|
|
size={props.size}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|