Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
628 changes: 628 additions & 0 deletions week8/UMC_KREAM.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions week8/UMC_KREAM/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
35 changes: 35 additions & 0 deletions week8/UMC_KREAM/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions week8/UMC_KREAM/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
76 changes: 76 additions & 0 deletions week8/UMC_KREAM/Common/CustomNavagationTitle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// CustomNavagationTitle.swift
// UMC_KREAM
//
// Created by 소민준 on 11/19/24.
//

import UIKit
import SnapKit

class CustomNavagationTitle: UIView {

let titleText: String
let subTitleText: String?


init(frame: CGRect, titleText: String, subTitleText: String?) {
self.titleText = titleText
self.subTitleText = subTitleText

super.init(frame: frame)

setTitle(title: titleText, subTitle: subTitleText)
constraints()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
/// 네비게이션 타이틀뷰의 메인 타이틀 라벨
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = .black
label.font = UIFont.systemFont(ofSize: 15, weight: .bold)
return label
}()

/// 네비게이션 타이틀뷰의 서브 타이틀 라벨
private lazy var subTitleLabel: UILabel = {
let label = UILabel()
label.textColor = .gray
label.font = UIFont.systemFont(ofSize: 10, weight: .regular)
return label
}()

/// 네비게이션 타이틀뷰의 메인 타이틀 + 서브 타이틀 스택
private lazy var titleStack: UIStackView = {
let stack = UIStackView(arrangedSubviews: [titleLabel, subTitleLabel])
stack.axis = .vertical
stack.spacing = 2
stack.alignment = .center
return stack
}()

// MARK: - Function

/// 초기화를 통해 전달 받은 메인 타이틀 값, 서브 타이틀 값을 전달하여 해당 라벨에 적용
/// - Parameters:
/// - title: 초기화를 통해 설정된 메인 타이틀 값
/// - subTitle: 초기화를 통해 설정된 서브 타이틀 값
private func setTitle(title: String, subTitle: String?) {
self.titleLabel.text = title
self.subTitleLabel.text = subTitle ?? nil
}

/// 제약 조건 설정
private func constraints() {
self.addSubview(titleStack)
titleStack.snp.makeConstraints {
$0.centerY.centerX.equalToSuperview()
}
}


}

45 changes: 45 additions & 0 deletions week8/UMC_KREAM/Common/PurchaseBottomBackground.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// PurchaseBottomBackground.swift
// UMC_KREAM
//
// Created by 소민준 on 11/19/24.
//

import UIKit

class PurchaseBottomBackground: UIView {

// MARK: - Init
override init(frame: CGRect) {
super.init(frame: frame)

self.backgroundColor = .white
self.addSubview(topLine)
constraints()
}

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

// MARK: - Property

/// 상단 구분선, 피그마를 통해 확대해서 보면 상단 선이 있음을 확인 가능
/// 피그마의 라인 색을 적용 안하고 연한색 값을 그냥 넣어서 작성함
private lazy var topLine: UIView = {
let view = UIView()
view.backgroundColor = .systemGray5
return view
}()

// MARK: - Function

/// 제약 조건 설정
private func constraints() {
topLine.snp.makeConstraints {
$0.top.left.equalToSuperview()
$0.width.equalToSuperview()
$0.height.equalTo(1)
}
}
}
149 changes: 149 additions & 0 deletions week8/UMC_KREAM/Common/PurchaseButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
//
// PurchaseButton.swift
// UMC_KREAM
//
// Created by 소민준 on 11/19/24.
//

import UIKit

class PurchaseButton: UIView, PurchaseButtonProtocol {

let btnType: PurchaseButtonType
init(frame: CGRect, btnType: PurchaseButtonType) {
self.btnType = btnType
super.init(frame: frame)

setConfigure(type: btnType)
setBackgroundColor(type: btnType)
addStackView()
addComponents()
constraints()
}

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

/// 커스텀 버튼에서 사용할 가격 표시 라벨
var priceLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 13, weight: .semibold)
label.textColor = UIColor.white
return label
}()

/// 커스텀 버튼에서 사용할 가격 밑에 보이는 텍스트, "즉시 판매가", "즉시 구매가"
var subLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 10, weight: .regular)
return label
}()

/// 버튼의 왼쪽에 구매 타입의 버튼인지, 판매 타입의 버튼인지 텍스트를 보일 라벨
var buttonLeftLabel: UILabel = {
let label = UILabel()
label.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
label.textColor = .white
return label
}()

/// priceLabel + subLabel을 담을 스택
var priceInfoStack: UIStackView = {
let stack = UIStackView()
stack.axis = .vertical
stack.spacing = 2
stack.distribution = .equalSpacing
stack.alignment = .leading
return stack
}()

// MARK: - Function

/// 컴포넌트 스택에 추가
private func addStackView() {
[priceLabel, subLabel].forEach{ self.priceInfoStack.addArrangedSubview($0) }
}

/// 버튼 내부에 추가할 컴포넌트
private func addComponents() {
[buttonLeftLabel, priceInfoStack].forEach{ self.addSubview($0) }
}

/// 제약 조건 설정
private func constraints() {
buttonLeftLabel.snp.makeConstraints {
$0.top.equalToSuperview().offset(15)
$0.bottom.equalToSuperview().offset(-15)
$0.left.equalToSuperview().offset(10)
$0.width.equalTo(28)
}

priceInfoStack.snp.makeConstraints {
$0.top.equalToSuperview().offset(8)
$0.left.equalTo(buttonLeftLabel.snp.right).offset(21)
$0.width.greaterThanOrEqualTo(53)
$0.height.equalTo(30)
}

priceLabel.snp.makeConstraints {
$0.width.greaterThanOrEqualTo(30)
$0.height.equalTo(16)
}

subLabel.snp.makeConstraints {
$0.width.greaterThanOrEqualTo(30)
$0.height.equalTo(12)
}
}

// MARK: - SetupButton Custom

/// 버튼 타입을 통해 버튼 내부 텍스트 커스텀 및 버튼 자체 커스텀
/// - Parameter type: 구매 버튼 or 판매 버튼
private func setConfigure(type: PurchaseButtonType) {

self.clipsToBounds = true
self.layer.cornerRadius = 10

buttonLeftLabel.text = buttonLeftText(type: type)
subLabel.textColor = setTextColor(type: type)
}


/// 버튼 타입에 따른 서브라벨 텍스트 컬러 반환
/// - Parameter type: 구매 버튼 or 판매 버튼
/// - Returns: 버튼 타입에 맞는 컬러 반환
private func setTextColor(type: PurchaseButtonType) -> UIColor {
switch type {
case .purchase:
return UIColor(red: 0.639, green: 0.216, blue: 0.137, alpha: 1)
case .sales:
return UIColor(red: 0.122, green: 0.467, blue: 0.271, alpha: 1)
}
}

/// 버튼 타입에 따른 버튼 배경색 반환
/// - Parameter type: 구매 버튼 or 판매 버튼
private func setBackgroundColor(type: PurchaseButtonType) {
switch type {
case .purchase:
self.backgroundColor = UIColor(red: 0.937, green: 0.384, blue: 0.329, alpha: 1)
case .sales:
self.backgroundColor = UIColor(red: 0.255, green: 0.725, blue: 0.478, alpha: 1)
}
}

/// 버튼 타입에 따른 왼쪽 타입을 나타내는 텍스트 반환
/// - Parameter type: 구매 버튼 or 판매 버튼
/// - Returns: 타입을 스트링으로 반환
private func buttonLeftText(type: PurchaseButtonType) -> String {
switch type {
case .purchase:
return "구매"
case .sales:
return "판매"
}
}
}
Loading