diff --git a/Example/ContainerControllerSwift.xcodeproj/project.pbxproj b/Example/ContainerControllerSwift.xcodeproj/project.pbxproj index d6fada8..0674811 100644 --- a/Example/ContainerControllerSwift.xcodeproj/project.pbxproj +++ b/Example/ContainerControllerSwift.xcodeproj/project.pbxproj @@ -962,7 +962,7 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - DevelopmentTeam = Y7546NLJW9; + DevelopmentTeam = YKFJWH4C9S; LastSwiftMigration = 0900; }; }; @@ -1303,7 +1303,7 @@ baseConfigurationReference = 0AA8BF39B9F182FE833C0178 /* Pods-ContainerControllerSwift_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = Y7546NLJW9; + DEVELOPMENT_TEAM = YKFJWH4C9S; INFOPLIST_FILE = ContainerControllerSwift/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; @@ -1319,7 +1319,7 @@ baseConfigurationReference = 84550121AB9630F101ECE515 /* Pods-ContainerControllerSwift_Example.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = Y7546NLJW9; + DEVELOPMENT_TEAM = YKFJWH4C9S; INFOPLIST_FILE = ContainerControllerSwift/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; diff --git a/Example/ContainerControllerSwift/Base.lproj/Main.storyboard b/Example/ContainerControllerSwift/Base.lproj/Main.storyboard index 0e5e5d9..9c9da4c 100644 --- a/Example/ContainerControllerSwift/Base.lproj/Main.storyboard +++ b/Example/ContainerControllerSwift/Base.lproj/Main.storyboard @@ -1,33 +1,35 @@ - + - + + + - + - + - - + + - + + - @@ -39,20 +41,31 @@ - + - - - + + + + + + - + - + - + + + + + + + + + diff --git a/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.storyboard b/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.storyboard index 12294f8..bb5f783 100644 --- a/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.storyboard +++ b/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.storyboard @@ -1,9 +1,11 @@ - + - + + + @@ -14,13 +16,44 @@ - + + + + + + + + + + + + + + + + + + + diff --git a/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.swift b/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.swift index 30fe820..344a6a7 100644 --- a/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.swift +++ b/Example/ContainerControllerSwift/ExampleAddCollectionView/ExampleAddCollectionViewController.swift @@ -13,11 +13,15 @@ class ExampleAddCollectionViewController: StoryboardController { var container: ContainerController! + @IBOutlet var btnChangeTranslucent: UIButton! // MARK: - Init override func viewDidLoad() { super.viewDidLoad() + title = "Example Add CollectionView" + + btnUpdateText() let layoutC = ContainerLayout() layoutC.positions = ContainerPosition(top: 100, middle: 250, bottom: 70) @@ -33,6 +37,24 @@ class ExampleAddCollectionViewController: StoryboardController { container.move(type: .middle) } + @IBAction func btnChangeTranslucentAction(_ sender: UIButton) { + + guard let translucent = navigationController?.navigationBar.isTranslucent else { return } + + navigationController?.navigationBar.isTranslucent = !translucent + + btnUpdateText() + + container.move(type: container.moveType) + } + + func btnUpdateText() { + + guard let translucent = navigationController?.navigationBar.isTranslucent else { return } + + btnChangeTranslucent.setTitle("NavBar isTranslucent \(translucent)", for: .normal) + } + func addCollectionView() -> UICollectionView { let layout = UICollectionViewFlowLayout() diff --git a/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.storyboard b/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.storyboard index fbf62ed..73ca216 100644 --- a/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.storyboard +++ b/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.storyboard @@ -1,9 +1,11 @@ - + - + + + @@ -14,8 +16,8 @@ - + @@ -23,4 +25,9 @@ + + + + + diff --git a/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.swift b/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.swift index 7fd6d07..bde904d 100644 --- a/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.swift +++ b/Example/ContainerControllerSwift/ExamplesAddTableView/ExampleAddTableViewController.swift @@ -18,6 +18,8 @@ class ExampleAddTableViewController: StoryboardController { override func viewDidLoad() { super.viewDidLoad() + title = "Example Add TableView" + let layout = ContainerLayout() layout.backgroundShadowShow = true layout.positions = ContainerPosition(top: 70, middle: 250, bottom: 100) diff --git a/Example/ContainerControllerSwift/ExamplesSettings/Container/ExamplesContainerController.swift b/Example/ContainerControllerSwift/ExamplesSettings/Container/ExamplesContainerController.swift index 3a8e45d..9b93837 100644 --- a/Example/ContainerControllerSwift/ExamplesSettings/Container/ExamplesContainerController.swift +++ b/Example/ContainerControllerSwift/ExamplesSettings/Container/ExamplesContainerController.swift @@ -70,6 +70,9 @@ class ExamplesContainerController: ContainerController, ExampleCellDelegate { ExampleSwitchCellItem(height: h, delegate: self, type: .shadowBackground, value: false), ExampleSliderCellItem(height: h, delegate: self, type: .shadowContainer, value: 0.2, maximumValue: 1.0), ExampleSliderCellItem(height: h, delegate: self, type: .cornerRadius, value: 15, maximumValue: 140), + + ExampleSwitchCellItem(height: h, delegate: self, type: .navbarTranslucent, value: false), + ExampleSwitchCellItem(height: h, delegate: self, type: .movingEnabled, value: true), ExampleSwitchCellItem(height: h, delegate: self, type: .trackingPosition, value: false), ExampleSliderCellItem(height: h, delegate: self, type: .footerPadding, value: 0, maximumValue: Float(ContainerDevice.screenMax)), @@ -122,6 +125,8 @@ class ExamplesContainerController: ContainerController, ExampleCellDelegate { case .shadowContainer: self.view.addShadow(opacity: value) + case .navbarTranslucent: self.controller?.navigationController?.navigationBar.isTranslucent = boolValue; move(type: moveType) + case .movingEnabled: set(movingEnabled: boolValue) case .trackingPosition: set(trackingPosition: boolValue) diff --git a/Example/ContainerControllerSwift/ExamplesSettings/ExamplesSettingsViewController.swift b/Example/ContainerControllerSwift/ExamplesSettings/ExamplesSettingsViewController.swift index 35b2cc7..c985052 100644 --- a/Example/ContainerControllerSwift/ExamplesSettings/ExamplesSettingsViewController.swift +++ b/Example/ContainerControllerSwift/ExamplesSettings/ExamplesSettingsViewController.swift @@ -19,6 +19,8 @@ class ExamplesSettingsViewController: StoryboardController { override func viewDidLoad() { super.viewDidLoad() + title = "Example Add/Settings Container" + let barButtonAddItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(navigationBarAddAction)) let barButtonCloseItem = UIBarButtonItem(barButtonSystemItem: .close, target: self, action: #selector(navigationBarCloseAction)) self.navigationItem.rightBarButtonItems = [ barButtonAddItem, barButtonCloseItem ] diff --git a/Example/ContainerControllerSwift/ExamplesSettings/UI/Cell/ExampleCellStyle.swift b/Example/ContainerControllerSwift/ExamplesSettings/UI/Cell/ExampleCellStyle.swift index 435898c..6c0c867 100644 --- a/Example/ContainerControllerSwift/ExamplesSettings/UI/Cell/ExampleCellStyle.swift +++ b/Example/ContainerControllerSwift/ExamplesSettings/UI/Cell/ExampleCellStyle.swift @@ -20,6 +20,7 @@ extension ExampleCell { public enum Style: String { case `default` = "" case shadowContainer = "ShadowContainer" + case navbarTranslucent = "NavbarTranslucent" case movingEnabled = "MovingEnabled" case cornerRadius = "CornerRadius" case footerPadding = "FooterView.Padding" diff --git a/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift b/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift index 3da68de..ffda32b 100644 --- a/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift +++ b/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift @@ -44,13 +44,16 @@ class MapViewManager: NSObject { // MARK: - Location Manager func loadLocation() { - - if CLLocationManager.locationServicesEnabled() { - locationManager = CLLocationManager() - locationManager?.delegate = self - locationManager?.desiredAccuracy = kCLLocationAccuracyBest - locationManager?.requestAlwaysAuthorization() - locationManager?.startUpdatingLocation() + DispatchQueue.global().async { + if CLLocationManager.locationServicesEnabled() { + DispatchQueue.main.async { + self.locationManager = CLLocationManager() + self.locationManager?.delegate = self + self.locationManager?.desiredAccuracy = kCLLocationAccuracyBest + self.locationManager?.requestAlwaysAuthorization() + self.locationManager?.startUpdatingLocation() + } + } } } diff --git a/Example/ContainerControllerSwift/Maps/MapsViewController.swift b/Example/ContainerControllerSwift/Maps/MapsViewController.swift index 69763d0..5db69cc 100644 --- a/Example/ContainerControllerSwift/Maps/MapsViewController.swift +++ b/Example/ContainerControllerSwift/Maps/MapsViewController.swift @@ -59,6 +59,8 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + navigationController?.navigationBar.isTranslucent = false + setNeedsStatusBarAppearanceUpdate() navBar(hide: true) @@ -125,7 +127,7 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, let paddingStatusBar: CGFloat = (ContainerDevice.statusBarHeight + padding) switch ContainerDevice.orientation { - case .portrait: + case .portrait, .portraitUpsideDown: paddingTop = paddingStatusBar paddingRight = padding paddingWeatherTop = padding @@ -144,7 +146,7 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, switch ContainerDevice.orientation { - case .portrait: + case .portrait, .portraitUpsideDown: width = ContainerDevice.screenMin height = ContainerDevice.screenMax case .landscapeLeft, diff --git a/Example/ContainerControllerSwift/ViewController.swift b/Example/ContainerControllerSwift/ViewController.swift index b415997..512f2ed 100644 --- a/Example/ContainerControllerSwift/ViewController.swift +++ b/Example/ContainerControllerSwift/ViewController.swift @@ -21,7 +21,7 @@ class ViewController: UIViewController { navigationController?.interactivePopGestureRecognizer?.delegate = self navigationController?.interactivePopGestureRecognizer?.isEnabled = true - + navigationController?.view.backgroundColor = .systemGroupedBackground items = [ TitleTextItem(title: "Maps.app", clss: MapsViewController.self), TitleTextItem(title: "Example. Settings", clss: ExamplesSettingsViewController.self), diff --git a/Sources/ContainerController/ContainerController.swift b/Sources/ContainerController/ContainerController.swift index aa9c0d6..d4e226e 100644 --- a/Sources/ContainerController/ContainerController.swift +++ b/Sources/ContainerController/ContainerController.swift @@ -223,7 +223,7 @@ open class ContainerController: NSObject { shadowHiddenCheck() - delegate?.containerControllerRotation(self) + delegate?.containerControllerRotation?(self) calculationView() calculationScrollViewHeight(from: .rotation) @@ -362,7 +362,7 @@ open class ContainerController: NSObject { } @objc private func shadowButtonAction() { - delegate?.containerControllerShadowClick(self) + delegate?.containerControllerShadowClick?(self) } // MARK: - Create Container-View @@ -506,7 +506,11 @@ open class ContainerController: NSObject { transform.ty = ((positionTop / 2) + (transform.ty / 2)) } - let position = transform.ty + var position = transform.ty + if topTranslucent { + position = position + topBarHeight + } + let type: ContainerMoveType = moveType let from: ContainerFromType = .pan let animation = false @@ -584,7 +588,7 @@ open class ContainerController: NSObject { scrollInsetsBottom = 0.0 } - let top: CGFloat = layout.scrollInsets.top + var top: CGFloat = layout.scrollInsets.top let bottom: CGFloat = layout.scrollInsets.bottom + scrollInsetsBottom let indicatorTop: CGFloat = layout.scrollIndicatorInsets.top @@ -604,6 +608,10 @@ open class ContainerController: NSObject { height = 0 } + if topTranslucent { + height = height + topBarHeight + } + if animation , !isScrolling, footerView == nil, @@ -764,7 +772,10 @@ open class ContainerController: NSObject { from: ContainerFromType = .custom, completion: (() -> Void)? = nil) { - let position = positionMoveFrom(type: type) + var position = positionMoveFrom(type: type) + if topTranslucent { + position = position + topBarHeight + } move(position: position, animation: animation, @@ -863,7 +874,7 @@ open class ContainerController: NSObject { type: ContainerMoveType, animation: Bool) { - delegate?.containerControllerMove(self, position: position, type: type, animation: animation) + delegate?.containerControllerMove?(self, position: position, type: type, animation: animation) } //MARK: - Shadow Alpha Level @@ -1258,7 +1269,10 @@ extension ContainerController: UIScrollViewDelegate { scrollTransform = view.transform - let top: CGFloat = positionTop + var top: CGFloat = positionTop + if topTranslucent { + top = top + topBarHeight + } if gesture.state == .ended { scrollOnceBeginDragging = false diff --git a/Sources/ContainerController/ContainerControllerDelegate.swift b/Sources/ContainerController/ContainerControllerDelegate.swift index d680f7f..0be2ba7 100644 --- a/Sources/ContainerController/ContainerControllerDelegate.swift +++ b/Sources/ContainerController/ContainerControllerDelegate.swift @@ -11,16 +11,16 @@ import UIKit @available(iOS 13.0, *) -public protocol ContainerControllerDelegate { +@objc public protocol ContainerControllerDelegate { /// Reports rotation and orientation changes - func containerControllerRotation(_ containerController: ContainerController) + @objc optional func containerControllerRotation(_ containerController: ContainerController) /// Reports a click on the background shadow - func containerControllerShadowClick(_ containerController: ContainerController) + @objc optional func containerControllerShadowClick(_ containerController: ContainerController) /// Reports the changes current position of the container, after its use - func containerControllerMove(_ containerController: ContainerController, position: CGFloat, type: ContainerMoveType, animation: Bool) + @objc optional func containerControllerMove(_ containerController: ContainerController, position: CGFloat, type: ContainerMoveType, animation: Bool) } @@ -39,4 +39,3 @@ public extension ContainerControllerDelegate { } #endif - diff --git a/Sources/ContainerController/ContainerTypes.swift b/Sources/ContainerController/ContainerTypes.swift index 5dcec02..b253d61 100644 --- a/Sources/ContainerController/ContainerTypes.swift +++ b/Sources/ContainerController/ContainerTypes.swift @@ -10,7 +10,7 @@ import UIKit typealias ContainerCompletion = () -> Void -public enum ContainerMoveType { +@objc public enum ContainerMoveType: Int { case top case middle case bottom