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>
44 lines
1.2 KiB
Swift
44 lines
1.2 KiB
Swift
import Pow
|
|
import SwiftUI
|
|
|
|
struct PopExample: View, Example {
|
|
@State
|
|
var isFavorited: Bool = false
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
HStack {
|
|
if isFavorited {
|
|
Image(systemName: "heart.fill")
|
|
.foregroundColor(.red)
|
|
.transition(
|
|
.movingParts.pop(.red)
|
|
)
|
|
} else {
|
|
Image(systemName: "heart")
|
|
.foregroundColor(.gray)
|
|
.transition(.identity)
|
|
}
|
|
|
|
let favoriteCount = isFavorited ? 143 : 142
|
|
|
|
Text(favoriteCount.formatted())
|
|
.foregroundColor(isFavorited ? .red : .gray)
|
|
.animation(isFavorited ? .default.delay(0.4) : nil, value: isFavorited)
|
|
}
|
|
}
|
|
.defaultBackground()
|
|
.onTapGesture {
|
|
withAnimation(.spring(dampingFraction: 1)) {
|
|
isFavorited.toggle()
|
|
}
|
|
}
|
|
.autotoggle($isFavorited, with: .spring(dampingFraction: 1))
|
|
}
|
|
|
|
static let localPath = LocalPath()
|
|
|
|
static var icon: Image? {
|
|
Image(systemName: "rays")
|
|
}
|
|
}
|