Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Examples/Gallery/Selection/GlassSliderExample.swift8// Module : Examples9// Repository : https://git.spboucher.ai/sp-glasskit10// Project Website : https://glass.spboucher.ai11// Created : 2026-12-0212// Last Modified : 2026-12-0213//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import SwiftUI42import SPGlassKit4344public struct GlassSliderExample: GlassExample {45 public static let componentID = "glass-slider"46 @State private var brightness = 0.647 @State private var temperature = 21.048 @State private var budget = 1500.049 @State private var locked = 0.350 @State private var isDragging = false5152 public init() {}5354 public var body: some View {55 ScrollView {56 VStack(alignment: .leading, spacing: 24) {57 GlassSlider("Brightness", value: $brightness, format: .percent.precision(.fractionLength(0)))5859 GlassSlider("Temperature", value: $temperature, in: 16...28, step: 0.5, showsBoundLabels: true) { value in60 Measurement(value: value, unit: UnitTemperature.celsius)61 .formatted(.measurement(width: .abbreviated, usage: .asProvided, numberFormatStyle: .number.precision(.fractionLength(1))))62 }6364 GlassSlider(65 "Monthly budget",66 value: $budget,67 in: 0...5000,68 step: 250,69 format: .currency(code: "CAD").precision(.fractionLength(0)),70 onEditingChanged: { isDragging = $0 }71 )72 Text(isDragging ? "Adjusting…" : "Released")73 .font(.caption)74 .foregroundStyle(.secondary)7576 GlassSlider("Locked by policy", value: $locked)77 .disabled(true)78 }79 .padding()80 }81 }82}8384#Preview("GlassSlider") { GlassSliderExample().glassTheme(.ocean) }85