From fed2a70eecdaafe98682cef89b9795c83c84e251 Mon Sep 17 00:00:00 2001 From: Cong Nguyen Date: Sat, 6 Jun 2020 10:07:03 +0900 Subject: [PATCH] FMPhotoPresenter: hide edit button when no filter or crop options are available --- .../Presenter/Editor/FMImageEditorViewController.swift | 8 ++++---- .../Scene/Presenter/FMPhotoPresenterViewController.swift | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/Editor/FMImageEditorViewController.swift b/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/Editor/FMImageEditorViewController.swift index ffa3d32..8e97feb 100644 --- a/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/Editor/FMImageEditorViewController.swift +++ b/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/Editor/FMImageEditorViewController.swift @@ -125,10 +125,6 @@ public class FMImageEditorViewController: UIViewController { public init(config: FMPhotoPickerConfig, sourceImage: UIImage) { self.config = config - if config.availableCrops == nil, config.availableFilters == nil { - fatalError("Plase set at least one crop option or one filter option in order to use the editor") - } - var forceCropType: FMCroppable? = nil if config.forceCropEnabled, let firstCrop = config.availableCrops?.first { forceCropType = firstCrop @@ -171,6 +167,10 @@ public class FMImageEditorViewController: UIViewController { override public func viewDidLoad() { super.viewDidLoad() + if config.availableCrops == nil, config.availableFilters == nil { + fatalError("Plase set at least one crop option or one filter option in order to use the editor") + } + headerView.isHidden = true bottomViewContainer.isHidden = true diff --git a/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/FMPhotoPresenterViewController.swift b/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/FMPhotoPresenterViewController.swift index c46967c..54af0d3 100644 --- a/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/FMPhotoPresenterViewController.swift +++ b/FMPhotoPicker/FMPhotoPicker/source/Scene/Presenter/FMPhotoPresenterViewController.swift @@ -19,6 +19,7 @@ class FMPhotoPresenterViewController: UIViewController { private weak var numberOfSelectedPhoto: UILabel! private weak var doneButton: UIButton! private weak var backButton: UIButton! + private weak var bottomViewContainer: UIView! // MARK: - Public public var swipeInteractionController: FMPhotoInteractionAnimator? @@ -234,6 +235,8 @@ class FMPhotoPresenterViewController: UIViewController { if fmAsset.mediaType == .video { bottomView.videoMode() + bottomViewContainer.isHidden = false + fmAsset.requestVideoFrames { cgImages in if let asset = fmAsset.asset { self.bottomView.resetPlaybackControl(cgImages: cgImages, duration: asset.duration) @@ -241,6 +244,7 @@ class FMPhotoPresenterViewController: UIViewController { } } else { bottomView.imageMode() + bottomViewContainer.isHidden = config.availableFilters == nil && config.availableCrops == nil } } @@ -478,6 +482,7 @@ private extension FMPhotoPresenterViewController { ]) let bottomViewContainer = UIView() + self.bottomViewContainer = bottomViewContainer bottomViewContainer.backgroundColor = .white bottomViewContainer.translatesAutoresizingMaskIntoConstraints = false