mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
feat(native): Android tablets get the shortcuts, two panes meet at a foldable's fold
The Android shell now reports keyCommands and windowLayout, so the large screen layout no longer assumes an iPad: - The keyboard host hands the shortcuts to the app whenever the shell has the keyCommands feature, whatever the platform. Before it also required iOS, so an Android tablet with a keyboard answered the keys in the page and never listed them in the system's shortcuts. - useWindowFold follows the layout the Android shell reports (feature windowLayout). When a vertical fold separates the window, a foldable half open like a book, MobileShell marks it with data-fold and its place, and the leading pane (the trip's plan, a tab's summary, a list beside its detail) ends at the fold while the trailing one starts there, on either reading direction. A flat fold that does not separate stays one screen. - The split size class starts at 840pt, Android's expanded width, instead of 900pt, so a foldable unfolded on its side (about 841dp) gets two panes like an iPad does. An 11" iPad upright (834pt) stays a single pane. The address screen of the native shell follows the same width. - TrekShell exports NativeWindowLayout for it. Also: the sheet's width and anchor types and the collab board type stay private to their modules, which nothing else imports (knip).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ReactNode, useRef } from 'react'
|
||||
import { CSSProperties, ReactNode, useRef } from 'react'
|
||||
import { useMatch } from 'react-router'
|
||||
import BottomNav from '../components/Layout/BottomNav'
|
||||
import ErrorBoundary from '../components/shared/ErrorBoundary'
|
||||
@@ -11,6 +11,7 @@ import MToastHost from './components/MToastHost'
|
||||
import MEdgeBack from './components/MEdgeBack'
|
||||
import { useNativeCapabilities } from '../native/capabilities'
|
||||
import { isNativeIos } from '../native/platform'
|
||||
import { useWindowFold } from '../native/windowFold'
|
||||
import './mobile.css'
|
||||
|
||||
interface MobileShellProps {
|
||||
@@ -46,6 +47,12 @@ export default function MobileShell({ isPhone, children }: MobileShellProps) {
|
||||
// On a wide window (an iPad, a foldable unfolded) the rail on the leading edge
|
||||
// replaces the dock, and the page column starts after it.
|
||||
const wide = useIsWide()
|
||||
// A foldable's fold, as the Android app reports it: two-pane screens end their
|
||||
// leading pane there (mobile.css, data-fold).
|
||||
const fold = useWindowFold()
|
||||
const foldStyle = fold
|
||||
? ({ '--m-fold-start': `${fold.start}px`, '--m-fold-end': `${fold.end}px` } as CSSProperties)
|
||||
: undefined
|
||||
|
||||
if (!isPhone) {
|
||||
return (
|
||||
@@ -59,7 +66,7 @@ export default function MobileShell({ isPhone, children }: MobileShellProps) {
|
||||
return (
|
||||
// min-h-svh, not min-h-dvh: dvh grows while Safari's toolbar retracts, so a
|
||||
// dvh page length would chase the animation it just triggered.
|
||||
<div className="m-root m-shell flex min-h-svh flex-col text-m-ink">
|
||||
<div className="m-root m-shell flex min-h-svh flex-col text-m-ink" data-fold={fold ? 'vertical' : undefined} style={foldStyle}>
|
||||
{/* Background and screen gradient live on their own viewport-sized layer.
|
||||
The shell root is as tall as the document now, and --m-scr is a radial
|
||||
gradient measured against its element box, so on it the light cone would
|
||||
|
||||
Reference in New Issue
Block a user