feat(mobile): add dev phone preview and system-bar safe areas
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped

This commit is contained in:
1xDed committed 2026-12-01 20:20:53 +03:00
1 parent c15742ff2a
commit 7fb3d6cfa4
30 files changed
+278 -55

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<!-- <script src="http://localhost:8097"></script> -->
<title>Blink</title>
<style>
+5 -3
View File
@@ -236,7 +236,7 @@
@media (max-width: 700px) {
.appBar {
padding: 0.55rem 0.6rem !important;
padding: calc(0.55rem + var(--safe-top)) 0.6rem 0.55rem !important;
html.is-macos & {
padding-left: 76px !important;
@@ -260,8 +260,8 @@
@media (max-width: 700px) {
.library-drawer.MuiDrawer-paper {
width: min(84vw, 320px);
margin: 8px;
height: calc(100% - 16px) !important;
margin: calc(8px + var(--safe-top)) 8px calc(8px + var(--safe-bottom));
height: calc(100% - 16px - var(--safe-top) - var(--safe-bottom)) !important;
border-radius: 20px;
background: rgb(18 18 24 / 0.98) !important;
backdrop-filter: blur(24px) saturate(160%);
@@ -316,6 +316,8 @@
.back-only-bar {
padding-top: var(--safe-top);
html.is-macos & {
padding-left: 76px;
}
+1 -1
View File
@@ -242,7 +242,7 @@
@media (max-width: 700px) {
.item-detail-page.item {
padding: 0.75rem 1rem 7.5rem !important;
padding: 0.75rem 1rem calc(7.5rem + var(--safe-bottom)) !important;
.item-detail {
grid-template-columns: 1fr;
+1 -1
View File
@@ -103,7 +103,7 @@ $cardWidth: 18%;
align-items: center;
justify-content: flex-start;
gap: 1rem;
padding: 5.5rem 1rem 7.5rem;
padding: calc(5.5rem + var(--safe-top)) 1rem calc(7.5rem + var(--safe-bottom));
box-sizing: border-box;
text-align: center;
@@ -71,7 +71,7 @@
@media (max-width: 700px) {
.library-header {
inset: 0.5em 0.5em auto 0.5em !important;
inset: calc(0.5em + var(--safe-top)) 0.5em auto 0.5em !important;
width: auto !important;
flex-wrap: wrap;
border-radius: 22px;
@@ -121,7 +121,7 @@
}
.library-items {
padding: 7.8em 0.75rem 7.5em !important;
padding: calc(8.4em + var(--safe-top)) 0.75rem calc(7.5em + var(--safe-bottom)) !important;
}
.alpha-selector {
+1 -1
View File
@@ -280,7 +280,7 @@
@media (max-width: 700px) {
.login-shell {
padding: 4.5rem 1rem 2rem;
padding: calc(4.5rem + var(--safe-top)) 1rem calc(2rem + var(--safe-bottom));
}
.profile-grid {
+82
View File
@@ -0,0 +1,82 @@
import React, { useEffect, useState } from "react";
import "./mobilePreview.scss";
const MOBILE_QUERY = "(max-width: 700px)";
const isRealMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
const platformClass = () => {
const ua = navigator.userAgent;
if (ua.includes("Android")) return ["is-android", "is-mobile"];
if (/iPhone|iPad|iPod/.test(ua)) return ["is-ios", "is-mobile"];
if (ua.includes("Macintosh")) return ["is-macos"];
if (ua.includes("Windows")) return ["is-windows"];
return ["is-linux"];
};
const clock = () =>
new Date().toLocaleTimeString("ru-RU", {
hour: "2-digit",
minute: "2-digit",
});
/**
* Dev-only phone chrome: a transparent Android status bar and the bottom
* gesture pill are drawn over the app while the Tauri window is phone-sized.
* It lets the mobile layout be checked without a physical device.
*/
const MobilePreview = () => {
const [narrow, setNarrow] = useState(() =>
window.matchMedia(MOBILE_QUERY).matches,
);
const [time, setTime] = useState(clock);
const enabled = import.meta.env.DEV && !isRealMobile && narrow;
useEffect(() => {
const media = window.matchMedia(MOBILE_QUERY);
const onChange = (event: MediaQueryListEvent) => setNarrow(event.matches);
media.addEventListener("change", onChange);
return () => media.removeEventListener("change", onChange);
}, []);
useEffect(() => {
if (!enabled) return;
const root = document.documentElement;
const previous = ["is-macos", "is-windows", "is-linux"].filter((name) =>
root.classList.contains(name),
);
root.classList.remove("is-macos", "is-windows", "is-linux");
root.classList.add("mobile-preview");
return () => {
root.classList.remove("mobile-preview");
for (const name of platformClass()) root.classList.add(name);
for (const name of previous) root.classList.add(name);
};
}, [enabled]);
useEffect(() => {
if (!enabled) return;
const timer = window.setInterval(() => setTime(clock()), 30_000);
return () => window.clearInterval(timer);
}, [enabled]);
if (!enabled) return null;
return (
<div className="mobile-preview" aria-hidden="true">
<div className="mobile-preview-status">
<span className="mobile-preview-time">{time}</span>
<span className="mobile-preview-status-icons">
<span className="material-symbols-rounded">signal_cellular_alt</span>
<span className="material-symbols-rounded">wifi</span>
<span className="material-symbols-rounded">battery_full</span>
</span>
</div>
<div className="mobile-preview-gesture">
<span />
</div>
</div>
);
};
export default MobilePreview;
@@ -0,0 +1,61 @@
html.mobile-preview {
--safe-top: 32px;
--safe-bottom: 28px;
}
html.mobile-preview .window-controls,
html.mobile-preview .window-chrome {
display: none !important;
}
.mobile-preview {
position: fixed;
inset: 0;
z-index: 10000;
pointer-events: none;
color: #fff;
font-family: "Medeo Sans", system-ui, sans-serif;
}
.mobile-preview-status {
position: absolute;
inset: 0 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
height: 32px;
padding: 0 18px;
box-sizing: border-box;
text-shadow: 0 1px 3px rgb(0 0 0 / 0.45);
}
.mobile-preview-time {
font-size: 0.82rem;
font-weight: 600;
letter-spacing: 0.01em;
}
.mobile-preview-status-icons {
display: flex;
align-items: center;
gap: 0.3rem;
.material-symbols-rounded {
font-size: 1rem;
}
}
.mobile-preview-gesture {
position: absolute;
inset: auto 0 0;
display: grid;
place-items: center;
height: 28px;
span {
width: 108px;
height: 4px;
border-radius: 999px;
background: rgb(255 255 255 / 0.85);
}
}
@@ -20,6 +20,8 @@ export const ErrorNotice = ({ error }: { error?: unknown }) => {
justifyContent: "center",
alignItems: "center",
flexFlow: "column",
boxSizing: "border-box",
padding: "calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom))",
// opacity: 0.2,
}}
>
@@ -52,8 +54,9 @@ export const ErrorNotice = ({ error }: { error?: unknown }) => {
background: "rgb(0 0 0 / 1)",
borderRadius: "8px",
border: "2px dashed rgb(255 255 255 / 0.5)",
maxWidth: "40em",
maxWidth: "100%",
maxHeight: "20em",
boxSizing: "border-box",
overflow: "auto",
marginTop: "1em",
whiteSpace: "pre-wrap",
@@ -12,7 +12,7 @@ html.player-full-open .audio-player {
position: fixed;
left: 0;
right: 0;
bottom: 0.85rem;
bottom: calc(0.85rem + var(--safe-bottom));
margin: 0 auto;
width: min(1700px, calc(100% - 3rem));
height: 82px;
@@ -348,7 +348,7 @@ html.player-full-open .audio-player {
.audio-player {
width: calc(100% - 1rem);
height: 64px;
bottom: 0.5rem;
bottom: calc(0.5rem + var(--safe-bottom));
padding: 0 0.55rem;
gap: 0.5rem;
border-radius: 22px;
@@ -208,7 +208,11 @@ const AudioPlayer = () => {
// Media Session metadata/actions for local playback.
useEffect(() => {
if ("mediaSession" in navigator && item) {
if (
navigator.mediaSession &&
typeof MediaMetadata !== "undefined" &&
item
) {
const imageUrl = item.ImageTags?.Primary
? api &&
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Primary", {
@@ -227,7 +231,7 @@ const AudioPlayer = () => {
}, [item, api]);
useEffect(() => {
if (!("mediaSession" in navigator)) return;
if (!navigator.mediaSession?.setActionHandler) return;
navigator.mediaSession.setActionHandler("play", () => {
audioRef.current?.play();
});
@@ -320,14 +324,14 @@ const AudioPlayer = () => {
const onPlay = () => {
setPlaying(true);
updatePositionState();
if ("mediaSession" in navigator) {
if (navigator.mediaSession) {
navigator.mediaSession.playbackState = "playing";
}
};
const onPause = () => {
setPlaying(false);
updatePositionState();
if ("mediaSession" in navigator) {
if (navigator.mediaSession) {
navigator.mediaSession.playbackState = "paused";
}
};
@@ -11,6 +11,8 @@ const ForwardButton = () => {
);
useEffect(() => {
if (!navigator.mediaSession?.setActionHandler) return;
navigator.mediaSession.setActionHandler("seekforward", (details) => {
if (details.seekOffset) {
seekForward(details.seekOffset);
@@ -11,6 +11,8 @@ const RewindButton = () => {
);
React.useEffect(() => {
if (!navigator.mediaSession?.setActionHandler) return;
navigator.mediaSession.setActionHandler("seekbackward", (details) => {
if (details.seekOffset) {
seekBackward(details.seekOffset);
@@ -27,8 +27,9 @@
display: flex;
align-items: center;
gap: 0.75em;
padding: 4px 8px;
min-height: 46px;
padding: calc(4px + var(--safe-top)) 8px 4px;
min-height: calc(46px + var(--safe-top));
box-sizing: border-box;
user-select: none;
&-end {
@@ -51,7 +52,7 @@
flex-direction: column;
align-self: stretch;
justify-content: space-between;
padding: 2em 3em;
padding: 2em 3em calc(2em + var(--safe-bottom));
background: linear-gradient(
to bottom,
rgba(0, 0, 0, 0.8) 0%,
@@ -148,7 +149,7 @@ html.is-macos .video-player-titlebar.is-fullscreen {
}
@media (max-width: 700px) {
.video-player-osd {
padding: 0.75em 1em;
padding: 0.75em 1em calc(0.75em + var(--safe-bottom));
}
.video-player-osd-info {
+3 -1
View File
@@ -4,6 +4,7 @@ import React, { useEffect, useState } from "react";
import "./windowControls.scss";
const isMac = navigator.userAgent.includes("Macintosh");
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
const WindowsControls = () => {
const [maximized, setMaximized] = useState(false);
@@ -68,6 +69,7 @@ const WindowsControls = () => {
* Window buttons for frameless windows on Windows/Linux. macOS keeps its
* native traffic lights (overlay titlebar), so this renders nothing there.
*/
const WindowControls = () => (isMac ? null : <WindowsControls />);
const WindowControls = () =>
isMac || isMobile ? null : <WindowsControls />;
export default WindowControls;
@@ -6,6 +6,7 @@ import WindowControls from ".";
import "./windowControls.scss";
const isMac = navigator.userAgent.includes("Macintosh");
const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
/**
* Frameless-window fallback for pages that do not draw the app header:
@@ -17,7 +18,7 @@ const isMac = navigator.userAgent.includes("Macintosh");
*/
const WindowChrome = () => {
const { pathname } = useLocation();
if (isMac) return null;
if (isMac || isMobile) return null;
// The global app header owns the window buttons on these routes.
if (shouldShowAppBar(pathname)) return null;
// The home page draws its own header inside the hero frame.
+7 -1
View File
@@ -129,7 +129,13 @@ const init = async () => {
// Frameless titlebar: macOS keeps the native traffic lights; Windows and
// Linux use the custom window buttons in the header.
const userAgent = navigator.userAgent;
if (userAgent.includes("Macintosh")) {
const isAndroid = userAgent.includes("Android");
const isIOS = /iPhone|iPad|iPod/.test(userAgent);
if (isAndroid) {
document.documentElement.classList.add("is-android", "is-mobile");
} else if (isIOS) {
document.documentElement.classList.add("is-ios", "is-mobile");
} else if (userAgent.includes("Macintosh")) {
document.documentElement.classList.add("is-macos");
} else if (userAgent.includes("Windows")) {
document.documentElement.classList.add("is-windows");
+2
View File
@@ -5,6 +5,7 @@ import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
import { SnackbarProvider } from "notistack";
import React from "react";
import { AppBar } from "@/components/appBar/appBar";
import MobilePreview from "@/components/mobilePreview";
// import NProgress from "@/components/nProgress";
import AudioPlayer from "@/components/playback/audioPlayer";
@@ -72,6 +73,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
<QuickConnectApprovalDialog />
<DeepLinkHandler />
<AppBar />
<MobilePreview />
<WindowChrome />
<WindowDrag />
<WindowResizeHandles />
+1 -1
View File
@@ -142,7 +142,7 @@
@media (max-width: 700px) {
.favorite-page {
padding: 4.8rem 0 7rem !important;
padding: calc(4.8rem + var(--safe-top)) 0 calc(7rem + var(--safe-bottom)) !important;
}
.favorite-page .favorite-header {
+2 -2
View File
@@ -267,7 +267,7 @@ body.has-player-bar .home-sections {
}
.home-header {
padding: 0.55rem 0.8rem 1rem;
padding: calc(0.55rem + var(--safe-top)) 0.8rem 1rem;
.home-header-groups,
.home-header-cast {
@@ -306,6 +306,6 @@ body.has-player-bar .home-sections {
}
.home-sections {
padding: 2rem 1.1rem 8rem;
padding: 2rem 1.1rem calc(8rem + var(--safe-bottom));
}
}
+2 -1
View File
@@ -221,6 +221,7 @@
}
.library-items {
padding-top: 8.4em !important;
padding-top: calc(8.4em + var(--safe-top)) !important;
padding-bottom: calc(7.5em + var(--safe-bottom)) !important;
}
}
+28 -10
View File
@@ -24,8 +24,9 @@
z-index: 6;
display: flex;
align-items: center;
min-height: 46px;
padding: 4px 8px;
min-height: calc(46px + var(--safe-top));
padding: calc(4px + var(--safe-top)) 8px 4px;
box-sizing: border-box;
&-end {
margin-left: auto;
@@ -34,7 +35,7 @@
&-collapse {
position: absolute;
top: 58px;
top: calc(58px + var(--safe-top));
right: 22px;
z-index: 6;
display: grid;
@@ -68,7 +69,7 @@
&-stage {
position: absolute;
inset: 46px 0 96px;
inset: calc(46px + var(--safe-top)) 0 calc(96px + var(--safe-bottom));
z-index: 2;
display: flex;
align-items: center;
@@ -209,8 +210,8 @@
align-items: center;
justify-content: space-between;
gap: 16px;
height: 96px;
padding: 0 clamp(1.25rem, 3vw, 3rem);
height: calc(96px + var(--safe-bottom));
padding: 0 clamp(1.25rem, 3vw, 3rem) var(--safe-bottom);
box-sizing: border-box;
.MuiIconButton-root {
@@ -561,12 +562,29 @@
position: static;
}
&-main {
transition:
transform 0.32s cubic-bezier(0.2, 0, 0, 1),
opacity 0.25s ease;
}
&.has-panel &-main {
transform: translateX(-120%);
opacity: 0;
pointer-events: none;
}
&-panel {
position: absolute;
top: 1rem;
right: 1rem;
bottom: 0;
width: min(84vw, 520px);
inset: 0;
width: 100%;
background: linear-gradient(
180deg,
rgb(12 10 20 / 0.97),
rgb(12 10 20 / 0.93)
);
backdrop-filter: blur(24px) saturate(150%);
box-sizing: border-box;
}
}
}
+14 -2
View File
@@ -457,8 +457,8 @@ function AudioPlayerRoute() {
</span>
<IconButton
size="small"
aria-label="Показать очередь"
onClick={() => setPanelTab("queue")}
aria-label="Закрыть"
onClick={() => setPanelOpen(false)}
>
<span className="material-symbols-rounded">close</span>
</IconButton>
@@ -479,6 +479,17 @@ function AudioPlayerRoute() {
</div>
</>
) : (
<>
<div className="music-player-panel-head">
<span className="music-player-panel-source">Очередь</span>
<IconButton
size="small"
aria-label="Закрыть"
onClick={() => setPanelOpen(false)}
>
<span className="material-symbols-rounded">close</span>
</IconButton>
</div>
<div className="music-player-panel-body">
{upcoming.length === 0 ? (
<p className="music-player-panel-empty">
@@ -504,6 +515,7 @@ function AudioPlayerRoute() {
</div>
)}
</div>
</>
)}
</div>
</motion.aside>
+7 -1
View File
@@ -305,7 +305,12 @@ export function VideoPlayer() {
if (videoElement) videoElement.currentTime = target;
}
if (navigator.mediaSession && mediaSource) {
if (
navigator.mediaSession &&
typeof navigator.mediaSession.setActionHandler === "function" &&
mediaSource
) {
if (typeof MediaMetadata !== "undefined") {
navigator.mediaSession.metadata = new MediaMetadata({
title: isEpisode
? `${itemName} - ${episodeTitle}`
@@ -325,6 +330,7 @@ export function VideoPlayer() {
},
],
});
}
navigator.mediaSession.setActionHandler("play", () => {
toggleIsPlaying();
});
+3 -3
View File
@@ -579,8 +579,8 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
}
.remote-topbar {
height: 52px;
padding: 0 16px;
height: calc(52px + var(--safe-top));
padding: var(--safe-top) 16px 0;
}
html.is-macos .remote-topbar {
@@ -689,7 +689,7 @@ html.is-macos .remote-topbar-right .remote-topbar-divider {
justify-content: flex-start;
gap: 0.35rem;
height: auto;
padding: 0.5rem 1rem 1rem;
padding: 0.5rem 1rem calc(1rem + var(--safe-bottom));
}
.remote-bottom-item {
+2 -2
View File
@@ -196,7 +196,7 @@
@media (max-width: 900px) {
.search-page .search-header {
inset: 0.5em 0.5em auto 0.5em !important;
inset: calc(0.5em + var(--safe-top)) 0.5em auto 0.5em !important;
width: auto !important;
flex-wrap: wrap;
border-radius: 22px;
@@ -230,7 +230,7 @@
}
.search-page-content {
padding: 8.4em 1rem 8rem;
padding: calc(8.4em + var(--safe-top)) 1rem calc(8rem + var(--safe-bottom));
}
}
+8 -4
View File
@@ -211,7 +211,7 @@
align-items: center;
gap: 0.25em;
width: 100%;
padding: 0.4rem 0.6rem;
padding: calc(0.4rem + var(--safe-top)) 0.6rem 0.4rem;
border-right: 0;
border-bottom: 1px solid rgb(255 255 255 / 0.06);
overflow-x: auto;
@@ -219,7 +219,7 @@
box-sizing: border-box;
html.is-macos & {
padding-top: 0.4rem;
padding-top: calc(0.4rem + var(--safe-top));
padding-left: 76px;
}
}
@@ -309,10 +309,14 @@
.settings-sidebar-list-item .MuiButtonBase-root {
width: auto;
padding: 0.4em 0.6em !important;
padding: 0.4em 0.8em 0.4em 0.6em !important;
font-size: 0.82rem;
}
.settings-sidebar-list-item.active .MuiButtonBase-root {
padding-right: 2em !important;
}
.settings-sidebar-controls {
display: flex;
flex: 0 0 auto;
@@ -323,7 +327,7 @@
}
.settings-page-scrollY {
padding: 0.75rem 1rem 7.5rem !important;
padding: 0.75rem 1rem calc(7.5rem + var(--safe-bottom)) !important;
}
.settings-form {
+1 -1
View File
@@ -24,7 +24,7 @@
.serverContainer {
width: 100%;
max-width: 40em;
padding: 1rem;
padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
box-sizing: border-box;
.MuiPaper-root {
+1 -1
View File
@@ -57,7 +57,7 @@
@media (max-width: 700px) {
.server-list {
padding: 1rem;
padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
box-sizing: border-box;
&-container {
+18 -4
View File
@@ -32,6 +32,20 @@
:root {
--font-mono: "Medeo Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
--safe-top: env(safe-area-inset-top, 0px);
--safe-bottom: env(safe-area-inset-bottom, 0px);
}
/* Android WebViews run edge-to-edge: env() reports cutouts but not the system
bars, so keep a platform fallback clear of the status and navigation bars. */
html.is-android {
--safe-top: max(env(safe-area-inset-top, 0px), 32px);
--safe-bottom: max(env(safe-area-inset-bottom, 0px), 28px);
}
html.is-ios {
--safe-top: env(safe-area-inset-top, 0px);
--safe-bottom: env(safe-area-inset-bottom, 0px);
}
::-webkit-scrollbar {
@@ -488,20 +502,20 @@ a {
@media (max-width: 700px) {
.scrollY {
padding: 0.75rem 1rem;
padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
}
.scrollY.padded-top {
padding-top: 4.8rem;
padding-top: calc(4.8rem + var(--safe-top));
}
}
@media (max-width: 700px) {
.MuiDialog-container .MuiDialog-paper {
margin: 1rem;
margin: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
width: calc(100% - 2rem) !important;
max-width: calc(100% - 2rem) !important;
max-height: calc(100% - 2rem);
max-height: calc(100% - 2rem - var(--safe-top) - var(--safe-bottom));
border-radius: 18px;
background-color: rgb(20 20 27) !important;
background-image: none !important;