Skip to content

Commit 4efb3e5

Browse files
committed
Wrote documentation for find subviews.
1 parent 5875e40 commit 4efb3e5

File tree

8 files changed

+91
-1
lines changed

8 files changed

+91
-1
lines changed

Sources/CodeEditSourceEditor/Find/PanelView/FindControls.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
import SwiftUI
99

10+
/// A SwiftUI view that provides the navigation controls for the find panel.
11+
///
12+
/// The `FindControls` view is responsible for:
13+
/// - Displaying previous/next match navigation buttons
14+
/// - Showing a done button to dismiss the find panel
15+
/// - Adapting button appearance based on match count
16+
/// - Supporting both condensed and full layouts
17+
/// - Providing tooltips for button actions
18+
///
19+
/// The view is part of the find panel's control section and works in conjunction with
20+
/// the find text field to provide navigation through search results.
1021
struct FindControls: View {
1122
@ObservedObject var viewModel: FindPanelViewModel
1223
var condensed: Bool

Sources/CodeEditSourceEditor/Find/PanelView/FindModePicker.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
import SwiftUI
99

10+
/// A SwiftUI view that provides a mode picker for the find panel.
11+
///
12+
/// The `FindModePicker` view is responsible for:
13+
/// - Displaying a dropdown menu to switch between find and replace modes
14+
/// - Managing the wrap around option for search
15+
/// - Providing a visual indicator (magnifying glass icon) for the mode picker
16+
/// - Adapting its appearance based on the control's active state
17+
/// - Handling mode selection and wrap around toggling
18+
///
19+
/// The view works in conjunction with the find panel to manage the current search mode
20+
/// and wrap around settings.
1021
struct FindModePicker: NSViewRepresentable {
1122
@Binding var mode: FindPanelMode
1223
@Binding var wrapAround: Bool

Sources/CodeEditSourceEditor/Find/PanelView/FindPanelContent.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
import SwiftUI
99

10+
/// A SwiftUI view that provides the main content layout for the find and replace panel.
11+
///
12+
/// The `FindPanelContent` view is responsible for:
13+
/// - Arranging the find and replace text fields in a vertical stack
14+
/// - Arranging the control buttons in a vertical stack
15+
/// - Handling the layout differences between find and replace modes
16+
/// - Supporting both full and condensed layouts
17+
///
18+
/// The view is designed to be used within `FindPanelView` and adapts its layout based on the
19+
/// available space and current mode (find or replace).
1020
struct FindPanelContent: View {
1121
@ObservedObject var viewModel: FindPanelViewModel
1222
@FocusState.Binding var focus: FindPanelView.FindPanelFocus?

Sources/CodeEditSourceEditor/Find/PanelView/FindPanelHostingView.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@ import SwiftUI
99
import AppKit
1010
import Combine
1111

12-
/// A subclass of `NSHostingView` that hosts a `FindPanelView` in an AppKit context.
12+
/// A subclass of `NSHostingView` that hosts the SwiftUI `FindPanelView` in an
13+
/// AppKit context.
14+
///
15+
/// The `FindPanelHostingView` class is responsible for:
16+
/// - Bridging between SwiftUI and AppKit by hosting the FindPanelView
17+
/// - Managing keyboard event monitoring for the escape key
18+
/// - Handling the dismissal of the find panel
19+
/// - Providing proper view lifecycle management
20+
/// - Ensuring proper cleanup of event monitors
21+
///
22+
/// This class is essential for integrating the SwiftUI-based find panel into the AppKit-based
23+
/// text editor.
1324
final class FindPanelHostingView: NSHostingView<FindPanelView> {
1425
private weak var viewModel: FindPanelViewModel?
1526

Sources/CodeEditSourceEditor/Find/PanelView/FindPanelView.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@ import SwiftUI
99
import AppKit
1010
import CodeEditSymbols
1111

12+
/// A SwiftUI view that provides a find and replace interface for the text editor.
13+
///
14+
/// The `FindPanelView` is the main container view for the find and replace functionality. It manages:
15+
/// - The find/replace mode switching
16+
/// - Focus management between find and replace fields
17+
/// - Panel height adjustments based on mode
18+
/// - Search text changes and match highlighting
19+
/// - Case sensitivity and wrap-around settings
20+
///
21+
/// The view automatically adapts its layout based on available space using `ViewThatFits`, providing
22+
/// both a full and condensed layout option.
1223
struct FindPanelView: View {
24+
/// Represents the current focus state of the find panel
1325
enum FindPanelFocus: Equatable {
26+
/// The find text field is focused
1427
case find
28+
/// The replace text field is focused
1529
case replace
1630
}
1731

@@ -67,6 +81,7 @@ struct FindPanelView: View {
6781
}
6882
}
6983

84+
/// A preference key used to track the width of the find mode picker
7085
private struct FindModePickerWidthPreferenceKey: PreferenceKey {
7186
static var defaultValue: CGFloat = 0
7287
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {

Sources/CodeEditSourceEditor/Find/PanelView/FindSearchField.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
import SwiftUI
99

10+
/// A SwiftUI view that provides the search text field for the find panel.
11+
///
12+
/// The `FindSearchField` view is responsible for:
13+
/// - Displaying and managing the find text input field
14+
/// - Showing the find mode picker (find/replace) in both condensed and full layouts
15+
/// - Providing case sensitivity toggle
16+
/// - Displaying match count information
17+
/// - Handling keyboard navigation (Enter to find next)
18+
///
19+
/// The view adapts its layout based on the `condensed` parameter, providing a more compact
20+
/// interface when space is limited.
1021
struct FindSearchField: View {
1122
@ObservedObject var viewModel: FindPanelViewModel
1223
@FocusState.Binding var focus: FindPanelView.FindPanelFocus?

Sources/CodeEditSourceEditor/Find/PanelView/ReplaceControls.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
import SwiftUI
99

10+
/// A SwiftUI view that provides the replace controls for the find panel.
11+
///
12+
/// The `ReplaceControls` view is responsible for:
13+
/// - Displaying replace and replace all buttons
14+
/// - Managing button states based on find text and match count
15+
/// - Adapting button appearance between condensed and full layouts
16+
/// - Providing tooltips for button actions
17+
/// - Handling replace operations through the view model
18+
///
19+
/// The view is only shown when the find panel is in replace mode and works in conjunction
20+
/// with the replace text field to perform text replacements.
1021
struct ReplaceControls: View {
1122
@ObservedObject var viewModel: FindPanelViewModel
1223
var condensed: Bool

Sources/CodeEditSourceEditor/Find/PanelView/ReplaceSearchField.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
import SwiftUI
99

10+
/// A SwiftUI view that provides the replace text field for the find panel.
11+
///
12+
/// The `ReplaceSearchField` view is responsible for:
13+
/// - Displaying and managing the replace text input field
14+
/// - Showing a visual indicator (pencil icon) for the replace field
15+
/// - Adapting its layout between condensed and full modes
16+
/// - Maintaining focus state for keyboard navigation
17+
///
18+
/// The view is only shown when the find panel is in replace mode and adapts its layout
19+
/// based on the `condensed` parameter to match the find field's appearance.
1020
struct ReplaceSearchField: View {
1121
@ObservedObject var viewModel: FindPanelViewModel
1222
@FocusState.Binding var focus: FindPanelView.FindPanelFocus?

0 commit comments

Comments
 (0)