Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleve committed Aug 13, 2020
1 parent ca74281 commit 1e27376
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
17 changes: 8 additions & 9 deletions Demo/Sources/Demos/Demo Screens/AccordionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,18 @@ fileprivate struct AccordionHeader : BlueprintHeaderFooterContent, Equatable
}

var background: Element? {
Overlay(
elements: [
Box(backgroundColor: .white),
Box(backgroundColor: .init(white: 0.85, alpha: 1.0))
.constrainedTo(height: .absolute(1.0))
.aligned(vertically: .bottom, horizontally: .fill)
]
)
self.background(with: .white)
}

var pressedBackground: Element? {
self.background(with: .white(0.9))
}

private func background(with color : UIColor) -> Element {
Overlay(
elements: [
Box(backgroundColor: .white(0.9)),
Box(backgroundColor: color),

Box(backgroundColor: .init(white: 0.85, alpha: 1.0))
.constrainedTo(height: .absolute(1.0))
.aligned(vertically: .bottom, horizontally: .fill)
Expand All @@ -77,6 +75,7 @@ fileprivate struct AccordionHeader : BlueprintHeaderFooterContent, Equatable
}
}


fileprivate struct AccordionRow : BlueprintItemContent, Equatable
{
var text : String
Expand Down
4 changes: 2 additions & 2 deletions Listable/Sources/HeaderFooter/HeaderFooterContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public protocol HeaderFooterContent
///
associatedtype PressedBackgroundView:UIView = BackgroundView

/// Create and return a new background view used to render the content's selected background.
/// Create and return a new background view used to render the content's pressed background.
///
/// This view is displayed when the content is highlighted or selected.
/// This view is displayed when the user taps/presses the header / footer.
///
/// If your `BackgroundView` and `SelectedBackgroundView` are the same type, this method
/// is provided automatically by calling `createReusableBackgroundView`.
Expand Down
20 changes: 15 additions & 5 deletions Listable/Sources/Internal/HeaderFooterContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ final class HeaderFooterContentView<Content:HeaderFooterContent> : UIView

override init(frame: CGRect) {

self.content = Content.createReusableContentView(frame: frame)
self.background = Content.createReusableBackgroundView(frame: frame)
self.pressedBackground = Content.createReusablePressedBackgroundView(frame: frame)
let bounds = CGRect(origin: .zero, size: frame.size)

self.content = Content.createReusableContentView(frame: bounds)
self.background = Content.createReusableBackgroundView(frame: bounds)
self.pressedBackground = Content.createReusablePressedBackgroundView(frame: bounds)

self.pressRecognizer = PressGestureRecognizer()
self.pressRecognizer.minimumPressDuration = 0.0
Expand Down Expand Up @@ -136,8 +138,16 @@ fileprivate final class PressGestureRecognizer : UILongPressGestureRecognizer {
self.initialPoint = self.location(in: self.view)
}

override func canPrevent(_ preventedGestureRecognizer: UIGestureRecognizer) -> Bool {
false
override func canPrevent(_ gesture: UIGestureRecognizer) -> Bool {

// We want to allow the pan gesture of our containing scroll view to continue to track
// when the user moves their finger vertically or horizontally, when we are cancelled.

if let panGesture = gesture as? UIPanGestureRecognizer, panGesture.view is UIScrollView {
return false
}

return super.canPrevent(gesture)
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) {
Expand Down
2 changes: 1 addition & 1 deletion Listable/Sources/Layout/SupplementaryKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation


public enum SupplementaryKind : String, CaseIterable
enum SupplementaryKind : String, CaseIterable
{
case listHeader = "Listable.ListHeader"
case listFooter = "Listable.ListFooter"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ public protocol HeaderFooterContent

associatedtype ContentView:UIView
static func createReusableContentView(frame : CGRect) -> ContentView

associatedtype BackgroundView:UIView
static func createReusableBackgroundView(frame : CGRect) -> BackgroundView

associatedtype PressedBackgroundView:UIView
static func createReusablePressedBackgroundView(frame : CGRect) -> PressedBackgroundView
}
```

Expand Down

0 comments on commit 1e27376

Please sign in to comment.