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>
62 lines
1.9 KiB
Swift
62 lines
1.9 KiB
Swift
import Pow
|
|
import SwiftUI
|
|
|
|
struct MoveExample: View, Example {
|
|
@State
|
|
var angle: Angle = .degrees(225)
|
|
|
|
@State
|
|
var isVisible: Bool = false
|
|
|
|
var body: some View {
|
|
VStack {
|
|
GroupBox {
|
|
LabeledContent {
|
|
Slider(value: $angle.degrees, in: 0 ... 360, step: 5)
|
|
} label: {
|
|
Text("Angle")
|
|
Spacer()
|
|
Text(Measurement(value: angle.degrees, unit: UnitAngle.degrees).formatted(.measurement(width: .narrow, numberFormatStyle: .number.precision(.fractionLength(0)))))
|
|
.foregroundColor(.secondary)
|
|
.font(.subheadline.monospacedDigit())
|
|
}
|
|
}
|
|
.padding(.horizontal)
|
|
|
|
VStack {
|
|
if isVisible {
|
|
PlaceholderView()
|
|
.compositingGroup()
|
|
.transition(.movingParts.move(angle: angle).combined(with: .opacity))
|
|
}
|
|
}
|
|
.defaultBackground()
|
|
.onTapGesture {
|
|
withAnimation(.spring(dampingFraction: 1)) {
|
|
isVisible.toggle()
|
|
}
|
|
}
|
|
}
|
|
.labeledContentStyle(VerticalLabeledContentStyle())
|
|
.defaultBackground()
|
|
.autotoggle($isVisible, with: .spring(dampingFraction: 1))
|
|
}
|
|
|
|
static let localPath = LocalPath()
|
|
|
|
static var icon: Image? {
|
|
Image(systemName: "arrow.up.left.and.down.right.and.arrow.up.right.and.down.left")
|
|
}
|
|
}
|
|
|
|
private struct VerticalLabeledContentStyle: LabeledContentStyle {
|
|
func makeBody(configuration: Configuration) -> some View {
|
|
VStack(alignment: .leading) {
|
|
HStack(alignment: .firstTextBaseline) {
|
|
configuration.label
|
|
}
|
|
|
|
configuration.content
|
|
}
|
|
}
|
|
}
|