From b4c40c81439b27735165b6f99b7532e04f1263e4 Mon Sep 17 00:00:00 2001 From: DaSol Kim Date: Tue, 5 Sep 2023 21:43:28 +0900 Subject: [PATCH 1/3] feat: add pin button and automation setting button. --- .../xcshareddata/swiftpm/Package.resolved | 14 ++++++++ .../View/BoxFunctionViewGroup.swift | 2 +- Box42/FunctionButton/View/PinButtonView.swift | 4 +-- Box42/QuickSlot/View/QuickSlotGroupView.swift | 2 +- .../Scripts/View/Table/ScriptsTableView.swift | 2 ++ .../Controller/ToolbarViewController.swift | 28 +++++++++++++--- Box42/Toolbar/View/SideBarLeading.swift | 32 +++++++++++++------ 7 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..009c162 --- /dev/null +++ b/Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,14 @@ +{ + "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + } + ], + "version" : 2 +} diff --git a/Box42/FunctionButton/View/BoxFunctionViewGroup.swift b/Box42/FunctionButton/View/BoxFunctionViewGroup.swift index 2e961a0..6510582 100644 --- a/Box42/FunctionButton/View/BoxFunctionViewGroup.swift +++ b/Box42/FunctionButton/View/BoxFunctionViewGroup.swift @@ -10,7 +10,7 @@ import SnapKit class BoxFunctionViewGroup: NSView { lazy var preferenceButton: PreferenceButtonView = PreferenceButtonView(image: NSImage(imageLiteralResourceName: "plus"), completion: { self.preferenceAction?() }) - lazy var pinButton: PinButtonView = PinButtonView(image: NSImage(imageLiteralResourceName: "pin-box"), completion: { self.pinAction?() }) + lazy var pinButton: PinButtonView = PinButtonView(title: "Pin Box", image: NSImage(imageLiteralResourceName: "pin-box"), completion: { self.pinAction?() }) lazy var quitButton: QuitButtonView = QuitButtonView(image: NSImage(imageLiteralResourceName: "figure.snowboarding"), completion: { self.quitAction?() }) lazy var boxButton: BoxFunctionButtonView = BoxFunctionButtonView(image: NSImage(imageLiteralResourceName: "shippingbox"), completion: { self.boxAction?() }) diff --git a/Box42/FunctionButton/View/PinButtonView.swift b/Box42/FunctionButton/View/PinButtonView.swift index 31cf50e..158fbf3 100644 --- a/Box42/FunctionButton/View/PinButtonView.swift +++ b/Box42/FunctionButton/View/PinButtonView.swift @@ -16,7 +16,7 @@ class PinButtonView: NSView { return button }() - init(image: NSImage, completion: @escaping () -> Void) { + init(title: String, image: NSImage, completion: @escaping () -> Void) { super.init(frame: .zero) pinBoxButton.image = image @@ -31,7 +31,7 @@ class PinButtonView: NSView { pinBoxButton.layer?.backgroundColor = NSColor.clear.cgColor pinBoxButton.bezelStyle = .inline - let pinBoxTitle = "Pin Box" + let pinBoxTitle = title let attributes: [NSAttributedString.Key: Any] = [ NSAttributedString.Key.font: NSFont.systemFont(ofSize: 14.0, weight: .semibold), // 원하는 폰트 및 무게로 설정 diff --git a/Box42/QuickSlot/View/QuickSlotGroupView.swift b/Box42/QuickSlot/View/QuickSlotGroupView.swift index 6352cbd..399dace 100644 --- a/Box42/QuickSlot/View/QuickSlotGroupView.swift +++ b/Box42/QuickSlot/View/QuickSlotGroupView.swift @@ -11,7 +11,7 @@ import SnapKit class QuickSlotGroupView: NSView { lazy var divider: NSBox = Divider(completion: { [weak self] in self?.dividerAction?() }) - lazy var headerView: QuickSlotHeaderView = QuickSlotHeaderView(image: NSImage(imageLiteralResourceName: "star"), completion: { [weak self] in self?.headerAction?() }) + lazy var headerView: QuickSlotHeaderView = QuickSlotHeaderView(image: NSImage(imageLiteralResourceName: "Star"), completion: { [weak self] in self?.headerAction?() }) lazy var buttonCollectionView: QuickSlotButtonCollectionViewController = QuickSlotButtonCollectionViewController() var dividerAction: (() -> Void)? diff --git a/Box42/Scripts/View/Table/ScriptsTableView.swift b/Box42/Scripts/View/Table/ScriptsTableView.swift index 54a8d38..6d1f3ab 100644 --- a/Box42/Scripts/View/Table/ScriptsTableView.swift +++ b/Box42/Scripts/View/Table/ScriptsTableView.swift @@ -32,6 +32,8 @@ class ScriptsTableView: NSTableView { func setup() { self.delegate = self self.dataSource = self + self.headerView = nil + self.backgroundColor = .white let column1 = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("Scripts")) self.addTableColumn(column1) } diff --git a/Box42/Toolbar/Controller/ToolbarViewController.swift b/Box42/Toolbar/Controller/ToolbarViewController.swift index 3bcaf21..18f0ddc 100644 --- a/Box42/Toolbar/Controller/ToolbarViewController.swift +++ b/Box42/Toolbar/Controller/ToolbarViewController.swift @@ -26,6 +26,7 @@ class ToolbarViewController: NSViewController { toolbarViewGroup = BoxToolbarViewGroup() toolbarViewGroup?.sidebar = sidebar + } // func runPrefsHelperApplication() { @@ -41,12 +42,22 @@ class ToolbarViewController: NSViewController { // } // } - lazy var sidebarLeading: SideBarLeading = SideBarLeading(image: NSImage(imageLiteralResourceName: "toggle-on"), completion: { [weak self] in self?.sidebar() }) + lazy var pinButton: PinButtonView = PinButtonView(title: "", image: NSImage(imageLiteralResourceName: "pin-box"), completion: { StateManager.shared.togglePin() + + let newImage: NSImage + if StateManager.shared.pin { + newImage = NSImage(imageLiteralResourceName: "pin-box-ver") + } else { + newImage = NSImage(imageLiteralResourceName: "pin-box") + } + + self.pinButton.changePinImage(to: newImage) + }) func sidebar() { -// print("sidebar") -// BookmarkViewModel.shared.addBookmark(item: URLItem(name: "chan", url: "https://42box.kr/")) + // print("sidebar") + // BookmarkViewModel.shared.addBookmark(item: URLItem(name: "chan", url: "https://42box.kr/")) toolbarViewGroup = BoxToolbarViewGroup() if let baseContainerVC = baseContainerVC { baseContainerVC.leftView.isHidden.toggle() @@ -56,7 +67,7 @@ class ToolbarViewController: NSViewController { make.top.bottom.trailing.equalToSuperview().inset(12) make.leading.equalToSuperview().offset(24 + 24) } - + baseContainerVC.view.addSubview(sidebarLeading) sidebarLeading.snp.makeConstraints { make in make.top.equalToSuperview().inset(63) @@ -64,12 +75,21 @@ class ToolbarViewController: NSViewController { make.width.equalTo(24) make.height.equalTo(24) } + + baseContainerVC.view.addSubview(pinButton) + pinButton.snp.makeConstraints { make in + make.leading.equalToSuperview().inset(10) + make.left.bottom.equalTo(baseContainerVC.leftView) + make.width.equalTo(FunctionButtonUI.size.pinWidth) + make.height.equalTo(FunctionButtonUI.size.pinHeight) + } } else { baseContainerVC.contentGroup.snp.remakeConstraints { make in make.top.bottom.trailing.equalToSuperview().inset(12) make.leading.equalTo(baseContainerVC.leftView.snp.trailing) } sidebarLeading.removeFromSuperview() + pinButton.removeFromSuperview() } // 제약 조건을 다시 설정 diff --git a/Box42/Toolbar/View/SideBarLeading.swift b/Box42/Toolbar/View/SideBarLeading.swift index 11b81eb..c76be41 100644 --- a/Box42/Toolbar/View/SideBarLeading.swift +++ b/Box42/Toolbar/View/SideBarLeading.swift @@ -48,18 +48,30 @@ class SideBarLeading: NSButton { } } - func runPrefsHelperApplication() { - if let appURL = Bundle.main.url(forResource: "prefsHelper", withExtension: "app") { - let workspace = NSWorkspace.shared - do { - try workspace.open([appURL], withAppBundleIdentifier: nil, options: [], additionalEventParamDescriptor: nil, launchIdentifiers: nil) - } catch { - print("Error opening app: \(error)") + func runPrefsHelperApplication() { + if let appURL = Bundle.main.url(forResource: "prefsHelper", withExtension: "app") { + let workspace = NSWorkspace.shared + do { + try workspace.open([appURL], withAppBundleIdentifier: nil, options: [], additionalEventParamDescriptor: nil, launchIdentifiers: nil) + } catch { + print("Error opening app: \(error)") + } + } else { + print("App not found") } - } else { - print("App not found") } - } +// func runPrefsHelperApplication() { +// let prefsHelperAppPath = "/Users/solda/Downloads/prefsHelper.app" // prefsHelper.app의 경로 +// +// let appURL = URL(fileURLWithPath: prefsHelperAppPath) +// +// let workspace = NSWorkspace.shared +// do { +// try workspace.open([appURL], withAppBundleIdentifier: nil, options: [], additionalEventParamDescriptor: nil, launchIdentifiers: nil) +// } catch { +// print("Error opening app: \(error)") +// } +// } @objc func sideBarLeading() { From 53a1f859604f048d84a6e56930396bf294715095 Mon Sep 17 00:00:00 2001 From: KIM CHAN HEE <85754295+chanhihi@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:55:37 +0900 Subject: [PATCH 2/3] chore: delete --- .../xcshareddata/swiftpm/Package.resolved | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 009c162..0000000 --- a/Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "snapkit", - "kind" : "remoteSourceControl", - "location" : "https://github.com/SnapKit/SnapKit.git", - "state" : { - "revision" : "f222cbdf325885926566172f6f5f06af95473158", - "version" : "5.6.0" - } - } - ], - "version" : 2 -} From a31517d6c9381c81db313034e95caa5b494a8805 Mon Sep 17 00:00:00 2001 From: KIM CHAN HEE <85754295+chanhihi@users.noreply.github.com> Date: Tue, 5 Sep 2023 22:56:12 +0900 Subject: [PATCH 3/3] chore: QuickSlotGroupView.swift --- Box42/QuickSlot/View/QuickSlotGroupView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Box42/QuickSlot/View/QuickSlotGroupView.swift b/Box42/QuickSlot/View/QuickSlotGroupView.swift index 399dace..6352cbd 100644 --- a/Box42/QuickSlot/View/QuickSlotGroupView.swift +++ b/Box42/QuickSlot/View/QuickSlotGroupView.swift @@ -11,7 +11,7 @@ import SnapKit class QuickSlotGroupView: NSView { lazy var divider: NSBox = Divider(completion: { [weak self] in self?.dividerAction?() }) - lazy var headerView: QuickSlotHeaderView = QuickSlotHeaderView(image: NSImage(imageLiteralResourceName: "Star"), completion: { [weak self] in self?.headerAction?() }) + lazy var headerView: QuickSlotHeaderView = QuickSlotHeaderView(image: NSImage(imageLiteralResourceName: "star"), completion: { [weak self] in self?.headerAction?() }) lazy var buttonCollectionView: QuickSlotButtonCollectionViewController = QuickSlotButtonCollectionViewController() var dividerAction: (() -> Void)?