Show the start day on the table header view
MODIFY
frontend/ios/DroidKaigi 2019/Scenes/Session/SessionTableHeaderView.swift
frontend/ios/DroidKaigi 2019/Scenes/Session/SessionTableHeaderView.swift
@@ -12,6 +12,12 @@ import SnapKit
class SessionTableHeaderView: UIView {
+ var startDayText: Binder<String> {
+ return Binder(startDayLabel) { label, text in
+ label.text = text
+ }
+ }
+
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
@@ -31,7 +37,6 @@ class SessionTableHeaderView: UIView {
label.numberOfLines = 1
label.font = UIFont.systemFont(ofSize: 20)
label.textColor = UIColor(hex: "95959c")
- label.text = "2019.2.7"
return label
}()

MODIFY
frontend/ios/DroidKaigi 2019/Scenes/Session/SessionsViewController.swift
frontend/ios/DroidKaigi 2019/Scenes/Session/SessionsViewController.swift
@@ -61,8 +61,11 @@ final class SessionsViewController: UIViewController {
private func bind() {
let viewWillAppear = rx.methodInvoked(#selector(self.viewWillAppear)).map { _ in }
+ let topVisibleSession = dataSource.topVisibleSession
let toggleFavorite = dataSource.toggleFavorite
- let input = SessionsViewModel.Input(viewWillAppear: viewWillAppear, toggleFavorite: toggleFavorite)
+ let input = SessionsViewModel.Input(viewWillAppear: viewWillAppear,
+ topVisibleSession: topVisibleSession,
+ toggleFavorite: toggleFavorite)
let output = viewModel.transform(input: input)
output.error
.drive(onNext: { errorMessage in
@@ -71,12 +74,13 @@ final class SessionsViewController: UIViewController {
}
})
.disposed(by: bag)
- output.sessions
- .drive(tableView.rx.items(dataSource: dataSource))
+
+ output.startDayText
+ .drive(tableHeaderView.startDayText)
.disposed(by: bag)
- dataSource.topVisibleSession
- .subscribe(onNext: { print($0.id_) })
+ output.sessions
+ .drive(tableView.rx.items(dataSource: dataSource))
.disposed(by: bag)
}
}

MODIFY
frontend/ios/DroidKaigi 2019/Scenes/Session/SessionsViewModel.swift
frontend/ios/DroidKaigi 2019/Scenes/Session/SessionsViewModel.swift
@@ -40,10 +40,12 @@ extension SessionsViewModel {
struct Input {
let viewWillAppear: Observable<Void>
+ let topVisibleSession: Observable<Session>
let toggleFavorite: Observable<Session>
}
struct Output {
+ let startDayText: Driver<String>
let sessions: Driver<[SessionByStartTime]>
let error: Driver<String?>
}
@@ -53,6 +55,11 @@ extension SessionsViewModel {
.subscribe(onNext: { [weak self] in self?.favoriteRepository.toggle(sessionId: $0.id_) })
.disposed(by: bag)
+ let startDayText = input.topVisibleSession
+ .map { $0.startDayText }
+ .distinctUntilChanged()
+ .asDriver(onErrorJustReturn: "")
+
let sessionContents = input.viewWillAppear
.flatMap { [weak self] (_) -> Observable<SessionContents> in
guard let `self` = self else { return Observable.empty() }
@@ -99,6 +106,6 @@ extension SessionsViewModel {
}
.asDriver(onErrorJustReturn: [])
let error = _error.asDriver()
- return Output(sessions: sessions, error: error)
+ return Output(startDayText: startDayText, sessions: sessions, error: error)
}
}

Show the start day on the table header view