CKT 1.0.2 | otorrinolaringologista

This commit is contained in:
Carlos Correia
2026-07-16 12:58:46 +01:00
parent a8af2c6845
commit f5884d8c36
12 changed files with 611 additions and 53 deletions

View File

@@ -194,6 +194,11 @@ Future<void> showVideoPlayerDialog(
class VideoScreen extends StatefulWidget {
const VideoScreen({super.key, this.scopeId});
/// Nome de rota usado para identificar esta tela na pilha de navegação —
/// permite que o botão de voltar de um vídeo (mesmo vários "Próximos"
/// adentro) volte diretamente para aqui, em vez de vídeo a vídeo.
static const String routeName = 'video_library';
/// Identifica a criança selecionada (`'${uid}_${childId}'`), usado para
/// guardar localmente quais episódios ela já assistiu até ao fim.
final String? scopeId;
@@ -717,15 +722,32 @@ class _YoutubePlayerPageState extends State<_YoutubePlayerPage>
super.dispose();
}
/// Volta diretamente para a grelha de vídeos ([VideoScreen]), mesmo que
/// se tenha chegado aqui através de vários vídeos "Próximos" seguidos —
/// em vez de um pop normal, que voltaria vídeo a vídeo.
void _returnToLibrary() {
final navigator = Navigator.of(context);
if (navigator.canPop()) {
navigator.popUntil(
(route) => route.settings.name == VideoScreen.routeName,
);
}
}
@override
Widget build(BuildContext context) {
return ValueListenableBuilder<YoutubePlayerValue>(
valueListenable: _controller,
builder: (context, value, _) {
return PopScope(
canPop: !value.isFullScreen,
canPop: false,
onPopInvokedWithResult: (didPop, _) {
if (!didPop) _controller.toggleFullScreenMode();
if (didPop) return;
if (value.isFullScreen) {
_controller.toggleFullScreenMode();
} else {
_returnToLibrary();
}
},
child: Scaffold(
backgroundColor: value.isFullScreen
@@ -745,6 +767,10 @@ class _YoutubePlayerPageState extends State<_YoutubePlayerPage>
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back_rounded),
onPressed: _returnToLibrary,
),
title: Text(
widget.video.title,
style: const TextStyle(fontWeight: FontWeight.w900),
@@ -823,6 +849,9 @@ class _YoutubePlayerPageState extends State<_YoutubePlayerPage>
onTap: () =>
Navigator.of(context).push(
MaterialPageRoute<void>(
settings: const RouteSettings(
name: VideoScreen.routeName,
),
builder: (_) => VideoScreen(
scopeId: widget.scopeId,
),