spotube/lib/components/player/volume_slider.dart
Kingkor Roy Tirtho 68374efd3e
feat: LAN connect a.k.a control remote Spotube playback and local output device selection (#1355)
* feat: add connect server support

* feat: add ability discover and connect to same network Spotube(s) and sync queue

* feat(connect): add player controls, shuffle, loop, progress bar and queue support

* feat: make control page adaptive

* feat: add volume control support

* cd: upgrade macos runner version

* chore: upgrade inappwebview version to 6

* feat: customized devices button

* feat: add user icon next to devices button

* feat: add play in remote device support

* feat: show alert when new client connects

* fix: ignore the device itself from broadcast list

* fix: volume control not working

* feat: add ability to select current device's output speaker
2024-04-04 22:22:00 +06:00

69 lines
1.7 KiB
Dart

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/spotube_icons.dart';
class VolumeSlider extends HookConsumerWidget {
final bool fullWidth;
final double value;
final ValueChanged<double> onChanged;
const VolumeSlider({
super.key,
this.fullWidth = false,
required this.value,
required this.onChanged,
});
@override
Widget build(BuildContext context, ref) {
var slider = Listener(
onPointerSignal: (event) async {
if (event is PointerScrollEvent) {
if (event.scrollDelta.dy > 0) {
final newValue = value - .2;
onChanged(newValue < 0 ? 0 : newValue);
} else {
final newValue = value + .2;
onChanged(newValue > 1 ? 1 : newValue);
}
}
},
child: Slider(
min: 0,
max: 1,
value: value,
onChanged: onChanged,
),
);
return Row(
mainAxisAlignment:
!fullWidth ? MainAxisAlignment.center : MainAxisAlignment.start,
children: [
IconButton(
icon: Icon(
value == 0
? SpotubeIcons.volumeMute
: value <= 0.2
? SpotubeIcons.volumeLow
: value <= 0.6
? SpotubeIcons.volumeMedium
: SpotubeIcons.volumeHigh,
size: 16,
),
onPressed: () {
if (value == 0) {
onChanged(1);
} else {
onChanged(0);
}
},
),
if (fullWidth) Expanded(child: slider) else slider,
],
);
}
}