Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Claude Remote / Codex Remote9// File : Packages/ClaudeRemoteKit/Sources/ClaudeRemoteDesign/Haptics.swift10// Module : ClaudeRemoteDesign11// Repository : https://git.spboucher.ai/claude-remote-apple12// Project Website : https://claude.spboucher.ai13// Created : 2026-11-2914// Last Modified : 2026-11-2915//16// =============================================================================17// AUTHOR & PROFESSIONAL AFFILIATION18// =============================================================================19//20// Author : Simon-Pierre Boucher21// Position : Professor of Finance22// Institution : Université du Québec en Outaouais (UQO)23// Department : Département des sciences administratives24// Organization : SP Boucher25//26// Website : https://spboucher.ai27// Git : https://git.spboucher.ai28//29// =============================================================================30// OFFICIAL CONTACT DIRECTORY31// =============================================================================32//33// General : info@spboucher.ai34// Professional : contact@spboucher.ai35// Direct : simon@spboucher.ai36// Research : research@spboucher.ai37// Development : dev@spboucher.ai38// Support : support@spboucher.ai39// Security/Admin : admin@spboucher.ai40// Notifications : notifications@spboucher.ai41//42// Preferred Contact: support@spboucher.ai43//44// =============================================================================45// COPYRIGHT & INTELLECTUAL PROPERTY46// =============================================================================47//48// Copyright (c) 202649// Simon-Pierre Boucher50//51// All rights reserved where applicable.52//53// This file is governed by the applicable project license,54// copyright notices, institutional agreements and relevant law.55//56// Unless expressly authorized by the applicable license or57// rights holder, copying, redistribution, sublicensing,58// publication and commercial exploitation are not permitted.59//60// Existing third-party rights and notices remain unaffected.61//62// =============================================================================63// CONFIDENTIALITY & SECURITY64// =============================================================================65//66// Classification : Public67// Distribution : Public repository; use is governed by the project license68// Security Contact : admin@spboucher.ai69//70// Access to this source does not independently grant permission71// to redistribute or disclose confidential materials.72//73// Do not embed credentials, private keys, access tokens,74// certificates or confidential personal information.75//76// =============================================================================77// LICENSE & MAINTENANCE78// =============================================================================79//80// License : None specified (no license file in this repository)81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import SwiftUI89#if canImport(UIKit) && !os(watchOS) && !os(tvOS) && !os(visionOS)90import UIKit91#endif9293/// Haptic feedback: real on iPhone / iPad, no-op on macOS.94@MainActor95public enum Haptics {96 public enum Impact: Sendable {97 case light, medium, heavy, soft, rigid98 }99100 /// Set to false to silence all haptics (user setting).101 public static var isEnabled = true102103 /// Physical tap (key row presses, toggles).104 public static func impact(_ style: Impact = .light) {105 #if canImport(UIKit) && os(iOS)106 guard isEnabled else { return }107 let mapped: UIImpactFeedbackGenerator.FeedbackStyle = switch style {108 case .light: .light109 case .medium: .medium110 case .heavy: .heavy111 case .soft: .soft112 case .rigid: .rigid113 }114 UIImpactFeedbackGenerator(style: mapped).impactOccurred()115 #endif116 }117118 /// Selection change (pickers, sticky modifiers).119 public static func selection() {120 #if canImport(UIKit) && os(iOS)121 guard isEnabled else { return }122 UISelectionFeedbackGenerator().selectionChanged()123 #endif124 }125126 public static func success() { notify(0) }127 public static func warning() { notify(1) }128 public static func error() { notify(2) }129130 private static func notify(_ kind: Int) {131 #if canImport(UIKit) && os(iOS)132 guard isEnabled else { return }133 let type: UINotificationFeedbackGenerator.FeedbackType = kind == 0 ? .success : kind == 1 ? .warning : .error134 UINotificationFeedbackGenerator().notificationOccurred(type)135 #endif136 }137}138