2019-12-02 21:38:47 +01:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
2019-12-02 21:05:49 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2019-12-02 21:38:47 +01:00
|
|
|
import '../backend.dart';
|
|
|
|
|
|
|
|
|
|
class ProgramScreen extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_ProgramScreenState createState() => _ProgramScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ProgramScreenState extends State<ProgramScreen> {
|
|
|
|
|
Backend 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;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-02 21:05:49 +01:00
|
|
|
@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'),
|
|
|
|
|
),
|
2019-12-02 21:38:47 +01:00
|
|
|
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;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2019-12-02 21:05:49 +01:00
|
|
|
);
|
|
|
|
|
}
|
2019-12-02 21:38:47 +01:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
positionSubscription.cancel();
|
|
|
|
|
}
|
2019-12-02 21:05:49 +01:00
|
|
|
}
|