Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Examples/Gallery/Containers/GlassAccordionExample.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 GlassAccordionExample: GlassExample {45 public static let componentID = "glass-accordion"4647 private struct Question: Identifiable {48 let id: String49 let title: String50 let answer: String51 }5253 private let questions = [54 Question(id: "delivery", title: "How long does delivery take?", answer: "Two to four working days for this sample shop."),55 Question(id: "returns", title: "Can I return an item?", answer: "Yes, within 30 days, in its original packaging."),56 Question(id: "unicode", title: "Les accents et les émojis passent-ils ? 🎉", answer: "Oui : « é », « ñ », « 日本語 » et le texte de droite à gauche (مرحبا) s'affichent sans casser la mise en page."),57 ]58 @State private var expanded: Set<String> = ["delivery"]59 @State private var singleMode = true6061 public init() {}6263 public var body: some View {64 ScrollView {65 VStack(alignment: .leading, spacing: 16) {66 Toggle("One section at a time", isOn: $singleMode)67 GlassAccordion(questions, expanded: $expanded, mode: singleMode ? .single : .multiple, style: .grouped) { question in68 Text(question.title)69 } content: { question in70 Text(question.answer)71 }72 Text("\(expanded.count) open").font(.caption).foregroundStyle(.secondary)73 }74 .padding()75 }76 }77}7879#Preview("GlassAccordion") { GlassAccordionExample() }80