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

[E03 T01] 장르, Sort정보(난이도, 만족도, 거리순) 버튼 Cell UI를 작업한다. #22

Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions Escaper/Escaper/Common/Library/ColorPalette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
enum ColorPalette {
case bloodyBlack
case bloodyBurgundy
case bloodyDarkBurgundy
case bloodyRed
case charcoal
case gloomyPink
Expand Down
7 changes: 6 additions & 1 deletion Escaper/Escaper/Domain/DataStruct/Genre.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import Foundation

enum Genre: String, Codable {
enum Genre: String, Tagable, CaseIterable, Codable {

var name: String {
return self.rawValue
}

case all = "전체"
case history = "역사"
case fear = "공포"
Expand Down
2 changes: 1 addition & 1 deletion Escaper/Escaper/Domain/DataStruct/SortingOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum SortingOption: String {
enum SortingOption: String, Tagable, CaseIterable {
case satisfaction = "만족도순"
case level = "난이도순"
case distance = "거리순"
Expand Down
12 changes: 12 additions & 0 deletions Escaper/Escaper/Domain/Protocol/Tagable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Tagable.swift
// Escaper
//
// Created by shinheeRo on 2021/11/03.
//

import Foundation

protocol Tagable {
var name: String { get }
}
44 changes: 44 additions & 0 deletions Escaper/Escaper/Presentation/RoomList/Views/TagButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// TagButton.swift
// Escaper
//
// Created by shinheeRo on 2021/11/03.
//

import UIKit

class TagButton: UIButton {

shinhee-rebecca marked this conversation as resolved.
Show resolved Hide resolved
private(set) var element: Tagable?

required init?(coder: NSCoder) {
super.init(coder: coder)
self.configure()
}

override init(frame: CGRect) {
super.init(frame: frame)
self.configure()
}

convenience init(element: Tagable) {
self.init(frame: .zero)
self.element = element
self.setTitle(element.name, for: .normal)
}

private func configure() {
self.layer.cornerRadius = 5
self.titleLabel?.textColor = UIColor(named: ColorPalette.skullWhite.code)
self.untouched()
}

func touched() {
self.backgroundColor = UIColor(named: ColorPalette.pumpkin.code)
}

func untouched() {
self.backgroundColor = UIColor(named: ColorPalette.bloodyDarkBurgundy.code)
}

}