feat: zen mode and hide extra badge

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2024-10-29 23:52:48 +08:00
parent dcbae89020
commit 7ba07adff1
4 changed files with 48 additions and 4 deletions
@@ -16,6 +16,7 @@ import { memo, useCallback, useState } from "react"
import { useTranslation } from "react-i18next"
import { getMainContainerElement } from "~/atoms/dom"
import { useUISettingKey } from "~/atoms/settings/ui"
import { useFeedActions, useInboxActions, useListActions } from "~/hooks/biz/useFeedActions"
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
@@ -94,6 +95,7 @@ const FeedItemImpl = ({ view, feedId, className }: FeedItemProps) => {
useAnyPointDown(() => {
isContextMenuOpen && setIsContextMenuOpen(false)
})
const hideExtraBadge = useUISettingKey("hideExtraBadge")
if (!feed) return null
const isFeed = feed.type === "feed" || !feed.type
@@ -160,8 +162,8 @@ const FeedItemImpl = ({ view, feedId, className }: FeedItemProps) => {
>
<FeedIcon fallback feed={feed} size={16} />
<div className="truncate">{getPreferredTitle(feed)}</div>
{isFeed && <FeedCertification feed={feed} className="text-[15px]" />}
{isFeed && <BoostCertification feed={feed} className="text-[15px]" />}
{isFeed && !hideExtraBadge && <FeedCertification feed={feed} className="text-[15px]" />}
{isFeed && !hideExtraBadge && <BoostCertification feed={feed} className="text-[15px]" />}
{isFeed && feed.errorAt && (
<Tooltip delayDuration={300}>
<TooltipTrigger asChild>
@@ -17,12 +17,14 @@ import {
useUISettingSelector,
useUISettingValue,
} from "~/atoms/settings/ui"
import { setFeedColumnShow, useFeedColumnShow } from "~/atoms/sidebar"
import { isElectronBuild } from "~/constants"
import { useSetTheme } from "~/hooks/common"
import { SettingTabbedSegment } from "../control"
import { SettingDescription, SettingSwitch, SettingTabbedSegment } from "../control"
import { createDefineSettingItem } from "../helper/builder"
import { createSettingBuilder } from "../helper/setting-builder"
import { SettingItemGroup } from "../section"
import { ContentFontSelector, UIFontSelector } from "../sections/fonts"
const SettingBuilder = createSettingBuilder(useUISettingValue)
@@ -59,6 +61,16 @@ export const SettingAppearance = () => {
label: t("appearance.sidebar_show_unread_count.label"),
}),
{
type: "title",
value: t("appearance.sidebar"),
},
defineItem("hideExtraBadge", {
label: t("appearance.hide_extra_badge.label"),
description: t("appearance.hide_extra_badge.description"),
}),
ZenMode,
{
type: "title",
value: t("appearance.fonts"),
@@ -217,3 +229,28 @@ export const AppThemeSegment = () => {
/>
)
}
const ZenMode = () => {
const { t } = useTranslation("settings")
const feedColumnShow = useFeedColumnShow()
const isWideMode = useUISettingKey("wideMode")
return (
<SettingItemGroup>
<SettingSwitch
checked={!feedColumnShow && isWideMode}
className="mt-4"
onCheckedChange={(checked) => {
if (checked) {
setFeedColumnShow(false)
setUISetting("wideMode", true)
} else {
setFeedColumnShow(true)
setUISetting("wideMode", false)
}
}}
label={t("appearance.zen_mode.label")}
/>
<SettingDescription>{t("appearance.zen_mode.description")}</SettingDescription>
</SettingItemGroup>
)
}