// `/search` — the pill on top, the answer underneath, on the paper ground.//// The answer itself is `SearchResults` (`Screens/Search/SearchResults.swift`),// which Home draws too, under its own title (design 2026-09-13 §4.4). This// screen is what is LEFT once the answer is shared: the page ground and the// pill at the top, where the redesign's picture 29 puts it. Everything about// what a search shows — recents at rest, grouped hits as you type, a place// swapping and a record pushing — lives in the shared view and `SearchModel`,// so the page and Home cannot drift.//// Taps persist and a drag dismisses the keyboard — that is// `.scrollDismissesKeyboard(.immediately)` on the results, where the scroller// is.importCottonKitimportSwiftUIpublicstructSearchScreen: View {privatelet model: SearchModel/// The pill's close. On this screen the search IS the screen, so leaving/// is the only thing close can mean. @Environment(\.dismiss) privatevar dismiss @Environment(\.theme) privatevar theme/// The gallery draws a specimen that must not raise a keyboard nobody asked/// for — the same argument `SearchPill` already takes.privatelet takesFocus: Bool @FocusState privatevar isFocused: Boolpublicinit( model: SearchModel, takesFocus: Bool = true ) {self.model = modelself.takesFocus = takesFocus }privatevar field: Binding<String> {Binding(get: { model.query }, set: { model.type($0) }) }publicvar body: someView { ZStack(alignment: .top) {PageGroundFill().ignoresSafeArea() VStack(spacing: 0) {// THE app search field, on top: it focuses itself on appear,// so the page opens asking. HStack(spacing: 10) {SearchField(text: field, placeholder: SearchWords.scope, isFocused: $isFocused) .accessibilityIdentifier("cap-search")Button {SearchGrammar.close(clear: { model.type("") }, then: { dismiss() }) } label: {Text(ShellLines.line("search", "close")) .font(CottonFonts.type(theme.scale.titleSize)) .underline() .foregroundStyle(CottonColors.ink) .padding(.vertical, 12) } .buttonStyle(.plain) .accessibilityIdentifier("cap-search-close") } .padding(.horizontal, ChromeKnobs.chromeSettingsMargin) .padding(.top, 6) .accessibilityElement(children: .contain) .accessibilityIdentifier("search-pill-row")// An empty field is the page at rest — the searches made// before, else the one line saying what a search reaches// (`SearchResults`). Never a list of every table: a table is// found by typing its name, which answers it as a place.SearchResults(model: model) .padding(.top, 10) } } .cottonPageGround(.groundMuted) .cottonPageTexture(.plaster) .accessibilityElement(children: .contain) .accessibilityIdentifier("global-search") .onAppear { if takesFocus { isFocused = true } } }}