Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 64 additions & 9 deletions Sources/ContainerController/ContainerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,23 @@ open class ContainerController: NSObject {

// MARK: - Positions Move

private var positionTop: CGFloat {
var top = layout.positions.top
if !isPortrait {
if let landscape = layout.landscapePositions {
top = landscape.top
public var positionTop: CGFloat {
if let top = layout.positions.top {
if !isPortrait {
if let landscapeTop = layout.landscapePositions?.top {
return landscapeTop
} else {
return top
}
} else {
return top
}
} else {

let bottomPosition = layout.positions.bottom

return deviceHeight - bottomPosition
}
return top
}

public var positionMiddle: CGFloat {
Expand All @@ -127,8 +136,18 @@ open class ContainerController: NSObject {
}
return deviceHeight - middle
}

public var positionCustom: CGFloat {
var custom = layout.positions.custom ?? layout.positions.bottom
if !isPortrait {
if let landscape = layout.landscapePositions {
custom = landscape.custom ?? 0.0
}
}
return deviceHeight - custom
}

private var positionBottom: CGFloat {
public var positionBottom: CGFloat {
var bottom = layout.positions.bottom
if !isPortrait {
if let landscape = layout.landscapePositions {
Expand Down Expand Up @@ -178,7 +197,7 @@ open class ContainerController: NSObject {
self.controller = controller
set(layout: layout)

NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: UIDevice.orientationDidChangeNotification, object: nil)

createShadowButton()
createContainerView()
Expand Down Expand Up @@ -448,9 +467,29 @@ open class ContainerController: NSObject {
}

view.contentView?.addSubview(scrollView)
// scrollView.translatesAutoresizingMaskIntoConstraints = false
// scrollView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
// scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
// scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
// scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
calculationViews()

self.addRecognizerToScrollView(scrollView: scrollView)
}

func addRecognizerToScrollView(scrollView: UIScrollView) {
if let panGesture = panGesture {
print("didScroll addRecognizer")
scrollView.addGestureRecognizer(panGesture)
}
}

func removeRecognizerToScrollView(scrollView: UIScrollView) {
if let panGesture = panGesture {
print("didScroll removeRecognizer")
scrollView.removeGestureRecognizer(panGesture)
}
}
// MARK: - Pan Gesture

@objc private func handlePan(_ gesture: UIPanGestureRecognizer) {
Expand Down Expand Up @@ -496,6 +535,14 @@ open class ContainerController: NSObject {

move(type: type, animation: true, velocity: velocityY, from: .pan)

if type == .top && scrollView?.contentSize.height ?? 0.0 > (UIScreen.main.bounds.height * 0.95) {

if let scrollView = self.scrollView {
self.removeRecognizerToScrollView(scrollView: scrollView)

}
}

default: break
}
}
Expand Down Expand Up @@ -756,7 +803,7 @@ open class ContainerController: NSObject {
else { return positionMiddle }
case .bottom: return positionBottom
case .hide: return deviceHeight
case .custom: return 0.0
case .custom: return positionCustom
}
}

Expand Down Expand Up @@ -1266,6 +1313,10 @@ extension ContainerController: UIScrollViewDelegate {
let from: ContainerFromType = .scrollBorder
let animation = false

print("didScroll a \(position) \(type)")

self.addRecognizerToScrollView(scrollView: scrollView)

shadowLevelAlpha(position: position, animation: false)
changeFooterView(position: position)
calculationScrollViewHeight(from: from)
Expand Down Expand Up @@ -1301,12 +1352,16 @@ extension ContainerController: UIScrollViewDelegate {
let from: ContainerFromType = .scroll
let animation = false

print("didScroll b \(position) \(type)")

changeView(transform: scrollTransform)
shadowLevelAlpha(position: position, animation: false)
changeFooterView(position: position)
calculationScrollViewHeight(from: from)
changeMove(position: position, type: type, animation: animation)
}
} else {
print("didScroll false")
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/ContainerController/ContainerControllerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public protocol ContainerControllerDelegate {
/// Reports the changes current position of the container, after its use
func containerControllerMove(_ containerController: ContainerController, position: CGFloat, type: ContainerMoveType, animation: Bool)

func hideMenu(position: Double)

}

@available(iOS 13.0, *)
Expand All @@ -33,6 +35,9 @@ public extension ContainerControllerDelegate {
}

func containerControllerMove(_ containerController: ContainerController, position: CGFloat, type: ContainerMoveType, animation: Bool) {

hideMenu(position: position)

}
}

20 changes: 1 addition & 19 deletions Sources/ContainerController/ContainerDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,7 @@ open class ContainerDevice {
// MARK: - Orientation

class public var isPortrait: Bool {

var portrait: Bool = false

let size: CGSize = UIScreen.main.bounds.size
if size.width / size.height > 1 {
portrait = false
} else {
portrait = true
}

switch UIDevice.current.orientation {
case .landscapeLeft, .landscapeRight:
portrait = false
case .portrait:
portrait = true
default: break
}

return portrait
return true
}

class var statusBarOrientation: UIInterfaceOrientation? {
Expand Down
7 changes: 5 additions & 2 deletions Sources/ContainerController/ContainerLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ import UIKit

open class ContainerPosition {

public var top: CGFloat
public var top: CGFloat?

public var middle: CGFloat?

public var bottom: CGFloat

static let zero = ContainerPosition(top: 0, bottom: 0)

public init(top: CGFloat, middle: CGFloat? = nil, bottom: CGFloat) {
public var custom: CGFloat?

public init(top: CGFloat? = nil, middle: CGFloat? = nil, bottom: CGFloat, custom: CGFloat? = nil) {
self.top = top
self.middle = middle
self.bottom = bottom
self.custom = custom
}
}

Expand Down
20 changes: 16 additions & 4 deletions Sources/ContainerController/ContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,25 @@ open class ContainerView: UIView {
public func addBlur(style: UIBlurEffect.Style) {

if visualEffectView == nil {
let blurView = UIVisualEffectView(effect: UIBlurEffect(style: style))
self.insertSubview(blurView, at: 0)
visualEffectView = blurView
if #available(iOS 26.0, *) {
let glassEffect = UIGlassEffect(style: .regular)

let blurView = UIVisualEffectView(effect: glassEffect)
self.insertSubview(blurView, at: 0)
visualEffectView = blurView
} else {
let blurView = UIVisualEffectView(effect: UIBlurEffect(style: style))
self.insertSubview(blurView, at: 0)
visualEffectView = blurView
}
}

guard let visualEffectView = visualEffectView else { return }
visualEffectView.effect = UIBlurEffect(style: style)
if #available(iOS 26.0, *) {
visualEffectView.effect = UIGlassEffect(style: .regular)
} else {
visualEffectView.effect = UIBlurEffect(style: style)
}
visualEffectView.bounds = bounds
visualEffectView.frame = CGRect(x: 0, y: 0, width: visualEffectView.frame.width, height: visualEffectView.frame.height)
visualEffectView.layer.cornerRadius = radius()
Expand Down