diff --git a/Box42/FunctionButton/View/PinButtonView.swift b/Box42/FunctionButton/View/PinButtonView.swift index 9c9db8b..31cf50e 100644 --- a/Box42/FunctionButton/View/PinButtonView.swift +++ b/Box42/FunctionButton/View/PinButtonView.swift @@ -11,35 +11,44 @@ import SnapKit class PinButtonView: NSView { private var callback: (() -> Void)? - private var pinBoxButton: NSButton! - private var pinBoxLabel: NSTextField! + private let pinBoxButton: NSButton = { + let button = NSButton() + return button + }() init(image: NSImage, completion: @escaping () -> Void) { super.init(frame: .zero) - pinBoxButton = NSButton(image: image, target: self, action: #selector(pin)) + pinBoxButton.image = image + pinBoxButton.imagePosition = .imageLeading + pinBoxButton.image?.alignmentRect = NSRect(x: 0, y: 7, width: 22, height: 22) + + pinBoxButton.target = self + pinBoxButton.action = #selector(pin) + pinBoxButton.isBordered = false pinBoxButton.wantsLayer = true pinBoxButton.layer?.backgroundColor = NSColor.clear.cgColor + pinBoxButton.bezelStyle = .inline + let pinBoxTitle = "Pin Box" + + let attributes: [NSAttributedString.Key: Any] = [ + NSAttributedString.Key.font: NSFont.systemFont(ofSize: 14.0, weight: .semibold), // 원하는 폰트 및 무게로 설정 + NSAttributedString.Key.foregroundColor: NSColor(red: 0.41, green: 0.41, blue: 0.41, alpha: 1), + ] + + let attributedTitle = NSAttributedString(string: pinBoxTitle, attributes: attributes) + + pinBoxButton.attributedTitle = attributedTitle + pinBoxButton.attributedAlternateTitle = attributedTitle + self.addSubview(pinBoxButton) - - pinBoxLabel = NSTextField(labelWithString: "Pin Box") - pinBoxLabel.font = NSFont(name: "Inter", size: 14) - pinBoxLabel.textColor = NSColor(hex: "#696969") - pinBoxLabel.backgroundColor = NSColor.clear - pinBoxLabel.isBordered = false - - self.addSubview(pinBoxLabel) - pinBoxButton.snp.makeConstraints { make in make.left.equalToSuperview() make.centerY.equalToSuperview() - } - - pinBoxLabel.snp.makeConstraints { make in - make.left.equalTo(pinBoxButton.snp.right).offset(2) - make.centerY.equalToSuperview() + make.width.equalTo(89) + make.height.equalTo(27) } self.callback = completion diff --git a/Box42/Main/BoxBaseContainerViewController.swift b/Box42/Main/BoxBaseContainerViewController.swift index 861a902..4c1c4b0 100644 --- a/Box42/Main/BoxBaseContainerViewController.swift +++ b/Box42/Main/BoxBaseContainerViewController.swift @@ -25,32 +25,32 @@ let bookMarkList = [ class BoxBaseContainerViewController: NSViewController { // MARK: - LeftContainer -// var splitView: BoxBaseSplitView = BoxBaseSplitView() + // var splitView: BoxBaseSplitView = BoxBaseSplitView() var contentGroup: BoxContentsViewGroup = BoxContentsViewGroup() var toolbarGroupVC: ToolbarViewController = ToolbarViewController() var quickSlotGroupVC: QuickSlotViewController = QuickSlotViewController() var functionGroupVC: BoxFunctionViewController = BoxFunctionViewController() let windowViewGroupVC: WindowButtonViewController = WindowButtonViewController() -// var leftContainer: MovableContainerView = MovableContainerView() -// var buttonGroupVC: ButtonGroupViewController = ButtonGroupViewController() + // var leftContainer: MovableContainerView = MovableContainerView() + // var buttonGroupVC: ButtonGroupViewController = ButtonGroupViewController() // MARK: - QuickSlot var preferenceVC: PreferencesViewController = PreferencesViewController() var scriptsVC: ScriptsViewController = ScriptsViewController() - + weak var menubarVCDelegate: MenubarViewControllerDelegate? // extension var quickSlotManagerVC: QuickSlotManagerViewController = QuickSlotManagerViewController() var quickSlotButtonCollectionVC: QuickSlotButtonCollectionViewController = QuickSlotButtonCollectionViewController() - - private let splitView: NSSplitView = { - let splitView = NSSplitView() - splitView.isVertical = true - splitView.dividerStyle = .thick - return splitView - }() - private let leftView: NSView = { + // private let splitView: NSSplitView = { + // let splitView = NSSplitView() + // splitView.isVertical = true + // splitView.dividerStyle = .thick + // return splitView + // }() + + public let leftView: NSView = { let view = NSView() view.frame.size.width = 302 - 12 view.frame.size.height = 1200 @@ -75,6 +75,8 @@ class BoxBaseContainerViewController: NSViewController { var selectedButton: DraggableButton? override func loadView() { + toolbarGroupVC.baseContainerVC = self + self.view = NSView() self.view.wantsLayer=true self.view.layer?.backgroundColor = NSColor(hex: "#E7E7E7").cgColor @@ -83,17 +85,37 @@ class BoxBaseContainerViewController: NSViewController { make.height.equalTo(BoxSizeManager.shared.size.height) } - splitView.addArrangedSubview(leftView) - splitView.addArrangedSubview(contentGroup) - self.view.addSubview(splitView) + // splitView.adjustSubviews() + // splitView.setNeedsDisplay(splitView.bounds) + // splitView.addArrangedSubview(leftView) + // splitView.addArrangedSubview(contentGroup) + // self.view.addSubview(splitView) + // + // splitView.snp.makeConstraints { make in + // make.edges.equalToSuperview().inset(10) + // } + self.view.addSubview(leftView) + self.view.addSubview(contentGroup) + + leftView.snp.makeConstraints { make in + make.top.bottom.equalToSuperview().inset(12) + make.leading.equalToSuperview().offset(16) + make.trailing.equalTo(contentGroup.snp.leading).offset(-18) + make.width.equalTo((268 + 16 + 18)) + } - splitView.snp.makeConstraints { make in - make.edges.equalToSuperview().inset(10) + contentGroup.snp.makeConstraints { make in + make.top.bottom.trailing.equalToSuperview().inset(12) + make.leading.equalTo(leftView.snp.trailing) } + let borderView = NSView() + borderView.wantsLayer = true + borderView.layer?.backgroundColor = NSColor(red: 0.773, green: 0.773, blue: 0.773, alpha: 1).cgColor leftView.addSubview(windowViewGroupVC.view) leftView.addSubview(bookMarkView) leftView.addSubview(toolbarGroupVC.view) + leftView.addSubview(borderView) leftView.addSubview(quickSlotGroupVC.view) leftView.addSubview(functionGroupVC.view) @@ -114,9 +136,15 @@ class BoxBaseContainerViewController: NSViewController { make.leading.trailing.equalToSuperview() make.bottom.equalTo(quickSlotGroupVC.view.snp.top).offset(-Constants.UI.groupAutolayout) } + borderView.snp.makeConstraints { make in + make.top.equalTo(bookMarkView.snp.bottom).offset(15) + make.leading.trailing.equalToSuperview() + make.height.equalTo(1) + } quickSlotGroupVC.view.snp.makeConstraints { make in + make.top.equalTo(borderView.snp.bottom).offset(0) make.bottom.equalTo(functionGroupVC.view.snp.top).offset(-27) - make.right.equalTo(leftView).offset(-Constants.UI.groupAutolayout) + make.right.equalTo(leftView).offset(0) make.left.equalTo(leftView) make.height.equalTo(178) } @@ -125,19 +153,17 @@ class BoxBaseContainerViewController: NSViewController { make.left.bottom.equalTo(leftView) } - splitView.delegate = self - - let stackView = NSStackView() - stackView.orientation = .horizontal - stackView.spacing = 6 - stackView.alignment = .centerY + let superView = NSView() let imageView = NSImageView() imageView.image = NSImage(named: NSImage.Name("bookmark")) + imageView.image?.size = NSSize(width: 18, height: 18) + superView.addSubview(imageView) let label = NSTextField(labelWithString: "북마크") label.textColor = NSColor.black label.font = NSFont.boldSystemFont(ofSize: 16) + superView.addSubview(label) let buttonImage = NSImage(named: NSImage.Name("add"))! buttonImage.size = NSSize(width: 24, height: 24) @@ -146,16 +172,23 @@ class BoxBaseContainerViewController: NSViewController { button.bezelStyle = .texturedRounded button.isBordered = false button.wantsLayer = true - button.layer?.backgroundColor = NSColor(hex: "#E7E7E7").cgColor - let spacerView = NSView() - spacerView.snp.makeConstraints { make in - make.width.equalTo(173) + button.layer?.backgroundColor = NSColor(hex:"#E7E7E7").cgColor + superView.addSubview(button) + + imageView.snp.makeConstraints { make in + make.left.equalToSuperview() + make.centerY.equalToSuperview() } - stackView.addArrangedSubview(imageView) - stackView.addArrangedSubview(label) - stackView.addArrangedSubview(spacerView) - stackView.addArrangedSubview(button) + label.snp.makeConstraints { make in + make.left.equalTo(imageView.snp.right).offset(8) + make.centerY.equalToSuperview() + } + + button.snp.makeConstraints { make in + make.right.equalToSuperview() + make.centerY.equalToSuperview() + } tableView.wantsLayer = true tableView.backgroundColor = NSColor(hex: "#E7E7E7") @@ -178,11 +211,11 @@ class BoxBaseContainerViewController: NSViewController { scrollView.hasVerticalScroller = true scrollView.documentView = tableView - bookMarkView.addSubview(stackView) + bookMarkView.addSubview(superView) bookMarkView.addSubview(scrollView) // bookMarkView.addSubview(tableView) - stackView.snp.makeConstraints { make in + superView.snp.makeConstraints { make in make.top.equalToSuperview().offset(18) make.leading.trailing.equalToSuperview().offset(0) make.height.equalTo(24) @@ -194,7 +227,7 @@ class BoxBaseContainerViewController: NSViewController { // } scrollView.snp.makeConstraints { make in - make.top.equalTo(stackView.snp.bottom).offset(0) + make.top.equalTo(superView.snp.bottom).offset(0) make.leading.trailing.equalToSuperview().offset(0) make.bottom.equalToSuperview() } @@ -205,162 +238,141 @@ class BoxBaseContainerViewController: NSViewController { } @objc func addBookMarkButtonClicked(_ sender: NSButton) { - splitView.removeArrangedSubview(contentGroup) - contentGroup.removeFromSuperview() - - let newView = BookmarkEditorView(bookMarkList: bookMarkList) - newView.wantsLayer = true - newView.layer?.backgroundColor = NSColor.black.cgColor - newView.layer?.cornerRadius = 20 - newView.frame.size = contentGroup.frame.size - - contentGroup.addSubview(newView) - newView.snp.makeConstraints { make in - make.edges.equalToSuperview() - } - - splitView.addArrangedSubview(contentGroup) + // splitView.removeArrangedSubview(contentGroup) + // contentGroup.removeFromSuperview() + // + // let newView = BookmarkEditorView(bookMarkList: bookMarkList) + // newView.wantsLayer = true + // newView.layer?.backgroundColor = NSColor.black.cgColor + // newView.layer?.cornerRadius = 20 + // newView.frame.size = contentGroup.frame.size + // + // contentGroup.addSubview(newView) + // newView.snp.makeConstraints { make in + // make.edges.equalToSuperview() + // } + // + // splitView.addArrangedSubview(contentGroup) } override func viewDidLoad() { -// self.view.wantsLayer = true -// -//// self.view.layer?.backgroundColor = NSColor(hex: "#FF9548").cgColor -// self.view.layer?.backgroundColor = NSColor(hex: "#E7E7E7").cgColor + // self.view.wantsLayer = true + // + //// self.view.layer?.backgroundColor = NSColor(hex: "#FF9548").cgColor + // self.view.layer?.backgroundColor = NSColor(hex: "#E7E7E7").cgColor NotificationCenter.default.addObserver(self, selector: #selector(handleButtonTapped), name: .collectionButtonTapped, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(headerTappedQuickSlotManagerHandle), name: .collectionHeaderTapped, object: nil) } -// func BoxButtonViewGroupInit() -> BoxButtonViewGroup { -// -// let buttonGroup = BoxButtonViewGroup { sender in -// self.clickBtn(sender: sender) -// } -// -// return buttonGroup -// } + // func BoxButtonViewGroupInit() -> BoxButtonViewGroup { + // + // let buttonGroup = BoxButtonViewGroup { sender in + // self.clickBtn(sender: sender) + // } + // + // return buttonGroup + // } -// func clickBtn(sender: Any?) { -// if let button = sender as? NSButton { -// guard let clickCount = NSApp.currentEvent?.clickCount else { return } -// if clickCount == 2 { -// WebViewManager.shared.list[button.title]!.reload() -// print("Dobule Click") -// } else if clickCount > 2 { -// if let currentURL = WebViewManager.shared.hostingWebView?.url { -// NSWorkspace.shared.open(currentURL) -// } -// print("Triple Click") -// } else if clickCount < 2 { -// contentGroup.removeAllSubviews() -// contentGroup.showWebviews(button) -// } -// } else { -// if let str = sender as? String { -// if str == "box" { -// contentGroup.removeAllSubviews() -// print("box inside") -// } -// } -// } -// } -// -// private func leftContainerInit() { -// leftContainer.frame.size.width = BoxSizeManager.shared.windowButtonGroupSize.width -// leftContainer.frame.size.height = BoxSizeManager.shared.windowButtonGroupSize.height -// leftContainer.addSubview(windowViewGroupVC.view) -// leftContainer.addSubview(buttonGroupVC.view) -// leftContainer.addSubview(toolbarGroupVC.view) -// leftContainer.addSubview(quickSlotGroupVC.view) -// leftContainer.addSubview(functionGroupVC.view) -// -// leftContainerAutolayout() -// } -// -// private func leftContainerAutolayout() { -// windowViewGroupVC.view.snp.makeConstraints { make in -// make.top.equalTo(leftContainer) -// make.left.equalTo(leftContainer).offset(3) -// make.width.equalTo(77) -// make.height.equalTo(21) -// } -// -// toolbarGroupVC.view.snp.makeConstraints { make in -// make.top.equalTo(windowViewGroupVC.view.snp.bottom).offset(31) -// make.right.equalTo(leftContainer) -// make.left.equalTo(leftContainer) -// make.height.equalTo(44 + 14 + 24) -// } -// -// buttonGroupVC.view.snp.makeConstraints { make in -// make.top.equalTo(toolbarGroupVC.view.snp.bottom).offset(Constants.UI.groupAutolayout) -// make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) -// make.left.equalTo(leftContainer) -// make.bottom.equalTo(quickSlotGroupVC.view.snp.top).offset(-Constants.UI.groupAutolayout) -// } -// -// quickSlotGroupVC.view.snp.makeConstraints { make in -// make.bottom.equalTo(functionGroupVC.view.snp.top).offset(-27) -// make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) -// make.left.equalTo(leftContainer) -// make.height.equalTo(178) -// } -// -// functionGroupVC.view.snp.makeConstraints { make in -// make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) -// make.left.bottom.equalTo(leftContainer) -// } -// } -// -// func viewInit() { -// self.boxViewSizeInit() -// -// splitView.addArrangedSubview(leftContainer) -// splitView.addArrangedSubview(contentGroup) -// self.view.addSubview(splitView) -// -// splitView.snp.makeConstraints { make in -// make.top.equalToSuperview().offset(Constants.UI.groupAutolayout) -// make.left.equalToSuperview().offset(Constants.UI.groupAutolayout) -// make.right.equalToSuperview().offset(-Constants.UI.groupAutolayout) -// make.bottom.equalToSuperview().offset(-Constants.UI.groupAutolayout) -// } -// } -// -// func boxViewSizeInit() { -// self.view.frame.size.width = BoxSizeManager.shared.size.width -// self.view.frame.size.height = BoxSizeManager.shared.size.height -// } + // func clickBtn(sender: Any?) { + // if let button = sender as? NSButton { + // guard let clickCount = NSApp.currentEvent?.clickCount else { return } + // if clickCount == 2 { + // WebViewManager.shared.list[button.title]!.reload() + // print("Dobule Click") + // } else if clickCount > 2 { + // if let currentURL = WebViewManager.shared.hostingWebView?.url { + // NSWorkspace.shared.open(currentURL) + // } + // print("Triple Click") + // } else if clickCount < 2 { + // contentGroup.removeAllSubviews() + // contentGroup.showWebviews(button) + // } + // } else { + // if let str = sender as? String { + // if str == "box" { + // contentGroup.removeAllSubviews() + // print("box inside") + // } + // } + // } + // } + // + // private func leftContainerInit() { + // leftContainer.frame.size.width = BoxSizeManager.shared.windowButtonGroupSize.width + // leftContainer.frame.size.height = BoxSizeManager.shared.windowButtonGroupSize.height + // leftContainer.addSubview(windowViewGroupVC.view) + // leftContainer.addSubview(buttonGroupVC.view) + // leftContainer.addSubview(toolbarGroupVC.view) + // leftContainer.addSubview(quickSlotGroupVC.view) + // leftContainer.addSubview(functionGroupVC.view) + // + // leftContainerAutolayout() + // } + // + // private func leftContainerAutolayout() { + // windowViewGroupVC.view.snp.makeConstraints { make in + // make.top.equalTo(leftContainer) + // make.left.equalTo(leftContainer).offset(3) + // make.width.equalTo(77) + // make.height.equalTo(21) + // } + // + // toolbarGroupVC.view.snp.makeConstraints { make in + // make.top.equalTo(windowViewGroupVC.view.snp.bottom).offset(31) + // make.right.equalTo(leftContainer) + // make.left.equalTo(leftContainer) + // make.height.equalTo(44 + 14 + 24) + // } + // + // buttonGroupVC.view.snp.makeConstraints { make in + // make.top.equalTo(toolbarGroupVC.view.snp.bottom).offset(Constants.UI.groupAutolayout) + // make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) + // make.left.equalTo(leftContainer) + // make.bottom.equalTo(quickSlotGroupVC.view.snp.top).offset(-Constants.UI.groupAutolayout) + // } + // + // quickSlotGroupVC.view.snp.makeConstraints { make in + // make.bottom.equalTo(functionGroupVC.view.snp.top).offset(-27) + // make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) + // make.left.equalTo(leftContainer) + // make.height.equalTo(178) + // } + // + // functionGroupVC.view.snp.makeConstraints { make in + // make.right.equalTo(leftContainer).offset(-Constants.UI.groupAutolayout) + // make.left.bottom.equalTo(leftContainer) + // } + // } + // + // func viewInit() { + // self.boxViewSizeInit() + // + // splitView.addArrangedSubview(leftContainer) + // splitView.addArrangedSubview(contentGroup) + // self.view.addSubview(splitView) + // + // splitView.snp.makeConstraints { make in + // make.top.equalToSuperview().offset(Constants.UI.groupAutolayout) + // make.left.equalToSuperview().offset(Constants.UI.groupAutolayout) + // make.right.equalToSuperview().offset(-Constants.UI.groupAutolayout) + // make.bottom.equalToSuperview().offset(-Constants.UI.groupAutolayout) + // } + // } + // + // func boxViewSizeInit() { + // self.view.frame.size.width = BoxSizeManager.shared.size.width + // self.view.frame.size.height = BoxSizeManager.shared.size.height + // } } extension BoxBaseContainerViewController: NSSplitViewDelegate { - func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMinimumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat { - - if dividerIndex == 0 { - return CGFloat(132).pointsToPixels() - } - return proposedMinimumPosition - } - - func splitView(_ splitView: NSSplitView, constrainMaxCoordinate proposedMaximumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat { - if dividerIndex == 0 { - return CGFloat(302).pointsToPixels() - } - return proposedMaximumPosition + func splitView(_ splitView: NSSplitView, shouldAdjustSizeOfSubview view: NSView) -> Bool { + return false } - func splitView(_ splitView: NSSplitView, resizeSubviewsWithOldSize oldSize: NSSize) { - let dividerThickness = splitView.dividerThickness - let newWidth = splitView.frame.width - dividerThickness - - let leftWidth = leftView.frame.width - let contentWidth = newWidth - leftWidth - - leftView.frame = NSRect(x: 0, y: 0, width: leftWidth, height: splitView.bounds.height) - contentGroup.frame = NSRect(x: leftWidth + dividerThickness, y: 0, width: contentWidth, height: splitView.bounds.height) - } } extension BoxBaseContainerViewController: NSTableViewDelegate { @@ -397,9 +409,6 @@ class ButtonTableCellView: NSTableCellView { override func viewWillDraw() { super.viewWillDraw() - self.frame.size.width = 268.0 - self.frame = NSRect(x: self.frame.origin.x - 3, y: self.frame.origin.y, - width: self.frame.size.width, height: self.frame.size.height) } } @@ -413,7 +422,7 @@ extension BoxBaseContainerViewController: NSTableViewDataSource { let cellView = ButtonTableCellView() cellView.rowIndex = row - let button = DraggableButton(frame: NSRect(x: 0, y: 0, width: 300, height: 44)) + let button = DraggableButton(frame: NSRect(x: 0, y: 0, width: 268, height: 44)) button.tag = row button.bezelStyle = .inline button.isBordered = false @@ -424,7 +433,6 @@ extension BoxBaseContainerViewController: NSTableViewDataSource { button.delegate = self let label = NSTextField(frame: NSRect(x: 26 + 21 + 8, y: 25 / 2, width: button.bounds.width, height: button.bounds.height)) - label.stringValue = buttonTitleArray[row] label.backgroundColor = .clear label.isBordered = false @@ -440,7 +448,6 @@ extension BoxBaseContainerViewController: NSTableViewDataSource { label.attributedStringValue=attributedStringTitle button.addSubview(label) - // let image = NSImage(named: NSImage.Name("bookmark-default")) // image?.size = NSSize(width: 21, height: 21) // button.image = image @@ -453,16 +460,14 @@ extension BoxBaseContainerViewController: NSTableViewDataSource { imageView.imageAlignment = .alignCenter button.addSubview(imageView) - - cellView.addSubview(button) button.snp.makeConstraints { make in make.top.equalToSuperview().offset(2) make.leading.equalToSuperview() make.trailing.equalToSuperview() - // make.width.equalTo(268) - make.width.lessThanOrEqualTo(268) + make.width.equalTo(268) + // make.width.lessThanOrEqualTo(268) make.height.equalTo(44) } @@ -484,7 +489,6 @@ extension BoxBaseContainerViewController: NSTableViewDataSource { @objc func buttonClicked(_ sender: DraggableButton) { selectedButton?.layer?.backgroundColor = NSColor.clear.cgColor - // Update the reference to the currently selected button and change its background color. selectedButton = sender sender.layer?.backgroundColor = NSColor.white.cgColor @@ -519,7 +523,6 @@ extension BoxBaseContainerViewController: NSTableViewDataSource { guard let cellView = subview as? CustomTableCellView else { continue } - cellView.button.title = buttonTitleArray[cellView.rowIndex] } @@ -541,7 +544,6 @@ class DraggableButton: NSButton, NSDraggingSource { if event.locationInWindow == down.locationInWindow { self.target?.perform(self.action, with: self) } - super.mouseUp(with:event) self.mouseDownEvent = nil } diff --git a/Box42/Preferences/View/Funtion/CPUView.swift b/Box42/Preferences/View/Funtion/CPUView.swift index 74a296b..651afa6 100644 --- a/Box42/Preferences/View/Funtion/CPUView.swift +++ b/Box42/Preferences/View/Funtion/CPUView.swift @@ -13,25 +13,25 @@ class CPUView: NSView { // UI Elements private let usageLabel: NSTextField = { let label = NSTextField(labelWithString: "Usage: ") - label.font = NSFont.systemFont(ofSize: 16) + label.font = NSFont.systemFont(ofSize: 16, weight: .semibold) return label }() private let systemLabel: NSTextField = { let label = NSTextField(labelWithString: "System: ") - label.font = NSFont.systemFont(ofSize: 16) + label.font = NSFont.systemFont(ofSize: 16, weight: .semibold) return label }() private let userLabel: NSTextField = { let label = NSTextField(labelWithString: "User: ") - label.font = NSFont.systemFont(ofSize: 16) + label.font = NSFont.systemFont(ofSize: 16, weight: .semibold) return label }() private let idleLabel: NSTextField = { let label = NSTextField(labelWithString: "Idle: ") - label.font = NSFont.systemFont(ofSize: 16) + label.font = NSFont.systemFont(ofSize: 16, weight: .semibold) return label }() diff --git a/Box42/Preferences/View/Funtion/IconSettingView.swift b/Box42/Preferences/View/Funtion/IconSettingView.swift index 4993aa1..bac701a 100644 --- a/Box42/Preferences/View/Funtion/IconSettingView.swift +++ b/Box42/Preferences/View/Funtion/IconSettingView.swift @@ -38,7 +38,7 @@ class CustomSwitch: NSButton { class IconSettingView: NSView { private let iconSettingLabel: NSTextField = { let label = NSTextField(labelWithString: "아이콘 설정") - label.font = NSFont.systemFont(ofSize: 20) + label.font = NSFont.systemFont(ofSize: 20, weight: .semibold) label.isEditable = false label.isSelectable = false return label @@ -46,6 +46,7 @@ class IconSettingView: NSView { private let flipLabel: NSTextField = { let label = NSTextField(labelWithString: "아이콘 좌우반전") + label.font = NSFont.systemFont(ofSize: 14, weight: .medium) return label }() @@ -85,14 +86,14 @@ class IconSettingView: NSView { self.addSubview(speedUpSwitch) iconSettingLabel.snp.makeConstraints { (make) in - make.top.equalToSuperview().offset(10) - make.left.equalToSuperview().offset(10) - make.right.equalToSuperview().offset(-10) + make.top.equalToSuperview().offset(20) + make.leading.equalToSuperview().offset(12) + make.trailing.equalToSuperview().offset(-12) } flipLabel.snp.makeConstraints { (make) in make.top.equalTo(iconSettingLabel.snp.bottom).offset(20) - make.left.equalToSuperview().offset(10) + make.leading.equalToSuperview().offset(22) } flipSwitch.snp.makeConstraints { (make) in diff --git a/Box42/Preferences/View/Funtion/NotificationSettingView.swift b/Box42/Preferences/View/Funtion/NotificationSettingView.swift index 978df63..f7384c9 100644 --- a/Box42/Preferences/View/Funtion/NotificationSettingView.swift +++ b/Box42/Preferences/View/Funtion/NotificationSettingView.swift @@ -13,7 +13,7 @@ class NotificationSettingView: NSView { // Create a label for the title let titleLabel: NSTextField = { let label = NSTextField(labelWithString: "Box 알림 설정") - label.font = NSFont.systemFont(ofSize: 20) + label.font = NSFont.systemFont(ofSize: 20, weight: .semibold) label.isEditable = false label.isSelectable = false return label @@ -22,6 +22,9 @@ class NotificationSettingView: NSView { // Create a switch button let toggleButton: NSButton = { let toggle = NSButton(checkboxWithTitle: "알림 활성화", target: nil, action: #selector(toggleChanged)) + let titleFont = NSFont.systemFont(ofSize: 14, weight: .medium) + toggle.attributedTitle = NSAttributedString(string: toggle.title, attributes: [.font: titleFont]) + return toggle }() @@ -40,14 +43,14 @@ class NotificationSettingView: NSView { addSubview(titleLabel) titleLabel.snp.makeConstraints { make in make.top.equalTo(self).offset(20) - make.centerX.equalTo(self) + make.leading.equalToSuperview().offset(12) } // Add toggleButton to the view addSubview(toggleButton) toggleButton.snp.makeConstraints { make in make.top.equalTo(titleLabel.snp.bottom).offset(20) - make.centerX.equalTo(self) + make.leading.equalToSuperview().offset(22) } toggleButton.target = self diff --git a/Box42/Preferences/View/Funtion/RequestAccessView.swift b/Box42/Preferences/View/Funtion/RequestAccessView.swift index b95e905..22b4612 100644 --- a/Box42/Preferences/View/Funtion/RequestAccessView.swift +++ b/Box42/Preferences/View/Funtion/RequestAccessView.swift @@ -11,7 +11,7 @@ import SnapKit class RequestAccessView: NSView { private let requestAccessLabel: NSTextField = { let label = NSTextField(labelWithString: "Request Access") - label.font = NSFont.systemFont(ofSize: 20) + label.font = NSFont.systemFont(ofSize: 20, weight: .semibold) label.isEditable = false label.isSelectable = false return label @@ -24,7 +24,7 @@ class RequestAccessView: NSView { override init(frame frameRect: NSRect) { super.init(frame: .zero) self.wantsLayer = true - self.layer?.backgroundColor = NSColor(hex: "#7FFFFFFF").cgColor +// self.layer?.backgroundColor = NSColor(hex: "#7FFFFFFF").cgColor self.layer?.cornerRadius = 13 // Add subviews @@ -51,7 +51,7 @@ class RequestAccessView: NSView { func textfieldInit() { requestAccessTextField.stringValue = "Script 및 기능들을 실행하기 위해서 루트 디렉토리의 권한이 필요합니다." - requestAccessTextField.font = NSFont.systemFont(ofSize: 15) + requestAccessTextField.font = NSFont.systemFont(ofSize: 14, weight: .medium) requestAccessTextField.isEditable = false requestAccessTextField.isBordered = false requestAccessTextField.backgroundColor = NSColor.clear @@ -61,17 +61,23 @@ class RequestAccessView: NSView { func buttonInit() { grantAccessButton.title = "권한 부여" + grantAccessButton.bezelStyle = .inline + grantAccessButton.wantsLayer = true + grantAccessButton.layer?.cornerRadius = 15 grantAccessButton.target = self grantAccessButton.action = #selector(requestFolderAccess(_:)) revokeAccessButton.title = "권한 취소" + revokeAccessButton.bezelStyle = .inline + revokeAccessButton.wantsLayer = true + revokeAccessButton.layer?.cornerRadius = 15 revokeAccessButton.target = self revokeAccessButton.action = #selector(revokeFolderAccess(_:)) } func directoryNameTextFieldInit() { + directoryNameTextField.font = NSFont.systemFont(ofSize: 12, weight: .light) directoryNameTextField.stringValue = "선택된 디렉터리: 없음" - directoryNameTextField.font = NSFont.systemFont(ofSize: 15) directoryNameTextField.isEditable = false directoryNameTextField.isBordered = false directoryNameTextField.backgroundColor = NSColor.clear @@ -80,35 +86,38 @@ class RequestAccessView: NSView { func directoryNameTextFieldConstraints() { directoryNameTextField.snp.makeConstraints { make in - make.top.equalTo(revokeAccessButton.snp.bottom).offset(10) - make.leading.equalToSuperview().offset(17) - make.trailing.equalToSuperview().offset(-17) + make.top.equalTo(revokeAccessButton.snp.centerY) + make.leading.equalToSuperview().offset(30) } } func textfieldConstraints() { requestAccessLabel.snp.makeConstraints { make in - make.top.equalToSuperview().offset(10) - make.leading.equalToSuperview().offset(17) - make.trailing.equalToSuperview().offset(-17) + make.top.equalToSuperview().offset(20) + make.leading.equalToSuperview().offset(12) + make.trailing.equalToSuperview().offset(-12) } requestAccessTextField.snp.makeConstraints { make in - make.top.equalTo(requestAccessLabel.snp.bottom).offset(10) - make.leading.equalToSuperview().offset(17) - make.trailing.equalToSuperview().offset(-17) + make.top.equalTo(requestAccessLabel.snp.bottom).offset(20) + make.leading.equalToSuperview().offset(22) + make.trailing.equalToSuperview().offset(-22) } } func buttonConstraints() { grantAccessButton.snp.makeConstraints { make in - make.top.equalTo(requestAccessTextField.snp.bottom).offset(10) - make.leading.equalToSuperview().offset(17) + make.top.equalTo(requestAccessTextField.snp.bottom).offset(20) + make.trailing.equalTo(revokeAccessButton.snp.leading).offset(-10) + make.width.equalTo(70) + make.height.equalTo(30) } revokeAccessButton.snp.makeConstraints { make in - make.top.equalTo(requestAccessTextField.snp.bottom).offset(10) - make.leading.equalTo(grantAccessButton.snp.trailing).offset(10) + make.top.equalTo(requestAccessTextField.snp.bottom).offset(20) + make.trailing.equalTo(requestAccessLabel.snp.trailing).offset(0) + make.width.equalTo(70) + make.height.equalTo(30) } } @@ -121,13 +130,22 @@ class RequestAccessView: NSView { openPanel.canCreateDirectories = true openPanel.allowsMultipleSelection = false openPanel.canChooseFiles = false +// openPanel.level = .popUpMenu +// openPanel.begin { (result) in +// if result == .OK { +//// completionHandler(openPanel.urls) +// } else { +//// completionHandler(nil) +// } +// } if openPanel.runModal() == NSApplication.ModalResponse.OK { let result = openPanel.url - + if let result = result { print("Selected folder is \(result.path)") - + +// directoryNameTextField.font = NSFont.systemFont(ofSize: 12, weight: .light) directoryNameTextField.stringValue = "선택된 디렉터리: \(result.path)" do { diff --git a/Box42/Preferences/View/Funtion/ShortcutSettingView.swift b/Box42/Preferences/View/Funtion/ShortcutSettingView.swift index f626c65..d635ee7 100644 --- a/Box42/Preferences/View/Funtion/ShortcutSettingView.swift +++ b/Box42/Preferences/View/Funtion/ShortcutSettingView.swift @@ -13,7 +13,7 @@ class ShortcutSettingView: NSView { // Create a label for the title let titleLabel: NSTextField = { let label = NSTextField(labelWithString: "앱 내부 단축키 설정") - label.font = NSFont.systemFont(ofSize: 20) + label.font = NSFont.systemFont(ofSize: 20, weight: .semibold) label.isEditable = false label.isSelectable = false return label @@ -34,45 +34,49 @@ class ShortcutSettingView: NSView { ] lazy var stackView: NSStackView = { - let stackView = NSStackView() - stackView.orientation = .vertical - stackView.distribution = .fillEqually - stackView.spacing = 20 - - var subStackView: NSStackView? + let stackView = NSStackView() + stackView.orientation = .vertical + stackView.distribution = .fillEqually + stackView.spacing = 20 + + var subStackView: NSStackView? + + for (index, (labelText, defaultKey)) in shortcutSettings.enumerated() { + let label = NSTextField(labelWithString: labelText) + label.font = NSFont.systemFont(ofSize: 14, weight: .medium) + label.isEditable = false + label.isSelectable = false + let textField = NSTextField() + textField.placeholderString = defaultKey + textField.snp.makeConstraints { make in + make.width.equalTo(50) + } - for (index, (labelText, defaultKey)) in shortcutSettings.enumerated() { - let label = NSTextField(labelWithString: labelText) - label.isEditable = false - label.isSelectable = false - let textField = NSTextField() - textField.placeholderString = defaultKey + if index == 0 || index == 1 { + let innerStackView = NSStackView(views: [label, textField]) + innerStackView.distribution = .fillProportionally + stackView.addArrangedSubview(innerStackView) + } else { + if index == 2 || index == 6 { + subStackView = NSStackView() + subStackView?.orientation = .horizontal + subStackView?.distribution = .fillEqually + subStackView?.spacing = 20 + } + + let innerStackView = NSStackView(views: [label, textField]) + innerStackView.distribution = .fillProportionally - if index == 0 || index == 1 { - let innerStackView = NSStackView(views: [label, textField]) - innerStackView.distribution = .fillProportionally - stackView.addArrangedSubview(innerStackView) - } else { - if index == 2 || index == 6 { - subStackView = NSStackView() - subStackView?.orientation = .horizontal - subStackView?.distribution = .fillEqually - subStackView?.spacing = 20 - } - - let innerStackView = NSStackView(views: [label, textField]) - innerStackView.distribution = .fillProportionally - - subStackView?.addArrangedSubview(innerStackView) - - if index == 4 || index == 8 { - stackView.addArrangedSubview(subStackView!) - } + subStackView?.addArrangedSubview(innerStackView) + + if index == 4 || index == 8 { + stackView.addArrangedSubview(subStackView!) } } - - return stackView - }() + } + + return stackView + }() override init(frame frameRect: NSRect) { super.init(frame: frameRect) @@ -89,17 +93,15 @@ class ShortcutSettingView: NSView { addSubview(titleLabel) titleLabel.snp.makeConstraints { make in make.top.equalTo(self).offset(20) - make.centerX.equalTo(self) + make.leading.equalToSuperview().offset(12) } // Add stackView to the view addSubview(stackView) stackView.snp.makeConstraints { make in make.top.equalTo(titleLabel.snp.bottom).offset(20) - make.left.equalTo(self).offset(20) - make.right.equalTo(self).offset(-20) + make.leading.equalToSuperview().offset(22) + make.trailing.equalToSuperview().offset(-22) } } - - // Further actions like saving the shortcuts, adding validations can be implemented } diff --git a/Box42/Preferences/View/Funtion/StorageView.swift b/Box42/Preferences/View/Funtion/StorageView.swift index 9a72a30..953fe24 100644 --- a/Box42/Preferences/View/Funtion/StorageView.swift +++ b/Box42/Preferences/View/Funtion/StorageView.swift @@ -42,24 +42,28 @@ class StorageView: NSView { func initTextFields() { // Initialize textfields - currentStorageTextField.stringValue = "Current Storage: ?? GB" - remainingStorageTextField.stringValue = "Remaining Storage: ?? GB" - totalStorageTextField.stringValue = "Total Storage: ?? GB" + let labels = [currentStorageTextField, remainingStorageTextField, totalStorageTextField, thresholdTextField, intervalTextField] + for label in labels { + label.font = NSFont.systemFont(ofSize: 14, weight: .semibold) + label.isEditable = false + label.isBordered = false + label.backgroundColor = NSColor.clear + } + currentStorageTextField.stringValue = "Current Storage : ?? GB" + remainingStorageTextField.stringValue = "Remaining Storage : ?? GB" + totalStorageTextField.stringValue = "Total Storage : ?? GB" thresholdTextField.placeholderString = "Enter threshold (%)" intervalTextField.placeholderString = "Enter interval (seconds)" - - [currentStorageTextField, remainingStorageTextField, totalStorageTextField, thresholdTextField, intervalTextField].forEach { textField in - textField.isEditable = false - textField.isBordered = false - textField.backgroundColor = NSColor.clear - } - + intervalTextField.isEditable = true thresholdTextField.isEditable = true } func initButton() { executeScriptButton.title = "Run Script" + executeScriptButton.bezelStyle = .inline + executeScriptButton.wantsLayer = true + executeScriptButton.layer?.cornerRadius = 15 executeScriptButton.target = self executeScriptButton.action = #selector(runScript(_:)) } @@ -95,8 +99,10 @@ class StorageView: NSView { } executeScriptButton.snp.makeConstraints { make in - make.top.equalTo(intervalTextField.snp.bottom).offset(20) + make.top.equalTo(intervalTextField.snp.bottom).offset(0) // 여기에 20을 추가합니다. make.leading.equalToSuperview().offset(20) + make.width.equalTo(70) + make.height.equalTo(30) } } diff --git a/Box42/Preferences/View/Table/PreferencesTableView.swift b/Box42/Preferences/View/Table/PreferencesTableView.swift index 9c8119f..a0427b4 100644 --- a/Box42/Preferences/View/Table/PreferencesTableView.swift +++ b/Box42/Preferences/View/Table/PreferencesTableView.swift @@ -58,14 +58,17 @@ class PreferencesTableView: NSTableView { self.delegate = self self.dataSource = self + self.headerView = nil + self.selectionHighlightStyle = .none + + self.backgroundColor = .white + if #available(macOS 10.14, *) { + self.appearance = NSAppearance(named: .aqua) + } + let column1 = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("Preferences")) - column1.width = 100.0 - column1.title = "Preferences" self.addTableColumn(column1) - -// self.selectionHighlightStyle = .none } - } extension PreferencesTableView: NSTableViewDelegate, NSTableViewDataSource { diff --git a/Box42/QuickSlot/Controller/QuickSlotManagerViewController.swift b/Box42/QuickSlot/Controller/QuickSlotManagerViewController.swift index 18a9f47..84363fc 100644 --- a/Box42/QuickSlot/Controller/QuickSlotManagerViewController.swift +++ b/Box42/QuickSlot/Controller/QuickSlotManagerViewController.swift @@ -21,6 +21,7 @@ class QuickSlotManagerViewController: NSViewController { quickSlotManagerTableView = QuickSlotTableView(frame: .zero) quickSlotManagerTableView?.setup() quickSlotManagerTableView?.viewModel = viewModel + quickSlotManagerTableView?.backgroundColor = .white let scrollView = NSScrollView() scrollView.documentView = quickSlotManagerTableView diff --git a/Box42/QuickSlot/View/ButtonCollectionView/QuickSlotButtonCollectionViewController.swift b/Box42/QuickSlot/View/ButtonCollectionView/QuickSlotButtonCollectionViewController.swift index 9b5ebfc..4c9b310 100644 --- a/Box42/QuickSlot/View/ButtonCollectionView/QuickSlotButtonCollectionViewController.swift +++ b/Box42/QuickSlot/View/ButtonCollectionView/QuickSlotButtonCollectionViewController.swift @@ -107,6 +107,8 @@ extension QuickSlotButtonCollectionViewController: NSCollectionViewDelegate, NSC btn.snp.makeConstraints { make in make.left.top.right.equalToSuperview() +// make.width.equalTo(58) + make.height.equalTo(58) } label.snp.makeConstraints { make in @@ -117,6 +119,21 @@ extension QuickSlotButtonCollectionViewController: NSCollectionViewDelegate, NSC } return item } +// func collectionView(_ collectionView: NSCollectionView, mouseEnteredAt indexPath: IndexPath) { +// // 호버 효과를 적용하려는 코드 +// if let item = collectionView.item(at: indexPath) as? QuickSlotButtonViewItem, +// let button = item.view.subviews.first as? QuickSlotItemButton { +// button.mouseEntered(with: NSEvent()) // 호버 효과 메서드 호출 +// } +// } +// +// func collectionView(_ collectionView: NSCollectionView, mouseExitedAt indexPath: IndexPath) { +// // 호버 효과를 해제하려는 코드 +// if let item = collectionView.item(at: indexPath) as? QuickSlotButtonViewItem, +// let button = item.view.subviews.first as? QuickSlotItemButton { +// button.mouseExited(with: NSEvent()) // 호버 효과 해제 메서드 호출 +// } +// } } extension QuickSlotButtonCollectionViewController { diff --git a/Box42/QuickSlot/View/ButtonCollectionView/Vertical Item/QuickSlotItemButton.swift b/Box42/QuickSlot/View/ButtonCollectionView/Vertical Item/QuickSlotItemButton.swift index 8fdaf8c..d225eb7 100644 --- a/Box42/QuickSlot/View/ButtonCollectionView/Vertical Item/QuickSlotItemButton.swift +++ b/Box42/QuickSlot/View/ButtonCollectionView/Vertical Item/QuickSlotItemButton.swift @@ -27,13 +27,41 @@ class QuickSlotItemButton: NSButton { } else if buttonModel.type == "default-pref" { self.image = NSImage(imageLiteralResourceName: "setting") } + self.target = self + self.action = #selector(mouseEntered) self.isBordered = false self.wantsLayer = true - self.layer?.backgroundColor = NSColor.clear.cgColor + self.layer?.backgroundColor = NSColor.white.cgColor // 흰색 배경 색상 + self.layer?.cornerRadius = 8.0 + self.layer?.zPosition = 1 + let trackingArea = NSTrackingArea( + rect: self.bounds, // 뷰의 경계를 기준으로 할 경우 + options: [.mouseEnteredAndExited, .activeAlways], + owner: self, + userInfo: nil + ) + self.addTrackingArea(trackingArea) + self.associatedString = buttonModel.path } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } + + override func mouseEntered(with event: NSEvent) { + super.mouseEntered(with: event) + + self.wantsLayer = true +// self.layer?.frame.size = CGSize(width: 58.0, height: 58.0) + self.layer?.backgroundColor = NSColor(red: 0.848, green: 0.848, blue: 0.848, alpha: 1).cgColor + } + + override func mouseExited(with event: NSEvent) { + super.mouseExited(with: event) + + wantsLayer = true +// layer?.frame.size = CGSize(width: 58.0, height: 58.0) + layer?.backgroundColor = NSColor.white.cgColor + } } diff --git a/Box42/QuickSlot/View/QuickSlotGroupView.swift b/Box42/QuickSlot/View/QuickSlotGroupView.swift index d6238eb..785a196 100644 --- a/Box42/QuickSlot/View/QuickSlotGroupView.swift +++ b/Box42/QuickSlot/View/QuickSlotGroupView.swift @@ -10,7 +10,7 @@ import SnapKit class QuickSlotGroupView: NSView { - lazy var divider: NSBox = Divider(completion: { [weak self] in self?.dividerAction?() }) +// 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 buttonCollectionView: QuickSlotButtonCollectionViewController = QuickSlotButtonCollectionViewController() @@ -30,16 +30,16 @@ class QuickSlotGroupView: NSView { } private func setupViews() { - self.addSubview(divider) +// self.addSubview(divider) self.addSubview(headerView) self.addSubview(buttonCollectionView.view) } private func setupConstraints() { - divider.snp.makeConstraints { make in - make.top.equalToSuperview() - make.left.right.equalToSuperview() - } +// divider.snp.makeConstraints { make in +// make.top.equalToSuperview() +// make.left.right.equalToSuperview() +// } headerView.snp.makeConstraints { make in make.top.equalToSuperview() diff --git a/Box42/QuickSlot/View/QuickSlotHeaderView.swift b/Box42/QuickSlot/View/QuickSlotHeaderView.swift index 341bc48..da5e6ae 100644 --- a/Box42/QuickSlot/View/QuickSlotHeaderView.swift +++ b/Box42/QuickSlot/View/QuickSlotHeaderView.swift @@ -11,51 +11,51 @@ import SnapKit class QuickSlotHeaderView: NSView { private var callback: (() -> Void)? - private var quickSlotHeaderButton: NSButton! + // private var quickSlotHeaderButton: NSButton! + private var quickSlotIcon: NSImageView! private var quickSlotHeaderLabel: NSTextField! private var quickSlotManageButton: NSButton! init(image: NSImage, completion: @escaping () -> Void) { super.init(frame: .zero) - quickSlotHeaderButton = NSButton(image: image, target: self, action: #selector(btnAction)) - quickSlotHeaderButton.isBordered = false - quickSlotHeaderButton.wantsLayer = true - quickSlotHeaderButton.layer?.backgroundColor = NSColor.clear.cgColor + quickSlotIcon = NSImageView() + quickSlotIcon.image = image + quickSlotIcon.image?.size = NSSize(width: 18, height: 18) + self.addSubview(quickSlotIcon) - self.addSubview(quickSlotHeaderButton) - - quickSlotHeaderLabel = NSTextField(labelWithString: "Quick Slot") - quickSlotHeaderLabel.font = NSFont(name: "Inter", size: QuickSlotUI.size.font) - quickSlotHeaderLabel.textColor = NSColor(hex: "#696969") + quickSlotHeaderLabel = NSTextField(labelWithString: "퀵슬롯") + quickSlotHeaderLabel.font = NSFont.boldSystemFont(ofSize: 16) + quickSlotHeaderLabel.textColor = NSColor.black quickSlotHeaderLabel.backgroundColor = NSColor.clear quickSlotHeaderLabel.isBordered = false - self.addSubview(quickSlotHeaderLabel) - quickSlotManageButton = NSButton(image: NSImage(imageLiteralResourceName: "add"), target: self, action: #selector(btnAction)) + let buttonImage = NSImage(named: NSImage.Name("add"))! + buttonImage.size = NSSize(width: 24, height: 24) + quickSlotManageButton = NSButton(image: buttonImage, target: self, action: #selector(btnAction)) + quickSlotManageButton.setButtonType(.momentaryChange) + quickSlotManageButton.bezelStyle = .texturedRounded quickSlotManageButton.isBordered = false quickSlotManageButton.wantsLayer = true quickSlotManageButton.layer?.backgroundColor = NSColor.clear.cgColor - self.addSubview(quickSlotManageButton) - - quickSlotHeaderButton.snp.makeConstraints { make in + + quickSlotIcon.snp.makeConstraints { make in make.left.equalToSuperview() - make.top.equalToSuperview().offset(13) + make.centerY.equalToSuperview() } quickSlotHeaderLabel.snp.makeConstraints { make in - make.left.equalTo(quickSlotHeaderButton.snp.right).offset(4) - make.bottom.equalTo(quickSlotHeaderButton.snp.bottom) + make.left.equalTo(quickSlotIcon.snp.right).offset(8) + make.centerY.equalToSuperview() } quickSlotManageButton.snp.makeConstraints { make in make.right.equalToSuperview() - make.bottom.equalTo(quickSlotHeaderLabel.snp.bottom) + make.centerY.equalToSuperview() } - self.callback = completion } diff --git a/Box42/QuickSlot/View/Table/QuickSlotCell.swift b/Box42/QuickSlot/View/Table/QuickSlotCell.swift index 89e6deb..dcaaf24 100644 --- a/Box42/QuickSlot/View/Table/QuickSlotCell.swift +++ b/Box42/QuickSlot/View/Table/QuickSlotCell.swift @@ -28,6 +28,17 @@ class QuickSlotCell: NSTableCellView { } private func setupUI() { + let labels = [titleLabel, pathLabel, typeLabel] + for label in labels { + label.wantsLayer = true + label.layer?.cornerRadius = 15 + label.layer?.borderColor = NSColor(red: 0.781, green: 0.781, blue: 0.781, alpha: 1).cgColor + label.layer?.borderWidth = 1 + + label.font = NSFont.systemFont(ofSize: 16, weight: .medium) + label.textColor = NSColor.black + } + addSubview(imageButton) addSubview(titleLabel) addSubview(pathLabel) @@ -44,25 +55,29 @@ class QuickSlotCell: NSTableCellView { deleteButton.snp.makeConstraints { make in make.right.equalToSuperview().offset(-8) make.centerY.equalToSuperview() - make.height.equalToSuperview() + make.width.equalTo(100) + make.height.equalTo(50) } titleLabel.snp.makeConstraints { make in make.left.equalTo(imageButton.snp.right).offset(8) make.right.equalTo(deleteButton.snp.left).offset(-8) make.top.equalTo(imageButton) + make.height.equalTo(30) } pathLabel.snp.makeConstraints { make in make.left.equalTo(titleLabel) make.right.equalTo(deleteButton.snp.left).offset(-8) make.top.equalTo(titleLabel.snp.bottom).offset(4) + make.height.equalTo(30) } typeLabel.snp.makeConstraints { make in make.left.equalTo(pathLabel) make.right.equalTo(deleteButton.snp.left).offset(-8) make.top.equalTo(pathLabel.snp.bottom).offset(4) + make.height.equalTo(30) } } diff --git a/Box42/QuickSlot/View/Table/QuickSlotCellDeleteButton.swift b/Box42/QuickSlot/View/Table/QuickSlotCellDeleteButton.swift index 9db5098..20d53a9 100644 --- a/Box42/QuickSlot/View/Table/QuickSlotCellDeleteButton.swift +++ b/Box42/QuickSlot/View/Table/QuickSlotCellDeleteButton.swift @@ -8,15 +8,19 @@ import AppKit class QuickSlotCellDeleteButton: NSButton { - init() { - super.init(frame: NSRect(x: 0, y: 0, width: 53, height: 100)) - - self.title = "퀵슬롯에서\n제거" + super.init(frame: NSRect(x: 0, y: 0, width: 0, height: 0)) + self.title = "삭제" + let attributes: [NSAttributedString.Key: Any] = [ + .font: NSFont.systemFont(ofSize: 14, weight: .medium), + .foregroundColor: NSColor.white + ] + let attributedTitle = NSAttributedString(string: title, attributes: attributes) + self.attributedTitle = attributedTitle self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = 15 + self.layer?.backgroundColor = NSColor.red.cgColor } override func layout() { @@ -37,40 +41,12 @@ class QuickSlotCellDeleteButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.toValue = WindowButtonUI.color.close - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.close - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 + self.layer?.backgroundColor = NSColor(red: 1, green: 0, blue: 0, alpha: 0.5).cgColor } override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.close - bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = NSColor.red.cgColor } } diff --git a/Box42/QuickSlot/View/Table/QuickSlotTableView.swift b/Box42/QuickSlot/View/Table/QuickSlotTableView.swift index 7fbf7b5..bf9f054 100644 --- a/Box42/QuickSlot/View/Table/QuickSlotTableView.swift +++ b/Box42/QuickSlot/View/Table/QuickSlotTableView.swift @@ -32,10 +32,11 @@ class QuickSlotTableView: NSTableView { func setup() { self.delegate = self self.dataSource = self + + self.headerView = nil + self.selectionHighlightStyle = .none let column1 = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("QuickSlots")) - column1.width = 100.0 - column1.title = "QuickSlot" self.addTableColumn(column1) } } @@ -69,10 +70,20 @@ extension QuickSlotTableView: NSTableViewDelegate, NSTableViewDataSource { } func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { - getCellForRow(at: row) +// getCellForRow(at: row) + let cellView = getCellForRow(at: row) + + // Remove the top border line for the first row (index 0) + if row == 0 { + let topBorder = CALayer() + topBorder.backgroundColor = NSColor.clear.cgColor + cellView.layer?.addSublayer(topBorder) + } + + return cellView } func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat { - return 200 + return 120 } } diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon.png b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 1.png similarity index 100% rename from Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon.png rename to Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 1.png diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 2.png b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 2.png new file mode 100644 index 0000000..fa00ba0 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 2.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 3.png b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 3.png new file mode 100644 index 0000000..fa00ba0 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Bookmark icon 3.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Contents.json index c1d7e62..7c379d1 100644 --- a/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Contents.json +++ b/Box42/Resources/Assets.xcassets/uibuttons/Bookmark.imageset/Contents.json @@ -1,15 +1,17 @@ { "images" : [ { + "filename" : "Bookmark icon 3.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "bookmark icon.png", + "filename" : "Bookmark icon 2.png", "idiom" : "universal", "scale" : "2x" }, { + "filename" : "Bookmark icon 1.png", "idiom" : "universal", "scale" : "3x" } diff --git a/Box42/Scripts/View/Button/ScriptDeleteButton.swift b/Box42/Scripts/View/Button/ScriptDeleteButton.swift index 3d592c8..26a9f5a 100644 --- a/Box42/Scripts/View/Button/ScriptDeleteButton.swift +++ b/Box42/Scripts/View/Button/ScriptDeleteButton.swift @@ -13,10 +13,16 @@ class ScriptDeleteButton: NSButton { super.init(frame: NSRect(x: 0, y: 0, width: 53, height: 40)) self.title = "삭제" + let attributes: [NSAttributedString.Key: Any] = [ + .font: NSFont.systemFont(ofSize: 13, weight: .medium), + .foregroundColor: NSColor.white + ] + let attributedTitle = NSAttributedString(string: title, attributes: attributes) + self.attributedTitle = attributedTitle self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = 15 + self.layer?.backgroundColor = NSColor.red.cgColor let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil) self.addTrackingArea(trackingArea) @@ -28,41 +34,13 @@ class ScriptDeleteButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.toValue = WindowButtonUI.color.close - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.close - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 + + self.layer?.backgroundColor = NSColor.red.withAlphaComponent(0.5).cgColor } override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) - - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.close - bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.duration = WindowButtonUI.animation.duration - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = NSColor.red.cgColor } } diff --git a/Box42/Scripts/View/Button/ScriptExcuteButton.swift b/Box42/Scripts/View/Button/ScriptExcuteButton.swift index e6d3b0c..54f4969 100644 --- a/Box42/Scripts/View/Button/ScriptExcuteButton.swift +++ b/Box42/Scripts/View/Button/ScriptExcuteButton.swift @@ -13,10 +13,16 @@ class ScriptExcuteButton: NSButton { super.init(frame: NSRect(x: 0, y: 0, width: 70, height: 40)) self.title = "실행하기" + let attributes: [NSAttributedString.Key: Any] = [ + .font: NSFont.systemFont(ofSize: 13, weight: .medium), + .foregroundColor: NSColor.white + ] + let attributedTitle = NSAttributedString(string: title, attributes: attributes) + self.attributedTitle = attributedTitle self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = 15 + self.layer?.backgroundColor = NSColor(hex: "#008000").cgColor let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil) self.addTrackingArea(trackingArea) @@ -29,40 +35,12 @@ class ScriptExcuteButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.toValue = WindowButtonUI.color.maximize - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.maximize - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 + self.layer?.backgroundColor = NSColor(hex: "#008000").withAlphaComponent(0.5).cgColor } override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.maximize - bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = NSColor(hex: "#008000").cgColor } } diff --git a/Box42/Scripts/View/Button/ScriptQuickSlotButton.swift b/Box42/Scripts/View/Button/ScriptQuickSlotButton.swift index e2351d7..7e3268c 100644 --- a/Box42/Scripts/View/Button/ScriptQuickSlotButton.swift +++ b/Box42/Scripts/View/Button/ScriptQuickSlotButton.swift @@ -13,10 +13,16 @@ class ScriptQuickSlotButton: NSButton { super.init(frame: NSRect(x: 0, y: 0, width: 53, height: 40)) self.title = "퀵슬롯" + let attributes: [NSAttributedString.Key: Any] = [ + .font: NSFont.systemFont(ofSize: 13, weight: .medium), + .foregroundColor: NSColor.white + ] + let attributedTitle = NSAttributedString(string: title, attributes: attributes) + self.attributedTitle = attributedTitle self.isBordered = false self.wantsLayer = true - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite + self.layer?.cornerRadius = 15 + self.layer?.backgroundColor = NSColor(hex: "#FFCE51").cgColor let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil) self.addTrackingArea(trackingArea) @@ -29,41 +35,13 @@ class ScriptQuickSlotButton: NSButton { override func mouseEntered(with event: NSEvent) { super.mouseEntered(with: event) - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.toValue = WindowButtonUI.color.minimize - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.minimize - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2 + self.layer?.backgroundColor = NSColor(hex: "#FFCE51").withAlphaComponent(0.5).cgColor } override func mouseExited(with event: NSEvent) { super.mouseExited(with: event) - let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor") - bgColorAnimation.fromValue = WindowButtonUI.color.minimize - bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite - bgColorAnimation.duration = WindowButtonUI.animation.duration - - let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius") - cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2 - cornerAnimation.toValue = WindowButtonUI.size.cornerRadius - cornerAnimation.duration = WindowButtonUI.animation.duration - - self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation") - self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation") - - self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite - self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius + self.layer?.backgroundColor = NSColor(hex: "#FFCE51").cgColor } override func mouseDown(with event: NSEvent) { diff --git a/Box42/Scripts/View/Table/ScriptCell.swift b/Box42/Scripts/View/Table/ScriptCell.swift index 251e194..b7f5b0b 100644 --- a/Box42/Scripts/View/Table/ScriptCell.swift +++ b/Box42/Scripts/View/Table/ScriptCell.swift @@ -28,6 +28,17 @@ class ScriptCell: NSTableCellView { } private func setupUI() { + let labels = [nameLabel, descriptionLabel] + for label in labels { + label.wantsLayer = true + label.layer?.cornerRadius = 15 + label.layer?.borderColor = NSColor(red: 0.781, green: 0.781, blue: 0.781, alpha: 1).cgColor + label.layer?.borderWidth = 1 + + label.font = NSFont.systemFont(ofSize: 16, weight: .medium) + label.textColor = NSColor.black + } + addSubview(nameLabel) addSubview(descriptionLabel) addSubview(quickSlotButton) @@ -38,13 +49,24 @@ class ScriptCell: NSTableCellView { make.centerY.equalToSuperview() make.left.equalToSuperview().offset(16) make.width.lessThanOrEqualTo(200).priority(.high) // 최대 너비와 우선순위 설정 + make.height.equalTo(30) + } + + descriptionLabel.snp.makeConstraints { make in + make.centerY.equalToSuperview() + make.left.equalTo(nameLabel.snp.right).offset(8) + make.right.lessThanOrEqualTo(quickSlotButton.snp.left).offset(-8) + make.width.greaterThanOrEqualTo(100).priority(.low) // 최소 너비와 낮은 우선순위 설정 + make.height.equalTo(30) } + deleteButton.snp.makeConstraints { make in make.centerY.equalToSuperview() make.right.equalToSuperview().offset(-16) make.width.equalTo(53) make.height.equalTo(40) + } excuteButton.snp.makeConstraints { make in @@ -60,13 +82,6 @@ class ScriptCell: NSTableCellView { make.width.equalTo(53) make.height.equalTo(40) } - - descriptionLabel.snp.makeConstraints { make in - make.centerY.equalToSuperview() - make.left.equalTo(nameLabel.snp.right).offset(8) - make.right.lessThanOrEqualTo(quickSlotButton.snp.left).offset(-8) - make.width.greaterThanOrEqualTo(100).priority(.low) // 최소 너비와 낮은 우선순위 설정 - } } diff --git a/Box42/Scripts/View/Table/ScriptsTableView.swift b/Box42/Scripts/View/Table/ScriptsTableView.swift index ccb1343..b312a51 100644 --- a/Box42/Scripts/View/Table/ScriptsTableView.swift +++ b/Box42/Scripts/View/Table/ScriptsTableView.swift @@ -33,9 +33,12 @@ class ScriptsTableView: NSTableView { self.delegate = self self.dataSource = self + self.headerView = nil + self.selectionHighlightStyle = .none + + self.backgroundColor = .white + let column1 = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("Scripts")) - column1.width = 100.0 - column1.title = "Scripts" self.addTableColumn(column1) } } diff --git a/Box42/Toolbar/Controller/ToolbarViewController.swift b/Box42/Toolbar/Controller/ToolbarViewController.swift index 45d74e0..50a77ae 100644 --- a/Box42/Toolbar/Controller/ToolbarViewController.swift +++ b/Box42/Toolbar/Controller/ToolbarViewController.swift @@ -19,27 +19,60 @@ class ToolbarViewController: NSViewController { self.view = toolbarViewGroup } - + var baseContainerVC: BoxBaseContainerViewController? + var toolbarViewGroup: BoxToolbarViewGroup? override func viewDidLoad() { super.viewDidLoad() - // Do view setup here. + + toolbarViewGroup = BoxToolbarViewGroup() + toolbarViewGroup?.sidebar = sidebar } -// func runPrefsHelperApplication() { -// let prefsHelperAppPath = "/Users/daskim/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)") -// } -// } + // func runPrefsHelperApplication() { + // let prefsHelperAppPath = "/Users/daskim/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)") + // } + // } + + + lazy var sidebarLeading: SideBarLeading = SideBarLeading(image: NSImage(imageLiteralResourceName: "toggle-on"), completion: { [weak self] in self?.sidebar() }) func sidebar() { - print("sidebar") + toolbarViewGroup = BoxToolbarViewGroup() + if let baseContainerVC = baseContainerVC { + baseContainerVC.leftView.isHidden.toggle() + + if baseContainerVC.leftView.isHidden { + baseContainerVC.contentGroup.snp.remakeConstraints { make in + 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) + make.leading.equalToSuperview().inset(12) + make.width.equalTo(24) + make.height.equalTo(24) + } + } else { + baseContainerVC.contentGroup.snp.remakeConstraints { make in + make.top.bottom.trailing.equalToSuperview().inset(12) + make.leading.equalTo(baseContainerVC.leftView.snp.trailing) + } + sidebarLeading.removeFromSuperview() + } + + // 제약 조건을 다시 설정 + baseContainerVC.view.layoutSubtreeIfNeeded() + } } func goBack() { diff --git a/Box42/Toolbar/View/BoxToolbarViewGroup.swift b/Box42/Toolbar/View/BoxToolbarViewGroup.swift index 00628df..22d9a6c 100644 --- a/Box42/Toolbar/View/BoxToolbarViewGroup.swift +++ b/Box42/Toolbar/View/BoxToolbarViewGroup.swift @@ -22,10 +22,13 @@ class BoxToolbarViewGroup: NSView { var goToHome: (() -> Void)? var sidebar: (() -> Void)? + var toolbarGroupVC: ToolbarViewController = ToolbarViewController() override init(frame: NSRect) { super.init(frame: frame) setupViews() setupConstraints() + + toolbarGroupVC.toolbarViewGroup = self } required init?(coder: NSCoder) { diff --git a/Box42/Toolbar/View/SideBarLeading.swift b/Box42/Toolbar/View/SideBarLeading.swift index c177e12..11b81eb 100644 --- a/Box42/Toolbar/View/SideBarLeading.swift +++ b/Box42/Toolbar/View/SideBarLeading.swift @@ -63,7 +63,7 @@ class SideBarLeading: NSButton { @objc func sideBarLeading() { - runPrefsHelperApplication() +// runPrefsHelperApplication() callback?() } }