Merge pull request #247 from TouchInstinct/feature/Add_orientation_viewController_logic
Add orientation viewController Extension
This commit is contained in:
commit
a56ecd5f79
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
### 0.10.5
|
||||
- **Add**: `OrientationNavigationController` .
|
||||
- **Add**: `Forced Interface Orientation logic to BaseConfigurableController` .
|
||||
- **Fix**: `Exclude files to watchos and tvos`.
|
||||
|
||||
### 0.10.4
|
||||
- **Fix**: `noConnection` error.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "LeadKit"
|
||||
s.version = "0.10.4"
|
||||
s.version = "0.10.5"
|
||||
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"
|
||||
|
|
@ -26,6 +26,8 @@ Pod::Spec.new do |s|
|
|||
ss.watchos.exclude_files = [
|
||||
"Sources/Classes/Controllers/**/*",
|
||||
"Sources/Classes/Views/SeparatorRowBox/*",
|
||||
"Sources/Classes/Views/BaseRxTableViewCell/*",
|
||||
"Sources/Classes/Views/ContainerTableCell/*",
|
||||
"Sources/Classes/Views/SeparatorCell/*",
|
||||
"Sources/Classes/Views/EmptyCell/*",
|
||||
"Sources/Classes/Views/LabelTableViewCell/*",
|
||||
|
|
@ -70,6 +72,8 @@ Pod::Spec.new do |s|
|
|||
]
|
||||
ss.tvos.exclude_files = [
|
||||
"Sources/Classes/Controllers/BaseTableContentController.swift",
|
||||
"Sources/Classes/Views/BaseRxTableViewCell/*",
|
||||
"Sources/Classes/Views/ContainerTableCell/*",
|
||||
"Sources/Classes/Views/SeparatorRowBox/*",
|
||||
"Sources/Classes/Views/SeparatorCell/*",
|
||||
"Sources/Classes/Views/EmptyCell/*",
|
||||
|
|
|
|||
|
|
@ -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 */; };
|
||||
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 */; };
|
||||
67051ADD1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; };
|
||||
6713C23720AF0C4D00875921 /* NetworkOperationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713C23620AF0C4D00875921 /* NetworkOperationState.swift */; };
|
||||
|
|
@ -561,6 +563,8 @@
|
|||
52421F8E24EAB84900948DD1 /* BaseRxTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseRxTableViewCell.swift; sourceTree = "<group>"; };
|
||||
52421F9324EBCFAE00948DD1 /* VoidTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoidTappableViewModel.swift; sourceTree = "<group>"; };
|
||||
52421F9524EBCFBB00948DD1 /* BaseTappableViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseTappableViewModel.swift; sourceTree = "<group>"; };
|
||||
5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseOrientationNavigationController.swift; sourceTree = "<group>"; };
|
||||
5ED2C0B4251A366700D4E258 /* UIDevice+ScreenOrientation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+ScreenOrientation.swift"; sourceTree = "<group>"; };
|
||||
67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinnerView.swift; sourceTree = "<group>"; };
|
||||
6713C23620AF0C4D00875921 /* NetworkOperationState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkOperationState.swift; sourceTree = "<group>"; };
|
||||
6713C23B20AF0D5900875921 /* NetworkOperationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkOperationModel.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -910,6 +914,14 @@
|
|||
path = TappableViewModel;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5ED2C0B3251A365800D4E258 /* UIDevice */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5ED2C0B4251A366700D4E258 /* UIDevice+ScreenOrientation.swift */,
|
||||
);
|
||||
path = UIDevice;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
671461C41EB3396E00EAB194 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -1375,6 +1387,7 @@
|
|||
672947E0206EA36B00AC6B6B /* UIKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5ED2C0B3251A365800D4E258 /* UIDevice */,
|
||||
6741CEB220E242B600FEC4D9 /* CollectionViewHolder */,
|
||||
6741CEAD20E2428A00FEC4D9 /* TableViewHolder */,
|
||||
674AF55A1EC45B1600038A8F /* UIActivityIndicatorView */,
|
||||
|
|
@ -1535,6 +1548,7 @@
|
|||
6741CECC20E243F800FEC4D9 /* BaseCustomViewController.swift */,
|
||||
675E0AA821072FF400CDC143 /* BaseScrollContentController.swift */,
|
||||
67DB776321086A12001CB56B /* BaseTableContentController.swift */,
|
||||
5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */,
|
||||
);
|
||||
path = Controllers;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -2484,6 +2498,7 @@
|
|||
6774528D20625C9E0024EEEF /* GeneralDataLoadingState.swift in Sources */,
|
||||
72005A1F2266226800ECE090 /* CustomizableButtonViewModel.swift in Sources */,
|
||||
677B06C4211884F3006C947D /* BaseTextAttributes.swift in Sources */,
|
||||
5ED2C0B2251A354E00D4E258 /* BaseOrientationNavigationController.swift in Sources */,
|
||||
675E0AA921072FF400CDC143 /* BaseScrollContentController.swift in Sources */,
|
||||
671463901EB3396E00EAB194 /* TemplateDrawingOperation.swift in Sources */,
|
||||
A658E54D1F8CD7790093527A /* TableRow+SeparatorsExtensions.swift in Sources */,
|
||||
|
|
@ -2525,6 +2540,7 @@
|
|||
67E902572125B66E008EDF45 /* UIImageView+ExpandCollapseDisclosure.swift in Sources */,
|
||||
671462781EB3396E00EAB194 /* ResizeMode.swift in Sources */,
|
||||
67E902512125B064008EDF45 /* BuildInNumberTypes+NSNumberConvertible.swift in Sources */,
|
||||
5ED2C0B5251A366700D4E258 /* UIDevice+ScreenOrientation.swift in Sources */,
|
||||
A676AE551F98112E001F9214 /* ObservableMappable.swift in Sources */,
|
||||
6741CEA520E2418200FEC4D9 /* TableViewHolder.swift in Sources */,
|
||||
8546C2E3224E86280059C255 /* ApiUploadRequestParameters.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -25,9 +25,35 @@ import UIKit.UIViewController
|
|||
/// Base controller that should be configured with view model.
|
||||
open class BaseConfigurableController<ViewModel>: UIViewController, ConfigurableController {
|
||||
|
||||
/// Ability to set forced screen orientation
|
||||
open var forcedInterfaceOrientation: UIInterfaceOrientation?
|
||||
|
||||
/// 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.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
import UIKit
|
||||
|
||||
open class OrientationNavigationController: UINavigationController {
|
||||
|
||||
// MARK: - Public properties
|
||||
|
||||
open override var shouldAutorotate: Bool {
|
||||
presentedViewController?.shouldAutorotate
|
||||
?? topViewController?.shouldAutorotate
|
||||
?? super.shouldAutorotate
|
||||
}
|
||||
|
||||
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||
presentedViewController?.supportedInterfaceOrientations
|
||||
?? topViewController?.supportedInterfaceOrientations
|
||||
?? super.supportedInterfaceOrientations
|
||||
}
|
||||
|
||||
open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
|
||||
presentedViewController?.preferredInterfaceOrientationForPresentation
|
||||
?? topViewController?.preferredInterfaceOrientationForPresentation
|
||||
?? super.preferredInterfaceOrientationForPresentation
|
||||
}
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ private extension ObservableType {
|
|||
default:
|
||||
resultError = .network(error: error, response: response)
|
||||
}
|
||||
|
||||
|
||||
case .responseSerializationFailed, .responseValidationFailed:
|
||||
resultError = .invalidResponse(error: afError, response: response)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import UIKit
|
||||
|
||||
public extension UIDevice {
|
||||
|
||||
/// Вручную повернуть экран устройства
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - orientation: ориентация в терминах ScreenOrientation
|
||||
func rotateManually(to orientation: UIInterfaceOrientation) {
|
||||
UIDevice.current.setValue(orientation, forKey: "orientation")
|
||||
UIViewController.attemptRotationToDeviceOrientation()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue