Skip to content

Commit

Permalink
Improve code (#843)
Browse files Browse the repository at this point in the history
* Improve PDFReaderViewController code

* Improve PDFReaderViewController code

* Fix AnnotationToolOptionsViewController memory leak

Improve AnnotationToolOptionsViewController code
  • Loading branch information
mvasilak authored Feb 9, 2024
1 parent 3ccb1ff commit e9afa97
Show file tree
Hide file tree
Showing 2 changed files with 366 additions and 365 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class AnnotationToolOptionsViewController: UIViewController {

viewModel.stateObservable
.observe(on: MainScheduler.instance)
.subscribe(with: self, onNext: { _, state in
update(state: state)
.subscribe(onNext: { [weak self] state in
self?.update(state: state)
})
.disposed(by: disposeBag)

Expand Down Expand Up @@ -148,13 +148,6 @@ class AnnotationToolOptionsViewController: UIViewController {
.disposed(by: disposeBag)
navigationItem.rightBarButtonItem = doneButton
}

func update(state: AnnotationToolOptionsState) {
valueChanged(state.colorHex, state.size)
if state.changes.contains(.color) {
presentingViewController?.dismiss(animated: true)
}
}
}

override func viewWillAppear(_ animated: Bool) {
Expand All @@ -167,4 +160,11 @@ class AnnotationToolOptionsViewController: UIViewController {
preferredContentSize = CGSize(width: Self.width, height: size.height)
}
}

private func update(state: AnnotationToolOptionsState) {
valueChanged(state.colorHex, state.size)
if state.changes.contains(.color) {
presentingViewController?.dismiss(animated: true)
}
}
}
Loading

0 comments on commit e9afa97

Please sign in to comment.