-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into lsp/document-content-sync
- Loading branch information
Showing
8 changed files
with
227 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
CodeEdit/Features/CodeEditUI/Views/MenuWithButtonStyle.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// MenuWithButtonStyle.swift | ||
// CodeEdit | ||
// | ||
// Created by Tommy Ludwig on 08.09.24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// A menu styled to resemble a bordered button. | ||
struct MenuWithButtonStyle<MenuView: View>: View { | ||
var systemImage: String | ||
var menu: () -> MenuView | ||
var body: some View { | ||
Menu { menu() } label: {} | ||
.background { | ||
Button {} label: { | ||
HStack { | ||
Image(systemName: systemImage) | ||
Image(systemName: "chevron.down") | ||
.resizable() | ||
.fontWeight(.bold) | ||
.frame(width: 8, height: 4.8) | ||
.padding(.leading, -1.5) | ||
.padding(.trailing, -2) | ||
}.offset(y: 1) | ||
} | ||
} | ||
.menuStyle(.borderlessButton) | ||
.menuIndicator(.hidden) | ||
.frame(width: 30) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// SearchField.swift | ||
// CodeEdit | ||
// | ||
// Created by Austin Condiff on 9/3/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SearchField: NSViewRepresentable { | ||
@Binding var text: String | ||
var placeholder: String | ||
|
||
init(_ placeholder: String, text: Binding<String>) { | ||
self.placeholder = placeholder | ||
self._text = text | ||
} | ||
|
||
func makeNSView(context: Context) -> NSSearchField { | ||
let searchField = NSSearchField() | ||
searchField.delegate = context.coordinator | ||
searchField.placeholderString = placeholder | ||
return searchField | ||
} | ||
|
||
func updateNSView(_ nsView: NSSearchField, context: Context) { | ||
nsView.stringValue = text | ||
} | ||
|
||
func makeCoordinator() -> Coordinator { | ||
Coordinator(self) | ||
} | ||
|
||
class Coordinator: NSObject, NSSearchFieldDelegate { | ||
var parent: SearchField | ||
|
||
init(_ parent: SearchField) { | ||
self.parent = parent | ||
} | ||
|
||
func controlTextDidChange(_ obj: Notification) { | ||
if let searchField = obj.object as? NSSearchField { | ||
parent.text = searchField.stringValue | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
SearchField("Search", text: .constant("Test")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
CodeEdit/Features/Settings/Pages/ThemeSettings/Models/Theme+FuzzySearchable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Theme+FuzzySearchable.swift | ||
// CodeEdit | ||
// | ||
// Created by Tommy Ludwig on 14.08.24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Theme: FuzzySearchable { | ||
var searchableString: String { | ||
return id | ||
} | ||
} |
Oops, something went wrong.