fix: audio player on mobile
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
|
||||
import { useAudioPlayerAtomSelector } from "~/atoms/player"
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { ROUTE_FEED_PENDING } from "~/constants/app"
|
||||
import { ENTRY_COLUMN_LIST_SCROLLER_ID, LOGO_MOBILE_ID } from "~/constants/dom"
|
||||
@@ -10,6 +11,10 @@ import { EntryColumn } from "~/modules/entry-column"
|
||||
import { MobileFloatBar } from "../feed-column/float-bar.mobile"
|
||||
|
||||
export const EntryColumnMobile = () => {
|
||||
const { isPlaying } = useAudioPlayerAtomSelector(
|
||||
useCallback((state) => ({ isPlaying: state.status === "playing" }), []),
|
||||
)
|
||||
|
||||
const isStartupTimeline = useGeneralSettingKey("startupScreen") === "timeline"
|
||||
|
||||
const [scrollContainer, setScrollContainer] = useState<null | HTMLDivElement>(null)
|
||||
@@ -28,7 +33,7 @@ export const EntryColumnMobile = () => {
|
||||
|
||||
{isStartupTimeline && (
|
||||
<MobileFloatBar
|
||||
className="!bottom-10"
|
||||
className={isPlaying ? "!bottom-safe-offset-28" : "!bottom-safe-offset-10"}
|
||||
scrollContainer={scrollContainer}
|
||||
onLogoClick={() => {
|
||||
;(document.querySelector(`#${LOGO_MOBILE_ID}`) as HTMLElement)?.click()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
|
||||
import { cn, isSafari } from "@follow/utils/utils"
|
||||
|
||||
@@ -75,7 +75,7 @@ export function ListItem({
|
||||
{!withAudio && <FeedIcon feed={related} fallback entry={entry.entries} />}
|
||||
<div
|
||||
className={cn(
|
||||
"-mt-0.5 flex-1 text-sm leading-tight",
|
||||
"-mt-0.5 w-[calc(100%-88px)] flex-1 text-sm leading-tight",
|
||||
|
||||
// FIXME: Safari bug, not support line-clamp cross elements
|
||||
!envIsSafari && (settingWideMode ? "line-clamp-2" : "line-clamp-4"),
|
||||
@@ -201,6 +201,7 @@ function AudioCover({
|
||||
durationInSeconds?: number
|
||||
feedIcon: React.ReactNode
|
||||
}) {
|
||||
const isMobile = useMobile()
|
||||
const playStatus = useAudioPlayerAtomSelector((playerValue) =>
|
||||
playerValue.src === src && playerValue.show ? playerValue.status : false,
|
||||
)
|
||||
@@ -208,7 +209,7 @@ function AudioCover({
|
||||
const estimatedMins = durationInSeconds ? Math.floor(durationInSeconds / 60) : undefined
|
||||
|
||||
const handleClickPlay = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (isMobile()) e.stopPropagation()
|
||||
if (isMobile) e.stopPropagation()
|
||||
if (!playStatus) {
|
||||
// switch this to play
|
||||
AudioPlayer.mount({
|
||||
@@ -230,7 +231,7 @@ function AudioCover({
|
||||
<div
|
||||
className={cn(
|
||||
"center absolute inset-0 w-full transition-all duration-200 ease-in-out group-hover:-translate-y-2 group-hover:opacity-100",
|
||||
playStatus ? "opacity-100" : "opacity-0",
|
||||
isMobile || playStatus ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
onClick={handleClickPlay}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useFocusable } from "@follow/components/common/Focusable.js"
|
||||
import { useMobile } from "@follow/components/hooks/useMobile.js"
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@follow/components/ui/tooltip/index.jsx"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { cn } from "@follow/utils/utils"
|
||||
@@ -92,6 +93,8 @@ const usePlayerTracker = () => {
|
||||
}, [show])
|
||||
}
|
||||
const CornerPlayerImpl = () => {
|
||||
const isMobile = useMobile()
|
||||
|
||||
const { t } = useTranslation()
|
||||
const entryId = useAudioPlayerAtomSelector((v) => v.entryId)
|
||||
const status = useAudioPlayerAtomSelector((v) => v.status)
|
||||
@@ -164,7 +167,12 @@ const CornerPlayerImpl = () => {
|
||||
fallback={false}
|
||||
className="m-0 size-[3.625rem] rounded-none"
|
||||
/>
|
||||
<div className="center absolute inset-0 w-full opacity-0 transition-all duration-200 ease-in-out group-hover:opacity-100">
|
||||
<div
|
||||
className={cn(
|
||||
"center absolute inset-0 w-full opacity-0 transition-all duration-200 ease-in-out group-hover:opacity-100",
|
||||
isMobile && "opacity-100",
|
||||
)}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="center size-10 rounded-full bg-theme-background opacity-95 hover:bg-accent hover:text-white hover:opacity-100"
|
||||
@@ -199,7 +207,12 @@ const CornerPlayerImpl = () => {
|
||||
</div>
|
||||
|
||||
{/* advanced controls */}
|
||||
<div className="absolute inset-x-0 top-0 z-[-1] flex justify-between border-t bg-theme-modal-background-opaque p-1 opacity-100 transition-all duration-200 ease-in-out group-hover:-translate-y-full group-hover:opacity-100">
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-x-0 top-0 z-[-1] flex justify-between border-t bg-theme-modal-background-opaque p-1 opacity-100 transition-all duration-200 ease-in-out group-hover:-translate-y-full group-hover:opacity-100",
|
||||
isMobile && "-translate-y-full opacity-100",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<ActionIcon
|
||||
className="i-mgc-close-cute-re"
|
||||
|
||||
Reference in New Issue
Block a user