Created
August 24, 2022 04:20
-
-
Save Foreman76/a07531c1e76c8880a9780fcb87d8ebf7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import ScalingHeaderScrollView | |
struct ContentView: View { | |
@State private var progress:CGFloat = 0.0 | |
@State private var showNS = false | |
var body: some View { | |
NavigationView { | |
ZStack { | |
ScalingHeaderScrollView { | |
myHeader | |
} content: { | |
myContent | |
} | |
.height(min: 150, max: 200) | |
.collapseProgress($progress) | |
.allowsHeaderCollapse() | |
if showNS { | |
NextScreen() | |
} | |
} | |
.navigationBarHidden(true) | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} | |
extension ContentView { | |
private var myContent: some View { | |
ForEach(0..<50, id: \.self ) { index in | |
NavigationLink { | |
NextScreen() | |
} label: { | |
Text("Load \(index)") | |
.padding() | |
.frame(maxWidth: .infinity) | |
.background(.red) | |
.cornerRadius(15) | |
.padding(.horizontal) | |
.foregroundColor(.white) | |
} | |
} | |
} | |
private var myHeader: some View { | |
ZStack { | |
Rectangle() | |
.fill(.gray) | |
Image(systemName: "trash.fill") | |
.resizable() | |
.scaledToFit() | |
.frame(width: progress == 1 ? 50 : 100, alignment: .center) | |
// .scaleEffect(y: 0.3 + (1 - progress) * 0.7) | |
// .offset(x: progress == 1 ? -60 : 0) | |
// .animation(.easeInOut, value: progress) | |
} | |
} | |
} | |
struct NextScreen: View { | |
var body: some View { | |
ZStack { | |
Color.green | |
Text("Hello") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment