Skip to content

Commit

Permalink
FMPhotoPresenter: hide edit button when no filter or crop options are…
Browse files Browse the repository at this point in the history
… available
  • Loading branch information
congnd committed Jun 6, 2020
1 parent eb6db97 commit fed2a70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -234,13 +235,16 @@ 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)
}
}
} else {
bottomView.imageMode()
bottomViewContainer.isHidden = config.availableFilters == nil && config.availableCrops == nil
}
}

Expand Down Expand Up @@ -478,6 +482,7 @@ private extension FMPhotoPresenterViewController {
])

let bottomViewContainer = UIView()
self.bottomViewContainer = bottomViewContainer
bottomViewContainer.backgroundColor = .white

bottomViewContainer.translatesAutoresizingMaskIntoConstraints = false
Expand Down

0 comments on commit fed2a70

Please sign in to comment.