From 8584a3620510a1d5c1bc38b18349c50d73fc7f66 Mon Sep 17 00:00:00 2001 From: luckyyy Date: Thu, 9 Jan 2025 00:43:13 +0900 Subject: [PATCH 1/5] [Feat/#20] schedule category btn --- .../Noostak_iOS/Domain/Entity/Schedule.swift | 18 +++- .../Components/ScheduleCategoryButton.swift | 94 +++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift diff --git a/Noostak_iOS/Noostak_iOS/Domain/Entity/Schedule.swift b/Noostak_iOS/Noostak_iOS/Domain/Entity/Schedule.swift index 58c71a3..fed3f40 100644 --- a/Noostak_iOS/Noostak_iOS/Domain/Entity/Schedule.swift +++ b/Noostak_iOS/Noostak_iOS/Domain/Entity/Schedule.swift @@ -5,9 +5,9 @@ // Created by 오연서 on 1/5/25. // -import Foundation +import UIKit -enum ScheduleCategory: String { +enum ScheduleCategory: String, CaseIterable { case important case schedule case hobby @@ -62,4 +62,18 @@ extension ScheduleCategory { return "기타" } } + + /// 색상 반환 + var displayColor: UIColor { + switch self { + case .important: + return .appOrange + case .schedule: + return .appBlue + case .hobby: + return .appPurple + case .other: + return .appMint + } + } } diff --git a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift new file mode 100644 index 0000000..3f80df8 --- /dev/null +++ b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift @@ -0,0 +1,94 @@ +// +// ScheduleCategoryButton.swift +// Noostak_iOS +// +// Created by 오연서 on 1/8/25. +// + +import UIKit +import RxSwift +import RxCocoa + +final class ScheduleCategoryButton: UIButton { + // MARK: Properties + var category: ScheduleCategory? + var categoryButtonType: ButtonType = .Input + private let disposeBag = DisposeBag() + private let isSelectedSubject = BehaviorRelay(value: false) + + // MARK: Init + init(category: ScheduleCategory? = nil, buttonType: ButtonType = .Input) { + self.category = category + self.categoryButtonType = buttonType + super.init(frame: .zero) + setUpUI() + setUpLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUpUI() { + switch categoryButtonType { + case .Input: + /// 입력 모드: 선택 여부에 따라 색상 변경 + self.isUserInteractionEnabled = true + self.titleLabel?.font = .PretendardStyle.b4_sb.font + self.layer.borderWidth = 1 + self.layer.cornerRadius = 18.5 + bindUI() + case .ReadOnly: + /// 표시 모드: 컬러 칩 스타일 + guard let category = category else { return } + self.isUserInteractionEnabled = false + self.backgroundColor = category.displayColor + self.setTitleColor(category == .other ? .appGray800 : .appWhite, for: .normal) + self.layer.borderColor = UIColor.appWhite.cgColor + self.titleLabel?.font = .PretendardStyle.c2_sb.font + self.layer.borderWidth = 1 + self.layer.cornerRadius = 15 + } + } + + private func setUpLayout() { + self.snp.makeConstraints { + switch categoryButtonType { + case .Input: + $0.height.equalTo(37) + $0.width.equalTo(66) + case .ReadOnly: + $0.height.equalTo(30) + $0.width.equalTo(53) + } + } + } + + private func bindUI() { + isSelectedSubject + .distinctUntilChanged() + .subscribe(onNext: { [weak self] isSelected in + guard let self = self else { return } + self.backgroundColor = isSelected ? .appBlack : .appWhite + self.layer.borderColor = isSelected ? UIColor.appBlack.cgColor : UIColor.appGray200.cgColor + self.setTitleColor(isSelected ? .appWhite : .appBlack, for: .normal) + }) + .disposed(by: disposeBag) + } + + /// 버튼 설정 + func configure(for category: ScheduleCategory, buttonType: ButtonType) { + self.category = category + self.categoryButtonType = buttonType + self.setTitle(category.name, for: .normal) + setUpUI() + setUpLayout() + } +} + +extension ScheduleCategoryButton { + enum ButtonType { + case Input + case ReadOnly + } +} From d66a37faacec23bbeba865a308a7d35f12c39ae7 Mon Sep 17 00:00:00 2001 From: luckyyy Date: Thu, 9 Jan 2025 14:35:06 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[Fix/#20]=20configure()=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=B0=8F=20=EC=A0=91=EA=B7=BC=EC=A7=80=EC=A0=95?= =?UTF-8?q?=EC=9E=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Components/ScheduleCategoryButton.swift | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift index 3f80df8..edd5453 100644 --- a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift +++ b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift @@ -17,10 +17,11 @@ final class ScheduleCategoryButton: UIButton { private let isSelectedSubject = BehaviorRelay(value: false) // MARK: Init - init(category: ScheduleCategory? = nil, buttonType: ButtonType = .Input) { + init(category: ScheduleCategory, buttonType: ButtonType) { + super.init(frame: .zero) self.category = category self.categoryButtonType = buttonType - super.init(frame: .zero) + self.setTitle(category.name, for: .normal) setUpUI() setUpLayout() } @@ -75,15 +76,6 @@ final class ScheduleCategoryButton: UIButton { }) .disposed(by: disposeBag) } - - /// 버튼 설정 - func configure(for category: ScheduleCategory, buttonType: ButtonType) { - self.category = category - self.categoryButtonType = buttonType - self.setTitle(category.name, for: .normal) - setUpUI() - setUpLayout() - } } extension ScheduleCategoryButton { From 180b9264fa56859e340aab95ceddcfebbf1a8167 Mon Sep 17 00:00:00 2001 From: luckyyy Date: Thu, 9 Jan 2025 14:36:38 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[Fix/#20]=20=EC=A0=91=EA=B7=BC=EC=A7=80?= =?UTF-8?q?=EC=A0=95=EC=9E=90=20=EB=B3=80=EA=B2=BD;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Components/ScheduleCategoryButton.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift index edd5453..d3c26e6 100644 --- a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift +++ b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift @@ -11,8 +11,8 @@ import RxCocoa final class ScheduleCategoryButton: UIButton { // MARK: Properties - var category: ScheduleCategory? - var categoryButtonType: ButtonType = .Input + private var category: ScheduleCategory? + private var categoryButtonType: ButtonType = .Input private let disposeBag = DisposeBag() private let isSelectedSubject = BehaviorRelay(value: false) From dbb72b9fffd4e269e9ff54b820cb1db7aad90502 Mon Sep 17 00:00:00 2001 From: luckyyy Date: Thu, 9 Jan 2025 17:30:24 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[Fix/#20]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Noostak_iOS/Global/Components/ScheduleCategoryButton.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift index d3c26e6..a71e20b 100644 --- a/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift +++ b/Noostak_iOS/Noostak_iOS/Global/Components/ScheduleCategoryButton.swift @@ -34,7 +34,6 @@ final class ScheduleCategoryButton: UIButton { switch categoryButtonType { case .Input: /// 입력 모드: 선택 여부에 따라 색상 변경 - self.isUserInteractionEnabled = true self.titleLabel?.font = .PretendardStyle.b4_sb.font self.layer.borderWidth = 1 self.layer.cornerRadius = 18.5 From b7e89b4053cb89580cb6fa934c3b1e9d0c78e885 Mon Sep 17 00:00:00 2001 From: luckyyy Date: Thu, 9 Jan 2025 17:43:15 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[Fix/#20]=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Global/Components/MemberAvailabilityChip.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Noostak_iOS/Noostak_iOS/Global/Components/MemberAvailabilityChip.swift b/Noostak_iOS/Noostak_iOS/Global/Components/MemberAvailabilityChip.swift index 983581d..62b26dd 100644 --- a/Noostak_iOS/Noostak_iOS/Global/Components/MemberAvailabilityChip.swift +++ b/Noostak_iOS/Noostak_iOS/Global/Components/MemberAvailabilityChip.swift @@ -42,7 +42,7 @@ final class MemberAvailabilityChip: UIView { private func setUpUI() { self.do { - $0.layer.cornerRadius = 16 + $0.layer.cornerRadius = 15 $0.layer.borderWidth = 1 switch status { @@ -69,7 +69,7 @@ final class MemberAvailabilityChip: UIView { private func setUpLayout() { self.snp.makeConstraints { if status == .myself { - $0.width.equalTo(28) + $0.width.equalTo(39) } $0.height.equalTo(30) }