Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Examples/Gallery/Feedback/GlassBannerExample.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 GlassBannerExample: GlassExample {45 public static let componentID = "glass-banner"46 @State private var showsWarning = true47 @State private var retryCount = 04849 public init() {}5051 public var body: some View {52 ScrollView {53 VStack(spacing: 12) {54 GlassBanner(.information, title: "Maintenance on Sunday", message: "The sample service will be read-only from 2:00 to 4:00.")55 GlassBanner(.success, title: "Payment received")56 if showsWarning {57 GlassBanner(58 .warning,59 title: "Your card expires soon",60 message: "Update your payment method before the end of the month to avoid an interruption.",61 action: GlassBannerAction("Update card") { showsWarning = false },62 onDismiss: { showsWarning = false }63 )64 }65 GlassBanner(66 .error,67 verbatim: "Synchronisation failed (attempt \(retryCount + 1))",68 message: "The server did not answer.",69 action: GlassBannerAction("Retry") { retryCount += 1 }70 )71 }72 .padding()73 }74 }75}7677#Preview("GlassBanner") { GlassBannerExample().glassTheme(.emerald) }78