Skip to content

Commit

Permalink
[refactor] NewNoteInputToolbar 구현 #299
Browse files Browse the repository at this point in the history
  • Loading branch information
skkimeo committed Jul 1, 2023
1 parent 5344726 commit 36544d4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Happiggy-bank/Happiggy-bank.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -245,6 +246,7 @@
A46B2E8029B5EBDA006A7870 /* NoteDetailListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteDetailListViewModel.swift; sourceTree = "<group>"; };
A46B2E8229B5EBE6006A7870 /* NoteDetailListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteDetailListViewController.swift; sourceTree = "<group>"; };
A46BC1EE2800626A00C2E5B4 /* TabItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabItem.swift; sourceTree = "<group>"; };
A472C5F429C2DCEA00097432 /* NewNoteInputToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewNoteInputToolbar.swift; sourceTree = "<group>"; };
A47D83472966D3870028AA1D /* FontSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontSelectionView.swift; sourceTree = "<group>"; };
A47D8349296716BF0028AA1D /* FontCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontCell.swift; sourceTree = "<group>"; };
A47D83532973A4860028AA1D /* FontPublishing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontPublishing.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -821,6 +823,7 @@
A4CF2C7F27C733FE001B01B1 /* ColorButton.swift */,
A4EDFE802902D72A0056C2DC /* ColorPickerBarItem.swift */,
A4845B5C2900DF0B00A6007C /* ColorPicker.swift */,
A472C5F429C2DCEA00097432 /* NewNoteInputToolbar.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 36544d4

Please sign in to comment.