This commit is contained in:
Carlos Correia
2026-07-10 23:53:33 +01:00
parent 30068d1501
commit 824fdb8089
12 changed files with 771 additions and 578 deletions

View File

@@ -15,10 +15,36 @@ class BrushingPrefs {
static String _key(String base, String scopeId) => '${base}_$scopeId';
static DateTime _currentWeekMonday() {
final now = DateTime.now();
return DateTime(
now.year,
now.month,
now.day,
).subtract(Duration(days: now.weekday - 1));
}
/// Lê as escovagens guardadas e, de caminho, descarta (apaga do
/// armazenamento) qualquer registo de semanas anteriores — o contador
/// semanal deve zerar a cada nova semana, não só na exibição mas também
/// nos dados guardados, para não crescer para sempre.
static Future<List<DateTime>> _getEntries(String scopeId) async {
final prefs = await SharedPreferences.getInstance();
final raw = prefs.getStringList(_key(_kDatesKey, scopeId)) ?? const [];
return raw.map(DateTime.tryParse).whereType<DateTime>().toList();
final key = _key(_kDatesKey, scopeId);
final raw = prefs.getStringList(key) ?? const [];
final entries = raw.map(DateTime.tryParse).whereType<DateTime>().toList();
final monday = _currentWeekMonday();
final kept = entries
.where((d) => !DateTime(d.year, d.month, d.day).isBefore(monday))
.toList();
if (kept.length != entries.length) {
await prefs.setStringList(
key,
kept.map((d) => d.toIso8601String()).toList(),
);
}
return kept;
}
static Future<int> getWeeklyGoal(String scopeId) async {
@@ -51,11 +77,15 @@ class BrushingPrefs {
/// o utilizador).
static Future<void> logToday(String scopeId) async {
if (!(await canLogMore(scopeId))) return;
// Usa as entradas já podadas (só da semana atual) para não ressuscitar
// registos de semanas anteriores ao gravar de volta.
final entries = await _getEntries(scopeId);
entries.add(DateTime.now());
final prefs = await SharedPreferences.getInstance();
final key = _key(_kDatesKey, scopeId);
final list = prefs.getStringList(key) ?? <String>[];
list.add(DateTime.now().toIso8601String());
await prefs.setStringList(key, list);
await prefs.setStringList(
_key(_kDatesKey, scopeId),
entries.map((d) => d.toIso8601String()).toList(),
);
}
/// Já atingiu o limite diário de [maxPerDay] escovagens hoje?
@@ -64,21 +94,9 @@ class BrushingPrefs {
}
/// Conta quantas escovagens foram registadas na semana atual
/// (segunda-feira a domingo).
/// (segunda-feira a domingo). [_getEntries] já descarta semanas
/// anteriores, por isso todas as entradas devolvidas já são desta semana.
static Future<int> getWeekCount(String scopeId) async {
final entries = await _getEntries(scopeId);
final now = DateTime.now();
final monday = DateTime(
now.year,
now.month,
now.day,
).subtract(Duration(days: now.weekday - 1));
return entries
.where(
(d) => !DateTime(d.year, d.month, d.day).isBefore(monday),
)
.length;
return (await _getEntries(scopeId)).length;
}
}

View File

@@ -166,15 +166,7 @@ class _HomeScreenState extends State<HomeScreen> {
clipBehavior: Clip.none,
children: [
Positioned.fill(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFE6F1), Color(0xFFFFC9DF)],
),
),
),
child: Container(color: const Color(0xFFFAFAF7)),
),
Positioned(
left: -size.width * 0.38,

File diff suppressed because it is too large Load Diff

View File

@@ -40,8 +40,16 @@ class MyApp extends StatelessWidget {
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF2F9E94)),
scaffoldBackgroundColor: const Color(0xFFFFE2EF),
scaffoldBackgroundColor: const Color(0xFFFAFAF7),
useMaterial3: true,
// Sem isto, o Material 3 aplica por padrão uma sobreposição de cor
// (surfaceTintColor) e uma elevação extra ao rolar (scrolledUnderElevation)
// por cima de qualquer app bar — o que "lavava" o gradiente customizado
// das app bars, fazendo-o parecer uma cor sólida em vez de gradiente.
appBarTheme: const AppBarTheme(
surfaceTintColor: Colors.transparent,
scrolledUnderElevation: 0,
),
),
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,

View File

@@ -148,15 +148,7 @@ class _QuizQuestionScreenState extends State<QuizQuestionScreen> {
clipBehavior: Clip.none,
children: [
Positioned.fill(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFE6F1), Color(0xFFFFC9DF)],
),
),
),
child: Container(color: const Color(0xFFFAFAF7)),
),
Positioned(
left: -size.width * 0.40,

View File

@@ -88,13 +88,7 @@ class _QuizResultScreenState extends State<QuizResultScreen> {
return Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFE6F1), Color(0xFFFFC9DF)],
),
),
color: const Color(0xFFFAFAF7),
child: SafeArea(
child: Center(
child: ConstrainedBox(

View File

@@ -10,38 +10,33 @@ import '../widgets/tap_bounce.dart';
class CuriosidadeScreen extends StatelessWidget {
const CuriosidadeScreen({super.key});
static const Color _teal = Color(0xFF2F9E94);
@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return Scaffold(
appBar: AppBar(
backgroundColor: _teal,
foregroundColor: Colors.white,
elevation: 0,
flexibleSpace: Container(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: Container(
decoration: const BoxDecoration(gradient: kAppBarGradient),
),
title: const Text(
'Curiosidades',
style: TextStyle(fontWeight: FontWeight.w900),
child: AppBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
title: const Text(
'Curiosidades',
style: TextStyle(fontWeight: FontWeight.w900),
),
),
),
),
body: Stack(
clipBehavior: Clip.none,
children: [
Positioned.fill(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFE6F1), Color(0xFFFFC9DF)],
),
),
),
child: Container(color: const Color(0xFFFAFAF7)),
),
Positioned(
left: -size.width * 0.40,

View File

@@ -76,7 +76,7 @@ class _HelloSplashScreenState extends State<HelloSplashScreen> with TickerProvid
child: Container(
width: size.width,
height: size.height,
color: const Color(0xFFFFC9DF),
color: const Color(0xFFFAFAF7),
child: SafeArea(
child: Center(
child: Column(
@@ -90,7 +90,7 @@ class _HelloSplashScreenState extends State<HelloSplashScreen> with TickerProvid
style: TextStyle(
fontSize: 64,
fontWeight: FontWeight.w900,
color: Colors.white,
color: const Color(0xFFFF9AD0),
height: 1.0,
),
),

View File

@@ -5,32 +5,30 @@ import '../widgets/app_gradients.dart';
class TermsScreen extends StatelessWidget {
const TermsScreen({super.key});
static const Color _teal = Color(0xFF2F9E94);
static const Color _accentPink = Color(0xFFFF55A7);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: _teal,
foregroundColor: Colors.white,
elevation: 0,
flexibleSpace: Container(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: Container(
decoration: const BoxDecoration(gradient: kAppBarGradient),
),
title: const Text(
'Termos de Serviço',
style: TextStyle(fontWeight: FontWeight.w900),
child: AppBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
title: const Text(
'Termos de Serviço',
style: TextStyle(fontWeight: FontWeight.w900),
),
),
),
),
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFE6F1), Color(0xFFFFC9DF)],
),
),
color: const Color(0xFFFAFAF7),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(20),

View File

@@ -38,79 +38,79 @@ final List<VideoData> videoList = [
VideoData(
id: 1,
title: 'Episódio 1',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência do nariz entupido na má oclusão',
youtubeId: 'PJ58CZv4ECw',
),
VideoData(
id: 2,
title: 'Episódio 2',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência das alergias sazionais na má oclusão',
youtubeId: 'y4_kWmZtAtg',
),
VideoData(
id: 3,
title: 'Episódio 3',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência das Otites frequentes na má oclusão',
youtubeId: 'nD75Y5PuKTo',
),
VideoData(
id: 4,
title: 'Episódio 4',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência das Amigdalites recorrentes na má oclusão',
youtubeId: 'yvFllWYeuLw',
),
VideoData(
id: 5,
title: 'Episódio 5',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência das Bronquiolites recorrentes na má oclusão',
youtubeId: 'DnhUa-T8_Ps',
),
VideoData(
id: 6,
title: 'Episódio 6',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência dos problemas respitatórios na má oclusão',
youtubeId: 'zKt_iwkrjvo',
),
VideoData(
id: 7,
title: 'Episódio 7',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência das interrupções respiratórias na má oclusão',
youtubeId: 'NpmQ2brap5A',
),
VideoData(
id: 8,
title: 'Episódio 8',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência do ressonar na má oclusão',
youtubeId: 'Wj3KYw9pBi0',
),
VideoData(
id: 9,
title: 'Episódio 9',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência de acordar com saliva seca na boca ou na almofada na saúde oral',
youtubeId: 'bOm9t61cT_U',
),
VideoData(
id: 10,
title: 'Episódio 10',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a Influência da respiração oral na má oclusão',
youtubeId: 'fAitMizbcms',
),
VideoData(
id: 11,
title: 'Episódio 11',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a influência do uso exagerado da chupeta na má oclusão',
youtubeId: '6sYoBUjks_I',
),
VideoData(
id: 12,
title: 'Episódio 12',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a influência do uso exagerado da chupeta na má oclusão',
youtubeId: 'eznKrErQbHo',
),
VideoData(
id: 13,
title: 'Episódio 13',
description: 'Aprenda sobre saúde bucal neste episódio',
description: 'Qual a influência do hábito de chuchar o dedo na má oclusão',
youtubeId: 'VO9CNqHRdeM',
),
];
@@ -236,32 +236,32 @@ class _VideoScreenState extends State<VideoScreen> {
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
return Scaffold(
appBar: AppBar(
backgroundColor: VideoScreen._teal,
foregroundColor: Colors.white,
surfaceTintColor: VideoScreen._teal,
elevation: 0,
flexibleSpace: Container(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
// O gradiente é pintado por este Container de tamanho fixo, em vez
// de confiar no `flexibleSpace` do AppBar — em alguns aparelhos o
// `flexibleSpace` de um AppBar comum não recebia o tamanho esperado
// e a gradiente aparecia como cor sólida.
child: Container(
decoration: const BoxDecoration(gradient: kAppBarGradient),
),
title: const Text(
'Videos Educativos',
style: TextStyle(fontWeight: FontWeight.w900),
child: AppBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
surfaceTintColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
title: const Text(
'Videos Educativos',
style: TextStyle(fontWeight: FontWeight.w900),
),
),
),
),
body: Stack(
clipBehavior: Clip.none,
children: [
Positioned.fill(
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFFFE6F1), Color(0xFFFFC9DF)],
),
),
),
child: Container(color: const Color(0xFFFAFAF7)),
),
Positioned(
left: -size.width * 0.40,
@@ -548,27 +548,84 @@ class _VideoButton extends StatelessWidget {
return TapBounce(
scale: 0.95,
child: Material(
elevation: 8,
shadowColor: Colors.black.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(16),
elevation: 10,
shadowColor: Colors.black.withValues(alpha: 0.18),
borderRadius: BorderRadius.circular(18),
color: Colors.white,
child: InkWell(
borderRadius: BorderRadius.circular(16),
borderRadius: BorderRadius.circular(18),
onTap: () => _showVideoPlayer(context, video),
child: Padding(
padding: const EdgeInsets.all(12),
padding: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 80,
decoration: BoxDecoration(
color: const Color(0xFFFFE6F1),
borderRadius: BorderRadius.circular(12),
AspectRatio(
aspectRatio: 16 / 9,
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: Stack(
fit: StackFit.expand,
children: [
ColoredBox(
color: const Color(0xFFFFE6F1),
child: VideoThumbnail(video: video, borderRadius: 0),
),
DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.transparent,
Colors.black.withValues(alpha: 0.32),
],
stops: const [0.55, 1.0],
),
),
),
Center(
child: Container(
width: 34,
height: 34,
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.92),
shape: BoxShape.circle,
),
child: const Icon(
Icons.play_arrow_rounded,
color: VideoScreen._accentPink,
size: 20,
),
),
),
Positioned(
left: 6,
bottom: 6,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 2,
),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(999),
),
child: Text(
'EP. ${video.id}',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w800,
fontSize: 9.5,
),
),
),
),
],
),
),
child: VideoThumbnail(video: video),
),
const SizedBox(height: 10),
const SizedBox(height: 8),
Text(
video.title,
style: const TextStyle(

View File

@@ -27,10 +27,4 @@ class WatchedVideosPrefs {
final ids = prefs.getStringList(_key(scopeId)) ?? const [];
return ids.length;
}
static Future<Set<int>> getWatchedIds(String scopeId) async {
final prefs = await SharedPreferences.getInstance();
final ids = prefs.getStringList(_key(scopeId)) ?? const [];
return ids.map((e) => int.tryParse(e) ?? -1).where((e) => e >= 0).toSet();
}
}

View File

@@ -1,18 +1,25 @@
import 'package:flutter/material.dart';
/// Gradiente usado em todas as app bars da aplicação.
/// Gradiente usado em todas as app bars da aplicação. Direção puramente
/// horizontal (não diagonal) de propósito: a app bar retrátil da Home é
/// alta (~190) enquanto as das outras abas são baixas (~56) — um gradiente
/// diagonal mostra proporções de cor bem diferentes consoante a altura,
/// fazendo a Home parecer mais "cheia de cor" que as outras. Na horizontal,
/// a transição depende só da largura (igual em todas as app bars), por
/// isso todas ficam visualmente idênticas.
const LinearGradient kAppBarGradient = LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [Color(0xFF6BB79F), Color(0xFF6BB79F)],
);
/// Gradiente usado nos botões verdes da aplicação — um toque da cor da app
/// bar (#6BB79F) misturado com o teal original.
const LinearGradient kGreenButtonGradient = LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Color(0xFF2F9E94), Color(0xFF6BB79F)],
colors: [Color(0xFF1C7A6E), Color(0xFF8FD4BB)],
);
/// Cor sólida (sem gradiente, de propósito) usada nos botões e cards verdes
/// da aplicação — botões de "Entrar"/"Criar conta", "Adicionar criança" e o
/// card "Vídeos educativos". Só as app bars usam gradiente ([kAppBarGradient]);
/// mantém-se como [LinearGradient] com as duas cores iguais para não obrigar
/// a mudar todos os `decoration: gradient: kGreenButtonGradient` existentes.
const LinearGradient kGreenButtonGradient = LinearGradient(
colors: [Color(0xFF2F9E94), Color(0xFF2F9E94)],
);
/// Gradiente rosa vivo do card do quiz na Home.