diff --git a/Box42/FunctionButton/Model/FunctionButtonUI.swift b/Box42/FunctionButton/Model/FunctionButtonUI.swift new file mode 100644 index 0000000..ebad572 --- /dev/null +++ b/Box42/FunctionButton/Model/FunctionButtonUI.swift @@ -0,0 +1,21 @@ +// +// FunctionButtonUI.swift +// Box42 +// +// Created by Chanhee Kim on 8/27/23. +// + +import AppKit + +struct FunctionButtonUI { + struct size { + static let font: CGFloat = 14 + } + + struct animation { + } + + struct color { + static let pinText = NSColor(hex: "#696969") + } +} diff --git a/Box42/FunctionButton/View/BoxFunctionViewGroup.swift b/Box42/FunctionButton/View/BoxFunctionViewGroup.swift index 2570826..60a96bd 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"), completion: { self.pinAction?() }) + lazy var pinButton: PinButtonView = PinButtonView(image: NSImage(imageLiteralResourceName: "Pin icon"), 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?() }) lazy var divider: NSBox = TopDivider(completion: { self.dividerAction?() }) @@ -47,29 +47,29 @@ class BoxFunctionViewGroup: NSView { make.left.right.equalToSuperview() } - preferenceButton.snp.makeConstraints { make in + pinButton.snp.makeConstraints { make in make.top.equalTo(divider).offset(10) make.bottom.equalToSuperview() make.left.equalToSuperview() make.width.equalTo(pinButton) } - pinButton.snp.makeConstraints { make in - make.top.bottom.equalTo(preferenceButton) - make.left.equalTo(preferenceButton.snp.right).offset(10) - make.width.equalTo(quitButton) - } - - quitButton.snp.makeConstraints { make in - make.top.bottom.equalTo(preferenceButton) - make.left.equalTo(pinButton.snp.right).offset(10) - make.width.equalTo(boxButton) - } - - boxButton.snp.makeConstraints { make in - make.top.bottom.equalTo(preferenceButton) - make.left.equalTo(quitButton.snp.right).offset(10) - make.right.equalToSuperview() - } +// preferenceButton.snp.makeConstraints { make in +// make.top.bottom.equalTo(pinButton) +// make.left.equalTo(pinButton.snp.right).offset(10) +// make.width.equalTo(quitButton) +// } +// +// quitButton.snp.makeConstraints { make in +// make.top.bottom.equalTo(pinButton) +// make.left.equalTo(preferenceButton.snp.right).offset(10) +// make.width.equalTo(boxButton) +// } +// +// boxButton.snp.makeConstraints { make in +// make.top.bottom.equalTo(pinButton) +// make.left.equalTo(quitButton.snp.right).offset(10) +// make.right.equalToSuperview() +// } } } diff --git a/Box42/FunctionButton/View/PinButtonView.swift b/Box42/FunctionButton/View/PinButtonView.swift index f80e9d3..ddaa1a4 100644 --- a/Box42/FunctionButton/View/PinButtonView.swift +++ b/Box42/FunctionButton/View/PinButtonView.swift @@ -10,17 +10,33 @@ import AppKit class PinButtonView: NSButton { private var callback: (() -> Void)? + private var pinBoxLabel: NSTextField! init(image: NSImage, completion: @escaping () -> Void) { super.init(frame: .zero) self.image = image - self.isBordered = false // 버튼의 테두리를 제거 + self.isBordered = false self.wantsLayer = true self.layer?.backgroundColor = NSColor.clear.cgColor self.target = self self.action = #selector(pin) self.callback = completion + + pinBoxLabel = NSTextField(labelWithString: "Pin Box") + pinBoxLabel.font = NSFont(name: "Inter", size: FunctionButtonUI.size.font) + pinBoxLabel.textColor = FunctionButtonUI.color.pinText + pinBoxLabel.backgroundColor = NSColor.clear + pinBoxLabel.isBordered = false + + self.addSubview(pinBoxLabel) // 라벨을 버튼에 추가 + + // 레이아웃을 설정 (예: AutoLayout) + pinBoxLabel.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + pinBoxLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor), + pinBoxLabel.leadingAnchor.constraint(equalTo: self.trailingAnchor, constant: 8) + ]) } required init?(coder: NSCoder) { diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Pin icon-1.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon-1.imageset/Contents.json new file mode 100644 index 0000000..7146232 --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon-1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Pin icon.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Pin icon-1.imageset/Pin icon.png b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon-1.imageset/Pin icon.png new file mode 100644 index 0000000..f9bd8d6 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon-1.imageset/Pin icon.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.imageset/Contents.json b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.imageset/Contents.json new file mode 100644 index 0000000..966e93e --- /dev/null +++ b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Pin icon_45.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.imageset/Pin icon_45.png b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.imageset/Pin icon_45.png new file mode 100644 index 0000000..265a579 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.imageset/Pin icon_45.png differ diff --git a/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.png b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.png new file mode 100644 index 0000000..f9bd8d6 Binary files /dev/null and b/Box42/Resources/Assets.xcassets/uibuttons/Pin icon.png differ