Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Sources/Manager/HapticManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// HapticManager.swift
// Sunday
//
// Created by Daniel Jermaine on 13/07/2025.
//

import Foundation

import UIKit

final class HapticManager {
static let shared = HapticManager()


private init() {}

public func vibrateForSelection() {
DispatchQueue.main.async {
let generator = UISelectionFeedbackGenerator()
generator.prepare()
generator.selectionChanged()
}
}

public func vibrate(for type:UINotificationFeedbackGenerator.FeedbackType) {
DispatchQueue.main.async {
let generator = UINotificationFeedbackGenerator()
generator.prepare()
generator.notificationOccurred(type)
}
}


}
6 changes: 4 additions & 2 deletions Sources/Services/HealthManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class HealthManager: ObservableObject {
}

func saveVitaminD(amount: Double, date: Date = Date()) {

guard isAuthorized else {
requestAuthorization()
HapticManager.shared.vibrate(for: .error)
return
}

HapticManager.shared.vibrate(for: .success)
// Convert IU to micrograms (1 IU = 0.025 mcg)
let micrograms = amount * 0.025
let quantity = HKQuantity(unit: .gramUnit(with: .micro), doubleValue: micrograms)
Expand Down Expand Up @@ -211,4 +213,4 @@ class HealthManager: ObservableObject {

healthStore.execute(query)
}
}
}