quiz redirecionado aos videos | redesing da notificação

This commit is contained in:
Carlos Correia
2026-07-10 13:06:40 +01:00
parent 7ddc76d393
commit 30068d1501
11 changed files with 323 additions and 142 deletions

View File

@@ -20,6 +20,7 @@ class QuizAnswer {
required this.weight,
this.imagePath,
this.value,
this.helpVideoId,
});
final String title;
@@ -27,6 +28,11 @@ class QuizAnswer {
final int weight;
final String? imagePath;
final String? value;
/// Quando definido (normalmente só na resposta "Não sei"), identifica um
/// vídeo em [videoList] que ajuda a responder a esta pergunta — mostrado
/// como um botão que expande quando esta resposta é selecionada.
final int? helpVideoId;
}
class QuizQuestionScreen extends StatefulWidget {
@@ -1013,6 +1019,15 @@ class _QuizAnswerPill extends StatelessWidget {
bool get _isYes => (answer.value ?? '').trim().toLowerCase() == 'sim';
bool get _isNo => (answer.value ?? '').trim().toLowerCase() == 'nao';
VideoData? get _helpVideo {
final id = answer.helpVideoId;
if (id == null) return null;
for (final v in videoList) {
if (v.id == id) return v;
}
return null;
}
@override
Widget build(BuildContext context) {
final accent = _isYes
@@ -1023,6 +1038,8 @@ class _QuizAnswerPill extends StatelessWidget {
final borderColor = selected
? const Color(0xFF2F9E94)
: Colors.black.withValues(alpha: 0.10);
final helpVideo = _helpVideo;
final showHelp = selected && helpVideo != null;
return TapBounce(
scale: 0.97,
@@ -1033,7 +1050,7 @@ class _QuizAnswerPill extends StatelessWidget {
color: selected
? Colors.white.withValues(alpha: 0.92)
: Colors.white.withValues(alpha: 0.70),
borderRadius: BorderRadius.circular(999),
borderRadius: BorderRadius.circular(22),
border: Border.all(color: borderColor, width: selected ? 1.4 : 1.0),
boxShadow: [
BoxShadow(
@@ -1045,71 +1062,138 @@ class _QuizAnswerPill extends StatelessWidget {
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(999),
onTap: onTap,
splashFactory: InkSparkle.splashFactory,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 10,
),
child: Row(
children: [
Container(
width: 28,
height: 28,
decoration: BoxDecoration(
color: accent,
shape: BoxShape.circle,
),
child: Icon(
_isYes
? Icons.check_rounded
: _isNo
? Icons.close_rounded
: Icons.help_outline_rounded,
color: Colors.white,
size: 17,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
InkWell(
borderRadius: BorderRadius.circular(22),
onTap: onTap,
splashFactory: InkSparkle.splashFactory,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 10,
),
const SizedBox(width: 12),
Expanded(
child: Text(
answer.title,
style: const TextStyle(
fontWeight: FontWeight.w800,
fontSize: 15,
color: Color(0xFF2F9E94),
child: Row(
children: [
Container(
width: 28,
height: 28,
decoration: BoxDecoration(
color: accent,
shape: BoxShape.circle,
),
child: Icon(
_isYes
? Icons.check_rounded
: _isNo
? Icons.close_rounded
: Icons.help_outline_rounded,
color: Colors.white,
size: 17,
),
),
),
),
AnimatedContainer(
duration: const Duration(milliseconds: 220),
width: 22,
height: 22,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: selected
? const Color(0xFF2F9E94)
: Colors.transparent,
border: Border.all(
color: selected
? const Color(0xFF2F9E94)
: Colors.black.withValues(alpha: 0.25),
width: 1.6,
const SizedBox(width: 12),
Expanded(
child: Text(
answer.title,
style: const TextStyle(
fontWeight: FontWeight.w800,
fontSize: 15,
color: Color(0xFF2F9E94),
),
),
),
),
child: selected
? const Icon(
Icons.check_rounded,
size: 14,
color: Colors.white,
)
: null,
AnimatedContainer(
duration: const Duration(milliseconds: 220),
width: 22,
height: 22,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: selected
? const Color(0xFF2F9E94)
: Colors.transparent,
border: Border.all(
color: selected
? const Color(0xFF2F9E94)
: Colors.black.withValues(alpha: 0.25),
width: 1.6,
),
),
child: selected
? const Icon(
Icons.check_rounded,
size: 14,
color: Colors.white,
)
: null,
),
],
),
],
),
),
AnimatedSize(
duration: const Duration(milliseconds: 220),
curve: Curves.easeOutCubic,
alignment: Alignment.topCenter,
child: !showHelp
? const SizedBox.shrink()
: Padding(
padding: const EdgeInsets.fromLTRB(14, 0, 14, 12),
child: _HelpVideoButton(video: helpVideo),
),
),
],
),
),
),
);
}
}
/// Botão que aparece quando a resposta "Não sei" é selecionada, sugerindo o
/// episódio que pode ajudar a esclarecer a dúvida antes de responder.
class _HelpVideoButton extends StatelessWidget {
const _HelpVideoButton({required this.video});
final VideoData video;
@override
Widget build(BuildContext context) {
return TapBounce(
scale: 0.97,
child: Material(
color: const Color(0xFF2F9E94).withValues(alpha: 0.10),
borderRadius: BorderRadius.circular(14),
child: InkWell(
borderRadius: BorderRadius.circular(14),
onTap: () => showVideoPlayerDialog(context, video),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Row(
children: [
const Icon(
Icons.play_circle_fill_rounded,
color: Color(0xFF2F9E94),
size: 22,
),
const SizedBox(width: 10),
Expanded(
child: Text(
'Não tem a certeza? Veja o "${video.title}" para ajudar a responder',
style: const TextStyle(
fontWeight: FontWeight.w700,
fontSize: 12.5,
color: Color(0xFF2F9E94),
),
),
),
const Icon(
Icons.chevron_right_rounded,
color: Color(0xFF2F9E94),
size: 20,
),
],
),
),
),