Skip to content

Commit

Permalink
🎨 refactor/code (#21)
Browse files Browse the repository at this point in the history
* 🎨 μ½”λ“œ MarkUp , 주석 μˆ˜μ •

* mend
  • Loading branch information
O-O-wl authored Jan 2, 2021
1 parent 8d25fa7 commit 518cb3a
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 347 deletions.
6 changes: 3 additions & 3 deletions Dear-World/Dear-World.xcodeproj/MessageCountBadgeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Created by rookie.w on 2020/12/26.
//

import UIKit
import SnapKit
import Then
import SnapKit
import UIKit

public final class MessageCountBadgeView: UIView {
final class MessageCountBadgeView: UIView {
private var totalCount: UILabel = UILabel()

public var count: Int? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Foundation
import ReactorKit

final class CheeringMapReactor: Reactor {

typealias API = World.API
typealias Model = World.Model

Expand All @@ -29,6 +28,8 @@ final class CheeringMapReactor: Reactor {
}

var initialState: State = State()

// MARK: πŸ”« Mutate
func mutate(action: Action) -> Observable<Mutation> {
switch action {
case .viewDidLoad:
Expand All @@ -42,6 +43,7 @@ final class CheeringMapReactor: Reactor {
}
}

// MARK: ⚑️ Reduce
func reduce(state: State, mutation: Mutation) -> State {
var newState = currentState
switch mutation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,140 +8,142 @@
import UIKit

final class MessageTableViewCell: UICollectionViewCell {
let emojiLabel: UILabel = UILabel()
let nameLabel: UILabel = UILabel()
let countryLabel: UILabel = UILabel()
let detailTextView: UITextView = UITextView()
// TODO: likeViewλ₯Ό μ»€μŠ€ν…€λ·°λ‘œ λ§Œλ“€κΈ°
let likeView: UIImageView = UIImageView()
let likeCountLabel: UILabel = UILabel()
let shareButton: UIButton = UIButton()

override func awakeFromNib() {
super.awakeFromNib()
// Initialization code

// MARK: πŸ–Ό UI
let emojiLabel: UILabel = UILabel()
let nameLabel: UILabel = UILabel()
let countryLabel: UILabel = UILabel()
let detailTextView: UITextView = UITextView()
let likeView: UIImageView = UIImageView()
let likeCountLabel: UILabel = UILabel()
let shareButton: UIButton = UIButton()

// MARK: 🏁 Initialize
override init(frame: CGRect) {
super.init(frame: frame)

setupUI()
bind()
}

required init?(coder: NSCoder) {
super.init(coder: coder)

setupUI()
bind()
}

// MARK: πŸŽ› Setup
private func setupUI() {
self.do {
$0.backgroundColor = .white
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 20
}

override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
bind()
let emojiView: UIImageView = UIImageView().then {
$0.image = UIImage(named: "emojiBox")
}
self.addSubview(emojiView)
emojiView.snp.makeConstraints {
$0.top.leading.equalToSuperview().inset(30)
$0.height.width.equalTo(40)
}

required init?(coder: NSCoder) {
super.init(coder: coder)
setupUI()
bind()
self.emojiLabel.do {
$0.text = "πŸŽ…πŸ»"
// FIXME : 14처럼 κ³ μ •λœ κ°’ 없이 μ΅œλŒ€λ‘œ κ½‰μ°¨κ²Œ ν•  수 μ—†λŠ”κ°€?
$0.font = .systemFont(ofSize: 14)
$0.textAlignment = .center
}
self.addSubview(self.emojiLabel)
self.emojiLabel.snp.makeConstraints {
$0.size.equalTo(20)
$0.center.equalTo(emojiView)
}

private func setupUI() {
self.do {
$0.backgroundColor = .white
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 20
}

let emojiView: UIImageView = UIImageView().then {
$0.image = UIImage(named: "emojiBox")
}
self.addSubview(emojiView)
emojiView.snp.makeConstraints {
$0.top.leading.equalToSuperview().inset(30)
$0.height.width.equalTo(40)
}

self.emojiLabel.do {
$0.text = "πŸŽ…πŸ»"
// FIXME : 14처럼 κ³ μ •λœ κ°’ 없이 μ΅œλŒ€λ‘œ κ½‰μ°¨κ²Œ ν•  수 μ—†λŠ”κ°€?
$0.font = .systemFont(ofSize: 14)
$0.textAlignment = .center
}
self.addSubview(self.emojiLabel)
self.emojiLabel.snp.makeConstraints {
$0.size.equalTo(20)
$0.center.equalTo(emojiView)
}

self.nameLabel.do {
$0.text = "Judy"
$0.font = .boldSystemFont(ofSize: 16)
$0.textColor = .warmBlue
}
self.addSubview(self.nameLabel)
self.nameLabel.snp.makeConstraints {
$0.top.equalTo(emojiView.snp.top)
$0.leading.equalTo(emojiView.snp.trailing).offset(10)
$0.trailing.greaterThanOrEqualToSuperview().inset(30)
}

self.countryLabel.do {
$0.text = "πŸ‡°πŸ‡· South Korea"
$0.font = .boldSystemFont(ofSize: 12)
$0.textColor = .grayWhite
}
self.addSubview(self.countryLabel)
self.countryLabel.snp.makeConstraints {
$0.bottom.equalTo(emojiView.snp.bottom)
$0.leading.equalTo(emojiView.snp.trailing).offset(10)
$0.trailing.greaterThanOrEqualToSuperview().inset(30)
}

self.detailTextView.do {
$0.text = "Hello world, dont worry because you’re strong enough to overcome this corona blue. At the end of the day, trust yourself. more"
$0.font = .systemFont(ofSize: 12)
$0.textColor = .black
$0.textContainerInset = .zero
$0.isScrollEnabled = false
$0.isEditable = false
}
self.addSubview(self.detailTextView)
self.detailTextView.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(30)
$0.top.equalTo(emojiView.snp.bottom).offset(10)
$0.height.equalTo(43)
}

self.likeView.do {
$0.image = UIImage(named: "heart")
}
self.addSubview(likeView)
self.likeView.snp.makeConstraints {
$0.leading.equalToSuperview().inset(30)
$0.bottom.equalToSuperview().inset(29)
$0.height.equalTo(17)
$0.width.equalTo(20)
}

self.likeCountLabel.do {
$0.font = .boldSystemFont(ofSize: 12)
$0.textColor = .grayWhite
$0.text = "32"
}
self.addSubview(self.likeCountLabel)
self.likeCountLabel.snp.makeConstraints {
$0.centerY.equalTo(likeView.snp.centerY)
$0.width.equalTo(16)
$0.height.equalTo(14)
$0.leading.equalTo(likeView.snp.trailing).offset(5)
}

self.shareButton.do {
$0.backgroundColor = .refreshingWhite
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 8
$0.setImage(UIImage(named: "share"), for: .normal)
$0.setImage(UIImage(named: "share_press"), for: .highlighted)
$0.tintColor = .warmBlue
}
self.addSubview(shareButton)
shareButton.snp.makeConstraints {
$0.trailing.equalToSuperview().inset(30)
$0.bottom.equalToSuperview().inset(25)
$0.width.equalTo(30)
$0.height.equalTo(25)
}
}
func bind() {

self.nameLabel.do {
$0.text = "Judy"
$0.font = .boldSystemFont(ofSize: 16)
$0.textColor = .warmBlue
}
self.addSubview(self.nameLabel)
self.nameLabel.snp.makeConstraints {
$0.top.equalTo(emojiView.snp.top)
$0.leading.equalTo(emojiView.snp.trailing).offset(10)
$0.trailing.greaterThanOrEqualToSuperview().inset(30)
}

self.countryLabel.do {
$0.text = "πŸ‡°πŸ‡· South Korea"
$0.font = .boldSystemFont(ofSize: 12)
$0.textColor = .grayWhite
}
self.addSubview(self.countryLabel)
self.countryLabel.snp.makeConstraints {
$0.bottom.equalTo(emojiView.snp.bottom)
$0.leading.equalTo(emojiView.snp.trailing).offset(10)
$0.trailing.greaterThanOrEqualToSuperview().inset(30)
}

self.detailTextView.do {
$0.text = "Hello world, dont worry because you’re strong enough to overcome this corona blue. At the end of the day, trust yourself. more"
$0.font = .systemFont(ofSize: 12)
$0.textColor = .black
$0.textContainerInset = .zero
$0.isScrollEnabled = false
$0.isEditable = false
}
self.addSubview(self.detailTextView)
self.detailTextView.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(30)
$0.top.equalTo(emojiView.snp.bottom).offset(10)
$0.height.equalTo(43)
}

self.likeView.do {
$0.image = UIImage(named: "heart")
}
self.addSubview(likeView)
self.likeView.snp.makeConstraints {
$0.leading.equalToSuperview().inset(30)
$0.bottom.equalToSuperview().inset(29)
$0.height.equalTo(17)
$0.width.equalTo(20)
}

self.likeCountLabel.do {
$0.font = .boldSystemFont(ofSize: 12)
$0.textColor = .grayWhite
$0.text = "32"
}
self.addSubview(self.likeCountLabel)
self.likeCountLabel.snp.makeConstraints {
$0.centerY.equalTo(likeView.snp.centerY)
$0.width.equalTo(16)
$0.height.equalTo(14)
$0.leading.equalTo(likeView.snp.trailing).offset(5)
}

self.shareButton.do {
$0.backgroundColor = .refreshingWhite
$0.layer.masksToBounds = true
$0.layer.cornerRadius = 8
$0.setImage(UIImage(named: "share"), for: .normal)
$0.setImage(UIImage(named: "share_press"), for: .highlighted)
$0.tintColor = .warmBlue
}
self.addSubview(shareButton)
shareButton.snp.makeConstraints {
$0.trailing.equalToSuperview().inset(30)
$0.bottom.equalToSuperview().inset(25)
$0.width.equalTo(30)
$0.height.equalTo(25)
}
}

// MARK: πŸ”— Bind
func bind() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ final class DiscoverReactor: Reactor {

var initialState: State

// MARK: 🏁 Initialize
init() {
self.initialState = State()
}

// MARK: πŸ”« Mutate
func mutate(action: Action) -> Observable<Mutation> {
switch action {
case let .countryDidChanged(country):
Expand All @@ -50,13 +52,15 @@ final class DiscoverReactor: Reactor {
.map { .setMessages(result: $0) },
.just(.setLoading(false))
)

case .refresh:
return .concat([
.just(Mutation.setRefreshing(true)),
APIMock().getMessages(page: 1, country: currentState.country)
.map { .setMessages(result: $0) },
.just(Mutation.setRefreshing(false))
])

case .loadMore:
return Observable<Mutation>.concat([
APIMock().getMessages(page: 2, country: currentState.country)
Expand All @@ -65,6 +69,7 @@ final class DiscoverReactor: Reactor {
}
}

// MARK: ⚑️ Reduce
func reduce(state: State, mutation: Mutation) -> State {
var newState: State = state
switch mutation {
Expand Down
Loading

0 comments on commit 518cb3a

Please sign in to comment.