gh-EmergeTools-Pow/Example/Pow Example/Examples/Change Effects/GlowExample.swift
Joe Fabisevich 781d455727
Moving Pow to @emergetools
Co-authored-by: Robert Böhnke <robb@robb.is>
Co-authored-by: Kasper Lahti <kasper@lahti.email>
2023-11-29 09:38:34 -05:00

71 lines
2.2 KiB
Swift

import Pow
import SwiftUI
struct GlowExample: View, Example {
@State
var changes: Int = 0
var body: some View {
VStack {
// GroupBox {
// LabeledContent("Drawing Mode") {
// Picker("Drawing Mode", selection: $drawingMode) {
// Text("Fill").tag(AnyChangeEffect.PulseDrawingMode.fill)
// Text("Stroke").tag(AnyChangeEffect.PulseDrawingMode.stroke)
// }
// }
// }
// .padding(.horizontal)
Spacer()
ZStack {
PlaceholderView()
.overlay(alignment: .badgeAlignment) {
let shape = Capsule()
Text(changes.formatted())
.font(.body.bold().monospacedDigit())
.foregroundColor(.white)
.padding(.vertical, 8)
.padding(.horizontal, 16)
.background {
shape.fill(.pink)
.changeEffect(.glow(color: .pink, radius: 20), value: changes)
}
.alignmentGuide(HorizontalAlignment.badgeAlignment) { d in
d[HorizontalAlignment.center]
}
.alignmentGuide(VerticalAlignment.badgeAlignment) { d in
d[VerticalAlignment.center]
}
.allowsHitTesting(false)
}
}
Spacer()
}
.defaultBackground()
.onTapGesture {
changes += 1
}
}
static var description: some View {
Text("""
Makes the view glow whenever a value changes
- Parameters:
- `color`: The color to use.
- `radius`: The radius of the glow.
""")
}
static let localPath = LocalPath()
static var icon: Image? {
Image(systemName: "dot.radiowaves.left.and.right")
}
static var newIn0_3_0: Bool { true }
}