Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Sources/SPGlassComponents/Buttons/GlassButtonGroup.swift8// Module : SPGlassComponents9// 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 SPGlassCore43import SPGlassTokens44import SPGlassThemes45import SPGlassEffects4647/// Lays related glass buttons out in one glass container.48///49/// ```swift50/// GlassButtonGroup {51/// GlassIconButton(systemImage: "bold", accessibilityLabel: "Bold") { … }52/// GlassIconButton(systemImage: "italic", accessibilityLabel: "Italic") { … }53/// }54/// ```55///56/// Glass cannot sample other glass: buttons that sit side by side must share a `GlassEffectContainer` to be57/// rendered consistently and to blend when they come close. The group provides that container, an even58/// spacing from the theme and a single accessibility container. It adds no surface of its own.59public struct GlassButtonGroup<Content: View>: View {60 @GlassThemed private var theme61 private let axis: Axis62 private let spacing: GlassSpacingStep63 private let label: Text?64 private let content: Content6566 /// - Parameters:67 /// - axis: direction of the group.68 /// - spacing: distance between buttons, from the theme's spacing scale.69 /// - accessibilityLabel: name of the group, read by VoiceOver before its buttons.70 public init(71 axis: Axis = .horizontal,72 spacing: GlassSpacingStep = .xs,73 accessibilityLabel: LocalizedStringKey? = nil,74 @ViewBuilder content: () -> Content75 ) {76 self.axis = axis77 self.spacing = spacing78 self.label = accessibilityLabel.map { Text($0) }79 self.content = content()80 }8182 public var body: some View {83 let distance = theme.spacing[spacing]84 GlassGroup(spacing: distance) {85 switch axis {86 case .horizontal: HStack(spacing: distance) { content }87 case .vertical: VStack(spacing: distance) { content }88 }89 }90 .accessibilityElement(children: .contain)91 .accessibilityLabel(label ?? Text(verbatim: ""))92 }93}94