Created
January 9, 2020 22:33
-
-
Save Yihwan/cd52f437a6a5767da68d1ef50f18e4e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Haptics.swift | |
// skills-timer | |
// | |
// Created by Yihwan Kim on 1/1/20. | |
// Copyright © 2020 Yihwan Kim. All rights reserved. | |
// | |
import Foundation | |
import UIKit | |
struct Haptics { | |
static let notificationGenerator = UINotificationFeedbackGenerator() | |
static let lightFeedbackGenerator = UIImpactFeedbackGenerator(style: .light) | |
static let mediumFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium) | |
static let heavyFeedbackGenerator = UIImpactFeedbackGenerator(style: .heavy) | |
static func success() { | |
Self.notificationGenerator.notificationOccurred(.success) | |
} | |
static func warning() { | |
Self.notificationGenerator.notificationOccurred(.warning) | |
} | |
static func light() { | |
Self.lightFeedbackGenerator.impactOccurred() | |
} | |
static func medium() { | |
Self.mediumFeedbackGenerator.impactOccurred() | |
} | |
static func heavy() { | |
Self.heavyFeedbackGenerator.impactOccurred() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haptics.success() is so much easier than the alternatives!