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

Refactor/#171: ZatchButton, 검색창 등 컴포넌트 생성 및 검색 도메인 리팩토링 #177

Merged
merged 24 commits into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e2f99b5
#176: MySearchViewController > ExchangeMyZatchSearchViewController 네이…
dev-muuu Feb 11, 2023
1502283
#171: Util 클래스로 TagLabel 생성 > padding 가지는 Label 역할
dev-muuu Feb 11, 2023
ed41611
#171: Tag 상속 클래스 UILabel > TagLabel 변경
dev-muuu Feb 11, 2023
264c196
feat: UICollectionView cellForItem(cellType:) 자동 캐스팅 메서드 추가
dev-muuu Feb 11, 2023
0a2feab
#176: MySearchView > ExchangeMyZatchSearchView 네이밍 변경
dev-muuu Feb 11, 2023
fa17dd1
#171: SearchTagCollectionViewCell 생성 > Search 부분 재사용 용도
dev-muuu Feb 11, 2023
c1a6887
#176: ExchangeMyZatchSearchVC SearchTagCollectionViewCell 적용으로 리팩토링
dev-muuu Feb 11, 2023
3866d9c
#171: ZatchButton 컴포넌트 생성
dev-muuu Feb 12, 2023
28faf40
#171: ZatchButton 하위 클래스인 FillButton 컴포넌트 생성
dev-muuu Feb 12, 2023
ab06b62
#176: ExchangeMyZatchSearchView FillButton 컴포넌트 적용
dev-muuu Feb 12, 2023
b4d224a
#171: BorderLine 컴포넌트 생성
dev-muuu Feb 12, 2023
69e57df
#171: 검색입력창 컴포넌트 생성
dev-muuu Feb 12, 2023
ef7e857
#171: TopTitleView 리팩토링 및 iOS 버전으로 속성 적용
dev-muuu Feb 12, 2023
ceae763
#176: SearchTagCollectionViewCell isSelectState 프로퍼티 추가
dev-muuu Feb 12, 2023
ffc86e3
#176: ExchangeMyZatchSearchVC collectionView didSelect/didDeselect 메서…
dev-muuu Feb 12, 2023
e3123c8
#176: ZatchSearchRequestManager 싱글톤 클래스 생성
dev-muuu Feb 12, 2023
43a5d3f
#176: SearchTextFieldView textField 접근제어 private > internal 변경
dev-muuu Feb 12, 2023
0c51f23
#176: ZatchSearchRequestManager myZatch 프로퍼티 추가
dev-muuu Feb 12, 2023
9bde2f1
#176: ExchangeMyZatchSearchView iOS 버전 UI 적용
dev-muuu Feb 12, 2023
d84b7cd
#176: ExchangeMyZatchSearchViewModel 생성 및 ExchangeMyZatchSearchVC RxS…
dev-muuu Feb 12, 2023
91fc5fa
#176: FindSearchTagCollectionViewCell, MySearchTagCollectionViewCell …
dev-muuu Feb 12, 2023
af9ab1d
#176: ExchangeMyZatchSearchViewController > FindSearchViewController …
dev-muuu Feb 12, 2023
3d69c02
#176: FindSearchViewController SearchTagCollectionViewCell과 didSelect…
dev-muuu Feb 12, 2023
c41e468
#176: SearchTagCollectionViewCell height 정적 프로퍼티 선언 및 collectionView …
dev-muuu Feb 12, 2023
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
84 changes: 64 additions & 20 deletions Zatch.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Zatch/Global/Resource/Extenstion/UICollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ extension UICollectionView{
}
return cell
}

final func cellForItem<T: BaseCollectionViewCell>(at indexPath: IndexPath, cellType: T.Type) -> T? {
if let cell = self.cellForItem(at: indexPath) as? T {
return cell
}
return nil
}
}
37 changes: 37 additions & 0 deletions Zatch/Global/Source/Component/BorderLine.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// BorderLine.swift
// Zatch
//
// Created by 박소윤 on 2023/02/12.
//

import Foundation

extension ZatchComponent{

class BorderLine: BaseView{

private let height: CGFloat
private let color: UIColor

init(color: UIColor, height: CGFloat){
self.color = color
self.height = height
super.init(frame: .zero)
}

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

override func style() {
self.backgroundColor = color
}

override func layout() {
self.snp.makeConstraints{
$0.height.equalTo(height)
}
}
}
}
73 changes: 73 additions & 0 deletions Zatch/Global/Source/Component/Button/ZatchButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// ZatchButton.swift
// Zatch
//
// Created by 박소윤 on 2023/02/11.
//

import Foundation

extension ZatchComponent{

enum ZatchButtonConfiguration{
case height48
}

class ZatchButton: UIButton{

var offset: CGFloat{
config.offset
}

private let config: ZatchButtonConfiguration

init(title: String, configuration: ZatchButtonConfiguration){
self.config = configuration
super.init(frame: .zero)
self.setTitle(title, for: .normal)
initialize()
}

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

private func initialize(){
style()
layout()
}

private func style(){
self.layer.cornerRadius = config.height / 2
self.titleLabel?.setTypoStyleWithSingleLine(typoStyle: config.typo)
}

private func layout(){
self.snp.makeConstraints{
$0.height.equalTo(config.height)
}
}
}

}

extension ZatchComponent.ZatchButtonConfiguration{

var height: CGFloat{
switch self{
case .height48: return 48
}
}

var typo: TypoStyle{
switch self{
case .height48: return .bold18
}
}

var offset: CGFloat{
switch self{
case .height48: return 56
}
}
}
51 changes: 51 additions & 0 deletions Zatch/Global/Source/Component/Button/ZatchFillButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// ZatchFillButton.swift
// Zatch
//
// Created by 박소윤 on 2023/02/12.
//

import Foundation

extension ZatchComponent{

class FillButton: ZatchButton{

enum ButtonColor{
case purple
case yellow
}

private let color: ButtonColor

init(color: ButtonColor, title: String, configuration: ZatchComponent.ZatchButtonConfiguration){
self.color = color
super.init(title: title, configuration: configuration)
initialize()
}

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

private func initialize(){
self.backgroundColor = color.backgroundColor
self.setTitleColor(color.textColor, for: .normal)
}
}
}

extension ZatchComponent.FillButton.ButtonColor{
var backgroundColor: UIColor{
switch self{
case .purple: return .zatchPurple
case .yellow: return .zatchDeepYellow
}
}

var textColor: UIColor{
switch self{
default: return .white
}
}
}
48 changes: 48 additions & 0 deletions Zatch/Global/Source/Component/SearchTextFieldView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// SearchTextFieldView.swift
// Zatch
//
// Created by 박소윤 on 2023/02/12.
//

import Foundation

extension ZatchComponent{

class SearchTextFieldView: BaseView{

let textField = UITextField().then{
$0.font = UIFont.pretendard(size: 18, family: .Bold)
$0.textAlignment = .center
}
private let searchIcon = UIImageView().then{
$0.image = Image.search
}
private let borderLine = ZatchComponent.BorderLine(color: .black85, height: 2)

override func hierarchy() {
self.addSubview(textField)
self.addSubview(searchIcon)
self.addSubview(borderLine)
}

override func layout() {
borderLine.snp.makeConstraints{
$0.leading.equalToSuperview().offset(40)
$0.trailing.equalToSuperview().offset(-40)
$0.bottom.equalToSuperview().offset(-16)
}
searchIcon.snp.makeConstraints{
$0.width.height.equalTo(28)
$0.top.equalToSuperview().offset(12)
$0.trailing.equalToSuperview().offset(-48)
$0.bottom.equalToSuperview().offset(-24)
}
textField.snp.makeConstraints{
$0.bottom.equalTo(borderLine.snp.top).offset(-10)
$0.trailing.equalTo(searchIcon.snp.leading).offset(-10)
$0.centerX.equalToSuperview()
}
}
}
}
17 changes: 2 additions & 15 deletions Zatch/Global/Source/Component/Tag/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension ZatchComponent{
}
}

class Tag: UILabel{
class Tag: TagLabel{

var isDisabled = false{
didSet{
Expand All @@ -50,27 +50,14 @@ extension ZatchComponent{
init(color: TagColor, configuration: TagType){
self.colorType = color
self.configuration = configuration
super.init(frame: .zero)
super.init(padding: configuration.padding)
initialize()
}

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

override func drawText(in rect: CGRect) {
let inset = configuration.padding.inset
super.drawText(in: rect.inset(by: inset))
}

override var intrinsicContentSize: CGSize{
let padding = configuration.padding
var contentSize = super.intrinsicContentSize
contentSize.height += padding.top + padding.bottom
contentSize.width += padding.left + padding.right
return contentSize
}

private func initialize(){
style()
layout()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// UIContainerView.swift
// TopTitleView.swift
// Zatch
//
// Created by 박지윤 on 2022/05/02.
Expand All @@ -8,21 +8,26 @@
import Foundation
import UIKit

class TitleView: UIView{
class TopTitleView: BaseView{

let titleLabel = UILabel().then{
private let titleLabel = UILabel().then{
$0.numberOfLines = 0
$0.font = UIFont.pretendard(size: 20, family: .Bold)
$0.font = UIFont.pretendard(size: 22, family: .Bold)
}

override init(frame: CGRect){
super.init(frame: frame)

self.snp.makeConstraints{ make in
make.height.equalTo(88)
}
init(title: String){
self.titleLabel.text = title
super.init(frame: .zero)
}

override func hierarchy() {
self.addSubview(titleLabel)

}

override func layout() {
self.snp.makeConstraints{
$0.height.equalTo(120)
}
titleLabel.snp.makeConstraints{ make in
make.top.equalToSuperview().offset(16)
make.leading.equalToSuperview().offset(28)
Expand Down
33 changes: 33 additions & 0 deletions Zatch/Global/Source/Utils/TagLabel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// TagLabel.swift
// Zatch
//
// Created by 박소윤 on 2023/02/11.
//

import Foundation

class TagLabel: UILabel{

private let padding: UIEdgeInsets

init(padding: ZatchComponent.Padding){
self.padding = padding.inset
super.init(frame: .zero)
}

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

override func drawText(in rect: CGRect) {
super.drawText(in: rect.inset(by: padding))
}

override var intrinsicContentSize: CGSize {
var contentSize = super.intrinsicContentSize
contentSize.height += padding.top + padding.bottom
contentSize.width += padding.left + padding.right
return contentSize
}
}

This file was deleted.

This file was deleted.

Loading