Files
OSGKeyboard/OSGKeyboardExt/Typing/KeyboardSurfaceRoot.swift
T
Rocky d1e5fed964 chore(typing): snapshot local pinyin WIP before syncing cloud branch
Preserve the in-progress local typing/pinyin implementation so feat/pinyin
can safely reset to origin/feat/pinyin (cloud English + Chinese typing).
2026-08-03 13:14:01 +08:00

52 lines
1.5 KiB
Swift

// KeyboardSurfaceRoot.swift
// OSGKeyboard · Keyboard Extension
//
// Switches between voice and typing surfaces driven by KeyboardState.surface.
import SwiftUI
import OSGKeyboardShared
struct KeyboardSurfaceRoot: View {
@ObservedObject var state: KeyboardState
@ObservedObject var typing: TypingSessionController
var onInsert: (String) -> Void
var onDeleteBackward: () -> Void
static var voiceHeight: CGFloat { KeyboardRootView.totalHeight }
static var typingHeight: CGFloat { TypingRootView.totalHeight }
static func height(for surface: KeyboardState.Surface) -> CGFloat {
switch surface {
case .voice: return voiceHeight
case .typing: return typingHeight
}
}
var body: some View {
Group {
switch state.surface {
case .voice:
KeyboardRootView(
state: state,
typing: typing,
onInsert: onInsert
)
case .typing:
TypingRootView(
state: state,
typing: typing,
onInsert: onInsert,
onDeleteBackward: onDeleteBackward
)
}
}
.animation(.easeInOut(duration: 0.15), value: state.surface)
.onChange(of: state.surface) { _, newSurface in
if newSurface == .voice {
typing.leaveTypingMode()
}
}
}
}