SPB Git

Repository Public MIT

GlassCardExample.swift 3.5 KB 88 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Examples/Gallery/Containers/GlassCardExample.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 GlassCardExample: GlassExample {45    public static let componentID = "glass-card"46    @State private var openCount = 04748    public init() {}4950    public var body: some View {51        ScrollView {52            VStack(alignment: .leading, spacing: 16) {53                GlassCard("Monthly rent") {54                    Text("1,450 $").font(.title2)55                    Text("Sample listing · 4½ · Plateau").foregroundStyle(.secondary)56                }57                GlassCard {58                    Text("A long description wraps on several lines and stays readable because the card is opaque: dense text never sits on glass.")59                } header: {60                    Label("About this place", systemImage: "text.alignleft")61                } footer: {62                    Text("Fictitious data")63                }64                GlassCard {65                    // Any view: a photo, a map, a drawing. Give it a height.66                    Rectangle().fill(.tint.opacity(0.25)).frame(height: 120)67                        .overlay { Image(systemName: "building.2").font(.largeTitle).foregroundStyle(.tint) }68                        .accessibilityHidden(true)69                } content: {70                    Text("Two bedrooms · 74 m² · Balcony").foregroundStyle(.secondary)71                } header: {72                    Text("Loft on the canal")73                } footer: {74                    Label("Available 1 July", systemImage: "calendar")75                }76                GlassCard(style: .floating, action: { openCount += 1 }) {77                    Label("3 listings nearby", systemImage: "mappin.and.ellipse")78                    Text("Opened \(openCount) times").font(.caption)79                }80                .accessibilityHint("Opens the list")81            }82            .padding()83        }84    }85}8687#Preview("GlassCard") { GlassCardExample().glassTheme(.ocean) }88
Files main
Menu

Theme