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

Qa 1 #36

Merged
merged 5 commits into from
Jan 11, 2021
Merged

Qa 1 #36

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
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 {
})
}
}