feat(ios): comprehensive iPhone+iPad UX polish — refined-native design system

Freeze a shared design system (DesignSystem/{Tokens,Typography,StatusStyle,
Primitives}.swift): indigo #7C8CFF accent (root .tint), semantic status colors,
2-4-8-12-16-20-24 spacing + sm8/md12/lg16 radii scale, SF Mono tabular numbers,
reduce-motion-gated animations, haptics, reusable StatusBadge/TelemetryChip/Card/
SectionHeader/DSButtonStyle/ContinueLastBanner. Every changed view consumes tokens
— no hardcoded colors/spacing.

Applied across all surfaces (visual only — zero behavior/logic change, all suites
green): session list rows + status system (shape+color, not color-alone) +
telemetry chips + thumbnail placeholders; terminal gate card (≥44pt approve/reject)
+ keybar + reconnect + quick-reply + digest + SwiftTerm accent theme; pairing hero
+ warning tiers + Projects cards + Timeline/Diff; nav chrome + iPad split placeholder
+ privacy shade + motion. Chinese gate copy. UX finding fixed: timeline class colors
now via DS.Palette (+timelineTool/timelineUser tokens).

Design review 8.5/10. Verified: iPhone 16 290 + iPad Pro 11 290 tests green;
packages + integration green; consistency audit ~clean; zero changes under
ios/Packages, src/, public/.
This commit is contained in:
Yaojia Wang
2026-07-05 22:00:31 +02:00
parent 823432b1c8
commit 660a40491a
25 changed files with 1742 additions and 650 deletions

View File

@@ -20,6 +20,14 @@ enum PrivacyShadePolicy {
/// Opaque cover rendered ABOVE the whole navigation tree (RootView ZStack)
/// deliberately no animation: the snapshot moment must never race a fade.
///
/// Security invariant (do NOT weaken): the FULL-SCREEN base is `DS.Palette.surface`
/// (`.systemBackground`, fully OPAQUE) + `.ignoresSafeArea()`, so no terminal
/// byte can leak into the on-disk switcher snapshot. The branded lockup is a
/// `.regularMaterial` card layered ON TOP of that opaque base (never over the
/// terminal), so the material's translucency is purely decorative it blurs
/// the opaque surface below it, not the PTY content. Accent lock + app name +
/// hint give the shade a refined-native identity instead of a flat cover.
///
/// Scope note (documented): sheets present in a separate presentation layer a
/// root overlay cannot cover but no terminal bytes are ever rendered in a
/// sheet (pairing / plan-gate only), so the root-level shade covers every
@@ -27,21 +35,36 @@ enum PrivacyShadePolicy {
struct PrivacyShadeView: View {
var body: some View {
ZStack {
Color(.systemBackground)
// OPAQUE full-screen occlusion the security base. Must stay opaque
// and edge-to-edge; the material card below only decorates it.
DS.Palette.surface
.ignoresSafeArea()
VStack(spacing: ShadeMetrics.spacing) {
Image(systemName: "terminal.fill")
.font(.largeTitle)
.foregroundStyle(.secondary)
Text("WebTerm")
.font(.headline)
.foregroundStyle(.secondary)
VStack(spacing: DS.Space.md12) {
Image(systemName: "lock.fill")
.font(DS.Typography.largeTitle)
.foregroundStyle(DS.Palette.accent)
Text(ShadeCopy.appName)
.font(DS.Typography.headline)
.foregroundStyle(DS.Palette.textPrimary)
Text(ShadeCopy.hint)
.font(DS.Typography.caption)
.foregroundStyle(DS.Palette.textSecondary)
}
.padding(.horizontal, DS.Space.xxl24)
.padding(.vertical, DS.Space.xl20)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: DS.Radius.lg16))
.overlay(
RoundedRectangle(cornerRadius: DS.Radius.lg16)
.strokeBorder(DS.Palette.hairline, lineWidth: DS.Stroke.hairline)
)
}
.accessibilityHidden(true)
}
private enum ShadeMetrics {
static let spacing: CGFloat = 12
}
}
/// Chinese, named constants
private enum ShadeCopy {
static let appName = "WebTerm"
static let hint = "内容已隐藏"
}

View File

@@ -5,19 +5,25 @@ import SwiftUI
/// + sheets/scenePhase/deepLink 线iPad T-iPad-2
///
/// - `RootView` struct `@main` WebTermApp
/// `RootView(coordinator:)` `AdaptiveRootView`
/// `RootView(coordinator:)` `AdaptiveRootView`
/// accent tint`DS.Palette.accent`DS
/// App //`.borderedProminent`
/// - `AdaptiveRootView` `horizontalSizeClass` `StackRootView`compact
/// `SplitRootView`regulariPad
/// / scenePhase / deepLink / sheets **线**
/// ZStack
///
/// `StackRootView` `RootView` body **** compact
/// iPhone
/// iPhone
/// `DS.*` token //
struct RootView: View {
@Bindable var coordinator: AppCoordinator
var body: some View {
AdaptiveRootView(coordinator: coordinator)
// DS tint Tokens.swift
// gate amber orange `.tint`
.tint(DS.Palette.accent)
}
}
@@ -26,6 +32,7 @@ struct RootView: View {
/// /scenePhase/deepLink/sheets `AdaptiveRootView`
struct StackRootView: View {
@Bindable var coordinator: AppCoordinator
@Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View {
NavigationStack {
@@ -66,38 +73,23 @@ struct StackRootView: View {
onAddHost: { coordinator.presentAddHost() }
)
.safeAreaInset(edge: .bottom) { continueLastBanner }
// / DS reduceMotion
.animation(
DS.Motion.gated(DS.Motion.base, reduceMotion: reduceMotion),
value: coordinator.continueLastSessionId
)
// T-iOS-26 · Projects RootView SessionListScreen
// T-iOS-23 W7 leading
// topBarTrailing hostMenu
.toolbar { projectsToolbarItem }
}
@ToolbarContentBuilder private var projectsToolbarItem: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) {
Button {
coordinator.presentProjects()
} label: {
Label(RootCopy.projects, systemImage: "folder")
}
.disabled(coordinator.sessionList.activeHost == nil)
.accessibilityIdentifier("sessions.projectsButton")
}
.toolbar { ProjectsToolbarItem(coordinator: coordinator) }
}
// MARK: - "" highlight (cold start step 5)
@ViewBuilder private var continueLastBanner: some View {
if coordinator.continueLastSessionId != nil {
Button {
coordinator.openContinueLast()
} label: {
Label(RootCopy.continueLast, systemImage: "arrow.uturn.forward.circle.fill")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.padding(.horizontal, RootMetrics.bannerHorizontalPadding)
.padding(.vertical, RootMetrics.bannerVerticalPadding)
.background(.thinMaterial)
ContinueLastBanner { coordinator.openContinueLast() }
.transition(.move(edge: .bottom).combined(with: .opacity))
}
}
@@ -131,12 +123,54 @@ struct StackRootView: View {
}
}
enum RootMetrics {
static let bannerHorizontalPadding: CGFloat = 16
static let bannerVerticalPadding: CGFloat = 8
// MARK: - Continue-last banner (shared stack + split, DRY)
/// 5 CTA stack split sidebar
/// DRY`.regularMaterial` + +
/// accent `DSButtonStyle(.primary)`
/// `action`= `coordinator.openContinueLast()`
struct ContinueLastBanner: View {
let action: () -> Void
var body: some View {
Button(action: action) {
Label(RootCopy.continueLast, systemImage: "arrow.uturn.forward.circle.fill")
}
.buttonStyle(DSButtonStyle(kind: .primary))
.accessibilityIdentifier("root.continueLastButton")
.padding(.horizontal, DS.Space.lg16)
.padding(.top, DS.Space.md12)
.padding(.bottom, DS.Space.sm8)
.background(.regularMaterial)
.overlay(alignment: .top) {
Rectangle()
.fill(DS.Palette.hairline)
.frame(height: DS.Stroke.hairline)
}
}
}
/// internal `SplitRootView` DRY
// MARK: - Projects toolbar item (shared stack + split, DRY)
/// leading stack split disabled
/// `presentProjects` a11y id tint label accent
struct ProjectsToolbarItem: ToolbarContent {
@Bindable var coordinator: AppCoordinator
var body: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) {
Button {
coordinator.presentProjects()
} label: {
Label(RootCopy.projects, systemImage: "folder")
}
.disabled(coordinator.sessionList.activeHost == nil)
.accessibilityIdentifier("sessions.projectsButton")
}
}
}
/// internal `SplitRootView` /DRY
enum RootCopy {
static let continueLast = "继续上次会话"
static let projects = "项目"

View File

@@ -10,12 +10,17 @@ import SwiftUI
/// split detail PLAN_IOS_IPAD §1
/// - ** `AppCoordinator` **sidebar
/// `selectSidebarItem` / `open` stack
/// `coordinator.sidebarSelection` highlight sidebar List
/// `selection:``SessionListScreen` List Owns
/// - **detail `.id(controller.id)`** controller
/// SwiftTerm ring bufferidentity T-iOS-29
/// - **** `AdaptiveRootView` ZStack
/// detail `scenePhase != .active`
/// - ****// `DS.*` token Primitive
/// stack
struct SplitRootView: View {
@Bindable var coordinator: AppCoordinator
@Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View {
NavigationSplitView {
@@ -37,23 +42,19 @@ struct SplitRootView: View {
onAddHost: { coordinator.presentAddHost() }
)
.safeAreaInset(edge: .bottom) { continueLastBanner }
.toolbar { projectsToolbarItem }
.animation(
DS.Motion.gated(DS.Motion.base, reduceMotion: reduceMotion),
value: coordinator.continueLastSessionId
)
.toolbar { ProjectsToolbarItem(coordinator: coordinator) }
}
/// `StackRootView.continueLastBanner` 5
/// sidebar iPad T-iPad-5 finding
/// stack 5
/// `ContinueLastBanner`iPad T-iPad-5 finding
@ViewBuilder private var continueLastBanner: some View {
if coordinator.continueLastSessionId != nil {
Button {
coordinator.openContinueLast()
} label: {
Label(RootCopy.continueLast, systemImage: "arrow.uturn.forward.circle.fill")
.frame(maxWidth: .infinity)
}
.buttonStyle(.borderedProminent)
.padding(.horizontal, RootMetrics.bannerHorizontalPadding)
.padding(.vertical, RootMetrics.bannerVerticalPadding)
.background(.thinMaterial)
ContinueLastBanner { coordinator.openContinueLast() }
.transition(.move(edge: .bottom).combined(with: .opacity))
}
}
@@ -62,21 +63,6 @@ struct SplitRootView: View {
request.sessionId.map(SidebarItem.session) ?? .newSession
}
/// `StackRootView.projectsToolbarItem` leading disabled
/// `presentProjects` iPad Projects sheet
/// T-iPad-4
@ToolbarContentBuilder private var projectsToolbarItem: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) {
Button {
coordinator.presentProjects()
} label: {
Label(RootCopy.projects, systemImage: "folder")
}
.disabled(coordinator.sessionList.activeHost == nil)
.accessibilityIdentifier("sessions.projectsButton")
}
}
// MARK: - Detail
@ViewBuilder private var detail: some View {
@@ -91,19 +77,27 @@ struct SplitRootView: View {
}
} else {
placeholder
.transition(.opacity)
}
}
/// detail accent + DS ContentUnavailableView
/// + + accent App
private var placeholder: some View {
ContentUnavailableView {
Label(SplitCopy.placeholderTitle, systemImage: "sidebar.left")
Label {
Text(SplitCopy.placeholderTitle)
} icon: {
Image(systemName: "terminal")
.foregroundStyle(DS.Palette.accent)
}
} description: {
Text(SplitCopy.placeholderHint)
}
}
}
/// split `RootCopy.projects`DRY
/// split / `RootCopy`DRY
private enum SplitCopy {
static let placeholderTitle = "选择或新建会话"
static let placeholderHint = "从左侧选择一个运行中的会话,或新建一个开始工作。"

View File

@@ -35,18 +35,20 @@ struct TerminalContainerView: View {
/// T-iOS-25 (additive) · Quick-reply palette store per-container over
/// `.standard` defaults (non-secret UI prefs, plan §5.3 split).
@State private var quickReplyStore = QuickReplyStore()
/// overlay DS.Motion.gated
@Environment(\.accessibilityReduceMotion) private var reduceMotion
private enum Metrics {
static let overlaySpacing: CGFloat = 8
static let overlayHorizontalPadding: CGFloat = 12
/// Clears TerminalScreen's own top-aligned ReconnectBanner zone.
static let overlayTopPadding: CGFloat = 52
/// Breathing room between the chip row and the keyboard/key-bar edge.
static let quickReplyBottomPadding: CGFloat = 8
/// Clears TerminalScreen's own top-aligned ReconnectBanner zone: a
/// hit-target-tall pill plus a gap. (They rarely co-exist the banner
/// hides on `.connected` while gates/digests only arrive connected.)
static let overlayTopPadding: CGFloat = DS.Layout.minHitTarget + DS.Space.sm8
}
private enum Copy {
static let planGatePending = "⚠ 计划待批准"
/// The re-entry chip's own amber StatusBadge carries the "needs me"
/// warning shape, so the copy itself stays plain (no emoji).
static let planGatePending = "计划待批准"
}
var body: some View {
@@ -75,16 +77,19 @@ struct TerminalContainerView: View {
gateViewModel: controller.gateViewModel,
store: quickReplyStore
)
.padding(.horizontal, Metrics.overlayHorizontalPadding)
.padding(.bottom, Metrics.quickReplyBottomPadding)
.animation(.default, value: controller.gateViewModel.currentGate)
.padding(.horizontal, DS.Space.md12)
.padding(.bottom, DS.Space.sm8)
.animation(
DS.Motion.gated(DS.Motion.base, reduceMotion: reduceMotion),
value: controller.gateViewModel.currentGate
)
}
// MARK: - Digest + tool gate (top stack)
@ViewBuilder private var topOverlays: some View {
let gateViewModel = controller.gateViewModel
VStack(spacing: Metrics.overlaySpacing) {
VStack(spacing: DS.Space.sm8) {
if let digest = gateViewModel.digest {
AwayDigestView(
digest: digest,
@@ -99,16 +104,38 @@ struct TerminalContainerView: View {
}
}
if hasDismissedPendingPlanGate {
Button(Copy.planGatePending) { dismissedPlanGateEpoch = nil }
.buttonStyle(.borderedProminent)
.tint(.orange)
.controlSize(.small)
planGatePendingChip
}
}
.padding(.horizontal, Metrics.overlayHorizontalPadding)
.padding(.horizontal, DS.Space.md12)
.padding(.top, Metrics.overlayTopPadding)
.animation(.default, value: gateViewModel.toolGate)
.animation(.default, value: gateViewModel.digest)
.animation(DS.Motion.gated(DS.Motion.base, reduceMotion: reduceMotion),
value: gateViewModel.toolGate)
.animation(DS.Motion.gated(DS.Motion.base, reduceMotion: reduceMotion),
value: gateViewModel.digest)
}
/// The "plan still pending" re-entry chip shown after the user swiped the
/// plan sheet away an amber pending-approval pill that re-presents the
/// sheet on tap.
private var planGatePendingChip: some View {
Button {
dismissedPlanGateEpoch = nil
} label: {
HStack(spacing: DS.Space.xs4) {
StatusBadge(status: .pendingApproval)
Text(Copy.planGatePending)
.font(DS.Typography.callout.weight(.medium))
.foregroundStyle(DS.Palette.textPrimary)
}
.padding(.horizontal, DS.Space.md12)
.frame(minHeight: DS.Layout.minHitTarget)
.background(.regularMaterial, in: Capsule())
.overlay(
Capsule().strokeBorder(DS.Palette.statusWaiting, lineWidth: DS.Stroke.hairline)
)
}
.buttonStyle(.plain)
}
// MARK: - Timeline drill-down (T-iOS-24, additive)