From 36544d43b4dc7a18eca98096c512eb3240203b34 Mon Sep 17 00:00:00 2001 From: sun Date: Thu, 16 Mar 2023 14:17:19 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20NewNoteInputToolbar=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20#299?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Happiggy-bank.xcodeproj/project.pbxproj | 4 ++ .../HomeTab/NewNote/UI/View/ColorButton.swift | 10 ++-- .../NewNote/UI/View/NewNoteInputToolbar.swift | 50 +++++++++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/NewNoteInputToolbar.swift diff --git a/Happiggy-bank/Happiggy-bank.xcodeproj/project.pbxproj b/Happiggy-bank/Happiggy-bank.xcodeproj/project.pbxproj index ef892261..5c14d9ac 100644 --- a/Happiggy-bank/Happiggy-bank.xcodeproj/project.pbxproj +++ b/Happiggy-bank/Happiggy-bank.xcodeproj/project.pbxproj @@ -65,6 +65,7 @@ A46B2E8129B5EBDA006A7870 /* NoteDetailListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A46B2E8029B5EBDA006A7870 /* NoteDetailListViewModel.swift */; }; A46B2E8329B5EBE6006A7870 /* NoteDetailListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A46B2E8229B5EBE6006A7870 /* NoteDetailListViewController.swift */; }; A46BC1EF2800626A00C2E5B4 /* TabItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A46BC1EE2800626A00C2E5B4 /* TabItem.swift */; }; + A472C5F529C2DCEA00097432 /* NewNoteInputToolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = A472C5F429C2DCEA00097432 /* NewNoteInputToolbar.swift */; }; A47D83462966C0C60028AA1D /* NotificationSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22ADF7E27F72F7300ECB77B /* NotificationSettingsViewModel.swift */; }; A47D83482966D3870028AA1D /* FontSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A47D83472966D3870028AA1D /* FontSelectionView.swift */; }; A47D834A296716BF0028AA1D /* FontCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A47D8349296716BF0028AA1D /* FontCell.swift */; }; @@ -245,6 +246,7 @@ A46B2E8029B5EBDA006A7870 /* NoteDetailListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteDetailListViewModel.swift; sourceTree = ""; }; A46B2E8229B5EBE6006A7870 /* NoteDetailListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteDetailListViewController.swift; sourceTree = ""; }; A46BC1EE2800626A00C2E5B4 /* TabItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabItem.swift; sourceTree = ""; }; + A472C5F429C2DCEA00097432 /* NewNoteInputToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewNoteInputToolbar.swift; sourceTree = ""; }; A47D83472966D3870028AA1D /* FontSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontSelectionView.swift; sourceTree = ""; }; A47D8349296716BF0028AA1D /* FontCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontCell.swift; sourceTree = ""; }; A47D83532973A4860028AA1D /* FontPublishing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontPublishing.swift; sourceTree = ""; }; @@ -821,6 +823,7 @@ A4CF2C7F27C733FE001B01B1 /* ColorButton.swift */, A4EDFE802902D72A0056C2DC /* ColorPickerBarItem.swift */, A4845B5C2900DF0B00A6007C /* ColorPicker.swift */, + A472C5F429C2DCEA00097432 /* NewNoteInputToolbar.swift */, ); path = View; sourceTree = ""; @@ -1420,6 +1423,7 @@ A4CF2C8227C73B42001B01B1 /* UIColor+AssetColors.swift in Sources */, A819CF9F27DDD97C00DE8E72 /* HapticManager.swift in Sources */, A4569CCF28128B4B001E3FD6 /* SettingsNonIconButtonCell.swift in Sources */, + A472C5F529C2DCEA00097432 /* NewNoteInputToolbar.swift in Sources */, A4396B1B29325D70005D9D3A /* PhotoViewController.swift in Sources */, A8ECD4A727E33BFA00886BC0 /* ListTabViewModel.swift in Sources */, A49AC5EB2917FFAB009315BC /* PhotoNoteCellViewModel.swift in Sources */, diff --git a/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/ColorButton.swift b/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/ColorButton.swift index 7d7c34e0..52ab2dd9 100644 --- a/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/ColorButton.swift +++ b/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/ColorButton.swift @@ -20,17 +20,17 @@ final class ColorButton: UIButton { let color: NoteColor /// 버튼의 테두리 색깔 - private let borderColor: UIColor + private let lineColor: UIColor? // MARK: - Init init(color: NoteColor, frame: CGRect = .zero) { self.color = color - self.borderColor = .noteBorder(for: self.color) + self.lineColor = AssetColor.noteLine(for: self.color) super.init(frame: frame) - self.tintColor = .noteHighlight(for: self.color) + self.tintColor = AssetColor.noteText(for: self.color) self.configure() } @@ -60,7 +60,7 @@ final class ColorButton: UIButton { /// 선택되지 않은 경우 하이라이트 효과를 끔 if !self.isSelected { if isLightMode, self.color == .white { - self.layer.borderColor = self.borderColor.cgColor + self.layer.borderColor = self.lineColor?.cgColor return } self.layer.borderWidth = .zero @@ -69,7 +69,7 @@ final class ColorButton: UIButton { /// 뷰 초기화 private func configure() { - self.backgroundColor = .note(color: self.color) + self.backgroundColor = AssetColor.noteBG(for: self.color) self.layer.cornerRadius = Metric.buttonCornerRadius } } diff --git a/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/NewNoteInputToolbar.swift b/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/NewNoteInputToolbar.swift new file mode 100644 index 00000000..50481cb9 --- /dev/null +++ b/Happiggy-bank/Happiggy-bank/HomeTab/NewNote/UI/View/NewNoteInputToolbar.swift @@ -0,0 +1,50 @@ +// +// NewNoteInputToolbar.swift +// Happiggy-bank +// +// Created by sun on 2023/03/16. +// + +import UIKit + +/// 쪽지 작성뷰에서 사용하는, 사진 라이브러리 버튼과 컬러피커가 담긴 툴바 +final class NewNoteInputToolbar: UIToolbar { + + // MARK: - Properties + + /// 사진 라이브러리를 여는 버튼 + let photoButton = UIButton().then { + $0.tintColor = AssetColor.subBrown02 + $0.setImage(AssetImage.gallery, for: .normal) + $0.adjustsImageWhenHighlighted = false + } + + /// 쪽지 컬러 피커 + let colorPicker = ColorPickerItem() + + + // MARK: - Init(s) + + override init(frame: CGRect) { + super.init(frame: frame) + + self.configureViews() + } + + + required init?(coder: NSCoder) { + super.init(coder: coder) + + self.configureViews() + } + + + // MARK: - Initialization Functions + + private func configureViews() { + self.barTintColor = .systemBackground + let spacer = UIBarButtonItem(systemItem: .flexibleSpace) + let buttonItem = UIBarButtonItem(customView: self.photoButton) + self.setItems([buttonItem, spacer, self.colorPicker], animated: true) + } +}