mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add detail display type to toggle
This commit is contained in:
@@ -95,7 +95,7 @@ export const AlbumListHeaderFilters = ({ toggleGenreTarget }: { toggleGenreTarge
|
|||||||
<ListRefreshButton listKey={pageKey as ItemListKey} />
|
<ListRefreshButton listKey={pageKey as ItemListKey} />
|
||||||
</Group>
|
</Group>
|
||||||
<Group gap="sm" wrap="nowrap">
|
<Group gap="sm" wrap="nowrap">
|
||||||
<ListDisplayTypeToggleButton listKey={ItemListKey.ALBUM} />
|
<ListDisplayTypeToggleButton enableDetail listKey={ItemListKey.ALBUM} />
|
||||||
<ListConfigMenu
|
<ListConfigMenu
|
||||||
detailConfig={{
|
detailConfig={{
|
||||||
optionsConfig: {
|
optionsConfig: {
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ export const DisplayTypeToggleButton = ({
|
|||||||
}: DisplayTypeToggleButtonProps) => {
|
}: DisplayTypeToggleButtonProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const isGrid = displayType === ListDisplayType.GRID;
|
const isGrid = displayType === ListDisplayType.GRID;
|
||||||
|
const isDetail = displayType === ListDisplayType.DETAIL;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
icon={isGrid ? 'layoutGrid' : 'layoutTable'}
|
icon={isGrid ? 'layoutGrid' : isDetail ? 'layoutDetail' : 'layoutTable'}
|
||||||
iconProps={{
|
iconProps={{
|
||||||
size: 'lg',
|
size: 'lg',
|
||||||
}}
|
}}
|
||||||
@@ -27,7 +28,9 @@ export const DisplayTypeToggleButton = ({
|
|||||||
tooltip={{
|
tooltip={{
|
||||||
label: isGrid
|
label: isGrid
|
||||||
? t('table.config.view.grid', { postProcess: 'sentenceCase' })
|
? t('table.config.view.grid', { postProcess: 'sentenceCase' })
|
||||||
: t('table.config.view.table', { postProcess: 'sentenceCase' }),
|
: isDetail
|
||||||
|
? t('table.config.view.detail', { postProcess: 'sentenceCase' })
|
||||||
|
: t('table.config.view.table', { postProcess: 'sentenceCase' }),
|
||||||
}}
|
}}
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const DISPLAY_TYPES = [
|
|||||||
{
|
{
|
||||||
label: (
|
label: (
|
||||||
<Group align="center" justify="center" p="sm">
|
<Group align="center" justify="center" p="sm">
|
||||||
<Icon icon="layoutList" size="lg" />
|
<Icon icon="layoutDetail" size="lg" />
|
||||||
{i18n.t('table.config.view.detail', { postProcess: 'sentenceCase' }) as string}
|
{i18n.t('table.config.view.detail', { postProcess: 'sentenceCase' }) as string}
|
||||||
</Group>
|
</Group>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,21 +3,50 @@ import { useSettingsStore, useSettingsStoreActions } from '/@/renderer/store';
|
|||||||
import { ItemListKey, ListDisplayType } from '/@/shared/types/types';
|
import { ItemListKey, ListDisplayType } from '/@/shared/types/types';
|
||||||
|
|
||||||
interface ListDisplayTypeToggleButtonProps {
|
interface ListDisplayTypeToggleButtonProps {
|
||||||
|
enableDetail?: boolean;
|
||||||
listKey: ItemListKey;
|
listKey: ItemListKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ListDisplayTypeToggleButton = ({ listKey }: ListDisplayTypeToggleButtonProps) => {
|
export const ListDisplayTypeToggleButton = ({
|
||||||
|
enableDetail = false,
|
||||||
|
listKey,
|
||||||
|
}: ListDisplayTypeToggleButtonProps) => {
|
||||||
const displayType = useSettingsStore(
|
const displayType = useSettingsStore(
|
||||||
(state) => state.lists[listKey]?.display,
|
(state) => state.lists[listKey]?.display,
|
||||||
) as ListDisplayType;
|
) as ListDisplayType;
|
||||||
const { setList } = useSettingsStoreActions();
|
const { setList } = useSettingsStoreActions();
|
||||||
|
|
||||||
const handleToggleDisplayType = () => {
|
const handleToggleDisplayType = () => {
|
||||||
const newDisplayType =
|
console.log('enableDetail', enableDetail);
|
||||||
displayType === ListDisplayType.GRID ? ListDisplayType.TABLE : ListDisplayType.GRID;
|
let newDisplayType: ListDisplayType;
|
||||||
|
|
||||||
|
if (enableDetail) {
|
||||||
|
if (displayType === ListDisplayType.DETAIL) {
|
||||||
|
newDisplayType = ListDisplayType.TABLE;
|
||||||
|
} else if (displayType === ListDisplayType.TABLE) {
|
||||||
|
newDisplayType = ListDisplayType.GRID;
|
||||||
|
} else if (displayType === ListDisplayType.GRID) {
|
||||||
|
newDisplayType = ListDisplayType.DETAIL;
|
||||||
|
} else {
|
||||||
|
newDisplayType = ListDisplayType.GRID;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (displayType === ListDisplayType.GRID) {
|
||||||
|
newDisplayType = ListDisplayType.TABLE;
|
||||||
|
} else if (displayType === ListDisplayType.TABLE) {
|
||||||
|
newDisplayType = ListDisplayType.GRID;
|
||||||
|
} else {
|
||||||
|
newDisplayType = ListDisplayType.GRID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('newDisplayType', newDisplayType);
|
||||||
|
|
||||||
setList(listKey, {
|
setList(listKey, {
|
||||||
display: newDisplayType,
|
display: newDisplayType,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
return <DisplayTypeToggleButton displayType={displayType} onToggle={handleToggleDisplayType} />;
|
return <DisplayTypeToggleButton displayType={displayType} onToggle={handleToggleDisplayType} />;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import {
|
|||||||
LuInfo,
|
LuInfo,
|
||||||
LuKeyboard,
|
LuKeyboard,
|
||||||
LuLayoutGrid,
|
LuLayoutGrid,
|
||||||
|
LuLayoutList,
|
||||||
LuLibrary,
|
LuLibrary,
|
||||||
LuList,
|
LuList,
|
||||||
LuListFilter,
|
LuListFilter,
|
||||||
@@ -186,6 +187,7 @@ export const AppIcon = {
|
|||||||
itemSong: LuMusic,
|
itemSong: LuMusic,
|
||||||
keyboard: LuKeyboard,
|
keyboard: LuKeyboard,
|
||||||
lastPlayed: LuHeadphones,
|
lastPlayed: LuHeadphones,
|
||||||
|
layoutDetail: LuLayoutList,
|
||||||
layoutGrid: LuLayoutGrid,
|
layoutGrid: LuLayoutGrid,
|
||||||
layoutList: LuList,
|
layoutList: LuList,
|
||||||
layoutTable: LuTable,
|
layoutTable: LuTable,
|
||||||
|
|||||||
Reference in New Issue
Block a user