-
-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into refactor/backgroundTasks
- Loading branch information
Showing
147 changed files
with
2,561 additions
and
230 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
57 changes: 57 additions & 0 deletions
57
packages/smooth_app/lib/helpers/haptic_feedback_helper.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:smooth_app/data_models/user_preferences.dart'; | ||
|
||
/// Haptic feedback/vibrations in the app | ||
/// Managed by a preference in the user's preferences | ||
class SmoothHapticFeedback { | ||
const SmoothHapticFeedback._(); | ||
|
||
/// Will vibrate smoothly twice | ||
static Future<void> confirm() async { | ||
if (!(await _areHapticFeedbackEnabled())) { | ||
return; | ||
} | ||
|
||
await HapticFeedback.lightImpact(); | ||
return Future<void>.delayed(const Duration(milliseconds: 50), () { | ||
HapticFeedback.lightImpact(); | ||
}); | ||
} | ||
|
||
/// Discrete vibration | ||
static Future<void> click() async { | ||
if (!(await _areHapticFeedbackEnabled())) { | ||
return; | ||
} | ||
|
||
return HapticFeedback.selectionClick(); | ||
} | ||
|
||
/// According to the doc: "a collision impact with a light mass" | ||
static Future<void> lightNotification() async { | ||
if (!(await _areHapticFeedbackEnabled())) { | ||
return; | ||
} | ||
|
||
return HapticFeedback.lightImpact(); | ||
} | ||
|
||
/// Will vibrate heavily twice | ||
static Future<void> error() async { | ||
if (!(await _areHapticFeedbackEnabled())) { | ||
return; | ||
} | ||
|
||
await HapticFeedback.heavyImpact(); | ||
return Future<void>.delayed(const Duration(milliseconds: 50), () { | ||
HapticFeedback.heavyImpact(); | ||
}); | ||
} | ||
|
||
static Future<bool> _areHapticFeedbackEnabled() async { | ||
return UserPreferences.getUserPreferences() | ||
.then((UserPreferences userPreferences) { | ||
return userPreferences.hapticFeedbackEnabled; | ||
}); | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.