return cell
|
144
|
140
|
})
|
|
145
|
141
|
}
|
|
|
|
@@ -168,6 +164,11 @@ extension PhotoDetailViewController {
|
|
168
|
164
|
bindCollectionViewToListViewModel()
|
|
169
|
165
|
bindListViewModelToCollectionView()
|
|
170
|
166
|
|
|
|
167
|
+ bindViewModelToWatermarkImage()
|
|
|
168
|
+ bindViewModelToWatermarkLabel()
|
|
|
169
|
+ bindViewModelToWatermarkImageWithBought()
|
|
|
170
|
+ bindViewModelToWatermarkLabelWithBought()
|
|
|
171
|
+
|
|
171
|
172
|
bindViewWillAppear()
|
|
172
|
173
|
|
|
173
|
174
|
monitorKeyboardWillShow()
|
|
|
|
@@ -244,7 +245,7 @@ extension PhotoDetailViewController {
|
|
244
|
245
|
}
|
|
245
|
246
|
|
|
246
|
247
|
func bindListViewModelToCollectionView() {
|
|
247
|
|
- listViewModel.content
|
|
|
248
|
+ viewModel.content
|
|
248
|
249
|
.bind(to: photoCollectionView.rx.items(dataSource: photoCollectionViewDataSource))
|
|
249
|
250
|
.disposed(by: disposeBag)
|
|
250
|
251
|
}
|
|
|
|
@@ -253,7 +254,7 @@ extension PhotoDetailViewController {
|
|
253
|
254
|
photoCollectionView.rx.willDisplayCell
|
|
254
|
255
|
.asDriver()
|
|
255
|
256
|
.drive(onNext: { [unowned self] in
|
|
256
|
|
- self.listViewModel.willShow(index: $0.at.row)
|
|
|
257
|
+ self.viewModel.willShow(index: $0.at.row)
|
|
257
|
258
|
})
|
|
258
|
259
|
.disposed(by: disposeBag)
|
|
259
|
260
|
}
|
|
|
|
@@ -261,15 +262,31 @@ extension PhotoDetailViewController {
|
|
261
|
262
|
func bindCollectionViewSelected() {
|
|
262
|
263
|
photoCollectionView.rx.itemSelected
|
|
263
|
264
|
.asDriver(onErrorJustReturn: IndexPath(item: 0, section: 0))
|
|
264
|
|
- .drive(onNext: { [unowned self] _ in self.listViewModel.didSelected() })
|
|
|
265
|
+ .drive(onNext: { [unowned self] _ in self.viewModel.didSelected() })
|
|
265
|
266
|
.disposed(by: disposeBag)
|
|
266
|
267
|
}
|
|
267
|
268
|
|
|
|
269
|
+ func bindViewModelToWatermarkImage() {
|
|
|
270
|
+ viewModel.watermarkImage.bind(to: waterMarkImage.rx.isHidden).disposed(by: disposeBag)
|
|
|
271
|
+ }
|
|
|
272
|
+
|
|
|
273
|
+ func bindViewModelToWatermarkLabel() {
|
|
|
274
|
+ viewModel.watermarkText.bind(to: waterMarkLabel.rx.text).disposed(by: disposeBag)
|
|
|
275
|
+ }
|
|
|
276
|
+
|
|
|
277
|
+ func bindViewModelToWatermarkImageWithBought() {
|
|
|
278
|
+ viewModel.watermarkImageWithBought.bind(to: waterMarkImage.rx.isHidden).disposed(by: disposeBag)
|
|
|
279
|
+ }
|
|
|
280
|
+
|
|
|
281
|
+ func bindViewModelToWatermarkLabelWithBought() {
|
|
|
282
|
+ viewModel.watermarkTextWithBought.bind(to: waterMarkLabel.rx.text).disposed(by: disposeBag)
|
|
|
283
|
+ }
|
|
|
284
|
+
|
|
268
|
285
|
func bindViewWillAppear() {
|
|
269
|
286
|
viewModel.viewWillAppear
|
|
270
|
287
|
.asDriver()
|
|
271
|
288
|
.drive(onNext: { [unowned self] _ in
|
|
272
|
|
- self.photoCollectionView.scrollToItem(at: IndexPath(item: self.listViewModel.currIndex, section: 0), at: .right, animated: false)
|
|
|
289
|
+ self.photoCollectionView.scrollToItem(at: IndexPath(item: self.viewModel.currIndex, section: 0), at: .right, animated: false)
|
|
273
|
290
|
})
|
|
274
|
291
|
.disposed(by: disposeBag)
|
|
275
|
292
|
}
|
|
|
|
@@ -17,7 +17,7 @@ final class PhotoPreviewViewController: UIViewController {
|
|
17
|
17
|
|
|
18
|
18
|
/// MARK: Storyboard property
|
|
19
|
19
|
@IBOutlet weak var collectionView: UICollectionView!
|
|
20
|
|
- var viewModel: PhotoDetailListViewModel!
|
|
|
20
|
+ var viewModel: PhotoDetailViewModel!
|
|
21
|
21
|
var disposeBag = DisposeBag()
|
|
22
|
22
|
|
|
23
|
23
|
override var prefersStatusBarHidden: Bool {
|
|
|
|
@@ -29,7 +29,6 @@ final class PhotoPreviewViewController: UIViewController {
|
|
29
|
29
|
binding()
|
|
30
|
30
|
scrollToSpecifiedImage()
|
|
31
|
31
|
navigationController?.setNavigationBarHidden(true, animated: true)
|
|
32
|
|
-
|
|
33
|
32
|
}
|
|
34
|
33
|
|
|
35
|
34
|
func scrollToSpecifiedImage() {
|