ExpandedControls castDevice name

This commit is contained in:
gianlucaparadise 2021-12-09 18:16:52 +01:00
parent 4c34bfb4b9
commit dcf62d0af6
3 changed files with 43 additions and 12 deletions

View file

@ -143,10 +143,9 @@ I used this project to test the capabilities of the following technologies:
## Roadmap
* Volume in Expanded Controls
* Currently connected cast device name
* CC in Expanded Controls
* Handle Ad Break
* Handle progress seek
* Handle queue
* Handle mini-player
* Produce HTML docs

View file

@ -2,12 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter_cast_framework/src/cast/widgets/expanded_controls/ExpandedControlsToolbar.dart';
import '../../../../cast.dart';
import 'ExpandedControlsConnectedDeviceLabel.dart';
import 'ExpandedControlsPlayer.dart';
import 'ExpandedControlsProgress.dart';
// TODO call framework to get cast device
const String castDevice = "cast device";
const _topDownBlackGradient = BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
@ -32,13 +30,13 @@ const _bottomUpBlackGradient = BoxDecoration(
class ExpandedControls extends StatefulWidget {
final FlutterCastFramework castFramework;
final String castingToText;
final String? castingToText;
final VoidCallback? onBackTapped;
final controller = ExpandedControlsProgressController();
ExpandedControls({
required this.castFramework,
this.castingToText = "Casting to",
this.castingToText,
this.onBackTapped,
});
@ -88,17 +86,15 @@ class _ExpandedControlsState extends State<ExpandedControls> {
}
Widget _getDecoratedControls(BuildContext context, MediaInfo? mediaInfo) {
final textStyle =
Theme.of(context).textTheme.bodyText2?.copyWith(color: Colors.white);
return Container(
decoration: _bottomUpBlackGradient,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child:
Text("${widget.castingToText} $castDevice", style: textStyle),
child: ExpandedControlsConnectedDeviceLabel(
castFramework: widget.castFramework,
),
),
Padding(
padding: const EdgeInsets.all(8.0),

View file

@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_cast_framework/cast.dart';
class ExpandedControlsConnectedDeviceLabel extends StatelessWidget {
final FlutterCastFramework castFramework;
final String castingToText;
const ExpandedControlsConnectedDeviceLabel({
Key? key,
required this.castFramework,
this.castingToText = "Casting to",
}) : super(key: key);
@override
Widget build(BuildContext context) {
final textStyle =
Theme.of(context).textTheme.bodyText2?.copyWith(color: Colors.white);
return FutureBuilder<CastDevice>(
future: castFramework.castContext.sessionManager.getCastDevice(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var castDevice = snapshot.data;
var castDeviceName = castDevice?.friendlyName ?? "";
return Text("$castingToText $castDeviceName", style: textStyle);
} else if (snapshot.hasError) {
debugPrint("error while retrieving cast device ${snapshot.error}");
return Text("");
} else {
return Text("");
}
},
);
}
}