SPB Git

spb/zyquo-atlas Public License

The AI-native macOS web browser — every surface, intelligent.

Swift 75.2% JavaScript 22% Shell 2% Makefile 0.9%
2.1 KB · 56 lines swift
Raw Blame History
1//2//  FindBarView.swift3//  Zyquo Atlas4//5//  Author: Simon-Pierre Boucher6//  Mail: contact@spboucher.ai7//8//  Find-in-page bar (⌘F): a compact field over the toolbar that drives the9//  tab's native WKWebView find (next/previous, wrap, case-insensitive).10//1112import SwiftUI1314struct FindBarView: View {15    @ObservedObject var tab: Tab16    let onClose: () -> Void17    @EnvironmentObject private var themeEngine: ThemeEngine18    private var theme: AtlasTheme { themeEngine.theme }1920    @State private var query = ""21    @State private var noMatch = false22    @FocusState private var focused: Bool2324    var body: some View {25        HStack(spacing: ZyquoSpacing.xs) {26            Image(systemName: "magnifyingglass")27                .font(.system(size: 11)).foregroundStyle(theme.textTertiary)28            TextField("Find on page", text: $query)29                .textFieldStyle(.plain)30                .font(ZyquoFont.control)31                .foregroundStyle(noMatch ? theme.danger : theme.textPrimary)32                .focused($focused)33                .onSubmit { find(forward: true) }34                .onChange(of: query) { _ in find(forward: true) }35            Button { find(forward: false) } label: { Image(systemName: "chevron.up") }36                .buttonStyle(.plain).foregroundStyle(theme.textSecondary)37            Button { find(forward: true) } label: { Image(systemName: "chevron.down") }38                .buttonStyle(.plain).foregroundStyle(theme.textSecondary)39            Button { tab.clearFind(); onClose() } label: { Image(systemName: "xmark") }40                .buttonStyle(.plain).foregroundStyle(theme.textTertiary)41        }42        .font(.system(size: 12))43        .padding(.horizontal, ZyquoSpacing.sm)44        .frame(height: 34)45        .background(theme.surface)46        .overlay(alignment: .bottom) {47            Rectangle().fill(theme.border).frame(height: ZyquoMetrics.hairline)48        }49        .onAppear { focused = true }50    }5152    private func find(forward: Bool) {53        tab.find(query, forward: forward) { found in noMatch = !found && !query.isEmpty }54    }55}56