SPB Git

Repository Public MIT

GlassPickerExample.swift 3.0 KB 82 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Examples/Gallery/Selection/GlassPickerExample.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 GlassPickerExample: GlassExample {45    public static let componentID = "glass-picker"4647    struct Plan: Hashable {48        let name: String49        let symbol: String50    }5152    private static let plans = [53        Plan(name: "Starter", symbol: "leaf"),54        Plan(name: "Team", symbol: "person.3"),55        Plan(name: "Enterprise with a long name", symbol: "building.2"),56    ]5758    @State private var plan = GlassPickerExample.plans[0]59    @State private var currency = "CAD"60    @State private var hour = 961    @State private var priority = "Normal"6263    public init() {}6465    public var body: some View {66        Form {67            GlassPicker("Plan", selection: $plan, options: Self.plans) { plan in68                Label(plan.name, systemImage: plan.symbol)69            }70            GlassPicker("Currency", selection: $currency, options: ["CAD", "EUR", "JPY", "USD"])71            GlassPicker("Reminder hour", selection: $hour, options: Array(6...22), presentation: .wheel) { hour in72                "\(hour.formatted(.number.precision(.integerLength(2)))):00"73            }74            GlassPicker("Priority", selection: $priority, options: ["Low", "Normal", "High"], presentation: .inline)75            GlassPicker("Region", selection: .constant("Canada"), options: ["Canada"])76                .disabled(true)77        }78    }79}8081#Preview("GlassPicker") { GlassPickerExample() }82
Files main
Menu

Theme