Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : MacLustr Storage Node9// File : MacLustrStorageNode/Features/Allocation/QuotaPicker.swift10// Description : Choice of the maximum capacity lent to the cluster:11// presets adapted to the space really available, or a custom12// value.13// Module : MacLustrStorageNode14// Repository : https://git.spboucher.ai/maclustr-storage-ios15// Project Website : https://storage.spboucher.ai16// Created : 2026-12-0117// Last Modified : 2026-12-0118//19// =============================================================================20// AUTHOR & PROFESSIONAL AFFILIATION21// =============================================================================22//23// Author : Simon-Pierre Boucher24// Position : Professor of Finance25// Institution : Université du Québec en Outaouais (UQO)26// Department : Département des sciences administratives27// Organization : SP Boucher28//29// Website : https://spboucher.ai30// Git : https://git.spboucher.ai31//32// =============================================================================33// OFFICIAL CONTACT DIRECTORY34// =============================================================================35//36// General : info@spboucher.ai37// Professional : contact@spboucher.ai38// Direct : simon@spboucher.ai39// Research : research@spboucher.ai40// Development : dev@spboucher.ai41// Support : support@spboucher.ai42// Security/Admin : admin@spboucher.ai43// Notifications : notifications@spboucher.ai44//45// Preferred Contact: admin@spboucher.ai46//47// =============================================================================48// COPYRIGHT & INTELLECTUAL PROPERTY49// =============================================================================50//51// Copyright (c) 202652// Simon-Pierre Boucher53//54// All rights reserved where applicable.55//56// This file is governed by the applicable project license,57// copyright notices, institutional agreements and relevant law.58//59// Unless expressly authorized by the applicable license or60// rights holder, copying, redistribution, sublicensing,61// publication and commercial exploitation are not permitted.62//63// Existing third-party rights and notices remain unaffected.64//65// =============================================================================66// CONFIDENTIALITY & SECURITY67// =============================================================================68//69// Classification : Public70// Distribution : Public repository; use is governed by the project license71// Security Contact : admin@spboucher.ai72//73// Access to this source does not independently grant permission74// to redistribute or disclose confidential materials.75//76// Do not embed credentials, private keys, access tokens,77// certificates or confidential personal information.78//79// =============================================================================80// LICENSE & MAINTENANCE81// =============================================================================82//83// License : None specified (no license file in this repository)84// Maintainer : Simon-Pierre Boucher85// Technical Contact: dev@spboucher.ai86//87// =============================================================================88// END OF SP BOUCHER SOURCE HEADER89// =============================================================================9091import SwiftUI9293struct QuotaPicker: View {94 @Binding var quota: Int6495 let capacity: Capacity9697 var body: some View {98 let options = CapacityMonitor.options(maxAllocatable: capacity.maxAllocatable)99 let maxGB = max(1, Double(capacity.maxAllocatable / Format.gb))100 VStack(alignment: .leading, spacing: 12) {101 HStack(alignment: .firstTextBaseline) {102 Text(Format.bytes(quota)).font(.system(size: 34, weight: .semibold).monospacedDigit()).foregroundStyle(Theme.text)103 Spacer()104 Text("of \(Format.bytes(capacity.maxAllocatable)) possible").font(.footnote).foregroundStyle(Theme.textTertiary)105 }106 if options.isEmpty {107 Text("Not enough free space above the reserve.").font(.footnote).foregroundStyle(Theme.warning)108 } else {109 LazyVGrid(columns: [GridItem(.adaptive(minimum: 84), spacing: 8)], spacing: 8) {110 ForEach(options, id: \.self) { o in111 Button { quota = o } label: {112 Text(Format.bytes(o)).font(.subheadline.weight(.medium).monospacedDigit()).frame(maxWidth: .infinity).padding(.vertical, 9)113 .background(quota == o ? Theme.accentMuted : Theme.raised)114 .overlay(RoundedRectangle(cornerRadius: 8).stroke(quota == o ? Theme.accent : Theme.border, lineWidth: 1))115 .clipShape(RoundedRectangle(cornerRadius: 8))116 .foregroundStyle(Theme.text)117 }.buttonStyle(.plain).accessibilityAddTraits(quota == o ? .isSelected : [])118 }119 }120 VStack(alignment: .leading, spacing: 2) {121 Text("Custom").font(.caption).foregroundStyle(Theme.textTertiary)122 Slider(value: Binding(get: { min(maxGB, Double(quota / Format.gb)) }, set: { quota = Int64($0.rounded()) * Format.gb }), in: 0...maxGB, step: 1)123 .accessibilityLabel("Custom capacity in gigabytes")124 }125 }126 }127 }128}129