-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding explicit transition support * Adding example for animation content independent of the main sheet * Adding support for keyboard show / hide animations * Improving animation example * Removing unnecessary async from example
- Loading branch information
1 parent
423eb88
commit 9364652
Showing
5 changed files
with
154 additions
and
56 deletions.
There are no files selected for viewing
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
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
78 changes: 78 additions & 0 deletions
78
Example/PartialSheetExample/Examples/AnimationContentExample.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// AnimationContentExample.swift | ||
// PartialSheetExample | ||
// | ||
// Created by Eliott Robson on 21/09/2020. | ||
// Copyright © 2020 Swift. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AnimationContentExample: View { | ||
@EnvironmentObject var partialSheet: PartialSheetManager | ||
|
||
var body: some View { | ||
VStack { | ||
Button( | ||
action: { | ||
self.partialSheet.showPartialSheet { | ||
AnimationSheetView() | ||
} | ||
}, | ||
label: { | ||
Text("Show Partial Sheet") | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
struct AnimationSheetView: View { | ||
|
||
@State private var explicitScale: CGFloat = 1 | ||
|
||
@State private var implicitScale: CGFloat = 1 | ||
|
||
@State private var noScale: CGFloat = 1 | ||
|
||
var body: some View { | ||
VStack { | ||
Text("Tap to animate explicitly") | ||
.padding() | ||
.background(Color.green) | ||
.cornerRadius(5) | ||
.scaleEffect(explicitScale) | ||
.onTapGesture { | ||
withAnimation { | ||
explicitScale = CGFloat.random(in: 0.5..<1.5) | ||
} | ||
} | ||
|
||
Text("Tap to animate implicitly") | ||
.padding() | ||
.background(Color.orange) | ||
.cornerRadius(5) | ||
.scaleEffect(implicitScale) | ||
.animation(.default) | ||
.onTapGesture { | ||
implicitScale = CGFloat.random(in: 0.5..<1.5) | ||
} | ||
|
||
Text("Tap to change with no animation") | ||
.padding() | ||
.background(Color.red) | ||
.cornerRadius(5) | ||
.scaleEffect(noScale) | ||
.onTapGesture { | ||
noScale = CGFloat.random(in: 0.5..<1.5) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct AnimationContentExample_Previews: PreviewProvider { | ||
static var previews: some View { | ||
AnimationContentExample() | ||
.environmentObject(PartialSheetManager()) | ||
} | ||
} |
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
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