Files
Pulse/Sources/PulseUI/Features/FileViewer/RichTextView/RichTextViewSearchToobar-macos.swift
2024-07-14 13:40:50 -04:00

51 lines
1.6 KiB
Swift
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The MIT License (MIT)
//
// Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean).
#if os(macOS)
import SwiftUI
struct RichTextViewSearchToobar: View {
@ObservedObject var viewModel: RichTextViewModel
var isSearchOptionsHidden = false
var body: some View {
HStack {
if !viewModel.matches.isEmpty {
HStack(spacing: 8) {
Button(action: viewModel.previousMatch) {
Image(systemName: "chevron.left.circle")
.foregroundColor(.secondary)
}
.buttonStyle(.plain)
.disabled(viewModel.matches.isEmpty)
Text(viewModel.matches.isEmpty ? "0/0" : "\(viewModel.selectedMatchIndex+1)/\(viewModel.matches.count)")
.font(Font.body.monospacedDigit())
.foregroundColor(.secondary)
Button(action: viewModel.nextMatch) {
Image(systemName: "chevron.right.circle")
.foregroundColor(.secondary)
}
.buttonStyle(.plain)
.disabled(viewModel.matches.isEmpty)
}
.padding(.leading, 3)
}
Spacer()
SearchBar(title: "Search", text: $viewModel.searchTerm).frame(maxWidth: 130)
StringSearchOptionsMenu(options: $viewModel.searchOptions, isKindNeeded: false)
.fixedSize()
}
.padding(6)
}
}
#endif