diff --git a/GEON-PPANG-iOS.xcodeproj/project.pbxproj b/GEON-PPANG-iOS.xcodeproj/project.pbxproj index 3c9ed386..a84dd071 100644 --- a/GEON-PPANG-iOS.xcodeproj/project.pbxproj +++ b/GEON-PPANG-iOS.xcodeproj/project.pbxproj @@ -49,12 +49,14 @@ 09B13F562A59410C00C0C723 /* CALayer+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B13F552A59410C00C0C723 /* CALayer+.swift */; }; 09B13F582A59433500C0C723 /* TabBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B13F572A59433500C0C723 /* TabBarItem.swift */; }; 09B13F5A2A5946B700C0C723 /* TabBar+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B13F592A5946B700C0C723 /* TabBar+.swift */; }; + 09B71BFC2A59CF3E00076AC2 /* Protocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B71BFB2A59CF3E00076AC2 /* Protocol.swift */; }; 09B71C002A59D50900076AC2 /* HomeTopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B71BFF2A59D50900076AC2 /* HomeTopView.swift */; }; 09B71C022A59D99200076AC2 /* SearchTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B71C012A59D99200076AC2 /* SearchTextField.swift */; }; 09C6264E2A5B29F8002C8110 /* SearchEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C6264D2A5B29F8002C8110 /* SearchEnum.swift */; }; 09C626542A5B344B002C8110 /* HomeBestBakeryResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C626532A5B344B002C8110 /* HomeBestBakeryResponseDTO.swift */; }; 09C626562A5B3572002C8110 /* HomeBestReviewResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C626552A5B3572002C8110 /* HomeBestReviewResponseDTO.swift */; }; 09C626582A5B4269002C8110 /* HomeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09C626572A5B4269002C8110 /* HomeHeaderView.swift */; }; + 09CA3EF82A5676AA0063897A /* CommonButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CA3EF72A5676AA0063897A /* CommonButton.swift */; }; 09CA3EFC2A569E4A0063897A /* URLConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CA3EFB2A569E4A0063897A /* URLConstant.swift */; }; 09CA3F062A569EB30063897A /* API.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CA3F052A569EB30063897A /* API.swift */; }; 09CA3F082A569EBA0063897A /* Service.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09CA3F072A569EBA0063897A /* Service.swift */; }; @@ -108,12 +110,14 @@ 09B13F552A59410C00C0C723 /* CALayer+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CALayer+.swift"; sourceTree = ""; }; 09B13F572A59433500C0C723 /* TabBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarItem.swift; sourceTree = ""; }; 09B13F592A5946B700C0C723 /* TabBar+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TabBar+.swift"; sourceTree = ""; }; + 09B71BFB2A59CF3E00076AC2 /* Protocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Protocol.swift; sourceTree = ""; }; 09B71BFF2A59D50900076AC2 /* HomeTopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeTopView.swift; sourceTree = ""; }; 09B71C012A59D99200076AC2 /* SearchTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTextField.swift; sourceTree = ""; }; 09C6264D2A5B29F8002C8110 /* SearchEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchEnum.swift; sourceTree = ""; }; 09C626532A5B344B002C8110 /* HomeBestBakeryResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeBestBakeryResponseDTO.swift; sourceTree = ""; }; 09C626552A5B3572002C8110 /* HomeBestReviewResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeBestReviewResponseDTO.swift; sourceTree = ""; }; 09C626572A5B4269002C8110 /* HomeHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeHeaderView.swift; sourceTree = ""; }; + 09CA3EF72A5676AA0063897A /* CommonButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonButton.swift; sourceTree = ""; }; 09CA3EFB2A569E4A0063897A /* URLConstant.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLConstant.swift; sourceTree = ""; }; 09CA3F052A569EB30063897A /* API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = API.swift; sourceTree = ""; }; 09CA3F072A569EBA0063897A /* Service.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Service.swift; sourceTree = ""; }; @@ -243,6 +247,7 @@ 0961C3602A501E9F0031A822 /* Global */ = { isa = PBXGroup; children = ( + 09CA3EF62A56738A0063897A /* Protocol */, 0961C3662A501EDD0031A822 /* Network */, 0961C3652A501ED40031A822 /* Extensions */, 0961C3622A501EB50031A822 /* Literals */, @@ -461,11 +466,20 @@ path = Model; sourceTree = ""; }; + 09CA3EF62A56738A0063897A /* Protocol */ = { + isa = PBXGroup; + children = ( + 09B71BFB2A59CF3E00076AC2 /* Protocol.swift */, + ); + path = Protocol; + sourceTree = ""; + }; 3E79B19B2A54523400D36A26 /* Button */ = { isa = PBXGroup; children = ( 0987288C2A5BA1F000A29402 /* BookmarkButton.swift */, 3E79B19C2A54523D00D36A26 /* BackButton.swift */, + 09CA3EF72A5676AA0063897A /* CommonButton.swift */, ); path = Button; sourceTree = ""; @@ -656,6 +670,7 @@ 093214082A5AE40900875EF6 /* SearchViewController.swift in Sources */, 09B13F542A593CD300C0C723 /* MyPageViewController.swift in Sources */, 3E79B19D2A54523D00D36A26 /* BackButton.swift in Sources */, + 09CA3EF82A5676AA0063897A /* CommonButton.swift in Sources */, 3EA2E1E32A53E88B003516A3 /* BaseViewController.swift in Sources */, 09C626582A5B4269002C8110 /* HomeHeaderView.swift in Sources */, 0915C1722A5C3D3700ACB8D4 /* PaddingLabel.swift in Sources */, @@ -673,6 +688,7 @@ 3EA2E1EB2A542151003516A3 /* SizeLiteral.swift in Sources */, 0987288D2A5BA1F000A29402 /* BookmarkButton.swift in Sources */, 090556202A51DB2C00752067 /* UIImage+.swift in Sources */, + 09B71BFC2A59CF3E00076AC2 /* Protocol.swift in Sources */, 0905562D2A51DBE700752067 /* UILabel+.swift in Sources */, 090556252A51DB9600752067 /* UICollectionView+.swift in Sources */, 09B13F582A59433500C0C723 /* TabBarItem.swift in Sources */, diff --git a/GEON-PPANG-iOS/Global/Protocol/Protocol.swift b/GEON-PPANG-iOS/Global/Protocol/Protocol.swift new file mode 100644 index 00000000..924a7429 --- /dev/null +++ b/GEON-PPANG-iOS/Global/Protocol/Protocol.swift @@ -0,0 +1,8 @@ +// +// Protocol.swift +// GEON-PPANG-iOS +// +// Created by JEONGEUN KIM on 2023/07/09. +// + +import Foundation diff --git a/GEON-PPANG-iOS/Presentation/Common/Button/CommonButton.swift b/GEON-PPANG-iOS/Presentation/Common/Button/CommonButton.swift new file mode 100644 index 00000000..59e0c24f --- /dev/null +++ b/GEON-PPANG-iOS/Presentation/Common/Button/CommonButton.swift @@ -0,0 +1,82 @@ +// +// CommonButton.swift +// GEON-PPANG-iOS +// +// Created by JEONGEUN KIM on 2023/07/06. +// + +import UIKit + +import SnapKit +import Then + +enum ButtonTitle: String, CaseIterable { + + case login = "로그인" + case signIn = "회원가입" + case next = "다음" + case confirm = "확인" + case duplicate = "중복확인" + case write = "작성하기" + case start = "시작하기" + +} + +final class CommonButton: UIButton { + + // MARK: - Life Cycle + + override init(frame: CGRect) { + super.init(frame: .zero) + + setUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Setting + + private func setUI() { + self.do { + $0.makeCornerRound(radius: 11) + $0.titleLabel?.font = .headLine + } + } + + func getButtonTitle(_ title: ButtonTitle) { + setTitle(title.rawValue, for: .normal) + } + + func getButtonUI(_ color: UIColor, _ border: UIColor? = .clear) { + self.backgroundColor = color + switch color { + case .gbbMain3!, .gbbGray700!: setTitleColor(.gbbGray100, for: .normal) + case .gbbMain2!: setTitleColor(.white, for: .normal) + default: + setTitleColor(.gbbGray400, for: .normal) + } + + if let border = border { + makeBorder(width: 1, color: border) + if border != .clear { + setTitleColor(border, for: .normal) + } + } + } + + func updateUI(_ isTrue: @escaping () -> Void, _ isFalse: @escaping () -> Void) { + let action = UIAction { [weak self] _ in + self?.isSelected.toggle() + if let isSelected = self?.isSelected { + if isSelected { + isTrue() + } else { + isFalse() + } + } + } + addAction(action, for: .touchUpInside) + } +}