chore: merge player icon with logo button

This commit is contained in:
Stephen Zhou
2024-11-26 00:06:33 +08:00
parent 4a1ae06688
commit 7db73d1520
@@ -83,13 +83,10 @@ export const MobileFloatBar = ({
animate={animateController}
>
<div className={styles["float-bar"]}>
<MotionButtonBase onClick={onLogoClick}>
<Logo className="size-5 shrink-0" />
</MotionButtonBase>
<PlayerIcon onLogoClick={onLogoClick} />
<DividerVertical className="h-3/4 shrink-0" />
<ViewTabs onViewChange={onViewChange} />
<DividerVertical className="h-3/4 shrink-0" />
<PlayerIcon />
<ProfileButton />
</div>
</m.div>
@@ -132,23 +129,25 @@ const ViewTabs = ({ onViewChange }: { onViewChange?: (view: number) => void }) =
)
}
const PlayerIcon = () => {
const PlayerIcon = ({ onLogoClick }: { onLogoClick?: () => void }) => {
const { isPlaying, entryId } = useAudioPlayerAtomSelector(
useCallback((state) => ({ isPlaying: state.status === "playing", entryId: state.entryId }), []),
)
const feedId = useEntry(entryId, (s) => s.feedId)
const feed = useFeedById(feedId, feedIconSelector)
const [isShowPlayer, setIsShowPlayer] = useState(false)
if (!feed) return null
if (!isPlaying) return null
if (!feed || !isPlaying) {
return (
<MotionButtonBase onClick={onLogoClick}>
<Logo className="size-5 shrink-0" />
</MotionButtonBase>
)
}
return (
<>
<button
type="button"
className="mr-3 size-5 shrink-0"
onClick={() => setIsShowPlayer((v) => !v)}
>
<FeedIcon feed={feed} />
<button type="button" className="size-5 shrink-0" onClick={() => setIsShowPlayer((v) => !v)}>
<FeedIcon feed={feed} noMargin />
</button>
{isShowPlayer && (