Skip to content

Commit

Permalink
Merge pull request #16 from TeamCatchMe/feature/14-add-socialLoginButton
Browse files Browse the repository at this point in the history
Feature/14 add social login button
  • Loading branch information
YoonAh-dev authored Dec 25, 2021
2 parents 22459a9 + 4374f64 commit 6ac585d
Show file tree
Hide file tree
Showing 29 changed files with 296 additions and 0 deletions.
137 changes: 137 additions & 0 deletions CDSKit/Source/Button/CDSSocialButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
//
// CDSSocialButton.swift
//
//
// Created by SHIN YOON AH on 2021/12/25.
//

#if !os(macOS)
import UIKit
import SnapKit

/**
- Description:

CDS 소셜 로그인 버튼입니다.

*/

public class CDSSocialButton: UIButton {

// MARK: - Enum

public enum SocialType {
case kakao
case naver
case apple

fileprivate var text: String {
switch self {
case .kakao:
return "카카오 로그인"
case .naver:
return "네이버 로그인"
case .apple:
return "Apple로 로그인"
}
}

fileprivate var background: UIColor {
switch self {
case .kakao:
return CDSBaseColor.kakaoBackground
case .naver:
return CDSBaseColor.naverBackground
case .apple:
return CDSBaseColor.white
}
}

fileprivate var foreground: UIColor {
switch self {
case .kakao,
.apple:
return .black
case .naver:
return .white
}
}

fileprivate var icon: UIImage {
switch self {
case .kakao:
return CDSIcon.icKakao
case .naver:
return CDSIcon.icNaver
case .apple:
return CDSIcon.icApple
}
}

fileprivate var hoverIcon: UIImage {
switch self {
case .kakao:
return CDSIcon.icKakaoHover
case .naver:
return CDSIcon.icNaverHover
case .apple:
return CDSIcon.icAppleHover
}
}
}

// MARK: - Private Properties

private var type: SocialType = .kakao

private var font: UIFont = CDSFont.body3

private var width: CGFloat = 335

private var height: CGFloat = 50

private var rounding: CGFloat = 12

// MARK: - Initalizing

public init(type: SocialType) {
super.init(frame: .zero)

self.type = type

setButtonConfiguration()
setSize()
}

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

// MARK: - Setting Method

private func setButtonConfiguration() {
setImage(type.icon, for: .normal)
setImage(type.hoverIcon, for: .highlighted)

setTitle(type.text, for: .normal)
setTitleColor(type.foreground, for: .normal)
setTitleColor(type.foreground.withAlphaComponent(0.5), for: .highlighted)

backgroundColor = type.background

self.layer.cornerRadius = rounding

self.titleLabel?.font = font

self.titleEdgeInsets = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 0)
}

private func setSize() {
self.snp.makeConstraints {
$0.height.equalTo(height)
$0.width.equalTo(width)
}
}

}
#endif
10 changes: 10 additions & 0 deletions CDSKit/Source/Foundation/CDSBaseColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ public enum CDSBaseColor {
return UIColor(hex: "#000000", alpha: 0.8)
}

public static var kakaoBackground: UIColor {
return UIColor(hex: "#FEE500")
}

public static var naverBackground: UIColor {
return UIColor(hex: "#03C75A")
}

// MARK: - Catchu-back Colors

public static var catchu100: UIColor {
Expand Down Expand Up @@ -136,6 +144,7 @@ public enum CDSBaseColor {
}

// MARK: - Check Colors

public static var red100: UIColor {
return UIColor(hex: "#EA4545")
}
Expand All @@ -145,6 +154,7 @@ public enum CDSBaseColor {
}

// MARK: - Hover Colors

public static var hover100: UIColor {
return UIColor(hex: "#FCFCFC", alpha: 0.35)
}
Expand Down
1 change: 1 addition & 0 deletions CDSKit/Source/Foundation/CDSFont.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum CDSFont {

public static let caption0 = UIFont.regularDINProFont(ofSize: 14)
public static let caption1 = UIFont.boldSpoqaFont(ofSize: 12)
public static let caption2 = UIFont.regularSpoqaFont(ofSize: 12)

public static let button0 = UIFont.mediumSpoqaFont(ofSize: 16)
public static let button1 = UIFont.mediumSpoqaFont(ofSize: 14)
Expand Down
7 changes: 7 additions & 0 deletions CDSKit/Source/Foundation/CDSIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ public enum CDSIcon {
public static var icWarning: UIImage { .load(name: "icWarning") }
public static var icLock2Fill: UIImage { .load(name: "systemsLock2Fill") }
public static var icUser3Fill: UIImage { .load(name: "usersUser3Fill") }
public static var icKakao: UIImage { .load(name: "icKakao") }
public static var icNaver: UIImage { .load(name: "icNaver") }
public static var icApple: UIImage { .load(name: "icApple") }
public static var icKakaoHover: UIImage { .load(name: "icKakaoHover") }
public static var icNaverHover: UIImage { .load(name: "icNaverHover") }
public static var icAppleHover: UIImage { .load(name: "icAppleHover") }


// MARK: - Image

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_Apple.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icAppleHover.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_Kakao.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icKakaoHover.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "ic_Naver.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icNaverHover.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions CDSKit/Source/Foundation/CDSTypography.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extension String {
case body7
case caption0
case caption1
case caption2
case button0
case button1
case catchu0
Expand Down Expand Up @@ -65,6 +66,8 @@ extension String {
return CDSFont.caption0
case .caption1:
return CDSFont.caption1
case .caption2:
return CDSFont.caption2
case .button0:
return CDSFont.button0
case .button1:
Expand Down

0 comments on commit 6ac585d

Please sign in to comment.