Files
Ensemble/lib/utils/queue_controls.dart
ChrisandClaude Opus 4.6 0a853bd862 Extract and centralize constant definitions
Added new constant classes to timings.dart:
- ImageSizes: defaultSize (256), highRes (512), max (1024)
- VolumeConstants: min (0), max (100), range (100)
- PlayerStates: playing, paused, idle, off
- RepeatModes: off, all, one

Updated MusicAssistantProvider and QueueControls to use these
constants instead of magic numbers and string literals.

This improves code maintainability by:
- Eliminating magic numbers
- Providing single source of truth for common values
- Making code more self-documenting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 12:04:33 +00:00

31 lines
822 B
Dart

import '../constants/timings.dart';
/// Utility methods for queue playback controls.
///
/// Extracted from MusicAssistantProvider to isolate queue control logic.
class QueueControls {
/// Get the next repeat mode in the cycle.
///
/// Cycle order: off → all → one → off
static String getNextRepeatMode(String? currentMode) {
switch (currentMode) {
case RepeatModes.off:
case null:
return RepeatModes.all;
case RepeatModes.all:
return RepeatModes.one;
case RepeatModes.one:
return RepeatModes.off;
default:
return RepeatModes.off;
}
}
/// Check if a repeat mode is valid.
static bool isValidRepeatMode(String? mode) {
return mode == RepeatModes.off ||
mode == RepeatModes.all ||
mode == RepeatModes.one;
}
}