mirror of
https://github.com/EmergeTools/Pow.git
synced 2026-03-25 08:55:50 +00:00
Co-authored-by: Robert Böhnke <robb@robb.is> Co-authored-by: Kasper Lahti <kasper@lahti.email>
38 lines
1,014 B
Swift
38 lines
1,014 B
Swift
import Pow
|
|
import SwiftUI
|
|
|
|
struct VanishExample: View, Example {
|
|
@State
|
|
var isVisible: Bool = false
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
if isVisible {
|
|
Circle()
|
|
.frame(width: 250, height: 250)
|
|
// Assign a random ID so that quick re-insertion will not
|
|
// play the vanish transition backwards.
|
|
.id(UUID())
|
|
.transition(
|
|
.asymmetric(
|
|
insertion: .opacity,
|
|
removal: .movingParts.vanish(Color(white: 0.8), mask: Circle())
|
|
)
|
|
)
|
|
}
|
|
}
|
|
.defaultBackground()
|
|
.onTapGesture {
|
|
withAnimation {
|
|
isVisible.toggle()
|
|
}
|
|
}
|
|
.autotoggle($isVisible)
|
|
}
|
|
|
|
static let localPath = LocalPath()
|
|
|
|
static var icon: Image? {
|
|
Image(systemName: "circle.dotted")
|
|
}
|
|
}
|