kz_educa/lib/screens/notification_settings_scree...

224 lines
9.0 KiB
Dart

import 'package:flutter/material.dart';
import '../utils/notifications.dart';
// KzEduca Palette from the other screens for consistency
const _kGradientStart = Color(0xFF512DA8); // Vibrant purple
const _kGradientEnd = Color(0xFF000000); // Deep black
const _kAccent = Color(0xFF00BFA5); // Teal green
const _kAction = Color(0xFFFFD600); // Golden yellow
class NotificationSettingsScreen extends StatefulWidget {
const NotificationSettingsScreen({super.key});
@override
State<NotificationSettingsScreen> createState() => _NotificationSettingsScreenState();
}
class _NotificationSettingsScreenState extends State<NotificationSettingsScreen> {
TimeOfDay? _selectedTime;
@override
Widget build(BuildContext context) {
// Style the time string for the card
final timeString = _selectedTime?.format(context) ?? 'Não definido';
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
title: const Text(
'Configurações de Notificação',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
letterSpacing: 0.5,
),
),
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
iconTheme: const IconThemeData(color: Colors.white),
),
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [_kGradientStart, _kGradientEnd],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Spacer(),
const Icon(Icons.notifications_rounded, size: 80, color: _kAccent),
const SizedBox(height: 24),
const Text(
'Receba sua dose diária de motivação financeira!',
style: TextStyle(
color: Colors.white70,
fontSize: 18,
fontStyle: FontStyle.italic,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 48),
// Card futurista para selecionar o horário
GestureDetector(
onTap: () async {
final picked = await showTimePicker(
context: context,
initialTime: _selectedTime ?? TimeOfDay.now(),
builder: (context, child) {
return Theme(
data: ThemeData.dark().copyWith(
colorScheme: const ColorScheme.dark(
primary: _kAccent,
onPrimary: Colors.black,
surface: Color(0xFF1c1c1c),
onSurface: Colors.white,
),
),
child: child!,
);
},
);
if (picked != null) {
setState(() => _selectedTime = picked);
}
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 20),
decoration: BoxDecoration(
color: _selectedTime != null ? _kAccent.withOpacity(0.2) : Colors.white.withOpacity(0.05),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: _selectedTime != null ? _kAccent : Colors.white.withOpacity(0.1),
width: 2,
),
boxShadow: [
if (_selectedTime != null)
BoxShadow(
color: _kAccent.withOpacity(0.3),
blurRadius: 15,
spreadRadius: 2,
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Horário da notificação',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
Text(
timeString,
style: TextStyle(
color: _selectedTime != null ? _kAction : Colors.white54,
fontSize: 28,
fontWeight: FontWeight.bold,
),
),
],
),
),
const Icon(
Icons.access_time_filled,
color: _kAccent,
size: 36,
),
],
),
),
),
const SizedBox(height: 32),
// Botão de ativação futurista
Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: _selectedTime != null
? const LinearGradient(
colors: [_kAction, _kAccent],
begin: Alignment.bottomLeft,
end: Alignment.topRight,
)
: null,
boxShadow: _selectedTime != null
? [
BoxShadow(
color: _kAccent.withOpacity(0.4),
blurRadius: 10,
offset: const Offset(0, 4),
),
]
: null,
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: _selectedTime == null
? null
: () async {
// A chamada da função foi alterada para a nova versão.
// A nova função não precisa mais do horário selecionado.
await scheduleDailyRandomMotivationNotification();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Notificação agendada com sucesso!'),
backgroundColor: _kAccent,
),
);
}
},
borderRadius: BorderRadius.circular(16),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 18.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.notifications_active_outlined,
color: _selectedTime != null ? Colors.black87 : Colors.white30,
),
const SizedBox(width: 12),
Text(
'Ativar Notificação Diária',
style: TextStyle(
color: _selectedTime != null ? Colors.black87 : Colors.white30,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
),
),
const Spacer(flex: 2),
],
),
),
),
),
);
}
}