// THE SHORT-TEXT INPUT (owner, 28 Oct 2026): the one way the shell writes a// text column — a title, a line — of every kind, and a new record's title.// One line of text rising with the keyboard over the dimmed deck, drawn as// the shell's one-line input is (`SearchField`: the paper-coloured capsule,// its hairline inking while it has the keyboard, the typed words in ink). No// sheet, and the card under it is not drawn again. Return commits — the// column written, or the record made; a tap on the dim dismisses, and// nothing is written.importCottonKitimportCottonPaperimportCottonVoiceimportSwiftUIenumDeckLineInputKnobs {/// Its gap over the keyboard and from the screen's sides.staticlet rise: CGFloat = 12staticlet side: CGFloat = 16}structDeckLineInput: View {let writing: DeckWritinglet commit: (String) -> Voidlet dismiss: () -> Void @Environment(\.theme) privatevar theme @Environment(\.cottonCore) privatevar core @State privatevar draft = "" @State privatevar selection: TextSelection? @State privatevar dictation: VoiceField? @FocusState privatevar focused: Boolvar body: someView { ZStack(alignment: .bottom) { theme.colors.shadow.color.opacity(Double(theme.scale[.pageDim])) .ignoresSafeArea() .contentShape(Rectangle()) .onTapGesture { dismiss() } .accessibilityLabel(Text(CottonStrings.cancel)) .accessibilityAddTraits(.isButton) .accessibilityIdentifier("deck-line-dim") VStack(spacing: 6) {// The words as they stand while dictating, the tentative ones// lighter, over the capsule.iflet dictation, dictation.isActive || !dictation.session.offers.isEmpty || dictation.session.isFailed {VoiceStrip(session: dictation.session, showsWords: true) .padding(.vertical, 8) .background(Capsule().fill(SearchGrammar.fill)) .padding(.horizontal, DeckLineInputKnobs.side) } HStack(spacing: 0) {TextField("", text: $draft, selection: $selection, prompt: writing.hint.map { Text($0).foregroundStyle(CottonColors.inkTertiary) }) .font(CottonFonts.type(theme.scale.titleSize)) .foregroundStyle(CottonColors.ink) .tint(theme.print(.red)) .submitLabel(.done) .phoneKeyboard(writing.keyboard == "phone", figures: writing.editor == .amount) .focused($focused) .onSubmit { submit() } .cottonPaperField() .accessibilityIdentifier("deck-line-input") .onChange(of: draft) { _, now in dictation?.fieldChanged(now) }iflet dictation {// The mic at the trailing end of the capsule on the keyboard.VoiceFieldBar( field: dictation, identifier: "deck-line-mic", showsStrip: false, request: { writing.voicePlan(surface: "deck") }, text: { draft }, selection: { draft.utf16Range(selection) }, write: { draft = $0 }) .fixedSize() } } .padding(.horizontal, DeckLineInputKnobs.side) .frame(height: SearchPillKnobs.chromeFooterSearchHeight) .frame(maxWidth: .infinity) .background(Capsule().fill(SearchGrammar.fill)) .cottonInkFocusRing(focused, in: Capsule()) .softShadow() .padding(.horizontal, DeckLineInputKnobs.side) .padding(.bottom, DeckLineInputKnobs.rise) } } .onAppear { draft = writing.words focused = trueif dictation == nil, let core { dictation = VoiceField(session: VoiceSessions.make(core: core), inlineTentative: false) } } .onDisappear { dictation?.session.cancel() } }/// Return while dictating keeps what was heard, then commits.privatefunc submit() {guardlet dictation, dictation.isActive else { return commit(draft) }Task { draft = await dictation.stop() commit(draft) } }}privateextensionView {/// A number's keyboard (Send's Add a person): digits, + and a return/// key to commit on, which the phone pad lacks; the system offers/// numbers it knows./// An amount's figures take the same keyboard, offered no numbers. @ViewBuilder func phoneKeyboard(_ phone: Bool, figures: Bool = false) -> someView { #if os(iOS)if figures { keyboardType(.numbersAndPunctuation) .autocorrectionDisabled() .textInputAutocapitalization(.never) } elseif phone { keyboardType(.numbersAndPunctuation) .textContentType(.telephoneNumber) .autocorrectionDisabled() .textInputAutocapitalization(.never) } else {self } #elseself #endif }}