Add BaseOrientationController
This commit is contained in:
parent
0bc80d98b8
commit
ccc085df3c
|
|
@ -16,6 +16,7 @@
|
|||
40F118471F8FEF97004AADAF /* AppearanceConfigurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */; };
|
||||
40F118491F8FF223004AADAF /* TableRow+AppearanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118481F8FF223004AADAF /* TableRow+AppearanceExtension.swift */; };
|
||||
411073AF23466B41002DD9B9 /* UIViewController+PresentFullScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 411073AE23466B41002DD9B9 /* UIViewController+PresentFullScreen.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 */; };
|
||||
|
|
@ -552,6 +553,7 @@
|
|||
40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceConfigurable.swift; sourceTree = "<group>"; };
|
||||
40F118481F8FF223004AADAF /* TableRow+AppearanceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TableRow+AppearanceExtension.swift"; sourceTree = "<group>"; };
|
||||
411073AE23466B41002DD9B9 /* UIViewController+PresentFullScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+PresentFullScreen.swift"; sourceTree = "<group>"; };
|
||||
5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseOrientationController.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>"; };
|
||||
|
|
@ -1496,6 +1498,7 @@
|
|||
675E0AA821072FF400CDC143 /* BaseScrollContentController.swift */,
|
||||
67DB776321086A12001CB56B /* BaseTableContentController.swift */,
|
||||
5ED2C0B1251A354E00D4E258 /* BaseOrientationNavigationController.swift */,
|
||||
5E23631E25263EFA00E2F96B /* BaseOrientationController.swift */,
|
||||
);
|
||||
path = Controllers;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -2530,6 +2533,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 */,
|
||||
|
|
|
|||
|
|
@ -23,37 +23,11 @@
|
|||
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?
|
||||
open class BaseConfigurableController<ViewModel>: 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 {
|
||||
return forcedInterfaceOrientation ?? super.preferredInterfaceOrientationForPresentation
|
||||
}
|
||||
|
||||
/// Initializer with view model parameter.
|
||||
///
|
||||
/// - Parameter viewModel: A view model to configure this controller.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue