SPB Git

Repository Public MIT

GlassControlSize.swift 2.7 KB 80 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Sources/SPGlassCore/GlassControlSize.swift8// Module           : SPGlassCore9// 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 Foundation4243/// Size of a custom control. System controls keep `ControlSize`; this type sizes surfaces GlassKit draws itself.44public enum GlassControlSize: String, Codable, CaseIterable, Sendable {45    case small, regular, large46}4748/// Vertical rhythm of a theme. It scales spacing, never the text size (Dynamic Type owns that).49public enum GlassDensity: String, Codable, CaseIterable, Sendable {50    case compact, regular, comfortable5152    public var spacingMultiplier: Double {53        switch self {54        case .compact: 0.855        case .regular: 1.056        case .comfortable: 1.257        }58    }59}6061/// Loading state shared by components that present asynchronous values.62public enum GlassLoadState<Value> {63    case idle64    case loading65    case loaded(Value)66    case empty67    case failed(message: String)6869    public var value: Value? {70        if case .loaded(let value) = self { value } else { nil }71    }7273    public var isLoading: Bool {74        if case .loading = self { true } else { false }75    }76}7778extension GlassLoadState: Sendable where Value: Sendable {}79extension GlassLoadState: Equatable where Value: Equatable {}80
Files main
Menu

Theme