// // FindBarView.swift // Zyquo Atlas // // Author: Simon-Pierre Boucher // Mail: contact@spboucher.ai // // Find-in-page bar (⌘F): a compact field over the toolbar that drives the // tab's native WKWebView find (next/previous, wrap, case-insensitive). // import SwiftUI struct FindBarView: View { @ObservedObject var tab: Tab let onClose: () -> Void @EnvironmentObject private var themeEngine: ThemeEngine private var theme: AtlasTheme { themeEngine.theme } @State private var query = "" @State private var noMatch = false @FocusState private var focused: Bool var body: some View { HStack(spacing: ZyquoSpacing.xs) { Image(systemName: "magnifyingglass") .font(.system(size: 11)).foregroundStyle(theme.textTertiary) TextField("Find on page", text: $query) .textFieldStyle(.plain) .font(ZyquoFont.control) .foregroundStyle(noMatch ? theme.danger : theme.textPrimary) .focused($focused) .onSubmit { find(forward: true) } .onChange(of: query) { _ in find(forward: true) } Button { find(forward: false) } label: { Image(systemName: "chevron.up") } .buttonStyle(.plain).foregroundStyle(theme.textSecondary) Button { find(forward: true) } label: { Image(systemName: "chevron.down") } .buttonStyle(.plain).foregroundStyle(theme.textSecondary) Button { tab.clearFind(); onClose() } label: { Image(systemName: "xmark") } .buttonStyle(.plain).foregroundStyle(theme.textTertiary) } .font(.system(size: 12)) .padding(.horizontal, ZyquoSpacing.sm) .frame(height: 34) .background(theme.surface) .overlay(alignment: .bottom) { Rectangle().fill(theme.border).frame(height: ZyquoMetrics.hairline) } .onAppear { focused = true } } private func find(forward: Bool) { tab.find(query, forward: forward) { found in noMatch = !found && !query.isEmpty } } }