MiniController tap handling

This commit is contained in:
gianlucaparadise 2022-01-14 06:22:22 +01:00
parent 2fc3f95889
commit 23f70dd444
3 changed files with 28 additions and 18 deletions

View file

@ -150,7 +150,6 @@ I used this project to test the capabilities of the following technologies:
* CC in Expanded Controls (iOS) * CC in Expanded Controls (iOS)
* Expanded Controls cosmetics (ad in progress bar, full screen, progress bar handle) * Expanded Controls cosmetics (ad in progress bar, full screen, progress bar handle)
* Handle mini-player
* Handle queue * Handle queue
* Handle progress seek * Handle progress seek
* Understand if it is better to refactor using streams instead of listeners * Understand if it is better to refactor using streams instead of listeners

View file

@ -177,6 +177,7 @@ class _MyAppState extends State<MyApp> {
padding: const EdgeInsets.symmetric(vertical: 8.0), padding: const EdgeInsets.symmetric(vertical: 8.0),
child: MiniController( child: MiniController(
castFramework: castFramework, castFramework: castFramework,
onControllerTapped: _openExpandedControls,
), ),
), ),
], ],

View file

@ -8,9 +8,15 @@ import 'MiniControllerPlayPauseButton.dart';
class MiniController extends StatelessWidget { class MiniController extends StatelessWidget {
final FlutterCastFramework castFramework; final FlutterCastFramework castFramework;
/// This is called when the mini controller is tapped and the tap is not
/// handled by the controller. Generally, you want to open the expanded controls
/// on this callback.
final VoidCallback? onControllerTapped;
const MiniController({ const MiniController({
Key? key, Key? key,
required this.castFramework, required this.castFramework,
this.onControllerTapped,
}) : super(key: key); }) : super(key: key);
Widget _getControls(MediaStatus? status) { Widget _getControls(MediaStatus? status) {
@ -38,24 +44,28 @@ class MiniController extends StatelessWidget {
status: status, status: status,
); );
return SizedBox( return InkWell(
height: 60, onTap: onControllerTapped,
child: Row( child: SizedBox(
children: [ height: 60,
thumbnail, child: Row(
Container(width: 12), children: [
Expanded( thumbnail,
child: Column( Container(width: 12),
crossAxisAlignment: CrossAxisAlignment.start, Expanded(
mainAxisAlignment: MainAxisAlignment.center, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
title, mainAxisAlignment: MainAxisAlignment.center,
subtitle, children: [
], title,
subtitle,
],
),
), ),
), // ),
playPauseButton, playPauseButton,
], ],
),
), ),
); );
} }