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" diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 7a65525e..ab9769bd 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -23,6 +23,8 @@ 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 */; }; + 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 */; }; @@ -563,6 +565,8 @@ 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 = ""; }; + 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 = ""; }; @@ -914,6 +918,14 @@ path = TappableViewModel; sourceTree = ""; }; + 5E2364162526488300E2F96B /* UIInterfaceOrientation */ = { + isa = PBXGroup; + children = ( + 5E2364172526489A00E2F96B /* UIInterfaceOrientation+ VideoOrientation.swift */, + ); + path = UIInterfaceOrientation; + sourceTree = ""; + }; 5ED2C0B3251A365800D4E258 /* UIDevice */ = { isa = PBXGroup; children = ( @@ -1004,6 +1016,7 @@ 671461DA1EB3396E00EAB194 /* Extensions */ = { isa = PBXGroup; children = ( + 5E2364162526488300E2F96B /* UIInterfaceOrientation */, 6732F23C214C09DF00B446F2 /* Foundation */, 671461DB1EB3396E00EAB194 /* Alamofire */, EFBE57CE1EC35ED90040E00A /* Array */, @@ -1549,6 +1562,7 @@ 675E0AA821072FF400CDC143 /* BaseScrollContentController.swift */, 67DB776321086A12001CB56B /* BaseTableContentController.swift */, 5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */, + 5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */, ); path = Controllers; sourceTree = ""; @@ -2512,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 */, @@ -2586,6 +2601,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..3d6981d8 --- /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 + } +} diff --git a/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift new file mode 100644 index 00000000..616968bf --- /dev/null +++ b/Sources/Extensions/UIInterfaceOrientation/UIInterfaceOrientation+ VideoOrientation.swift @@ -0,0 +1,24 @@ +import Foundation +import AVFoundation + +public extension UIInterfaceOrientation { + + var videoOrientation: AVCaptureVideoOrientation { + switch self { + case .portrait, .unknown: + return .portrait + + case .landscapeLeft: + return .landscapeLeft + + case .landscapeRight: + return .landscapeRight + + case .portraitUpsideDown: + return .portraitUpsideDown + + @unknown default: + return .portrait + } + } +}