Files
Pulse/Sources/PulseUI/Views/RichTextView/RichTextViewSearchToobar-macos.swift
T
Alex Grebenyuk 245898eff7 Squash
2023-04-09 08:34:41 -04:00

51 lines
1.6 KiB
Swift
Raw 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.
This file contains Unicode characters that might be confused with other characters. 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) 20202023 Alexander Grebenyuk (github.com/kean).
#if os(macOS)
import SwiftUI
struct RichTextViewSearchToobar: View {
@ObservedObject var viewModel: RichTextViewModel
var body: some View {
HStack {
if !viewModel.matches.isEmpty {
HStack(spacing: 8) {
Button(action: viewModel.previousMatch) {
Image(systemName: "chevron.left.circle")
}
.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")
}
.buttonStyle(.plain)
.disabled(viewModel.matches.isEmpty)
}
.padding(.leading, 3)
}
Spacer()
if viewModel.isFilterEnabled {
SearchBar(title: "Filter", imageName: "line.3.horizontal.decrease.circle", text: $viewModel.filterTerm).frame(maxWidth: 130)
}
SearchBar(title: "Search", text: $viewModel.searchTerm).frame(maxWidth: 130)
StringSearchOptionsMenu(options: $viewModel.searchOptions, isKindNeeded: false)
.fixedSize()
}
.padding(6)
}
}
#endif