2020-08-24 16:43:22 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../domain/entities/shuffle_mode.dart';
|
|
|
|
import '../state/audio_store.dart';
|
|
|
|
|
|
|
|
class ShuffleButton extends StatelessWidget {
|
|
|
|
const ShuffleButton({Key key, this.iconSize = 20.0}) : super(key: key);
|
|
|
|
|
|
|
|
final double iconSize;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final AudioStore audioStore = Provider.of<AudioStore>(context);
|
|
|
|
|
|
|
|
return Observer(
|
|
|
|
builder: (BuildContext context) {
|
2020-09-19 17:08:48 +02:00
|
|
|
if (audioStore.shuffleModeStream != null) {
|
|
|
|
switch (audioStore.shuffleModeStream.value) {
|
|
|
|
case ShuffleMode.none:
|
|
|
|
return IconButton(
|
|
|
|
icon: const Icon(
|
2020-12-31 17:52:20 +01:00
|
|
|
Icons.shuffle_rounded,
|
2020-09-20 12:33:11 +02:00
|
|
|
color: Colors.white30,
|
2020-09-19 17:08:48 +02:00
|
|
|
),
|
|
|
|
iconSize: iconSize,
|
2020-12-31 17:52:20 +01:00
|
|
|
onPressed: () => audioStore.setShuffleMode(ShuffleMode.standard),
|
2020-09-19 17:08:48 +02:00
|
|
|
);
|
|
|
|
case ShuffleMode.standard:
|
|
|
|
return IconButton(
|
|
|
|
icon: const Icon(
|
2020-12-31 17:52:20 +01:00
|
|
|
Icons.shuffle_rounded,
|
2020-09-19 17:08:48 +02:00
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
iconSize: iconSize,
|
2020-12-31 17:52:20 +01:00
|
|
|
onPressed: () => audioStore.setShuffleMode(ShuffleMode.plus),
|
2020-09-19 17:08:48 +02:00
|
|
|
);
|
|
|
|
case ShuffleMode.plus:
|
|
|
|
return IconButton(
|
|
|
|
icon: const Icon(
|
2020-12-31 17:52:20 +01:00
|
|
|
Icons.fingerprint_rounded,
|
2020-09-19 17:08:48 +02:00
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
iconSize: iconSize,
|
2020-12-31 17:52:20 +01:00
|
|
|
onPressed: () => audioStore.setShuffleMode(ShuffleMode.none),
|
2020-09-19 17:08:48 +02:00
|
|
|
);
|
|
|
|
}
|
2020-08-24 16:43:22 +02:00
|
|
|
}
|
2020-09-19 17:08:48 +02:00
|
|
|
return Container();
|
2020-08-24 16:43:22 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|