mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-27 09:08:31 +01:00
Upgraded expo from 54 to 55 Signed-off-by: Lance Chant <13349722+lancechant@users.noreply.github.com>
122 lines
3.6 KiB
TypeScript
122 lines
3.6 KiB
TypeScript
import {
|
|
Button,
|
|
ContextMenu,
|
|
Host,
|
|
Picker,
|
|
Text as SwiftUIText,
|
|
} from "@expo/ui/swift-ui";
|
|
import { buttonStyle, tag } from "@expo/ui/swift-ui/modifiers";
|
|
import { Platform, View } from "react-native";
|
|
import { FilterButton } from "@/components/filters/FilterButton";
|
|
import { JellyseerrSearchSort } from "@/components/jellyseerr/JellyseerrIndexPage";
|
|
|
|
interface DiscoverFiltersProps {
|
|
searchFilterId: string;
|
|
orderFilterId: string;
|
|
jellyseerrOrderBy: JellyseerrSearchSort;
|
|
setJellyseerrOrderBy: (value: JellyseerrSearchSort) => void;
|
|
jellyseerrSortOrder: "asc" | "desc";
|
|
setJellyseerrSortOrder: (value: "asc" | "desc") => void;
|
|
t: (key: string) => string;
|
|
}
|
|
|
|
const sortOptions = Object.keys(JellyseerrSearchSort).filter((v) =>
|
|
Number.isNaN(Number(v)),
|
|
);
|
|
|
|
const orderOptions = ["asc", "desc"] as const;
|
|
|
|
export const DiscoverFilters: React.FC<DiscoverFiltersProps> = ({
|
|
searchFilterId,
|
|
orderFilterId,
|
|
jellyseerrOrderBy,
|
|
setJellyseerrOrderBy,
|
|
jellyseerrSortOrder,
|
|
setJellyseerrSortOrder,
|
|
t,
|
|
}) => {
|
|
if (Platform.OS === "ios") {
|
|
return (
|
|
<Host
|
|
style={{
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
overflow: "visible",
|
|
height: 40,
|
|
width: 50,
|
|
marginLeft: "auto",
|
|
}}
|
|
>
|
|
<ContextMenu>
|
|
<ContextMenu.Trigger>
|
|
<Button
|
|
modifiers={[buttonStyle("glass")]}
|
|
systemImage='line.3.horizontal.decrease.circle'
|
|
></Button>
|
|
</ContextMenu.Trigger>
|
|
<ContextMenu.Items>
|
|
<Picker
|
|
label={t("library.filters.sort_by")}
|
|
selection={jellyseerrOrderBy as unknown as string}
|
|
onSelectionChange={(value) => {
|
|
setJellyseerrOrderBy(value as unknown as JellyseerrSearchSort);
|
|
}}
|
|
>
|
|
{sortOptions.map((item) => (
|
|
<SwiftUIText key={item} modifiers={[tag(item)]}>
|
|
{t(`home.settings.plugins.jellyseerr.order_by.${item}`)}
|
|
</SwiftUIText>
|
|
))}
|
|
</Picker>
|
|
<Picker
|
|
label={t("library.filters.sort_order")}
|
|
selection={jellyseerrSortOrder}
|
|
onSelectionChange={(value) => {
|
|
setJellyseerrSortOrder(value as "asc" | "desc");
|
|
}}
|
|
>
|
|
{orderOptions.map((item) => (
|
|
<SwiftUIText key={item} modifiers={[tag(item)]}>
|
|
{t(`library.filters.${item}`)}
|
|
</SwiftUIText>
|
|
))}
|
|
</Picker>
|
|
</ContextMenu.Items>
|
|
</ContextMenu>
|
|
</Host>
|
|
);
|
|
}
|
|
|
|
// Android UI
|
|
return (
|
|
<View className='flex flex-row justify-end items-center space-x-1'>
|
|
<FilterButton
|
|
id={searchFilterId}
|
|
queryKey='jellyseerr_search'
|
|
queryFn={async () =>
|
|
Object.keys(JellyseerrSearchSort).filter((v) =>
|
|
Number.isNaN(Number(v)),
|
|
)
|
|
}
|
|
set={(value) => setJellyseerrOrderBy(value[0])}
|
|
values={[jellyseerrOrderBy]}
|
|
title={t("library.filters.sort_by")}
|
|
renderItemLabel={(item) =>
|
|
t(`home.settings.plugins.jellyseerr.order_by.${item}`)
|
|
}
|
|
disableSearch={true}
|
|
/>
|
|
<FilterButton
|
|
id={orderFilterId}
|
|
queryKey='jellysearr_search'
|
|
queryFn={async () => ["asc", "desc"]}
|
|
set={(value) => setJellyseerrSortOrder(value[0])}
|
|
values={[jellyseerrSortOrder]}
|
|
title={t("library.filters.sort_order")}
|
|
renderItemLabel={(item) => t(`library.filters.${item}`)}
|
|
disableSearch={true}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|