From a68a77c9e5ec0221d90a6e13a30cd88b53b3998e Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:17:50 +0300 Subject: [PATCH 01/18] WorkspaceScreen.swift: --- Option1/UI/Screens/Workspace/WorkspaceScreen.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceScreen.swift b/Option1/UI/Screens/Workspace/WorkspaceScreen.swift index 8ea4e36..74bb5e9 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceScreen.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceScreen.swift @@ -26,7 +26,7 @@ struct WorkspaceScreen: View { Divider() .padding() - Text("Open Window Titles") + Text("Window Titles") .font(.system(size: 20, weight: .semibold)) .padding(.horizontal) .textAlign(.leading) From 8dc2f9de0121a82408b0fe9870dbd83e64ee6ac0 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:18:20 +0300 Subject: [PATCH 02/18] WorkspaceBindView.swift: --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index a97c51d..506688a 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -74,7 +74,7 @@ struct WorkspaceBindView: View { }, ) } else { - TextField("Part of title (optional)", text: $formUi.substring) + TextField("Window title (optional)", text: $formUi.substring) .autocorrectionDisabled() .frame(width: 200) } From da684948a17b9bd5ac678f5409d9f829ef6621ac Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:18:52 +0300 Subject: [PATCH 03/18] WorkspaceBindView.swift: Relative Path --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 506688a..e6e9eff 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -123,6 +123,8 @@ struct WorkspaceBindView: View { } } +private let userRelativePathRegex = /^\/Users\/(.*?)\/\b/ + private struct ProjectPickerView: View { let path: String @@ -134,6 +136,10 @@ private struct ProjectPickerView: View { @State private var isFilePickerPresented = false + private var validatedPath: String { + return path.replacing(userRelativePathRegex, with: "~/") + } + var body: some View { HStack(spacing: 4) { if path.isEmpty { @@ -146,7 +152,7 @@ private struct ProjectPickerView: View { }, ) } else { - Text(path) + Text(validatedPath) .padding(.vertical, 8) .foregroundColor(.green) .font(.system(size: fontSize, weight: .regular)) From 8e70262f933f77ad3b2c4127edbb239c45d29059 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:21:44 +0300 Subject: [PATCH 04/18] WorkspaceBindView.swift: Relative Path --- Option1/CachedWindow.swift | 6 +++--- Option1/HotKeysUtils.swift | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Option1/CachedWindow.swift b/Option1/CachedWindow.swift index b2edc5b..328b656 100644 --- a/Option1/CachedWindow.swift +++ b/Option1/CachedWindow.swift @@ -9,12 +9,12 @@ struct CachedWindow: Hashable { let axuiElementId: AXUIElementID let title: String let appBundle: String - let ideaProject: String? + let shellWithNewWindow: String? static func addByAxuiElement( nsRunningApplication: NSRunningApplication, axuiElement: AXUIElement, - ideaProject: String? = nil, + shellWithNewWindow: String? = nil, ) throws { if let pid = try axuiElement.pid(), @@ -29,7 +29,7 @@ struct CachedWindow: Hashable { axuiElementId: axuiElementId, title: title, appBundle: bundleIdentifier, - ideaProject: ideaProject ?? oldCachedWindow?.ideaProject, + shellWithNewWindow: shellWithNewWindow ?? oldCachedWindow?.shellWithNewWindow, ) } } diff --git a/Option1/HotKeysUtils.swift b/Option1/HotKeysUtils.swift index 6feba7e..4db0ccf 100644 --- a/Option1/HotKeysUtils.swift +++ b/Option1/HotKeysUtils.swift @@ -112,9 +112,11 @@ private func handleSpecial( // При вызове NSWorkspace.shared.openApplication() с createsNewApplicationInstance // macOS начинает анимацию запуска приложения в Dock, хотя по факту открывается еще // одно окно а не всё приложение. Каждый раз смотреть эти подпрыгивания не охото, - // по этому если уже есть окно с этим ideaProject - то его запуск. + // по этому если уже есть окно с этим путем - то его запуск. CachedWindow.cleanClosed__slow() - if let cachedProject = cachedWindows.first(where: { $0.value.ideaProject == project }) { + if let cachedProject = cachedWindows.first( + where: { $0.value.appBundle == bundle && $0.value.shellWithNewWindow == project } + ) { try? focusAxuiElement(cachedProject.value.axuiElement) return true } @@ -138,7 +140,7 @@ private func handleSpecial( try? CachedWindow.addByAxuiElement( nsRunningApplication: nsApp, axuiElement: focused, - ideaProject: project, + shellWithNewWindow: project, ) } }) From 7cec69e2ecfaeafb0e1566c6a39753e32c2de560 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:24:10 +0300 Subject: [PATCH 05/18] WorkspaceBindView.swift: UI --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index e6e9eff..782037b 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -154,7 +154,7 @@ private struct ProjectPickerView: View { } else { Text(validatedPath) .padding(.vertical, 8) - .foregroundColor(.green) + .foregroundColor(.blue) .font(.system(size: fontSize, weight: .regular)) .onTapGesture { isFilePickerPresented = true @@ -166,7 +166,7 @@ private struct ProjectPickerView: View { }, label: { Image(systemName: "xmark.circle") - .font(.system(size: fontSize, weight: .medium)) + .font(.system(size: fontSize, weight: .regular)) }, ) .buttonStyle(.borderless) From df4c408d22b3cd29c00efd9dd4766ec4978808bd Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:31:46 +0300 Subject: [PATCH 06/18] WorkspaceBindView.swift: UI --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 782037b..04644e0 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -76,7 +76,7 @@ struct WorkspaceBindView: View { } else { TextField("Window title (optional)", text: $formUi.substring) .autocorrectionDisabled() - .frame(width: 200) + .frame(width: 180) } } else if let sharedOverride = sharedOverride { HStack(spacing: 0) { From 1a9e45ad5139fa9f1efcceeb315928ac2da8952e Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:37:00 +0300 Subject: [PATCH 07/18] BundleIds.swift: --- Option1/BundleIds.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Option1/BundleIds.swift b/Option1/BundleIds.swift index 47cc492..a6fc607 100644 --- a/Option1/BundleIds.swift +++ b/Option1/BundleIds.swift @@ -1,5 +1,17 @@ class BundleIds { - static let Xcode = "com.apple.dt.Xcode" - static let IntelliJ = "com.jetbrains.intellij" + static let Finder = "com.apple.finder" + static let Xcode = "com.apple.dt.Xcode" + // JetBrains + static let IntelliJ = "com.jetbrains.intellij" + // Microsoft + static let MicrosoftWord = "com.microsoft.Word" + + static func isOpenByShellNoNewWindow(_ bundle: String) -> Bool { + [Finder, MicrosoftWord].contains(bundle) + } + + static func isOpenByShellWithNewWindow(_ bundle: String) -> Bool { + [IntelliJ].contains(bundle) + } } From 53cb1112cf8caa24d3ca12eb4bf6fe53dae3adb4 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:44:25 +0300 Subject: [PATCH 08/18] HotKeysUtils.swift: --- Option1/HotKeysUtils.swift | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Option1/HotKeysUtils.swift b/Option1/HotKeysUtils.swift index 4db0ccf..1a0b1b4 100644 --- a/Option1/HotKeysUtils.swift +++ b/Option1/HotKeysUtils.swift @@ -102,12 +102,21 @@ private func handleSpecial( return false } - if bindDb.bundle == BundleIds.IntelliJ { + if BundleIds.isOpenByShellNoNewWindow(bindDb.bundle) { let bundle = bindDb.bundle - let fileManager = FileManager.default - let project = bindDb.substring - if project.first == "/", - fileManager.fileExists(atPath: project) { + let path = bindDb.substring + if isFileExists(path) { + let result = shell("open", "-b", bundle, path) + // No sense to update cachedWindows + return result == 0 + } + return false + } + + if BundleIds.isOpenByShellWithNewWindow(bindDb.bundle) { + let bundle = bindDb.bundle + let path = bindDb.substring + if isFileExists(path) { // При вызове NSWorkspace.shared.openApplication() с createsNewApplicationInstance // macOS начинает анимацию запуска приложения в Dock, хотя по факту открывается еще @@ -115,7 +124,7 @@ private func handleSpecial( // по этому если уже есть окно с этим путем - то его запуск. CachedWindow.cleanClosed__slow() if let cachedProject = cachedWindows.first( - where: { $0.value.appBundle == bundle && $0.value.shellWithNewWindow == project } + where: { $0.value.appBundle == bundle && $0.value.shellWithNewWindow == path } ) { try? focusAxuiElement(cachedProject.value.axuiElement) return true @@ -125,7 +134,7 @@ private func handleSpecial( return false } let configuration = NSWorkspace.OpenConfiguration() - configuration.arguments = [project] + configuration.arguments = [path] configuration.createsNewApplicationInstance = true NSWorkspace.shared.openApplication(at: url, configuration: configuration, completionHandler: { _, _ in // Почему-то у объекта приложения из completionHandler .bundleIdentifier всегда nil, @@ -140,7 +149,7 @@ private func handleSpecial( try? CachedWindow.addByAxuiElement( nsRunningApplication: nsApp, axuiElement: focused, - shellWithNewWindow: project, + shellWithNewWindow: path, ) } }) From 7cef48df30c7b2ac12350f3a84e117cc78905a85 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:48:53 +0300 Subject: [PATCH 09/18] WorkspaceBindView.swift: --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 04644e0..b27e982 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -137,7 +137,7 @@ private struct ProjectPickerView: View { @State private var isFilePickerPresented = false private var validatedPath: String { - return path.replacing(userRelativePathRegex, with: "~/") + path.replacing(userRelativePathRegex, with: "~/") } var body: some View { From 232e13bdcd862a3ba67a4f3282de41a9b84977ac Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 16:53:18 +0300 Subject: [PATCH 10/18] WorkspaceBindView.swift: FileTypeView --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index b27e982..be5c95f 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -56,7 +56,7 @@ struct WorkspaceBindView: View { if formUi.bundle != nil { if formUi.bundle == BundleIds.Xcode { - ProjectPickerView( + FileTypeView( path: formUi.substring, pickerButtonText: "Select Xcode Project File or Folder", fileTypes: [.data, .directory], @@ -65,7 +65,7 @@ struct WorkspaceBindView: View { }, ) } else if formUi.bundle == BundleIds.IntelliJ { - ProjectPickerView( + FileTypeView( path: formUi.substring, pickerButtonText: "Select IDEA Project Folder", fileTypes: [.directory], @@ -125,7 +125,7 @@ struct WorkspaceBindView: View { private let userRelativePathRegex = /^\/Users\/(.*?)\/\b/ -private struct ProjectPickerView: View { +private struct FileTypeView: View { let path: String let pickerButtonText: String From ec69989a491be7daf382e45699627adcb719f407 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 16 Mar 2026 21:16:05 +0300 Subject: [PATCH 11/18] WorkspaceBindView.swift: Info Alert --- .../Screens/Workspace/WorkspaceBindView.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index be5c95f..831da1e 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -11,6 +11,7 @@ struct WorkspaceBindView: View { @State private var appsUi: [AppUi] @State private var formUi: FormUi + @State private var isTitleInfoPresented = false // Т.к. одновременно данное View отображается 10 раз а в формировании // списка много внутренней логики нужно давать хотябы 2 секунды. @@ -77,6 +78,18 @@ struct WorkspaceBindView: View { TextField("Window title (optional)", text: $formUi.substring) .autocorrectionDisabled() .frame(width: 180) + Button( + action: { + isTitleInfoPresented = true + }, + label: { + Image(systemName: "info.circle") + .font(.system(size: fontSize, weight: .regular)) + .foregroundColor(.secondary) + }, + ) + .buttonStyle(.borderless) + .padding(.leading, 10) } } else if let sharedOverride = sharedOverride { HStack(spacing: 0) { @@ -120,6 +133,15 @@ struct WorkspaceBindView: View { } } } + .alert( + "", + isPresented: $isTitleInfoPresented, + actions: {}, + // todo + // If you have many opened window's for __APP__ you can set the title that window will open with. + // You can type part of title + message: { Text("TODO from doc") }, + ) } } From c72288f69335ba67f466cdf6bf5bc85e8692226c Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 17 Mar 2026 14:19:27 +0300 Subject: [PATCH 12/18] WorkspaceBindView.swift: Word --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 831da1e..2fbe762 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -74,6 +74,15 @@ struct WorkspaceBindView: View { formUi.substring = path }, ) + } else if formUi.bundle == BundleIds.MicrosoftWord { + FileTypeView( + path: formUi.substring, + pickerButtonText: "Select Word Document", + fileTypes: [.data], + onPathChanged: { path in + formUi.substring = path + }, + ) } else { TextField("Window title (optional)", text: $formUi.substring) .autocorrectionDisabled() From 0fa13ba96c119fa94d1b06edd3027765bc9cc2d5 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 17 Mar 2026 14:55:05 +0300 Subject: [PATCH 13/18] WorkspaceBindView.swift: --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 2fbe762..b524b28 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -11,7 +11,12 @@ struct WorkspaceBindView: View { @State private var appsUi: [AppUi] @State private var formUi: FormUi + @State private var isTitleInfoPresented = false + private var titleInfoPrentedText: String { + let selectedName: String = appsUi.first(where: { $0.bundle == formUi.bundle })?.title ?? "app" + return "If you have multiple \(selectedName) windows open, enter the window title for window you want to open.\n\nYou can enter part of title as well." + } // Т.к. одновременно данное View отображается 10 раз а в формировании // списка много внутренней логики нужно давать хотябы 2 секунды. @@ -146,10 +151,7 @@ struct WorkspaceBindView: View { "", isPresented: $isTitleInfoPresented, actions: {}, - // todo - // If you have many opened window's for __APP__ you can set the title that window will open with. - // You can type part of title - message: { Text("TODO from doc") }, + message: { Text(titleInfoPrentedText) }, ) } } From a1a78fce9686f494dd42de214bf3805d12fd6198 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 17 Mar 2026 15:02:45 +0300 Subject: [PATCH 14/18] BundleIds.swift: --- Option1/BundleIds.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Option1/BundleIds.swift b/Option1/BundleIds.swift index a6fc607..43cdfc2 100644 --- a/Option1/BundleIds.swift +++ b/Option1/BundleIds.swift @@ -1,3 +1,7 @@ +// todo Android Studio +// todo Jetbrain IDE's +// todo Microsoft Office Products: Word, Excel, ... +// todo Text Edit class BundleIds { static let Finder = "com.apple.finder" From f8642e2e3e10d1fd473f1903724257a62563eef1 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 17 Mar 2026 15:08:17 +0300 Subject: [PATCH 15/18] WorkspaceBindView.swift: --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index b524b28..505c3c8 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -88,6 +88,15 @@ struct WorkspaceBindView: View { formUi.substring = path }, ) + } else if isFileExists(formUi.substring) { + FileTypeView( + path: formUi.substring, + pickerButtonText: "---", // Impossible to show because of .isFileExists() + fileTypes: [.data, .directory], + onPathChanged: { path in + formUi.substring = path + }, + ) } else { TextField("Window title (optional)", text: $formUi.substring) .autocorrectionDisabled() From 6fb47d5dcd9d2ded0433a4f03083db4b334725c7 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 17 Mar 2026 15:48:54 +0300 Subject: [PATCH 16/18] WorkspaceBindView.swift: --- .../Screens/Workspace/WorkspaceBindView.swift | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 505c3c8..4f06b0e 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -18,6 +18,9 @@ struct WorkspaceBindView: View { return "If you have multiple \(selectedName) windows open, enter the window title for window you want to open.\n\nYou can enter part of title as well." } + @State private var isAnyFilePickerPresented = false + @State private var isAnyFilePickerInfoPresented = false + // Т.к. одновременно данное View отображается 10 раз а в формировании // списка много внутренней логики нужно давать хотябы 2 секунды. private let updateAppsUiTimer = Timer.publish(every: 2, on: .main, in: .common).autoconnect() @@ -98,9 +101,24 @@ struct WorkspaceBindView: View { }, ) } else { + TextField("Window title (optional)", text: $formUi.substring) .autocorrectionDisabled() .frame(width: 180) + + Button( + action: { + isAnyFilePickerInfoPresented = true + }, + label: { + Image(systemName: "folder") + .font(.system(size: fontSize, weight: .regular)) + .foregroundColor(.secondary) + }, + ) + .buttonStyle(.borderless) + .padding(.leading, 12) + Button( action: { isTitleInfoPresented = true @@ -112,7 +130,7 @@ struct WorkspaceBindView: View { }, ) .buttonStyle(.borderless) - .padding(.leading, 10) + .padding(.leading, 8) } } else if let sharedOverride = sharedOverride { HStack(spacing: 0) { @@ -162,6 +180,32 @@ struct WorkspaceBindView: View { actions: {}, message: { Text(titleInfoPrentedText) }, ) + .confirmationDialog( + "", + isPresented: $isAnyFilePickerInfoPresented, + ) { + Button("Select File or Folder") { + isAnyFilePickerPresented = true + } + .keyboardShortcut(.defaultAction) + + Button("Cancel", role: .cancel) { + } + } message: { + Text("If the app supports opening files or folders, select the one you want to open.") + } + .fileImporter( + isPresented: $isAnyFilePickerPresented, + allowedContentTypes: [.data, .directory], + onCompletion: { result in + switch result { + case .success(let url): + formUi.substring = url.relativePath + case .failure: + break + } + } + ) } } From 0026906d69c2e83360466936a2140155a7dcedf5 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 18 Mar 2026 19:22:47 +0300 Subject: [PATCH 17/18] WorkspaceBindView.swift: --- .../Screens/Workspace/WorkspaceBindView.swift | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 4f06b0e..0aad37a 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -118,7 +118,33 @@ struct WorkspaceBindView: View { ) .buttonStyle(.borderless) .padding(.leading, 12) - + .confirmationDialog( + "", + isPresented: $isAnyFilePickerInfoPresented, + ) { + Button("Select File or Folder") { + isAnyFilePickerPresented = true + } + .keyboardShortcut(.defaultAction) + + Button("Cancel", role: .cancel) { + } + } message: { + Text("If the app supports opening files or folders, select the one you want to open.") + } + .fileImporter( + isPresented: $isAnyFilePickerPresented, + allowedContentTypes: [.data, .directory], + onCompletion: { result in + switch result { + case .success(let url): + formUi.substring = url.relativePath + case .failure: + break + } + } + ) + Button( action: { isTitleInfoPresented = true @@ -180,32 +206,6 @@ struct WorkspaceBindView: View { actions: {}, message: { Text(titleInfoPrentedText) }, ) - .confirmationDialog( - "", - isPresented: $isAnyFilePickerInfoPresented, - ) { - Button("Select File or Folder") { - isAnyFilePickerPresented = true - } - .keyboardShortcut(.defaultAction) - - Button("Cancel", role: .cancel) { - } - } message: { - Text("If the app supports opening files or folders, select the one you want to open.") - } - .fileImporter( - isPresented: $isAnyFilePickerPresented, - allowedContentTypes: [.data, .directory], - onCompletion: { result in - switch result { - case .success(let url): - formUi.substring = url.relativePath - case .failure: - break - } - } - ) } } From 0b1913ee87680e6672f3233d808721c907e6d2e5 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 18 Mar 2026 19:48:57 +0300 Subject: [PATCH 18/18] WorkspaceBindView.swift: --- Option1/UI/Screens/Workspace/WorkspaceBindView.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift index 0aad37a..dfa413d 100644 --- a/Option1/UI/Screens/Workspace/WorkspaceBindView.swift +++ b/Option1/UI/Screens/Workspace/WorkspaceBindView.swift @@ -13,9 +13,9 @@ struct WorkspaceBindView: View { @State private var formUi: FormUi @State private var isTitleInfoPresented = false - private var titleInfoPrentedText: String { - let selectedName: String = appsUi.first(where: { $0.bundle == formUi.bundle })?.title ?? "app" - return "If you have multiple \(selectedName) windows open, enter the window title for window you want to open.\n\nYou can enter part of title as well." + + private var selectedAppName: String? { + appsUi.first(where: { $0.bundle == formUi.bundle })?.title } @State private var isAnyFilePickerPresented = false @@ -204,7 +204,7 @@ struct WorkspaceBindView: View { "", isPresented: $isTitleInfoPresented, actions: {}, - message: { Text(titleInfoPrentedText) }, + message: { Text("If you have multiple \(selectedAppName ?? "app") windows open, enter the window title for window you want to open.\n\nYou can enter part of title as well.") } ) } }