Git Product home page Git Product logo

scalingheaderscrollview's Introduction


Scaling Header Scroll View

A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI.


We are a development agency building phenomenal apps.


Twitter Version Carthage Compatible License Platform

Usage

  1. Put your header and content bodies code into a ScalingHeaderScrollView constructor.
  2. Set the necessary modifiers, see below.
struct ContentView: View {

    var body: some View {
       ScalingHeaderScrollView {
            ZStack {
                Rectangle()
                    .fill(.gray.opacity(0.15))
                Image("header")
            }
        } content: {
            Text("↓ Pull to refresh ↓")
                .multilineTextAlignment(.center)
                .padding()
        }
    }
}

Required parameters

header - @ViewBuilder for your header
content - @ViewBuilder for your content

Available modifiers, optional

passes current collapse progress value into progress binding: 0 for not collapsed at all, 1 - for fully collapsed

.collapseProgress(_ progress: Binding<CGFloat>)

allows set up callback and isLoading state for pull-to-refresh action

.pullToRefresh(isLoading: Binding<Bool>, perform: @escaping () -> Void)

allows content scroll reset, need to change Binding to true

.scrollToTop(resetScroll: Binding<Bool>)

changes min and max heights of Header, default min = 150.0 and max = 350.0

.height(min: CGFloat = 150.0, max: CGFloat = 350.0)

when scrolling up - switch between actual header collapse and simply moving it up (by default moving up)

.allowsHeaderCollapse()

when scrolling down - enable (disabled by default) header scale

.allowsHeaderGrowth()

enable (disabled by default) header snap (once you lift your finger header snaps either to min or max height automatically)

.allowsHeaderSnap()

Examples

To try ScalingHeaderScrollView examples:

  • Clone the repo https://github.com/exyte/ScalingHeaderScrollView.git
  • Open terminal and run cd <ScalingHeaderScrollViewRepo>/Example/
  • Run pod install to install all dependencies
  • Run open Example.xcworkspace/ to open project in the Xcode
  • Try it!

Installation

To install ScalingHeaderScrollView, simply add the following line to your Podfile:

pod 'ScalingHeaderScrollView'

To integrate ScalingHeaderScrollView into your Xcode project using Carthage, specify it in your Cartfile

github "Exyte/ScalingHeaderScrollView"
dependencies: [
    .package(url: "https://github.com/exyte/ScalingHeaderScrollView.git", from: "1.0.0")
]

Requirements

  • iOS 14+
  • Xcode 12+

scalingheaderscrollview's People

Contributors

f3dm76 avatar kristalev avatar mnndnl avatar zapletnev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.