You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.4 KiB
97 lines
2.4 KiB
//
|
|
// DetailNotificationViewController.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon James Kim on 2020/02/11.
|
|
//Copyright © 2020 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
|
|
class DetailNotificationViewController: UIViewController {
|
|
|
|
// MARK: Properties
|
|
var presenter: DetailNotificationPresenter!
|
|
|
|
private let disposeBag = DisposeBag()
|
|
// MARK: Computed Properties
|
|
|
|
// MARK: IBOutlets
|
|
@IBOutlet private weak var imageView: UIImageView!
|
|
@IBOutlet private weak var titleLabel: UILabel!
|
|
@IBOutlet private weak var contentLabel: UILabel!
|
|
@IBOutlet private weak var dateLabel: UILabel!
|
|
@IBOutlet private weak var contentView: UIView!
|
|
|
|
// MARK: VC's Life cycle
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
setup()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
title = "Notice"
|
|
}
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
}
|
|
|
|
// MARK: IBActions
|
|
|
|
}
|
|
|
|
// MARK: Other Functions
|
|
extension DetailNotificationViewController {
|
|
|
|
private func setup() {
|
|
setUI()
|
|
setBinding()
|
|
setUIBinding()
|
|
}
|
|
|
|
private func setUI() {
|
|
}
|
|
|
|
private func setUIBinding() {
|
|
}
|
|
|
|
private func setBinding() {
|
|
let viewWillAppear = rx
|
|
.sentMessage(#selector(UIViewController.viewWillAppear(_:))).mapToVoid().asDriverOnErrorJustComplete()
|
|
|
|
let input = DetailNotificationPresenter.Input(
|
|
viewWillAppear: viewWillAppear
|
|
)
|
|
|
|
let output = presenter.transform(input: input)
|
|
|
|
output.isError
|
|
.drive(
|
|
onNext: { self.alert(type: .error, message: $0.localizedDescription) }
|
|
).disposed(by: disposeBag)
|
|
|
|
output.isProgress
|
|
.drive(
|
|
onNext: { $0 ? self.showProgressHud() : self.hideProgressHud() }
|
|
).disposed(by: disposeBag)
|
|
|
|
output.model.map {$0.body}.drive(contentLabel.rx.text).disposed(by: disposeBag)
|
|
output.model.map {$0.date}.drive(dateLabel.rx.text).disposed(by: disposeBag)
|
|
output.model.map {$0.title ?? ""}.drive(titleLabel.rx.text).disposed(by: disposeBag)
|
|
output.model.map {$0.imageURL}.drive(onNext: {[weak self] in
|
|
guard let imageURL = $0, let url = URL(string: imageURL) else {
|
|
self?.imageView.isHidden = true
|
|
return
|
|
}
|
|
|
|
self?.showProgressHud()
|
|
self?.imageView.kf.setImage(with: url) { _ in
|
|
self?.hideProgressHud()
|
|
}
|
|
}).disposed(by: disposeBag)
|
|
}
|
|
}
|