mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* feat(mobile): give every corner one of three shapes Corners had drifted to 17 different radii, so a screen mixed 6 pt buttons, 14 pt cards, 12 pt groups and 4 pt badges. Every corner now comes from the shape of what it is: - control (12): anything you tap — buttons, icon buttons, fields, pickers, segmented controls, key caps. - surface (16): anything that holds content — cards, groups, sheets, banners, code boxes. Dialogs and the composer box use floating (24). - pill: badges, chips, status pills, dots, avatars and the composer's own round buttons. - tile (10) for icon squares and mark (4) for inline code and check squares; nested shapes take the parent's radius minus the gap. Every rounded style also asks for the continuous (squircle) corner curve; iOS draws it, Android and the web ignore it. * fix(mobile): keep circles and pills on the circular corner curve The continuous curve squares off a corner radius that reaches half the element's size, so the FAB, dots, avatars and the composer's round buttons stopped being round on iOS. * fix(mobile): put the anchored detail card on the surface radius * fix(mobile): keep the circular curve on unclipped bordered styles React Native strokes an unclipped visible border on a circular path while it fills the background with the continuous curve, so the two edges drifted apart at the corners.
178 lines
5.4 KiB
TypeScript
178 lines
5.4 KiB
TypeScript
import type { ReactNode } from 'react'
|
|
import { Pressable, Text, View } from 'react-native'
|
|
import { ProtocolBlockScreen } from '../components/ProtocolBlockScreen'
|
|
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
|
|
import { themedStyleSheet } from '../theme/themed-styles'
|
|
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
|
|
import type { Translate } from '../i18n/mobile-i18n'
|
|
import { useMobileTranslation } from '../i18n/use-mobile-translation'
|
|
import type { HostDisplaySource } from '../transport/use-host-display'
|
|
import type { DownloadProgressFeed } from './download-progress-feed'
|
|
import type {
|
|
MobileWebShellFailureCause,
|
|
MobileWebShellSessionState
|
|
} from './mobile-web-shell-session-contract'
|
|
import { PageRouteUnavailableScreen } from './PageRouteUnavailableScreen'
|
|
import { ShellDownloadProgress } from './ShellDownloadProgress'
|
|
import { ShellWaitingFrame } from './ShellWaitingFrame'
|
|
|
|
function failureMessage(reason: MobileWebShellFailureCause, t: Translate): string {
|
|
switch (reason) {
|
|
case 'isolation-unavailable':
|
|
return t(
|
|
'webShell.shellStateScreen.isolationUnavailable',
|
|
"This device's WebView is too old to open the workspace safely."
|
|
)
|
|
case 'download-failed':
|
|
return t(
|
|
'webShell.shellStateScreen.downloadFailed',
|
|
'The latest app could not be downloaded from this host.'
|
|
)
|
|
case 'host-profile-unreadable':
|
|
return t(
|
|
'webShell.shellStateScreen.hostProfileUnreadable',
|
|
'Could not read this host on your device. Try again.'
|
|
)
|
|
case 'status-unreadable':
|
|
return t(
|
|
'webShell.shellStateScreen.statusUnreadable',
|
|
"Could not read this host's status. Go back and reopen it."
|
|
)
|
|
case 'render-process-gone':
|
|
return t('webShell.shellStateScreen.renderProcessGone', 'The workspace stopped responding.')
|
|
case 'generation-unreadable':
|
|
case 'document-load-failed':
|
|
return t(
|
|
'webShell.shellStateScreen.documentLoadFailed',
|
|
'The downloaded app could not be opened.'
|
|
)
|
|
}
|
|
}
|
|
|
|
function Centered({ children }: { children: ReactNode }) {
|
|
useMobileColorScheme()
|
|
return <View style={styles.centered}>{children}</View>
|
|
}
|
|
|
|
function Failed({
|
|
state,
|
|
onRetry
|
|
}: {
|
|
state: Extract<MobileWebShellSessionState, { kind: 'failed' }>
|
|
onRetry: () => void
|
|
}) {
|
|
const t = useMobileTranslation()
|
|
useMobileColorScheme()
|
|
// Retry cannot change a settled isolation gate or give an unsupported WebView the missing fence.
|
|
const retryable = state.reason !== 'isolation-unavailable' && state.reason !== 'status-unreadable'
|
|
return (
|
|
<Centered>
|
|
<Text style={styles.failedMessage} testID="mobile-web-shell-failed">
|
|
{failureMessage(state.reason, t)}
|
|
</Text>
|
|
{retryable ? (
|
|
<Pressable
|
|
style={({ pressed }) => [styles.retryButton, pressed && styles.pressed]}
|
|
testID="mobile-web-shell-retry"
|
|
onPress={onRetry}
|
|
>
|
|
<Text style={styles.retryLabel}>
|
|
{t('webShell.shellStateScreen.tryAgain', 'Try again')}
|
|
</Text>
|
|
</Pressable>
|
|
) : null}
|
|
</Centered>
|
|
)
|
|
}
|
|
|
|
// What the shell shows natively until its page is ready.
|
|
export function ShellStateScreen({
|
|
hostId,
|
|
state,
|
|
onRetry,
|
|
downloadProgress,
|
|
host
|
|
}: {
|
|
hostId: string
|
|
state: Exclude<MobileWebShellSessionState, { kind: 'ready' }>
|
|
onRetry: () => void
|
|
downloadProgress: DownloadProgressFeed
|
|
host: HostDisplaySource | null
|
|
}) {
|
|
const t = useMobileTranslation()
|
|
switch (state.kind) {
|
|
case 'route-unavailable':
|
|
return <PageRouteUnavailableScreen hostId={hostId} />
|
|
case 'wall':
|
|
return <ProtocolBlockScreen verdict={state.verdict} />
|
|
case 'failed':
|
|
return <Failed state={state} onRetry={onRetry} />
|
|
case 'offline':
|
|
return (
|
|
<Centered>
|
|
<Text style={styles.waitingLabel} testID="mobile-web-shell-offline">
|
|
{t(
|
|
'webShell.shellStateScreen.connectToDownload',
|
|
'Connect to this host to download the latest app'
|
|
)}
|
|
</Text>
|
|
</Centered>
|
|
)
|
|
case 'fetching':
|
|
return (
|
|
<Centered>
|
|
<ShellDownloadProgress state={state} feed={downloadProgress} host={host} />
|
|
</Centered>
|
|
)
|
|
case 'checking':
|
|
case 'activating':
|
|
return (
|
|
<Centered>
|
|
<ShellWaitingFrame
|
|
label={
|
|
state.kind === 'activating'
|
|
? t('webShell.shellStateScreen.openingWorkspace', 'Opening workspace')
|
|
: t('webShell.shellStateScreen.checkingHost', 'Checking host')
|
|
}
|
|
/>
|
|
</Centered>
|
|
)
|
|
}
|
|
}
|
|
|
|
const styles = themedStyleSheet(() => ({
|
|
centered: {
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
backgroundColor: colors.bgBase,
|
|
paddingHorizontal: spacing.lg
|
|
},
|
|
waitingLabel: {
|
|
fontSize: typography.bodySize,
|
|
color: colors.textSecondary,
|
|
marginTop: spacing.md,
|
|
textAlign: 'center'
|
|
},
|
|
failedMessage: {
|
|
fontSize: typography.bodySize,
|
|
color: colors.textPrimary,
|
|
textAlign: 'center',
|
|
marginBottom: spacing.lg
|
|
},
|
|
retryButton: {
|
|
backgroundColor: colors.bgRaised,
|
|
paddingVertical: spacing.sm + 2,
|
|
paddingHorizontal: spacing.lg,
|
|
borderRadius: radii.control
|
|
},
|
|
retryLabel: {
|
|
fontSize: typography.bodySize,
|
|
fontWeight: '600',
|
|
color: colors.textPrimary
|
|
},
|
|
pressed: {
|
|
opacity: 0.7
|
|
}
|
|
}))
|