Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Examples/Gallery/Selection/GlassStepperExample.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 GlassStepperExample: GlassExample {45 public static let componentID = "glass-stepper"46 @State private var guests = 247 @State private var dose = 0.548 @State private var zoom = 1.049 @State private var fixed = 35051 public init() {}5253 public var body: some View {54 ScrollView {55 VStack(alignment: .leading, spacing: 20) {56 GlassStepper("Guests", value: $guests, in: 1...12)5758 GlassStepper("Dose", value: $dose, in: 0...2.5, step: 0.25) { value in59 Measurement(value: value, unit: UnitMass.milligrams)60 .formatted(.measurement(width: .abbreviated, usage: .asProvided, numberFormatStyle: .number.precision(.fractionLength(2))))61 }6263 // The upper bound 4 is not on a step from 0.5 by 0.75: the last press stops at the bound.64 GlassStepper("Zoom", value: $zoom, in: 0.5...4, step: 0.75) { value in65 value.formatted(.percent.precision(.fractionLength(0)))66 }6768 GlassStepper("Seats (fixed by your plan)", value: $fixed, in: 1...5)69 .disabled(true)70 }71 .padding()72 }73 }74}7576#Preview("GlassStepper") { GlassStepperExample().glassTheme(.crystal) }77