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
10 changes: 10 additions & 0 deletions Examples/Samples/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@
//

import UIKit
import FloatingPanel

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FloatingPanelSurfaceView.appearance().shadowHidden = false
FloatingPanelSurfaceView.appearance().cornerRadius = 6.0
// FloatingPanelSurfaceView.appearance().backgroundColor = .lightGray
// FloatingPanelBackdropView.appearance().backgroundColor = .red
// GrabberHandleView.appearance().barColor = .red
return true
}
}
4 changes: 0 additions & 4 deletions Examples/Samples/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ class SampleListViewController: UIViewController {
mainPanelVC = FloatingPanelController()
mainPanelVC.delegate = self

// Initialize FloatingPanelController and add the view
mainPanelVC.surfaceView.cornerRadius = 6.0
mainPanelVC.surfaceView.shadowHidden = false

// Set a content view controller
mainPanelVC.set(contentViewController: contentVC)

Expand Down
2 changes: 0 additions & 2 deletions Framework/Sources/FloatingPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ class FloatingPanel: NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate
viewcontroller = vc

surfaceView = FloatingPanelSurfaceView()
surfaceView.backgroundColor = .white

backdropView = FloatingPanelBackdropView()
backdropView.backgroundColor = .black
backdropView.alpha = 0.0

self.layoutAdapter = FloatingPanelLayoutAdapter(surfaceView: surfaceView,
Expand Down
24 changes: 23 additions & 1 deletion Framework/Sources/FloatingPanelBackdropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,26 @@
import UIKit

/// A view that presents a backdrop interface behind a floating panel.
public class FloatingPanelBackdropView: UIView { }
public class FloatingPanelBackdropView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setUp()
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setUp()
}

private func setUp() {
layer.backgroundColor = UIColor.black.cgColor
}

@objc dynamic public override var backgroundColor: UIColor? {
get {
guard let color = layer.backgroundColor else { return nil }
return UIColor(cgColor: color)
}
set { layer.backgroundColor = newValue?.cgColor }
}
}
26 changes: 13 additions & 13 deletions Framework/Sources/FloatingPanelSurfaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class FloatingPanelSurfaceView: UIView {
public let grabberHandle: GrabberHandleView = GrabberHandleView()

/// Offset of the grabber handle from the top
public var grabberTopPadding: CGFloat = 6.0 { didSet {
@objc dynamic public var grabberTopPadding: CGFloat = 6.0 { didSet {
setNeedsUpdateConstraints()
} }

Expand All @@ -25,10 +25,10 @@ public class FloatingPanelSurfaceView: UIView {
}

/// Grabber view width and height
public var grabberHandleWidth: CGFloat = 36.0 { didSet {
@objc dynamic public var grabberHandleWidth: CGFloat = 36.0 { didSet {
setNeedsUpdateConstraints()
} }
public var grabberHandleHeight: CGFloat = 5.0 { didSet {
@objc dynamic public var grabberHandleHeight: CGFloat = 5.0 { didSet {
setNeedsUpdateConstraints()
} }

Expand All @@ -48,7 +48,7 @@ public class FloatingPanelSurfaceView: UIView {
private var color: UIColor? = .white { didSet { setNeedsLayout() } }
var bottomOverflow: CGFloat = 0.0 // Must not call setNeedsLayout()

public override var backgroundColor: UIColor? {
@objc dynamic public override var backgroundColor: UIColor? {
get { return color }
set { color = newValue }
}
Expand All @@ -57,34 +57,34 @@ public class FloatingPanelSurfaceView: UIView {
///
/// `self.contentView` is masked with the top rounded corners automatically on iOS 11 and later.
/// On iOS 10, they are not automatically masked because of a UIVisualEffectView issue. See https://forums.developer.apple.com/thread/50854
public var cornerRadius: CGFloat {
@objc dynamic public var cornerRadius: CGFloat {
set { containerView.layer.cornerRadius = newValue; setNeedsLayout() }
get { return containerView.layer.cornerRadius }
}

/// A Boolean indicating whether the surface shadow is displayed.
public var shadowHidden: Bool = false { didSet { setNeedsLayout() } }
@objc dynamic public var shadowHidden: Bool = false { didSet { setNeedsLayout() } }

/// The color of the surface shadow.
public var shadowColor: UIColor = .black { didSet { setNeedsLayout() } }
@objc dynamic public var shadowColor: UIColor = .black { didSet { setNeedsLayout() } }

/// The offset (in points) of the surface shadow.
public var shadowOffset: CGSize = CGSize(width: 0.0, height: 1.0) { didSet { setNeedsLayout() } }
@objc dynamic public var shadowOffset: CGSize = CGSize(width: 0.0, height: 1.0) { didSet { setNeedsLayout() } }

/// The opacity of the surface shadow.
public var shadowOpacity: Float = 0.2 { didSet { setNeedsLayout() } }
@objc dynamic public var shadowOpacity: Float = 0.2 { didSet { setNeedsLayout() } }

/// The blur radius (in points) used to render the surface shadow.
public var shadowRadius: CGFloat = 3 { didSet { setNeedsLayout() } }
@objc dynamic public var shadowRadius: CGFloat = 3 { didSet { setNeedsLayout() } }

/// The width of the surface border.
public var borderColor: UIColor? { didSet { setNeedsLayout() } }
@objc dynamic public var borderColor: UIColor? { didSet { setNeedsLayout() } }

/// The color of the surface border.
public var borderWidth: CGFloat = 0.0 { didSet { setNeedsLayout() } }
@objc dynamic public var borderWidth: CGFloat = 0.0 { didSet { setNeedsLayout() } }

/// Offset of the container view from the top
public var containerTopInset: CGFloat = 0.0 { didSet {
@objc dynamic public var containerTopInset: CGFloat = 0.0 { didSet {
setNeedsUpdateConstraints()
} }

Expand Down
4 changes: 3 additions & 1 deletion Framework/Sources/GrabberHandleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import UIKit

public class GrabberHandleView: UIView {

public var barColor = UIColor(displayP3Red: 0.76, green: 0.77, blue: 0.76, alpha: 1.0) { didSet { backgroundColor = barColor } }
@objc dynamic public var barColor = UIColor(displayP3Red: 0.76, green: 0.77, blue: 0.76, alpha: 1.0) {
didSet { backgroundColor = barColor }
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
Expand Down