From 70114359050975e12e540d376ae231f06ca3298d Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Thu, 1 Oct 2020 19:46:40 +0300 Subject: [PATCH 1/8] cherry-pick ccc085df3c5df7bd16f99188055b3036449d4c75 --- LeadKit.xcodeproj/project.pbxproj | 4 +++ .../BaseConfigurableController.swift | 28 +---------------- .../BaseOrientationController.swift | 30 +++++++++++++++++++ 3 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 Sources/Classes/Controllers/BaseOrientationController.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 7a65525e..d44851f8 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 52421F8F24EAB84900948DD1 /* BaseRxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F8E24EAB84900948DD1 /* BaseRxTableViewCell.swift */; }; 52421F9424EBCFAE00948DD1 /* VoidTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */; }; 52421F9624EBCFBB00948DD1 /* BaseTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */; }; + 5E23631F25263EFA00E2F96B /* BaseOrientationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */; }; 5ED2C0B2251A354E00D4E258 /* BaseOrientationNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */; }; 5ED2C0B5251A366700D4E258 /* UIDevice+ScreenOrientation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ED2C0B4251A366700D4E258 /* UIDevice+ScreenOrientation.swift */; }; 67051ADB1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; }; @@ -563,6 +564,7 @@ 52421F8E24EAB84900948DD1 /* BaseRxTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseRxTableViewCell.swift; sourceTree = ""; }; 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoidTappableViewModel.swift; sourceTree = ""; }; 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTappableViewModel.swift; sourceTree = ""; }; + 5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseOrientationController.swift; sourceTree = ""; }; 5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseOrientationNavigationController.swift; sourceTree = ""; }; 5ED2C0B4251A366700D4E258 /* UIDevice+ScreenOrientation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+ScreenOrientation.swift"; sourceTree = ""; }; 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinnerView.swift; sourceTree = ""; }; @@ -1549,6 +1551,7 @@ 675E0AA821072FF400CDC143 /* BaseScrollContentController.swift */, 67DB776321086A12001CB56B /* BaseTableContentController.swift */, 5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */, + 5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */, ); path = Controllers; sourceTree = ""; @@ -2586,6 +2589,7 @@ 671463081EB3396E00EAB194 /* UIView+Rotation.swift in Sources */, 6714626C1EB3396E00EAB194 /* XibView.swift in Sources */, 67274778206CD0B500725163 /* UILabel+ViewTextConfigurable.swift in Sources */, + 5E23631F25263EFA00E2F96B /* BaseOrientationController.swift in Sources */, 67ED2BE520B44F4300508B3E /* InitializableView+DefaultImplementation.swift in Sources */, 36FE777020F669E300284C09 /* String+ConvertToHost.swift in Sources */, 6774529220625D170024EEEF /* GeneralDataLoadingModel.swift in Sources */, diff --git a/Sources/Classes/Controllers/BaseConfigurableController.swift b/Sources/Classes/Controllers/BaseConfigurableController.swift index fc50616e..9b8a3dee 100644 --- a/Sources/Classes/Controllers/BaseConfigurableController.swift +++ b/Sources/Classes/Controllers/BaseConfigurableController.swift @@ -23,37 +23,11 @@ import UIKit.UIViewController /// Base controller that should be configured with view model. -open class BaseConfigurableController: UIViewController, ConfigurableController { - - /// Ability to set forced screen orientation - open var forcedInterfaceOrientation: UIInterfaceOrientation? +open class BaseConfigurableController: BaseOrientationController, ConfigurableController { /// A view model instance used by this controller. public let viewModel: ViewModel - open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { - switch forcedInterfaceOrientation { - case .landscapeLeft: - return .landscapeLeft - - case .landscapeRight: - return .landscapeRight - - case .portrait: - return .portrait - - case .portraitUpsideDown: - return .portraitUpsideDown - - default: - return super.supportedInterfaceOrientations - } - } - - open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { - forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation - } - /// Initializer with view model parameter. /// /// - Parameter viewModel: A view model to configure this controller. diff --git a/Sources/Classes/Controllers/BaseOrientationController.swift b/Sources/Classes/Controllers/BaseOrientationController.swift new file mode 100644 index 00000000..13a85aff --- /dev/null +++ b/Sources/Classes/Controllers/BaseOrientationController.swift @@ -0,0 +1,30 @@ +import Foundation + +open class BaseOrientationController: UIViewController { + + /// Ability to set forced screen orientation + open var forcedInterfaceOrientation: UIInterfaceOrientation? + + open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + switch forcedInterfaceOrientation { + case .landscapeLeft: + return .landscapeLeft + + case .landscapeRight: + return .landscapeRight + + case .portrait: + return .portrait + + case .portraitUpsideDown: + return .portraitUpsideDown + + default: + return super.supportedInterfaceOrientations + } + } + + open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { + return forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation + } +} From 9ae23ecef4521a33949abfb3568066cf93cdba68 Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Thu, 1 Oct 2020 20:28:46 +0300 Subject: [PATCH 2/8] Add videoOrientation extension --- .../UIInterfaceOrientation+ VideoOrientation.swift | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift diff --git a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift new file mode 100644 index 00000000..25e1fcfd --- /dev/null +++ b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift @@ -0,0 +1,9 @@ +// +// UIInterfaceOrientation+ VideoOrientation.swift +// LeadKit iOS +// +// Created by Mikhail Boyko on 01.10.2020. +// Copyright © 2020 Touch Instinct. All rights reserved. +// + +import Foundation From 451d99d36dfe88db1ad551e148f0ed3ae9e92c17 Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Thu, 1 Oct 2020 20:33:49 +0300 Subject: [PATCH 3/8] cherry-pick 28c51ae7f6f478987f86a9985705bcdd6e602309 --- LeadKit.xcodeproj/project.pbxproj | 12 +++++++++ ...terfaceOrientation+ VideoOrientation.swift | 27 +++++++++++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index d44851f8..8d9a5090 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 52421F9424EBCFAE00948DD1 /* VoidTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */; }; 52421F9624EBCFBB00948DD1 /* BaseTappableViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */; }; 5E23631F25263EFA00E2F96B /* BaseOrientationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */; }; + 5E2364182526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E2364172526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift */; }; 5ED2C0B2251A354E00D4E258 /* BaseOrientationNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */; }; 5ED2C0B5251A366700D4E258 /* UIDevice+ScreenOrientation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ED2C0B4251A366700D4E258 /* UIDevice+ScreenOrientation.swift */; }; 67051ADB1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; }; @@ -565,6 +566,7 @@ 52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoidTappableViewModel.swift; sourceTree = ""; }; 52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTappableViewModel.swift; sourceTree = ""; }; 5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseOrientationController.swift; sourceTree = ""; }; + 5E2364172526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIInterfaceOrientation+ VideoOrientation.swift"; sourceTree = ""; }; 5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseOrientationNavigationController.swift; sourceTree = ""; }; 5ED2C0B4251A366700D4E258 /* UIDevice+ScreenOrientation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+ScreenOrientation.swift"; sourceTree = ""; }; 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinnerView.swift; sourceTree = ""; }; @@ -916,6 +918,14 @@ path = TappableViewModel; sourceTree = ""; }; + 5E2364162526488300E2F96B /* UIInterfaceOrientation */ = { + isa = PBXGroup; + children = ( + 5E2364172526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift */, + ); + path = UIInterfaceOrientation; + sourceTree = ""; + }; 5ED2C0B3251A365800D4E258 /* UIDevice */ = { isa = PBXGroup; children = ( @@ -1006,6 +1016,7 @@ 671461DA1EB3396E00EAB194 /* Extensions */ = { isa = PBXGroup; children = ( + 5E2364162526488300E2F96B /* UIInterfaceOrientation */, 6732F23C214C09DF00B446F2 /* Foundation */, 671461DB1EB3396E00EAB194 /* Alamofire */, EFBE57CE1EC35ED90040E00A /* Array */, @@ -2515,6 +2526,7 @@ 82D2966D2264B1790067735C /* LabelTableViewCell.swift in Sources */, 671463301EB3396E00EAB194 /* CursorType.swift in Sources */, 67FDC25F1FA310EA00C76A77 /* RequestError.swift in Sources */, + 5E2364182526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift in Sources */, 677B06A021186A69006C947D /* SharedSequence+Extensions.swift in Sources */, 6760DC4D212F351700020BAE /* UIView+AddSubviews.swift in Sources */, 67745268206249360024EEEF /* UITableView+PaginationWrappable.swift in Sources */, diff --git a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift index 25e1fcfd..d087aa84 100644 --- a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift +++ b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift @@ -1,9 +1,20 @@ -// -// UIInterfaceOrientation+ VideoOrientation.swift -// LeadKit iOS -// -// Created by Mikhail Boyko on 01.10.2020. -// Copyright © 2020 Touch Instinct. All rights reserved. -// - import Foundation +import AVFoundation + +extension UIInterfaceOrientation { + + var videoOrientation: AVCaptureVideoOrientation { + switch self { + case .portrait: + return .portrait + case .landscapeLeft: + return .landscapeLeft + case .landscapeRight: + return .landscapeRight + case .portraitUpsideDown: + return .portraitUpsideDown + case .unknown: + return .portrait + } + } +} From 702f518e50285717447da83eafa02572f0912616 Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Thu, 1 Oct 2020 20:43:01 +0300 Subject: [PATCH 4/8] fix public extension --- .../UIInterfaceOrientation+ VideoOrientation.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift index d087aa84..dcf9bba5 100644 --- a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift +++ b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift @@ -1,7 +1,7 @@ import Foundation import AVFoundation -extension UIInterfaceOrientation { +public extension UIInterfaceOrientation { var videoOrientation: AVCaptureVideoOrientation { switch self { From c3827fcaf2fe1244ac5e214e86da35dc09821cf2 Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Thu, 1 Oct 2020 20:55:41 +0300 Subject: [PATCH 5/8] Update version and changelog --- CHANGELOG.md | 4 ++++ LeadKit.podspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9232b9c3..39462da1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 0.10.7 +- **Fix**: `Add BaseOrientationController`. +- **Fix**: `Add videoOrientation extension`. + ### 0.10.6 - **Fix**: `Add tvos exclude files`. diff --git a/LeadKit.podspec b/LeadKit.podspec index 0cd3687b..586a3734 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.10.6" + s.version = "0.10.7" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKit" s.license = "Apache License, Version 2.0" From 5427b0f1bea990b511a220d34223f82ac31b978b Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Thu, 1 Oct 2020 20:59:45 +0300 Subject: [PATCH 6/8] Fix indent --- LeadKit.xcodeproj/project.pbxproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 8d9a5090..ab9769bd 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -918,14 +918,14 @@ path = TappableViewModel; sourceTree = ""; }; - 5E2364162526488300E2F96B /* UIInterfaceOrientation */ = { - isa = PBXGroup; - children = ( - 5E2364172526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift */, - ); - path = UIInterfaceOrientation; - sourceTree = ""; - }; + 5E2364162526488300E2F96B /* UIInterfaceOrientation */ = { + isa = PBXGroup; + children = ( + 5E2364172526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift */, + ); + path = UIInterfaceOrientation; + sourceTree = ""; + }; 5ED2C0B3251A365800D4E258 /* UIDevice */ = { isa = PBXGroup; children = ( From 6b735be73322d1e9dca18f5bf3e5628b3c08d6ba Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Fri, 2 Oct 2020 15:53:47 +0300 Subject: [PATCH 7/8] Fix PR issue --- ...terfaceOrientation+ VideoOrientation.swift | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift index dcf9bba5..616968bf 100644 --- a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift +++ b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift @@ -4,17 +4,21 @@ import AVFoundation public extension UIInterfaceOrientation { var videoOrientation: AVCaptureVideoOrientation { - switch self { - case .portrait: - return .portrait - case .landscapeLeft: - return .landscapeLeft - case .landscapeRight: - return .landscapeRight - case .portraitUpsideDown: - return .portraitUpsideDown - case .unknown: - return .portrait + switch self { + case .portrait, .unknown: + return .portrait + + case .landscapeLeft: + return .landscapeLeft + + case .landscapeRight: + return .landscapeRight + + case .portraitUpsideDown: + return .portraitUpsideDown + + @unknown default: + return .portrait + } } - } } From 76b6822ce566140c830b08a167cbe7a94833f2ac Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Fri, 2 Oct 2020 15:55:11 +0300 Subject: [PATCH 8/8] Fix indent --- .../Classes/Controllers/BaseOrientationController.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Classes/Controllers/BaseOrientationController.swift b/Sources/Classes/Controllers/BaseOrientationController.swift index 13a85aff..3d6981d8 100644 --- a/Sources/Classes/Controllers/BaseOrientationController.swift +++ b/Sources/Classes/Controllers/BaseOrientationController.swift @@ -23,8 +23,8 @@ open class BaseOrientationController: UIViewController { return super.supportedInterfaceOrientations } } - - open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { - return forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation - } + + open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { + return forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation + } }