diff GeoQuiz/Logic/HapticsController.swift @ 19:f140bb277c96

refactor code
author Dennis C. M. <dennis@denniscm.com>
date Sun, 23 Oct 2022 00:11:38 +0100
parents GeoQuiz/Logic/HapticsClass.swift@136928bae534
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GeoQuiz/Logic/HapticsController.swift	Sun Oct 23 00:11:38 2022 +0100
@@ -0,0 +1,27 @@
+//
+//  HapticsController.swift
+//  GeoQuiz
+//
+//  Created by Dennis Concepción Martín on 18/9/22.
+//
+
+import Foundation
+import SwiftUI
+
+class HapticsController {
+    private var user = UserController()
+    
+    func success() {
+        if user.data.haptics {
+            let generator = UINotificationFeedbackGenerator()
+            generator.notificationOccurred(.success)
+        }
+    }
+
+    func error() {
+        if user.data.haptics {
+            let generator = UINotificationFeedbackGenerator()
+            generator.notificationOccurred(.error)
+        }
+    }
+}