Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #21 - 공통 버튼 구현 #27

Merged
merged 18 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions GEON-PPANG-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
098F32EA2A4200FE0092D09A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 098F32E92A4200FE0092D09A /* Assets.xcassets */; };
098F32ED2A4200FE0092D09A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 098F32EB2A4200FE0092D09A /* LaunchScreen.storyboard */; };
099FC1C62A51F19300116D00 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 099FC1C52A51F19300116D00 /* GoogleService-Info.plist */; };
09B71BFC2A59CF3E00076AC2 /* Protocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B71BFB2A59CF3E00076AC2 /* Protocol.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 */; };
Expand Down Expand Up @@ -66,6 +68,8 @@
098F32EC2A4200FE0092D09A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
098F32EE2A4200FE0092D09A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
099FC1C52A51F19300116D00 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
09B71BFB2A59CF3E00076AC2 /* Protocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Protocol.swift; sourceTree = "<group>"; };
09CA3EF72A5676AA0063897A /* CommonButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonButton.swift; sourceTree = "<group>"; };
09CA3EFB2A569E4A0063897A /* URLConstant.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLConstant.swift; sourceTree = "<group>"; };
09CA3F052A569EB30063897A /* API.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = API.swift; sourceTree = "<group>"; };
09CA3F072A569EBA0063897A /* Service.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Service.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -132,6 +136,7 @@
0961C3602A501E9F0031A822 /* Global */ = {
isa = PBXGroup;
children = (
09CA3EF62A56738A0063897A /* Protocol */,
0961C3662A501EDD0031A822 /* Network */,
0961C3652A501ED40031A822 /* Extensions */,
0961C3622A501EB50031A822 /* Literals */,
Expand Down Expand Up @@ -266,9 +271,26 @@
path = "GEON-PPANG-iOS";
sourceTree = "<group>";
};
09CA3EF32A566F380063897A /* Button */ = {
isa = PBXGroup;
children = (
09CA3EF72A5676AA0063897A /* CommonButton.swift */,
);
path = Button;
sourceTree = "<group>";
};
09CA3EF62A56738A0063897A /* Protocol */ = {
isa = PBXGroup;
children = (
09B71BFB2A59CF3E00076AC2 /* Protocol.swift */,
);
path = Protocol;
sourceTree = "<group>";
};
3EA2E1E02A53E864003516A3 /* Common */ = {
isa = PBXGroup;
children = (
09CA3EF32A566F380063897A /* Button */,
3EA2E1E12A53E880003516A3 /* Base */,
);
path = Common;
Expand Down Expand Up @@ -436,12 +458,14 @@
090556492A51E7EC00752067 /* UIScreen+.swift in Sources */,
09CA3F0A2A569EC50063897A /* Enum.swift in Sources */,
0961C3642A501EBF0031A822 /* Strings.swift in Sources */,
09CA3EF82A5676AA0063897A /* CommonButton.swift in Sources */,
3EA2E1E32A53E88B003516A3 /* BaseViewController.swift in Sources */,
090556222A51DB3300752067 /* UIFont+.swift in Sources */,
09CA3EFC2A569E4A0063897A /* URLConstant.swift in Sources */,
09CA3F082A569EBA0063897A /* Service.swift in Sources */,
0905564B2A51E81D00752067 /* UIViewController+.swift in Sources */,
090556202A51DB2C00752067 /* UIImage+.swift in Sources */,
09B71BFC2A59CF3E00076AC2 /* Protocol.swift in Sources */,
0905562D2A51DBE700752067 /* UILabel+.swift in Sources */,
090668FE2A4FF3C600F413FA /* ViewController.swift in Sources */,
090556252A51DB9600752067 /* UICollectionView.swift in Sources */,
Expand Down
11 changes: 10 additions & 1 deletion GEON-PPANG-iOS/Global/Literals/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@
import Foundation

struct I18N {

/// Common Button
struct Button {
static let login = "로그인"
static let signIn = "회원가입"
static let next = "다음"
static let start = "시작하기"
static let confirm = "확인"
static let write = "작성하기"
static let check = "중복확인"
}
}
8 changes: 8 additions & 0 deletions GEON-PPANG-iOS/Global/Protocol/Protocol.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Protocol.swift
// GEON-PPANG-iOS
//
// Created by JEONGEUN KIM on 2023/07/09.
//

import Foundation
75 changes: 75 additions & 0 deletions GEON-PPANG-iOS/Presentation/Common/Button/CommonButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// 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 = "중복 확인"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1:
"중복확인" 으로 변경 부탁드려요 !
띄어쓰기가 없어야 하는 것 같숩니다 !

case write = "작성하기"
case start = "시작하기"

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2:
훔 근데 Strings.swift 파일에 지정해 두었는데 여기서 또 텍스트로 작성하신 이유가 있을까요 ??
없다면 Strings.swift 파일의 값들 삭제 부탁드립니다 !


final class CommonButton: UIButton {

// MARK: - Property
// MARK: = UI Property

init() {
super.init(frame: .zero)

setUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Setting

private func setUI() {
makeCornerRound(radius: 11)
titleLabel?.font = .pretendardMedium(18)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q:
훔 제가 then 을 처음 써봐서 어느 상황에서는 property.do { ~~ } 를 쓸지,
어느 상황에서 property.font 이런식으로 쓸지 모르겠어서 그냥 다 전자로 통일시키긴 했거든요 ... ??
혹시 이에 대한 기준이 있을까여 ..??


func setButtonTitle(_ title: ButtonTitle) {
setTitle(title.rawValue, for: .normal)
}

func setButtonUI(_ 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 setAction(completion: ((UIAction) -> Void)? = nil) {
let action = UIAction { action in
completion?(action)
}
addAction(action, for: .touchUpInside)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q:
훔... 요건 논의해보면 좋을 것 같은 부분인데,
(정말 개인적인 코드 스타일) 저는 init 또는 viewDidLoad 에 들어가는 함수들만 set 을 앞에 붙였거든요 !
그 외에 설정하는 함수들은 configure 를 앞에 붙이고 쓰고 있습니다 !

오늘부터 합숙 시작하니까, 논의해보면 좋을 것 같아요 !!

}