Skip to content

Commit

Permalink
Merge branch 'hotfix/trending_avatar'
Browse files Browse the repository at this point in the history
  • Loading branch information
87kangsw committed Jun 7, 2020
2 parents bdb9f1d + a86650f commit 9c751fe
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions GitTime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.3.1;
PRODUCT_BUNDLE_IDENTIFIER = io.github.87kangsw.GitTime;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1548,7 +1548,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.3.1;
PRODUCT_BUNDLE_IDENTIFIER = io.github.87kangsw.GitTime;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ActivityViewController: BaseViewController, StoryboardView, ReactorBased {
return contributionView
}()
var filterButton: UIBarButtonItem!
private let refreshControl = UIRefreshControl()

// MARK: - Properties
static var dataSource: RxTableViewSectionedReloadDataSource<ActivitySection> {
Expand Down Expand Up @@ -67,11 +68,13 @@ class ActivityViewController: BaseViewController, StoryboardView, ReactorBased {

tableView.registerNib(cellType: ActivityItemCell.self)
tableView.registerNib(cellType: EmptyTableViewCell.self)

tableView.backgroundColor = .background
tableView.separatorColor = .underLine
tableView.tableFooterView = UIView()

tableView.refreshControl = refreshControl

let width: CGFloat = UIScreen.main.bounds.width

contributionHeaderView.snp.makeConstraints { make in
Expand Down Expand Up @@ -103,15 +106,25 @@ class ActivityViewController: BaseViewController, StoryboardView, ReactorBased {
.bind(to: reactor.action)
.disposed(by: self.disposeBag)

refreshControl.rx.controlEvent(.valueChanged)
.map { Reactor.Action.refresh }
.bind(to: reactor.action)
.disposed(by: self.disposeBag)

// State
reactor.state.map { $0.isLoading }
.bind(to: loadingIndicator.rx.isAnimating)
.disposed(by: self.disposeBag)

reactor.state.map { $0.isRefreshing }
.distinctUntilChanged()
.bind(to: refreshControl.rx.isRefreshing)
.disposed(by: self.disposeBag)

reactor.state.map { $0.sectionItems }
.bind(to: tableView.rx.items(dataSource: dataSource))
.disposed(by: self.disposeBag)

reactor.state.map { $0.contributionInfo }
.filterNil()
.take(1)
Expand Down
14 changes: 14 additions & 0 deletions GitTime/Sources/ViewControllers/Activity/ActivityViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ final class ActivityViewReactor: Reactor {
enum Action {
case firstLoad
case loadMoreActivities
case refresh
}

enum Mutation {
Expand All @@ -29,10 +30,12 @@ final class ActivityViewReactor: Reactor {
case fetchActivityMore([Event], nextPage: Int, canLoadMore: Bool)
case setPage(Int)
case setLoadMore(Bool)
case setRefreshing(Bool)
}

struct State {
var isLoading: Bool = false
var isRefreshing: Bool = false
var page: Int = 1
var canLoadMore: Bool = true
var contributionInfo: ContributionInfo?
Expand Down Expand Up @@ -80,6 +83,15 @@ final class ActivityViewReactor: Reactor {
let disableLoadMore: Observable<Mutation> = .just(.setLoadMore(false))
let requestMoreActivityMuation: Observable<Mutation> = self.requestMoreActivities()
return .concat([disableLoadMore, requestMoreActivityMuation])
case .refresh:
guard !self.currentState.isLoading else { return .empty() }
guard !self.currentState.isRefreshing else { return .empty() }
let clearPagingMutation = self.clearPaging()
let startRefreshing: Observable<Mutation> = .just(.setRefreshing(true))
let endRefreshing: Observable<Mutation> = .just(.setRefreshing(false))
let requestContributionMutation = self.requestContributions()
let requestActivityMutation = self.requestActivities()
return .concat([clearPagingMutation, startRefreshing, requestContributionMutation, requestActivityMutation, endRefreshing])
}
}

Expand All @@ -89,6 +101,8 @@ final class ActivityViewReactor: Reactor {
switch mutation {
case let .setLoading(isLoading):
state.isLoading = isLoading
case let .setRefreshing(isRefreshing):
state.isRefreshing = isRefreshing
case let .setPage(page):
state.page = page
case let .setLoadMore(canLoadMore):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ final class TrendViewReactor: Reactor {
let name = item.xpath(".//div[@class='d-sm-flex flex-auto']/div[@class='col-sm-8 d-md-flex']/div[@class='col-md-6'][1]/h1")
let username = item.xpath(".//div[@class='d-sm-flex flex-auto']/div[@class='col-sm-8 d-md-flex']/div[@class='col-md-6'][1]/p")
let url = "https://github.com"
let avatar = item.xpath(".//div[@class='mx-3']/a/img[@class='rounded-1']/@src")
let avatar = item.xpath(".//div[@class='mx-3']/a/img[@class='rounded-1 avatar-user']/@src")
let repoName = item.xpath(".//h1[@class='h4 lh-condensed']")
let repoURL = item.xpath(".//h1[@class='h4 lh-condensed']/a/@href")
let repoDescription = item.xpath(".//div[@class='f6 text-gray mt-1']")
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 4aee58e7a538e3f38bebcdc9cb32d29de257465d

COCOAPODS: 1.8.4
COCOAPODS: 1.9.2

0 comments on commit 9c751fe

Please sign in to comment.