SPB Git

Repository Public MIT

GlassPanelExample.swift 2.8 KB 77 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Examples/Gallery/Containers/GlassPanelExample.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 GlassPanelExample: GlassExample {45    public static let componentID = "glass-panel"46    @State private var isShown = true47    @State private var showsTransit = true48    @State private var showsTraffic = false49    @State private var size = CGSize(width: 300, height: 220)5051    public init() {}5253    public var body: some View {54        ZStack {55            LinearGradient(colors: [.teal, .indigo], startPoint: .topLeading, endPoint: .bottomTrailing)56                .ignoresSafeArea()57                .accessibilityHidden(true)58            if isShown {59                GlassPanel(60                    "Layers",61                    size: $size,62                    sizeLimits: GlassPanelSizeLimits(minimum: CGSize(width: 240, height: 180), maximum: CGSize(width: 480, height: 360)),63                    onClose: { isShown = false }64                ) {65                    Toggle("Transit", isOn: $showsTransit)66                    Toggle("Traffic", isOn: $showsTraffic)67                }68                .padding()69            } else {70                GlassButton("Show layers", systemImage: "square.3.layers.3d") { isShown = true }71            }72        }73    }74}7576#Preview("GlassPanel") { GlassPanelExample() }77
Files main
Menu

Theme