mirror of
https://github.com/kean/Pulse.git
synced 2026-05-30 21:07:33 +00:00
51 lines
1.6 KiB
Swift
51 lines
1.6 KiB
Swift
// 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
|