Skip to content

Commit

Permalink
[Chore] #253 - optional color unwrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
seongmin221 committed May 4, 2024
1 parent 47665de commit 15f6d34
Show file tree
Hide file tree
Showing 52 changed files with 138 additions and 132 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "a32b0a1c0ad6f6a91a39529043231e700bfb3a573e73a0172a5e40c9106b8bba",
"pins" : [
{
"identity" : "alamofire",
Expand Down Expand Up @@ -100,5 +101,5 @@
}
}
],
"version" : 2
"version" : 3
}
43 changes: 24 additions & 19 deletions GEON-PPANG-iOS/Core/DesignSystem/Source/Colors/UIColor+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,33 @@ extension UIColor {
// $0.textColor = .gbbMain1
// $0.backgroundColor = .gbbBackground1

static let gbbMain1 = UIColor(named: "Main_1")
static let gbbMain2 = UIColor(named: "Main_2")
static let gbbMain3 = UIColor(named: "Main_3")
// MARK: - main colors
static let gbbMain1: UIColor = UIColor(named: "Main_1")!
static let gbbMain2: UIColor = UIColor(named: "Main_2")!
static let gbbMain3: UIColor = UIColor(named: "Main_3")!

static let gbbPoint1 = UIColor(named: "Point_1")
static let gbbPoint2 = UIColor(named: "Point_2")
// MARK: - point colors
static let gbbPoint1: UIColor = UIColor(named: "Point_1")!
static let gbbPoint2: UIColor = UIColor(named: "Point_2")!

static let gbbError = UIColor(named: "Error")
// MARK: - error colors
static let gbbError: UIColor = UIColor(named: "Error")!

static let gbbBackground1 = UIColor(named: "Background_1")
static let gbbBackground2 = UIColor(named: "Background_2")
static let gbbAlertBackground = UIColor(named: "alert-gray")
// MARK: - background colors
static let gbbBackground1: UIColor = UIColor(named: "Background_1")!
static let gbbBackground2: UIColor = UIColor(named: "Background_2")!
static let gbbAlertBackground: UIColor = UIColor(named: "alert-gray")!

static let gbbWhite = UIColor(named: "Gray_Scale/white")
static let gbbGray100 = UIColor(named: "Gray_Scale/gray-100")
static let gbbGray200 = UIColor(named: "Gray_Scale/gray-200")
static let gbbGray300 = UIColor(named: "Gray_Scale/gray-300")
static let gbbGray400 = UIColor(named: "Gray_Scale/gray-400")
static let gbbGray500 = UIColor(named: "Gray_Scale/gray-500")
static let gbbGray600 = UIColor(named: "Gray_Scale/gray-600")
static let gbbGray700 = UIColor(named: "Gray_Scale/gray-700")
static let gbbBlack = UIColor(named: "Gray_Scale/black")
static let gray_500 = UIColor(named: "Gray_500")
// MARK: - grayscale colors
static let gbbWhite: UIColor = UIColor(named: "Gray_Scale/white")!
static let gbbGray100: UIColor = UIColor(named: "Gray_Scale/gray-100")!
static let gbbGray200: UIColor = UIColor(named: "Gray_Scale/gray-200")!
static let gbbGray300: UIColor = UIColor(named: "Gray_Scale/gray-300")!
static let gbbGray400: UIColor = UIColor(named: "Gray_Scale/gray-400")!
static let gbbGray500: UIColor = UIColor(named: "Gray_Scale/gray-500")!
static let gbbGray600: UIColor = UIColor(named: "Gray_Scale/gray-600")!
static let gbbGray700: UIColor = UIColor(named: "Gray_Scale/gray-700")!
static let gbbBlack: UIColor = UIColor(named: "Gray_Scale/black")!
static let gray_500: UIColor = UIColor(named: "Gray_500")!

}
4 changes: 2 additions & 2 deletions GEON-PPANG-iOS/Global/Extensions/UI/TabBar+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ extension UITabBar {
UITabBar.appearance().backgroundColor = UIColor.white
UITabBarItem.appearance().titlePositionAdjustment.vertical = -5
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont.captionB1!,
NSAttributedString.Key.foregroundColor: UIColor.gbbGray400!],
NSAttributedString.Key.foregroundColor: UIColor.gbbGray400],
for: .normal)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: UIFont.captionB1!,
NSAttributedString.Key.foregroundColor: UIColor.gbbMain3!],
NSAttributedString.Key.foregroundColor: UIColor.gbbMain3],
for: .selected)
}
}
2 changes: 1 addition & 1 deletion GEON-PPANG-iOS/Global/Utils/LayoutUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class LayoutUtils {

var config = UICollectionLayoutListConfiguration(appearance: appearance)
config.backgroundColor = .clear
config.separatorConfiguration.color = .gbbGray200!
config.separatorConfiguration.color = .gbbGray200
config.headerMode = headerMode
config.separatorConfiguration.topSeparatorVisibility = .hidden
config.itemSeparatorHandler = handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ final class CommonBottomSheet: UIView {
bottonSheetTitle.do {
$0.textAlignment = .center
$0.numberOfLines = 0
$0.basic(font: .pretendardBold(20), color: .gbbGray500!)
$0.basic(font: .pretendardBold(20), color: .gbbGray500)
}
confirmButton.do {
$0.configureButtonUI(.gbbGray700!)
$0.configureButtonUI(.gbbGray700)
$0.configureButtonTitle(.confirm)
$0.tappedCommonButton = {
self.dismissBottomSheet?()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ final class LoginRequiredViewController: BaseViewController {
$0.font = .title2
$0.numberOfLines = 2
$0.textAlignment = .center
$0.partColorChange(targetString: "로그인", textColor: .gbbMain2!)
$0.partColorChange(targetString: "로그인", textColor: .gbbMain2)
}

kakaoLoginButton.do {
Expand Down
4 changes: 2 additions & 2 deletions GEON-PPANG-iOS/Presentation/Common/Button/CommonButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ final class CommonButton: UIButton {

self.backgroundColor = color
switch color {
case .gbbMain2!, .gbbGray700!: setTitleColor(.gbbGray100, for: .normal)
case .gbbMain2, .gbbGray700: setTitleColor(.gbbGray100, for: .normal)
case .clear:
self.titleLabel?.font = .bodyB1!
setTitleColor(.gbbGray400, for: .normal)
Expand Down Expand Up @@ -108,6 +108,6 @@ final class CommonButton: UIButton {

func configureInteraction(to value: Bool) {
self.isUserInteractionEnabled = value
self.configureButtonUI(value ? .gbbGray700! : .gbbGray200!)
self.configureButtonUI(value ? .gbbGray700 : .gbbGray200)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ final class IconWithTextView: UIButton {

func configureListUI(text: String) {

self.configuration?.attributedTitle = AttributedString(text, attributes: AttributeContainer([.font: UIFont.captionM1!, .foregroundColor: UIColor.gbbGray400!]))
self.configuration?.attributedTitle = AttributedString(text, attributes: AttributeContainer([.font: UIFont.captionM1!, .foregroundColor: UIColor.gbbGray400]))

}

func configureHomeCell(count: Int) {

self.configuration?.attributedTitle = AttributedString("(\(count))", attributes: AttributeContainer([.font: UIFont.captionB1!, .foregroundColor: UIColor.gbbGray400!]))
self.configuration?.attributedTitle = AttributedString("(\(count))", attributes: AttributeContainer([.font: UIFont.captionB1!, .foregroundColor: UIColor.gbbGray400]))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class ReviewSortButton: UIButton {
private func setUI() {

iconLabelStackViewContainer.do {
$0.makeBorder(width: 1, color: .gbbGray200!)
$0.makeBorder(width: 1, color: .gbbGray200)
$0.makeCornerRound(radius: 18)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ final class DescriptionCollectionViewCell: UICollectionViewCell {

private var cellBorderColor: UIColor {
switch cellColor {
case .basic: return .gbbGray300!
case .sub: return .gbbPoint1!
case .basic: return .gbbGray300
case .sub: return .gbbPoint1
case .point: return .clear
}
}

private var cellBackgroundColor: UIColor {
switch cellColor {
case .basic: return .gbbBackground1!
case .sub: return .gbbBackground1!
case .point: return .gbbPoint2!
case .basic: return .gbbBackground1
case .sub: return .gbbBackground1
case .point: return .gbbPoint2
}
}

private var cellTextColor: UIColor {
switch cellColor {
case .basic: return .gbbGray400!
case .sub: return .gbbPoint1!
case .point: return .gbbPoint1!
case .basic: return .gbbGray400
case .sub: return .gbbPoint1
case .point: return .gbbPoint1
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class CustomNavigationBar: UIView {
}

centerTitleLabel.do {
$0.basic(text: title, font: font, color: .gbbGray700!)
$0.basic(text: title, font: font, color: .gbbGray700)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ final class BreadTypeStackView: UIStackView {

[glutenFreeChip, veganBreadChip, nutFreeChip, subSugarChip].enumerated().forEach { index, chip in
chip.do {
$0.basic(text: labeling[index], font: .captionM1!, color: .gbbPoint1!)
$0.basic(text: labeling[index], font: .captionM1!, color: .gbbPoint1)
$0.makeCornerRound(radius: 3)
$0.makeBorder(width: 0.5, color: .gbbPoint1!)
$0.makeBorder(width: 0.5, color: .gbbPoint1)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ final class IconLabelStackView: UIStackView {
private var labelColor: UIColor {
switch iconType {
case .bookmark, .review, .notice:
return .gbbGray300!
return .gbbGray300
case .basic:
return .gbbBlack!
return .gbbBlack
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class ReviewCategoryStackView: UIStackView {
[deliciousChip, zerowasteChip, specialChip, kindChip].enumerated().forEach { index, chip in
chip.do {
$0.backgroundColor = .gbbPoint2
$0.basic(text: labeling[index], font: .captionM1!, color: .gbbPoint1!)
$0.basic(text: labeling[index], font: .captionM1!, color: .gbbPoint1)
$0.makeCornerRound(radius: 3)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class CommonTextView: UIView {
private func setUI(type: SignInPropertyType) {

titleLabel.do {
$0.basic(font: .bodyB2!, color: .gbbGray400!)
$0.basic(font: .bodyB2!, color: .gbbGray400)
$0.text = type.title
}

Expand Down Expand Up @@ -103,8 +103,8 @@ final class CommonTextView: UIView {
titleLabel.textColor = isValid ? .gbbError: .gbbMain3
checkLabel.basic(text: message,
font: .captionM1!,
color: isValid ? .gbbError!: .gbbMain3!)
commonTextField.layer.borderColor = isValid ? UIColor.gbbError?.cgColor : UIColor.gbbMain3?.cgColor
color: isValid ? .gbbError: .gbbMain3)
commonTextField.layer.borderColor = isValid ? UIColor.gbbError.cgColor : UIColor.gbbMain3.cgColor
}

func clearErrorMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ final class SearchTextField: UITextField {

switch viewType {
case .search:
setPlaceholder(color: .gbbGray300!, font: .bodyM1!)
setPlaceholder(color: .gbbGray300, font: .bodyM1!)
leftView = searchButton
leftViewMode = .always
rightView = clearButton
rightViewMode = .whileEditing
case .home:
setPlaceholder(color: .gbbGray300!, font: .subHead!)
setPlaceholder(color: .gbbGray300, font: .subHead!)
setLeftPadding(amount: 0)
rightView = searchButton
rightViewMode = .always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class SignInTextField: UITextField {

$0.makeCornerRound(radius: 10)
$0.makeBorder(width: 1, color: .clear)
$0.setPlaceholder(color: .gbbGray300!, font: .headLine!)
$0.setPlaceholder(color: .gbbGray300, font: .headLine!)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class DrawDashLineView: UIView { // 코너가 들어간 점선 그리기
override init(frame: CGRect) {
super.init(frame: frame)

borderLayer.strokeColor = UIColor.gbbMain3?.cgColor
borderLayer.strokeColor = UIColor.gbbMain3.cgColor
borderLayer.lineDashPattern = [2, 2]
borderLayer.backgroundColor = UIColor.clear.cgColor
borderLayer.fillColor = UIColor.clear.cgColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ final class LogInViewController: BaseViewController {
$0.numberOfLines = 0
$0.basic(text: I18N.LogIn.title,
font: .title1!,
color: .gbbGray700!)
color: .gbbGray700)
}

loginButton.do {
$0.isUserInteractionEnabled = false
$0.configureButtonUI(.gbbGray200!)
$0.configureButtonUI(.gbbGray200)
$0.configureButtonTitle(.login)
}

signInButton.do {
$0.setTitle(I18N.LogIn.signIn, for: .normal)
$0.setTitleColor(.gbbGray500!, for: .normal)
$0.setTitleColor(.gbbGray500, for: .normal)
$0.titleLabel?.font = .bodyB2!
$0.setUnderline()
$0.addAction(UIAction { [weak self] _ in
Expand All @@ -132,7 +132,7 @@ final class LogInViewController: BaseViewController {
accountLabel.do {
$0.basic(text: I18N.LogIn.noAccount,
font: .subHead!,
color: .gray_500!)
color: .gray_500)
}

bottomSheet.do {
Expand All @@ -152,7 +152,7 @@ final class LogInViewController: BaseViewController {

loginButton.do {
$0.isUserInteractionEnabled = isValid
$0.configureButtonUI(isValid ? .gbbMain2!: .gbbGray200!)
$0.configureButtonUI(isValid ? .gbbMain2: .gbbGray200)
$0.tappedCommonButton = {
if isValid {
self.postLogin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ final class NickNameViewController: BaseViewController {
$0.numberOfLines = 0
$0.basic(text: I18N.Nickname.title,
font: .title1!,
color: .gbbGray700!)
color: .gbbGray700)
}

checkButton.do {
Expand All @@ -115,7 +115,7 @@ final class NickNameViewController: BaseViewController {

nextButton.do {
$0.isUserInteractionEnabled = false
$0.configureButtonUI(.gbbGray200!)
$0.configureButtonUI(.gbbGray200)
$0.configureButtonTitle(.next)
}

Expand All @@ -131,7 +131,7 @@ final class NickNameViewController: BaseViewController {
self.checkButton.do {
$0.isEnabled = isValid
$0.configureButtonUI(.clear)
$0.configureBorder(isValid ? 2 : 1, isValid ? .gbbMain2! : .gbbGray300!)
$0.configureBorder(isValid ? 2 : 1, isValid ? .gbbMain2 : .gbbGray300)
}
}

Expand All @@ -140,7 +140,7 @@ final class NickNameViewController: BaseViewController {
self.nextButton.do {
$0.isUserInteractionEnabled = isValid
$0.configureButtonTitle(isValid ? .start : .next)
$0.configureButtonUI(isValid ? .gbbMain2! : .gbbGray200!)
$0.configureButtonUI(isValid ? .gbbMain2 : .gbbGray200)
$0.tappedCommonButton = {
self.signUp()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ final class SignInViewController: BaseViewController {
$0.numberOfLines = 0
$0.basic(text: I18N.SignIn.title,
font: .title1!,
color: .gbbGray700!)
color: .gbbGray700)
}

emailTextField.do {
Expand All @@ -165,7 +165,7 @@ final class SignInViewController: BaseViewController {

nextButton.do {
$0.configureButtonTitle(.next)
$0.configureButtonUI(.gbbGray200!)
$0.configureButtonUI(.gbbGray200)
$0.isUserInteractionEnabled = false
}
}
Expand All @@ -180,7 +180,7 @@ final class SignInViewController: BaseViewController {
func configureButtonUI(_ isValid: Bool) {

nextButton.do {
$0.configureButtonUI(isValid ? .gbbMain2!: .gbbGray200!)
$0.configureButtonUI(isValid ? .gbbMain2: .gbbGray200)
$0.isUserInteractionEnabled = isValid
$0.tappedCommonButton = { [weak self] in
guard let self else { return }
Expand Down
Loading

0 comments on commit 15f6d34

Please sign in to comment.