Repository Public MIT
1import SwiftUI2import SPGlassKit34public struct GlassSliderExample: GlassExample {5 public static let componentID = "glass-slider"6 @State private var brightness = 0.67 @State private var temperature = 21.08 @State private var budget = 1500.09 @State private var locked = 0.310 @State private var isDragging = false1112 public init() {}1314 public var body: some View {15 ScrollView {16 VStack(alignment: .leading, spacing: 24) {17 GlassSlider("Brightness", value: $brightness, format: .percent.precision(.fractionLength(0)))1819 GlassSlider("Temperature", value: $temperature, in: 16...28, step: 0.5, showsBoundLabels: true) { value in20 Measurement(value: value, unit: UnitTemperature.celsius)21 .formatted(.measurement(width: .abbreviated, usage: .asProvided, numberFormatStyle: .number.precision(.fractionLength(1))))22 }2324 GlassSlider(25 "Monthly budget",26 value: $budget,27 in: 0...5000,28 step: 250,29 format: .currency(code: "CAD").precision(.fractionLength(0)),30 onEditingChanged: { isDragging = $0 }31 )32 Text(isDragging ? "Adjusting…" : "Released")33 .font(.caption)34 .foregroundStyle(.secondary)3536 GlassSlider("Locked by policy", value: $locked)37 .disabled(true)38 }39 .padding()40 }41 }42}4344#Preview("GlassSlider") { GlassSliderExample().glassTheme(.ocean) }45