mucke/lib/presentation/widgets/play_pause_button.dart
2021-02-26 22:07:18 +01:00

43 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:provider/provider.dart';
import '../state/audio_store.dart';
class PlayPauseButton extends StatelessWidget {
const PlayPauseButton({Key key, this.circle = false, this.iconSize = 24.0}) : super(key: key);
final bool circle;
final double iconSize;
@override
Widget build(BuildContext context) {
final AudioStore audioStore = Provider.of<AudioStore>(context);
return Observer(
builder: (BuildContext context) {
if (audioStore.playingStream?.value != null && audioStore.playingStream.value) {
return IconButton(
icon: circle
? const Icon(Icons.pause_circle_filled_rounded)
: const Icon(Icons.pause_rounded),
iconSize: iconSize,
onPressed: () {
audioStore.pause();
},
);
} else {
return IconButton(
icon: circle
? const Icon(Icons.play_circle_filled_rounded)
: const Icon(Icons.play_arrow_rounded),
iconSize: iconSize,
onPressed: () {
audioStore.play();
},
);
}
},
);
}
}