From d669c9e9cebae35bd5e7f55c770045aa5eebb152 Mon Sep 17 00:00:00 2001 From: gianlucaparadise Date: Tue, 30 Nov 2021 06:36:41 +0100 Subject: [PATCH] ExampleApp: add ExpandedControlsRoute --- example/lib/expanded_controls_route.dart | 21 ++++ example/lib/main.dart | 127 ++++++++++++----------- 2 files changed, 86 insertions(+), 62 deletions(-) create mode 100644 example/lib/expanded_controls_route.dart diff --git a/example/lib/expanded_controls_route.dart b/example/lib/expanded_controls_route.dart new file mode 100644 index 0000000..6186da4 --- /dev/null +++ b/example/lib/expanded_controls_route.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_cast_framework/cast.dart'; +import 'package:flutter_cast_framework/widgets.dart'; + +class ExpandedControlsRoute extends StatelessWidget { + final FlutterCastFramework castFramework; + + ExpandedControlsRoute({ + required this.castFramework, + }); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: ExpandedControls( + castFramework: castFramework, + onBackTapped: () => Navigator.pop(context), + ), + ); + } +} diff --git a/example/lib/main.dart b/example/lib/main.dart index 49414a5..ac5fd69 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,12 +1,15 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:flutter_cast_framework/cast.dart'; import 'package:flutter_cast_framework/widgets.dart'; +import 'package:flutter_cast_framework_example/expanded_controls_route.dart'; import 'media_load_request_data_helper.dart'; -void main() => runApp(MyApp()); +void main() => runApp( + MaterialApp( + home: MyApp(), + ), + ); class MyApp extends StatefulWidget { @override @@ -82,12 +85,14 @@ class _MyAppState extends State { } Future _openExpandedControls() async { - final remoteMediaClient = - this.castFramework.castContext.sessionManager.remoteMediaClient; - - final mediaInfo = await remoteMediaClient.getMediaInfo(); - debugPrint("$mediaInfo"); - inspect(mediaInfo); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ExpandedControlsRoute( + castFramework: castFramework, + ), + ), + ); } Widget _buildTitle(String text) { @@ -102,63 +107,61 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Cast plugin example app'), - ), - body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - CastButton( - castFramework: castFramework, - color: Colors.blue, - ), - _buildTitle("States"), - Text('Cast State: $_castState'), - Text('Session State: $_sessionState'), - _buildTitle("Message"), - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - Expanded( - child: TextField( - controller: textMessageController, - ), + return Scaffold( + appBar: AppBar( + title: const Text('Cast plugin example app'), + ), + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + CastButton( + castFramework: castFramework, + color: Colors.blue, + ), + _buildTitle("States"), + Text('Cast State: $_castState'), + Text('Session State: $_sessionState'), + _buildTitle("Message"), + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + Expanded( + child: TextField( + controller: textMessageController, ), - Padding( - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - child: Text('Send'), - onPressed: _onSendMessage, - ), - ) - ], - ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + child: Text('Send'), + onPressed: _onSendMessage, + ), + ) + ], ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text('Received Message: $_message'), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text('Received Message: $_message'), + ), + _buildTitle("Video"), + Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + child: Text('Cast video'), + onPressed: _onCastVideo, ), - _buildTitle("Video"), - Padding( - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - child: Text('Cast video'), - onPressed: _onCastVideo, - ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + child: Text('Expanded Controls'), + onPressed: _openExpandedControls, ), - Padding( - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - child: Text('Expanded Controls'), - onPressed: _openExpandedControls, - ), - ) - ], - ), + ) + ], ), ), );