mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
101 lines
2.4 KiB
Dart
101 lines
2.4 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../backend.dart';
|
|
import '../widgets/play_pause_button.dart';
|
|
|
|
class ProgramScreen extends StatefulWidget {
|
|
@override
|
|
_ProgramScreenState createState() => _ProgramScreenState();
|
|
}
|
|
|
|
class _ProgramScreenState extends State<ProgramScreen> {
|
|
BackendState backend;
|
|
StreamSubscription<double> positionSubscription;
|
|
double position = 0.0;
|
|
bool seeking = false;
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
|
|
backend = Backend.of(context);
|
|
|
|
if (positionSubscription != null) {
|
|
positionSubscription.cancel();
|
|
}
|
|
|
|
positionSubscription = backend.position.listen((pos) {
|
|
if (!seeking) {
|
|
setState(() {
|
|
position = pos;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.keyboard_arrow_down),
|
|
onPressed: () => Navigator.pop(context),
|
|
),
|
|
title: Text('Program'),
|
|
),
|
|
bottomNavigationBar: BottomAppBar(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Slider(
|
|
value: position,
|
|
onChangeStart: (_) {
|
|
seeking = true;
|
|
},
|
|
onChangeEnd: (pos) {
|
|
seeking = false;
|
|
backend.seekTo(pos);
|
|
},
|
|
onChanged: (pos) {
|
|
setState(() {
|
|
position = pos;
|
|
});
|
|
},
|
|
),
|
|
Row(
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 24.0),
|
|
child: Text('4:00'),
|
|
),
|
|
Spacer(),
|
|
IconButton(
|
|
icon: const Icon(Icons.skip_previous),
|
|
onPressed: () {},
|
|
),
|
|
PlayPauseButton(),
|
|
IconButton(
|
|
icon: const Icon(Icons.skip_next),
|
|
onPressed: () {},
|
|
),
|
|
Spacer(),
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 20.0),
|
|
child: Text('10:30'),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
positionSubscription.cancel();
|
|
}
|
|
}
|