Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import ParcelAnimationimport ParcelConfigimport SwiftUI
struct TourStepTabs: View { let selected: Int let count: Int let title: String let configuration: MotionConfiguration @Environment(\.accessibilityReduceMotion) private var reduceMotion @Environment(\.colorSchemeContrast) private var contrast @ScaledMetric(relativeTo: .body) private var scale: CGFloat = 1
init(selected: Int, count: Int, title: String, configuration: MotionConfiguration) { self.count = max(0, count) self.selected = min(max(0, selected), max(0, count - 1)) self.title = title self.configuration = configuration }
var body: some View { if count > 0 { HStack(spacing: 8 * scale) { ForEach(0..<count, id: \.self) { index in let active = index == selected let size = SelectionGripMetrics.size( selected: active, hovered: false, increaseContrast: contrast == .increased, available: CGSize(width: 44, height: 12)) Capsule() .fill(active ? Color.accentColor : Color.primary.opacity(contrast == .increased ? 0.65 : 0.28)) .frame(width: size.width * scale, height: size.height * scale) .accessibilityHidden(true) } } .frame(height: 12 * scale) .frame(maxWidth: .infinity) .animation(selectionAnimation, value: selected) .accessibilityRepresentation { ProgressView(value: Double(selected + 1), total: Double(count)) .accessibilityLabel( String( format: UIStrings.text("%@ · %@"), String(format: UIStrings.text("Step %lld of %lld"), Int64(selected + 1), Int64(count)), title) ) .accessibilityIdentifier("tour.steps") } } }
private var selectionAnimation: Animation? { guard configuration.enabled, !reduceMotion else { return nil } let spec = MotionToken.pop.spec(settings: configuration.uiMotionSettings) return .spring(duration: spec.duration, bounce: spec.bounce) }}