Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MediaEditor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -627,7 +627,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
35 changes: 21 additions & 14 deletions Sources/MediaEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ open class MediaEditor: UINavigationController {
///
public init(_ image: UIImage) {
self.images = [0: image]
super.init(rootViewController: hub)
super.init(nibName: nil, bundle: nil)
viewControllers = [hub]
setup()
}

Expand All @@ -84,7 +85,8 @@ open class MediaEditor: UINavigationController {
///
public init(_ images: [UIImage]) {
self.images = images.enumerated().reduce(into: [:]) { $0[$1.offset] = $1.element }
super.init(rootViewController: hub)
super.init(nibName: nil, bundle: nil)
viewControllers = [hub]
setup()
}

Expand All @@ -96,7 +98,8 @@ open class MediaEditor: UINavigationController {
///
public init(_ asyncImage: AsyncImage) {
self.asyncImages.append(asyncImage)
super.init(rootViewController: hub)
super.init(nibName: nil, bundle: nil)
viewControllers = [hub]
setup()
}

Expand All @@ -108,24 +111,17 @@ open class MediaEditor: UINavigationController {
///
public init(_ asyncImages: [AsyncImage]) {
self.asyncImages = asyncImages
super.init(rootViewController: hub)
super.init(nibName: nil, bundle: nil)
viewControllers = [hub]
setup()
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}

public override func viewDidLoad() {
super.viewDidLoad()

isEditingPlainUIImages = images.count > 0

hub.delegate = self

modalTransitionStyle = .crossDissolve
modalPresentationStyle = .fullScreen
navigationBar.isHidden = true
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}

public override func viewWillDisappear(_ animated: Bool) {
Expand All @@ -140,12 +136,21 @@ open class MediaEditor: UINavigationController {
}

private func setup() {
setupModalStyle()
setupHub()
setupForAsync()
presentIfSingleImageAndCapability()
}

private func setupModalStyle() {
modalTransitionStyle = .crossDissolve
modalPresentationStyle = .fullScreen
navigationBar.isHidden = true
}

private func setupHub() {
hub.delegate = self

hub.onCancel = { [weak self] in
self?.cancel()
}
Expand All @@ -166,6 +171,8 @@ open class MediaEditor: UINavigationController {
}

private func setupForAsync() {
isEditingPlainUIImages = images.count > 0

asyncImages.enumerated().forEach { offset, asyncImage in
if let thumb = asyncImage.thumb {
thumbnailAvailable(thumb, offset: offset)
Expand Down
1 change: 1 addition & 0 deletions Tests/MediaEditorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class MediaEditorTests: XCTestCase {
let thumbImage = UIImage(color: .black)
let mediaEditor = MediaEditor(asyncImage)
UIApplication.shared.topWindow?.addSubview(mediaEditor.view)
mediaEditor.view.layoutIfNeeded()

asyncImage.simulate(fullImageHasBeenDownloaded: fullImage)
asyncImage.simulate(thumbHasBeenDownloaded: thumbImage)
Expand Down