chore: run dart format
Some checks are pending
Flutter CI & Release / Test (push) Waiting to run
Flutter CI & Release / Build Android APKs (push) Blocked by required conditions
Flutter CI & Release / build_linux (push) Blocked by required conditions
Flutter CI & Release / Create GitHub Release (push) Blocked by required conditions

This commit is contained in:
Dr.Blank 2026-01-10 16:51:05 +05:30
parent a520136e01
commit e23c0b6c5f
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
84 changed files with 1565 additions and 1945 deletions

View file

@ -59,34 +59,29 @@ class ShakeDetector extends _$ShakeDetector {
final sleepTimer = ref.watch(sleepTimerProvider);
if (!shakeDetectionSettings.shakeAction.isPlaybackManagementEnabled &&
sleepTimer == null) {
_logger
.config('No playback management is enabled and sleep timer is off, '
'so shake detection is disabled');
_logger.config(
'No playback management is enabled and sleep timer is off, '
'so shake detection is disabled',
);
return null;
}
_logger.config('Creating shake detector');
final detector = core.ShakeDetector(
shakeDetectionSettings,
() {
final wasActionComplete = doShakeAction(
shakeDetectionSettings.shakeAction,
ref: ref,
);
if (wasActionComplete) {
shakeDetectionSettings.feedback.forEach(postShakeFeedback);
}
},
);
final detector = core.ShakeDetector(shakeDetectionSettings, () {
final wasActionComplete = doShakeAction(
shakeDetectionSettings.shakeAction,
ref: ref,
);
if (wasActionComplete) {
shakeDetectionSettings.feedback.forEach(postShakeFeedback);
}
});
ref.onDispose(detector.dispose);
return detector;
}
/// Perform the shake action and return whether the action was successful
bool doShakeAction(
ShakeAction shakeAction, {
required Ref ref,
}) {
bool doShakeAction(ShakeAction shakeAction, {required Ref ref}) {
final player = ref.read(simpleAudiobookPlayerProvider);
if (player.book == null && shakeAction.isPlaybackManagementEnabled) {
_logger.warning('No book is loaded');
@ -166,8 +161,11 @@ extension on ShakeAction {
}
bool get isPlaybackManagementEnabled {
return {ShakeAction.playPause, ShakeAction.fastForward, ShakeAction.rewind}
.contains(this);
return {
ShakeAction.playPause,
ShakeAction.fastForward,
ShakeAction.rewind,
}.contains(this);
}
bool get shouldActOnSleepTimer {