adds schema view and schema generating command
This commit is contained in:
@@ -8,7 +8,8 @@ struct WindowBridge: NSViewRepresentable {
|
||||
/// Passed as values so a project switch re-runs `updateNSView`, which renames the window and the app.
|
||||
let title: String
|
||||
let hasProject: Bool
|
||||
let gitViewOpen: Bool
|
||||
/// The Git or the Schema view covers the columns.
|
||||
let fullScreenViewOpen: Bool
|
||||
|
||||
func makeCoordinator() -> WindowCoordinator {
|
||||
WindowCoordinator(model: model)
|
||||
@@ -22,7 +23,7 @@ struct WindowBridge: NSViewRepresentable {
|
||||
|
||||
func updateNSView(_ view: BridgeView, context: Context) {
|
||||
context.coordinator.updateTitle(title, hasProject: hasProject)
|
||||
context.coordinator.updateGitView(open: gitViewOpen)
|
||||
context.coordinator.updateFullScreenView(open: fullScreenViewOpen)
|
||||
context.coordinator.guardClose()
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ final class WindowCoordinator: NSObject {
|
||||
/// Set once the unsaved prompt said yes, so the second close goes through.
|
||||
private var closeApproved = false
|
||||
private var isAskingToClose = false
|
||||
private var gitViewOpen = false
|
||||
private var fullScreenViewOpen = false
|
||||
|
||||
init(model: WorkspaceModel) {
|
||||
self.model = model
|
||||
@@ -106,11 +107,11 @@ final class WindowCoordinator: NSObject {
|
||||
AppName.set(hasProject ? title : AppName.standard)
|
||||
}
|
||||
|
||||
/// Opening the Git view takes the keyboard from the column behind it at once; its message field
|
||||
/// takes focus a run loop later, so typing never lands in a covered terminal.
|
||||
func updateGitView(open: Bool) {
|
||||
defer { gitViewOpen = open }
|
||||
guard open, !gitViewOpen, let window else { return }
|
||||
/// Opening the Git or Schema view takes the keyboard from the column behind it at once; the Git
|
||||
/// message field takes focus a run loop later, so typing never lands in a covered terminal.
|
||||
func updateFullScreenView(open: Bool) {
|
||||
defer { fullScreenViewOpen = open }
|
||||
guard open, !fullScreenViewOpen, let window else { return }
|
||||
window.makeFirstResponder(nil)
|
||||
}
|
||||
|
||||
@@ -221,7 +222,7 @@ final class WindowCoordinator: NSObject {
|
||||
|
||||
private func handleMouseDown(_ event: NSEvent) {
|
||||
guard let window, event.window === window, model.root != nil, !model.overlay.isPresented,
|
||||
!model.layout.isGitViewOpen else { return }
|
||||
!model.layout.isGitViewOpen, !model.layout.isSchemaViewOpen else { return }
|
||||
let point = event.locationInWindow
|
||||
let height = window.contentView?.bounds.height ?? window.frame.height
|
||||
guard height - point.y > Metrics.titleBar, point.y > Metrics.statusBar else { return }
|
||||
@@ -248,8 +249,9 @@ final class WindowCoordinator: NSObject {
|
||||
var editorSelection: TextSelectionInfo?
|
||||
var seed = ""
|
||||
let gitViewOpen = model.layout.isGitViewOpen
|
||||
let schemaViewOpen = model.layout.isSchemaViewOpen
|
||||
if let text = responder as? NSTextView {
|
||||
let column = gitViewOpen ? nil : column(of: text)
|
||||
let column = gitViewOpen || schemaViewOpen ? nil : column(of: text)
|
||||
owner = .text(in: column)
|
||||
let range = text.selectedRange()
|
||||
hasSelection = range.length > 0
|
||||
@@ -285,7 +287,11 @@ final class WindowCoordinator: NSObject {
|
||||
recentFileCount: editor?.history.count ?? 0,
|
||||
searchSeed: seed,
|
||||
gitViewOpen: gitViewOpen,
|
||||
inGitConsole: responder is GitConsoleFieldEditor
|
||||
inGitConsole: responder is GitConsoleFieldEditor,
|
||||
schemaAvailable: model.schema?.isLaravelApp ?? false,
|
||||
schemaViewOpen: schemaViewOpen,
|
||||
schemaHasSelection: model.schema?.selected != nil,
|
||||
schemaSearchHasText: responder is SchemaSearchFieldEditor && !(model.schema?.query.isEmpty ?? true)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user