// ============================================================================= // SP BOUCHER | SOFTWARE & RESEARCH // ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING // ============================================================================= // // Project : SP GlassKit // File : Sources/SPGlassComponents/Buttons/GlassButtonGroup.swift // Module : SPGlassComponents // Repository : https://git.spboucher.ai/sp-glasskit // Project Website : https://glass.spboucher.ai // Created : 2026-12-02 // Last Modified : 2026-12-02 // // Author : Simon-Pierre Boucher // Position : Professor of Finance // Institution : Université du Québec en Outaouais (UQO) // Organization : SP Boucher // Website : https://spboucher.ai // Git : https://git.spboucher.ai // // Preferred Contact: contact@spboucher.ai // Development : dev@spboucher.ai // Support : support@spboucher.ai // Security/Admin : admin@spboucher.ai // // Copyright (c) 2026 // Simon-Pierre Boucher // All rights reserved where applicable. This file is governed by the // applicable project license, copyright notices and relevant law. // Existing third-party rights and notices remain unaffected. // // License : MIT // // Do not embed credentials, private keys, access tokens, // certificates or confidential personal information. // // ============================================================================= // END OF SP BOUCHER SOURCE HEADER // ============================================================================= import SwiftUI /// Lays related glass buttons out in one glass container. /// /// ```swift /// GlassButtonGroup { /// GlassIconButton(systemImage: "bold", accessibilityLabel: "Bold") { … } /// GlassIconButton(systemImage: "italic", accessibilityLabel: "Italic") { … } /// } /// ``` /// /// Glass cannot sample other glass: buttons that sit side by side must share a `GlassEffectContainer` to be /// rendered consistently and to blend when they come close. The group provides that container, an even /// spacing from the theme and a single accessibility container. It adds no surface of its own. public struct GlassButtonGroup: View { @GlassThemed private var theme private let axis: Axis private let spacing: GlassSpacingStep private let label: Text? private let content: Content /// - Parameters: /// - axis: direction of the group. /// - spacing: distance between buttons, from the theme's spacing scale. /// - accessibilityLabel: name of the group, read by VoiceOver before its buttons. public init( axis: Axis = .horizontal, spacing: GlassSpacingStep = .xs, accessibilityLabel: LocalizedStringKey? = nil, @ViewBuilder content: () -> Content ) { self.axis = axis self.spacing = spacing self.label = accessibilityLabel.map { Text($0) } self.content = content() } public var body: some View { let distance = theme.spacing[spacing] GlassGroup(spacing: distance) { switch axis { case .horizontal: HStack(spacing: distance) { content } case .vertical: VStack(spacing: distance) { content } } } .accessibilityElement(children: .contain) .accessibilityLabel(label ?? Text(verbatim: "")) } }