import { Dropdown, DropdownOption, Focusable, PanelSectionRow, SteamSpinner, Tabs, TextField, findModule, } from 'decky-frontend-lib'; import { FC, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import logo from '../../../assets/plugin_store.png'; import Logger from '../../logger'; import { Store, StorePlugin, getPluginList, getStore } from '../../store'; import PluginCard from './PluginCard'; const logger = new Logger('Store'); const StorePage: FC<{}> = () => { const [currentTabRoute, setCurrentTabRoute] = useState('browse'); const [data, setData] = useState(null); const [isTesting, setIsTesting] = useState(false); const { TabCount } = findModule((m) => { if (m?.TabCount && m?.TabTitle) return true; return false; }); const { t } = useTranslation(); useEffect(() => { (async () => { const res = await getPluginList(); logger.log('got data!', res); setData(res); const storeRes = await getStore(); logger.log(`store is ${storeRes}, isTesting is ${storeRes === Store.Testing}`); setIsTesting(storeRes === Store.Testing); })(); }, []); return ( <>
{!data ? (
) : ( { setCurrentTabRoute(tabId); }} tabs={[ { title: t('Store.store_tabs.title'), content: , id: 'browse', renderTabAddon: () => {data.length}, }, { title: t('Store.store_tabs.about'), content: , id: 'about', }, ]} /> )}
); }; const BrowseTab: FC<{ children: { data: StorePlugin[]; isTesting: boolean } }> = (data) => { const { t } = useTranslation(); const sortOptions = useMemo( (): DropdownOption[] => [ { data: 1, label: t('Store.store_tabs.alph_desc') }, { data: 2, label: t('Store.store_tabs.alph_asce') }, ], [], ); // const filterOptions = useMemo((): DropdownOption[] => [{ data: 1, label: 'All' }], []); const [selectedSort, setSort] = useState(sortOptions[0].data); // const [selectedFilter, setFilter] = useState(filterOptions[0].data); const [searchFieldValue, setSearchValue] = useState(''); return ( <> {/* This should be used once filtering is added
{t("Store.store_sort.label")} setSort(e.data)} />
{t("Store.store_filter.label")} setFilter(e.data)} />
setSearchValue(e.target.value)} />
*/}
{t('Store.store_sort.label')} setSort(e.data)} />
setSearchValue(e.target.value)} />
{data.children.isTesting && (

{t('Store.store_testing_warning.label')}

{`${t('Store.store_testing_warning.desc')} `} decky.xyz/testing
)}
{data.children.data .filter((plugin: StorePlugin) => { return ( plugin.name.toLowerCase().includes(searchFieldValue.toLowerCase()) || plugin.description.toLowerCase().includes(searchFieldValue.toLowerCase()) || plugin.author.toLowerCase().includes(searchFieldValue.toLowerCase()) || plugin.tags.some((tag: string) => tag.toLowerCase().includes(searchFieldValue.toLowerCase())) ); }) .sort((a, b) => { if (selectedSort % 2 === 1) return a.name.localeCompare(b.name); else return b.name.localeCompare(a.name); }) .map((plugin: StorePlugin) => ( ))}
); }; const AboutTab: FC<{}> = () => { const { t } = useTranslation(); return (
Testing {t('Store.store_testing_cta')}{' '} decky.xyz/testing {t('Store.store_contrib.label')} {t('Store.store_contrib.desc')} {t('Store.store_source.label')} {t('Store.store_source.desc')}
); }; export default StorePage;