|
|
@@ -42,6 +42,7 @@ class _VolumeCardState extends State<VolumeCard> {
|
|
|
int get _max => widget.volume.max <= 0 ? 15 : widget.volume.max;
|
|
|
int get _value => widget.volume.index.clamp(0, _max);
|
|
|
bool get _muted => _value == 0;
|
|
|
+ bool get _fixed => widget.volume.fixed;
|
|
|
int get _percent => ((_value / _max) * 100).round();
|
|
|
|
|
|
String get _nowPlayingLabel {
|
|
|
@@ -118,79 +119,100 @@ class _VolumeCardState extends State<VolumeCard> {
|
|
|
min: 0,
|
|
|
max: _max.toDouble(),
|
|
|
divisions: _max <= 30 ? _max : null,
|
|
|
- onChanged: (next) {
|
|
|
- setState(() => _dragValue = next);
|
|
|
- widget.onSetVolume(next.round());
|
|
|
- },
|
|
|
- onChangeEnd: (_) => setState(() => _dragValue = null),
|
|
|
+ onChanged: _fixed
|
|
|
+ ? null
|
|
|
+ : (next) {
|
|
|
+ setState(() => _dragValue = next);
|
|
|
+ widget.onSetVolume(next.round());
|
|
|
+ },
|
|
|
+ onChangeEnd: _fixed
|
|
|
+ ? null
|
|
|
+ : (_) => setState(() => _dragValue = null),
|
|
|
semanticFormatterCallback: (value) =>
|
|
|
'${(value / _max * 100).round()} percent',
|
|
|
),
|
|
|
),
|
|
|
SizedBox(height: compact ? 4 : 8),
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- _StepButton(
|
|
|
- icon: Icons.remove_rounded,
|
|
|
- semanticLabel: 'Volume down',
|
|
|
- onTap: () => widget.onSetVolume(_value - 1),
|
|
|
- compact: compact,
|
|
|
+ if (_fixed)
|
|
|
+ Container(
|
|
|
+ height: compact ? 36 : 40,
|
|
|
+ alignment: Alignment.center,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: colors.surfaceStrong,
|
|
|
+ borderRadius: BorderRadius.circular(999),
|
|
|
+ border: Border.all(color: colors.border),
|
|
|
+ ),
|
|
|
+ child: Text(
|
|
|
+ 'Volume is controlled by the car',
|
|
|
+ style: theme.textTheme.labelMedium?.copyWith(
|
|
|
+ color: colors.inkMuted,
|
|
|
+ ),
|
|
|
),
|
|
|
- SizedBox(width: compact ? 8 : 10),
|
|
|
- Expanded(
|
|
|
- child: Pressable(
|
|
|
- onTap: widget.onToggleMute,
|
|
|
- semanticLabel: _muted ? 'Unmute' : 'Mute',
|
|
|
- pressedScale: 0.97,
|
|
|
- child: Container(
|
|
|
- height: compact ? 36 : 40,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: _muted
|
|
|
- ? colors.accentSoft
|
|
|
- : colors.surfaceStrong,
|
|
|
- borderRadius: BorderRadius.circular(999),
|
|
|
- border: Border.all(
|
|
|
+ )
|
|
|
+ else
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ _StepButton(
|
|
|
+ icon: Icons.remove_rounded,
|
|
|
+ semanticLabel: 'Volume down',
|
|
|
+ onTap: () => widget.onSetVolume(_value - 1),
|
|
|
+ compact: compact,
|
|
|
+ ),
|
|
|
+ SizedBox(width: compact ? 8 : 10),
|
|
|
+ Expanded(
|
|
|
+ child: Pressable(
|
|
|
+ onTap: widget.onToggleMute,
|
|
|
+ semanticLabel: _muted ? 'Unmute' : 'Mute',
|
|
|
+ pressedScale: 0.97,
|
|
|
+ child: Container(
|
|
|
+ height: compact ? 36 : 40,
|
|
|
+ decoration: BoxDecoration(
|
|
|
color: _muted
|
|
|
- ? colors.accent.withValues(alpha: 0.25)
|
|
|
- : colors.border,
|
|
|
- ),
|
|
|
- ),
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- AppIcon(
|
|
|
- _muted
|
|
|
- ? 'assets/icons/volume-x.svg'
|
|
|
- : 'assets/icons/volume-2.svg',
|
|
|
- size: compact ? 16 : 18,
|
|
|
+ ? colors.accentSoft
|
|
|
+ : colors.surfaceStrong,
|
|
|
+ borderRadius: BorderRadius.circular(999),
|
|
|
+ border: Border.all(
|
|
|
color: _muted
|
|
|
- ? colors.accent
|
|
|
- : colors.inkMuted,
|
|
|
- ),
|
|
|
- const SizedBox(width: 8),
|
|
|
- Text(
|
|
|
- _muted ? 'Unmute' : 'Mute',
|
|
|
- style: theme.textTheme.labelMedium
|
|
|
- ?.copyWith(
|
|
|
- color: _muted
|
|
|
- ? colors.accent
|
|
|
- : colors.inkMuted,
|
|
|
- ),
|
|
|
+ ? colors.accent.withValues(alpha: 0.25)
|
|
|
+ : colors.border,
|
|
|
),
|
|
|
- ],
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ AppIcon(
|
|
|
+ _muted
|
|
|
+ ? 'assets/icons/volume-x.svg'
|
|
|
+ : 'assets/icons/volume-2.svg',
|
|
|
+ size: compact ? 16 : 18,
|
|
|
+ color: _muted
|
|
|
+ ? colors.accent
|
|
|
+ : colors.inkMuted,
|
|
|
+ ),
|
|
|
+ const SizedBox(width: 8),
|
|
|
+ Text(
|
|
|
+ _muted ? 'Unmute' : 'Mute',
|
|
|
+ style: theme.textTheme.labelMedium
|
|
|
+ ?.copyWith(
|
|
|
+ color: _muted
|
|
|
+ ? colors.accent
|
|
|
+ : colors.inkMuted,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
),
|
|
|
- ),
|
|
|
- SizedBox(width: compact ? 8 : 10),
|
|
|
- _StepButton(
|
|
|
- icon: Icons.add_rounded,
|
|
|
- semanticLabel: 'Volume up',
|
|
|
- onTap: () => widget.onSetVolume(_value + 1),
|
|
|
- compact: compact,
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ SizedBox(width: compact ? 8 : 10),
|
|
|
+ _StepButton(
|
|
|
+ icon: Icons.add_rounded,
|
|
|
+ semanticLabel: 'Volume up',
|
|
|
+ onTap: () => widget.onSetVolume(_value + 1),
|
|
|
+ compact: compact,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
],
|
|
|
),
|
|
|
),
|