mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00

* feat: add riverpod based favorite album provider * feat: add album is saved, new releases and tracks providers * feat: add artist related providers * feat: add all categories providers * feat: add lyrics provider * feat: add playlist related providers * feat: add search provider * feat: add view and spotify friends provider * feat: add playlist create and update and favorite handlers * feat: use providers in home screen * chore: fix dart lint issues * feat: use new providers for playlist and albums screen * feat: use providers in artist page * feat: use providers on library page * feat: use provider for playlist and album card and heart button * feat: use provider in search page * feat: use providers in generate playlist * feat: use provider in lyrics screen * feat: use provider for create playlist * feat: use provider in add track dialog * feat: use providers in remaining pages and remove fl_query * fix: remove direct access to provider.value * fix: glitching when loading * fix: user album loading next page indicator * feat: make many provider autoDispose after 5 minutes of no usage * fix: ignore episodes in tracks
67 lines
1.8 KiB
Dart
67 lines
1.8 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';
|
|
import 'package:spotube/provider/volume_provider.dart';
|
|
|
|
class VolumeSlider extends HookConsumerWidget {
|
|
final bool fullWidth;
|
|
const VolumeSlider({
|
|
super.key,
|
|
this.fullWidth = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final volume = ref.watch(volumeProvider);
|
|
final volumeNotifier = ref.watch(volumeProvider.notifier);
|
|
|
|
var slider = Listener(
|
|
onPointerSignal: (event) async {
|
|
if (event is PointerScrollEvent) {
|
|
if (event.scrollDelta.dy > 0) {
|
|
final value = volume - .2;
|
|
volumeNotifier.setVolume(value < 0 ? 0 : value);
|
|
} else {
|
|
final value = volume + .2;
|
|
volumeNotifier.setVolume(value > 1 ? 1 : value);
|
|
}
|
|
}
|
|
},
|
|
child: Slider(
|
|
min: 0,
|
|
max: 1,
|
|
value: volume,
|
|
onChanged: volumeNotifier.setVolume,
|
|
),
|
|
);
|
|
return Row(
|
|
mainAxisAlignment:
|
|
!fullWidth ? MainAxisAlignment.center : MainAxisAlignment.start,
|
|
children: [
|
|
IconButton(
|
|
icon: Icon(
|
|
volume == 0
|
|
? SpotubeIcons.volumeMute
|
|
: volume <= 0.2
|
|
? SpotubeIcons.volumeLow
|
|
: volume <= 0.6
|
|
? SpotubeIcons.volumeMedium
|
|
: SpotubeIcons.volumeHigh,
|
|
size: 16,
|
|
),
|
|
onPressed: () {
|
|
if (volume == 0) {
|
|
volumeNotifier.setVolume(1);
|
|
} else {
|
|
volumeNotifier.setVolume(0);
|
|
}
|
|
},
|
|
),
|
|
if (fullWidth) Expanded(child: slider) else slider,
|
|
],
|
|
);
|
|
}
|
|
}
|