diff --git a/docs/feature-map/phonefit.md b/docs/feature-map/phonefit.md index 294f7d7..5c245c7 100644 --- a/docs/feature-map/phonefit.md +++ b/docs/feature-map/phonefit.md @@ -5,9 +5,9 @@ ## 子功能 - `phonefit-measure` 量:打開、回到前面、轉向、離開輸入框時,比螢幕高度、這頁看得到的高度和上下留白(狀態列、底部手勢條)。只看 iPhone 加入主畫面的 App;iPad、瀏覽器裡的不動。 -- `phonefit-short` iOS 少給下面一條(iOS 26.1、26.5 以後、27;WebKit 問題 301994):看得到的比螢幕少一個狀態列高,那條由系統畫、網頁畫不到,上面還多一層霧面。這時標題列往下讓開霧面(上面留白改成狀態列的 1.55 倍),底部不再多留手勢條的空間(它已經在系統那條裡),輸入框底下的顏色改成跟頁面一樣(系統那條也是這個顏色)。狀態列佔了上面的那種(上面留白是 0)不動。 +- `phonefit-short` iOS 少給下面一條(iOS 26.1、26.5 以後、27;WebKit 問題 301994):看得到的比螢幕少一個狀態列高,那條由系統畫、網頁畫不到,上面還多一層霧面。這時標題列往下讓開霧面(量到霧面停在狀態列下 20pt,字從狀態列下 26pt 開始),底部不再多留手勢條的空間(它已經在系統那條裡)。像原生 App 一樣不出現色塊:霧面蓋在頁面色上、系統那條也是頁面色(#faf9f6,跟 manifest 一樣),兩者都看不出來(量過差 ≤ 1);Bot 清單原本較深的底色會讓上下各浮出一塊,這時改穿頁面色;輸入框底下也是頁面色;網頁自己的底色跟著現在這頁(遠端畫面的黑)。狀態列佔了上面的那種(上面留白是 0)不動。 - `phonefit-keyboard` 鍵盤收起後畫面沒長回來(iOS 主畫面 App 的老問題,要關掉 App 才好):離開輸入框 0.14 秒後還比量過最高的矮,就把整頁重新排一次(捲到哪裡留著),再量一次。 -- `phonefit-ruler` 設定 › 更新 ›「這支手機」›「畫面」:一行寫量到的——螢幕寬×高、看得到多高、上/下留白、是哪一種、iOS 版本、主畫面 App 還是瀏覽器。點了打開量尺:上面、下面每 10 一格的刻度,中間是那幾個數字,頁面底下外面一條紅色(看得到=下面那條也能畫);點一下關掉。 +- `phonefit-ruler` 設定 › 更新 ›「這支手機」›「畫面」:一行寫量到的——螢幕寬×高、看得到多高、上/下留白、是哪一種、iOS 版本、主畫面 App 還是瀏覽器。點了打開量尺:上面、下面每 10 一格的刻度,中間是那幾個數字,頁面底下外面一條紅色(看得到=下面那條也能畫);開著時網頁底色換成強調色(最下面那條跟著變=那條取網頁的底色);點一下關掉、底色回來。 ## 使用者怎麼到 @@ -22,7 +22,7 @@ - 基本前提和「手機已登入」(README)。無頭 Chrome 不是 iPhone 主畫面 App:用 `window.FIT_TEST` 代替手機量到的數字(只在那一頁有效)。 -- **iOS 少給下面一條**(covers `phonefit-measure`、`phonefit-short`):指令:`$CTL phone click '.row[data-bot="1"]' && $CTL phone js '(() => { window.FIT_TEST = {iphone:true,standalone:true,screenW:393,screenH:852,innerH:793,safeT:59,safeB:34}; fit(); const cs = (q) => getComputedStyle(document.querySelector(q)); return [FIT.mode, cs("#v-chat .bar").paddingTop, cs(".dock").paddingBottom].join(" "); })()' && $CTL phone shot phonefit-short`;再把 innerH 換成 852(正常)、safeT 換成 0(狀態列佔上面)、iphone 換成 false(iPad)各跑一次。看到:「short 95px 8px」,截圖標題列往下、輸入框貼近底部;另外三次 mode 是空的或 topbar,標題列 4px、底部 8px(Chrome 的留白是 0)。 +- **iOS 少給下面一條**(covers `phonefit-measure`、`phonefit-short`):指令:`$CTL phone click '.row[data-bot="1"]' && $CTL phone js '(() => { window.FIT_TEST = {iphone:true,standalone:true,screenW:393,screenH:852,innerH:793,safeT:59,safeB:34}; fit(); const cs = (q) => getComputedStyle(document.querySelector(q)); return [FIT.mode, cs("#v-chat .bar").paddingTop, cs(".dock").paddingBottom].join(" "); })()' && $CTL phone shot phonefit-short`;再把 innerH 換成 852(正常)、safeT 換成 0(狀態列佔上面)、iphone 換成 false(iPad)各跑一次。看到:「short 89px 8px」,截圖標題列往下、輸入框貼近底部;回首頁 `getComputedStyle(document.querySelector("#v-home")).backgroundColor` 是頁面色 rgb(250, 249, 246)(正常時是較深的那個);另外三次 mode 是空的或 topbar,標題列 4px、底部 8px(Chrome 的留白是 0)。 - **量尺**(covers `phonefit-ruler`):換過程式後要開兩次(第一次是存著的舊頁面)。指令:`$CTL phone open --listed && $CTL phone open --listed && $CTL phone click '#b-me' && $CTL phone click '#sheet-in .opt' --text 設定 && $CTL phone click '[data-go="updates"]' && $CTL phone wait '[data-ruler]' && $CTL phone click '[data-ruler]' && $CTL phone wait '#ruler' && $CTL phone shot phonefit-ruler`。看到:「畫面」那行「390×844,看得到 844;上 0/下 0;整個螢幕都是 AnyBot 的;iOS 18.0;瀏覽器」;量尺左上、右下各一排刻度(20、40…140),中間是那幾個數字;紅色那條在畫面外(Chrome 看不到)。 - **鍵盤收起、真的 iPhone**(covers `phonefit-keyboard`、`phonefit-short`):指令:走不到——要實機:主畫面打開、打字再收鍵盤、看上面糊不糊、下面空不空,打開量尺截圖。看到:實機上標題列清楚、輸入框貼近手勢條,量尺那行是實機的數字。 - 自動測試:`cargo test featuremap::`。 @@ -30,5 +30,6 @@ ## 陷阱 - 下面那條是系統畫的,網頁畫不到:只能讓顏色一樣,輸入框不會跑進去(不切到)。 -- 霧面往下多深是量 iPhone 15 Pro 的截圖估的(狀態列的 1.55 倍);別的機型、別的 iOS 版本用量尺確認後再調。 +- 霧面往下多深是量 iPhone 15 Pro 的截圖(狀態列 59pt,霧面到 79pt);別的機型、別的 iOS 版本用量尺確認後再調 `FROST_PAST`。 +- 深色模式下系統那條是什麼顏色還沒量過(manifest 的底色是淺的):用量尺看那條跟不跟著強調色變。 - 用帳號連線時,手機頁面是帳號伺服器發的:改了要更新帳號伺服器;更新後第一次打開還是存著的舊頁面,再打開一次才換新的。 diff --git a/mobile/index.html b/mobile/index.html index 810ba38..b4ed2c9 100644 --- a/mobile/index.html +++ b/mobile/index.html @@ -1102,6 +1102,8 @@ function barColor() { const c = getComputedStyle(top).backgroundColor; if (!c || c === "rgba(0, 0, 0, 0)") return; document.querySelectorAll('meta[name="theme-color"]').forEach((m) => m.setAttribute("content", c)); + // (stripColor is in the last script: not there yet while this one first runs.) + if (typeof stripColor === "function") stripColor(); } function go(v, arg = {}, replace = false) { S.dir = replace ? "" : "in-fwd"; @@ -4428,15 +4430,43 @@ function fit() { const mode = lost >= 20 && lost <= 90 ? (safeT >= 20 ? "short" : "topbar") : ""; const root = document.documentElement; if (mode === "short") { - root.style.setProperty("--safe-t", Math.round(safeT * 1.55) + "px"); + // The frost ends at the status bar + 20 (measured: 79 pt on a 59 pt bar); the header's words + // start a little below that. + root.style.setProperty("--safe-t", Math.round(safeT + FROST_PAST) + "px"); root.style.setProperty("--safe-b", Math.max(0, Math.round(safeB - lost)) + "px"); + // 像原生 App: no bands. The frost lightens what lies under it and the system's strip at the + // bottom is the page colour (#faf9f6 here, the manifest's too): on the page colour neither shows + // (measured: ≤ 1 level). The Bot list's own darker colour showed both as blocks — it wears the + // page colour here. + root.style.setProperty("--side", "var(--pane)"); root.classList.add("fit-short"); } else { root.style.removeProperty("--safe-t"); root.style.removeProperty("--safe-b"); + root.style.removeProperty("--side"); root.classList.remove("fit-short"); } Object.assign(FIT, {mode, lost, safeT, safeB, screenW: landscape ? Math.max(sw, sh) : Math.min(sw, sh), screenH, innerH}); + stripColor(); +} +// How far below the status bar the header's words start when the system frosts the top. +const FROST_PAST = 26; +// What meets the system's strip: the page's own background is the showing view's (the remote +// screen's black, the list's colour…), so if the strip takes the page's colour it matches. +function stripColor() { + const root = document.documentElement, body = document.body; + // (The ruler holds the accent while it shows.) + if ($("ruler") || !body) return; + if (!root.classList.contains("fit-short")) { + root.style.removeProperty("background-color"); + body.style.removeProperty("background-color"); + return; + } + const v = document.querySelector(".view.on"); + const c = v ? getComputedStyle(v).backgroundColor : ""; + if (!c || c === "rgba(0, 0, 0, 0)") return; + root.style.backgroundColor = c; + body.style.backgroundColor = c; } // A text box let go: the keyboard bug leaves the page short — laid out again once, scroll kept. function heal() { @@ -4479,10 +4509,15 @@ function ruler() { const tick = (side, y) => `` + (y % 20 ? "" : `${y}`); for (let y = 0; y <= 140; y += 10) h += tick("top", y) + tick("bottom", y); - h += `