Skip to content

Commit

Permalink
Qa 1 (#36)
Browse files Browse the repository at this point in the history
* ๐Ÿ› Discover ๋‚˜๋ผ ํ•„ํ„ฐ ๋‚˜๋ผ ๊ธ€์ž ์ˆ˜ ๋ฌด์ œํ•œ ๋…ธ์ถœ ๋ฒ„๊ทธ

* ๐Ÿ› Discover ๋‚˜๋ผ ํ•„ํ„ฐ ๊ธ€์ž ์™ผ์ชฝ ์ •๋ ฌ

* ๐Ÿ› Discover ํ•˜ํŠธ ์ดˆ๊ธฐํ™” (sort ๊ฐ™์€ ํ˜„์ƒ)

* no message

* ๐Ÿ”จ๐Ÿ› discover ์ƒˆ๋กœ๊ณ ์นจ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ & weekly hot ํ˜ธ์ถœ ๋ฒ„๊ทธ ์ˆ˜์ •
  • Loading branch information
wan088 authored Jan 11, 2021
1 parent 4fa9ac4 commit 7bf2c46
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension Message.API {
var parameters: [String: Any?]? {
[
"countryCode": countryCode,
"type": type,
"type": type.rawValue,
"lastId": lastMsgId
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ final class MessageTableViewCell: UITableViewCell {
}
}
var isLike: Bool = false {
//FIXME : ๋‚ด๋ ค์˜ฌ ๋•Œ isLiked๊ฐ€ ํ•ญ์ƒ false๋กœ ๋‚ด๋ ค์˜ด
didSet {
self.likeView.image = isLike ? UIImage(named: "heart_liked") : UIImage(named: "heart")
self.likeCountLabel.textColor = isLike ? .loveRed : .grayWhite
}
}
var messageId: Int?
Expand Down Expand Up @@ -94,7 +94,7 @@ final class MessageTableViewCell: UITableViewCell {
self.nameLabel.snp.makeConstraints {
$0.top.equalTo(emojiView.snp.top)
$0.leading.equalTo(emojiView.snp.trailing).offset(10)
$0.trailing.greaterThanOrEqualToSuperview().inset(30)
$0.trailing.lessThanOrEqualToSuperview()
}

mainView.addSubview(countryFlagImageView)
Expand All @@ -106,19 +106,19 @@ final class MessageTableViewCell: UITableViewCell {
self.countryLabel.do {
$0.text = "South Korea"
$0.font = .boldSystemFont(ofSize: 12)
$0.textColor = .grayWhite
$0.textColor = .nightBlue
}
mainView.addSubview(self.countryLabel)
self.countryLabel.snp.makeConstraints {
$0.centerY.equalTo(countryFlagImageView)
$0.leading.equalTo(countryFlagImageView.snp.trailing).offset(10)
$0.trailing.greaterThanOrEqualToSuperview().inset(30)
$0.bottom.equalTo(emojiView.snp.bottom)
$0.leading.equalTo(emojiView.snp.trailing).offset(10)
$0.trailing.lessThanOrEqualToSuperview()
}

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.textColor = .warmBlue
$0.textContainerInset = .zero
$0.isScrollEnabled = false
$0.isEditable = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ final class DiscoverReactor: Reactor {
messageCount: 0,
messages: []
)
var isRefreshing: Bool = false
@Revision var isRefreshing: Bool = false

var isLoading: Bool = false
var isAnimating: Bool = false
@Revision var isPresentAboutPage: Bool = false
Expand Down Expand Up @@ -120,19 +121,26 @@ final class DiscoverReactor: Reactor {
countryCode: currentState.selectedCountry?.code,
lastMsgId: nil,
type: sortType ?? .recent
)
)
.filterNil()
.map{ Mutation.setMessages(result: $0) },
.just(.setLoading(false))
))
.filterNil()
.map{ .setMessages(result: $0)},
.just(.setLoading(false))
)
)
case .refresh:
return .concat([
.just(Mutation.setRefreshing(true)),
.just(Mutation.setRefreshing(false))
])

guard currentState.isRefreshing == false else { return .empty() }
return .merge(
Network.request(Message.API.MessageCount(countryCode: currentState.selectedCountry?.code))
.filterNil()
.map(\.messageCount)
.map{.setMessageCount($0)}
,.concat([
.just(.setRefreshing(true)),
Network.request(Message.API.Messages(countryCode: currentState.selectedCountry?.code, lastMsgId: nil, type: currentState.selectedSortType))
.filterNil()
.map{.setMessages(result: $0)},
.just(.setRefreshing(false))
]))
case .loadMore:
guard !currentState.isLoading else { return .empty() }
return Observable<Mutation>.concat([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ final class DiscoverViewController: UIViewController, View {
private let sortView: UIView = UIView()
private var sortLabel: UILabel = UILabel()
private var messages: [Message.Model.Message] = []
let filterContainerView: UIView = UIView()
private let filterContainerView: UIView = UIView()
private let refreshControl: UIRefreshControl = UIRefreshControl()

var disposeBag: DisposeBag = DisposeBag()

Expand Down Expand Up @@ -93,6 +94,7 @@ final class DiscoverViewController: UIViewController, View {
countryLabel.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.leading.equalTo(CountryFilterView.snp.leading)
$0.width.lessThanOrEqualTo(200)
}
let select: UIImageView = UIImageView().then {
$0.image = UIImage(named: "select")
Expand Down Expand Up @@ -144,6 +146,15 @@ final class DiscoverViewController: UIViewController, View {
$0.sectionHeaderHeight = 150
$0.tableHeaderView = nil
$0.allowsSelection = false
$0.refreshControl = refreshControl
}

refreshControl.addTarget(self, action: #selector(tableViewWillRefresh), for: .valueChanged)
}

@objc private func tableViewWillRefresh() {
if self.refreshControl.isRefreshing {
reactor?.action.on(.next(.refresh))
}
}

Expand Down Expand Up @@ -284,6 +295,13 @@ final class DiscoverViewController: UIViewController, View {
.map(\.title)
.bind(to: self.sortLabel.rx.text)
.disposed(by: self.disposeBag)

reactor.state
.distinctUntilChanged(\.$isRefreshing)
.map(\.isRefreshing)
.filter{!$0}
.bind(to: self.refreshControl.rx.isRefreshing)
.disposed(by: self.disposeBag)
}
}
extension DiscoverViewController: UITableViewDelegate, UITableViewDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ public final class CountrySelectController: UIViewController {
let cellBackgroudView = UIView()
cellBackgroudView.backgroundColor = .breathingWhite
cell.selectedBackgroundView = cellBackgroudView
//TODO: CheckMark ๋‹ฌ๊ธฐ
cell.textLabel?.snp.makeConstraints {
$0.left.equalToSuperview().inset(20)
$0.centerY.equalToSuperview()
}
return cell
}
.disposed(by: self.disposeBag)
Expand Down Expand Up @@ -242,4 +245,3 @@ public class AllCountries {
})
}
}

0 comments on commit 7bf2c46

Please sign in to comment.