Strings quase feitas

This commit is contained in:
2026-03-18 16:20:18 +00:00
parent 7f80ed47f3
commit 6322e8d798
8 changed files with 324 additions and 228 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../constants/app_colors.dart';
import '../constants/app_strings.dart';
import '../services/supabase_service.dart';
class SettingsScreen extends StatefulWidget {
@@ -18,15 +19,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
Widget build(BuildContext context) {
final user = SupabaseService.currentUser;
final userName =
user?.userMetadata?['name'] ?? user?.email?.split('@')[0] ?? 'Usuário';
user?.userMetadata?['name'] ?? user?.email?.split('@')[0] ?? AppStrings.userPlaceholder;
final userEmail = user?.email ?? 'usuario@exemplo.com';
return Scaffold(
backgroundColor: AppColors.background,
appBar: AppBar(
title: const Text(
'CONFIGURAÇÕES',
style: TextStyle(
title: Text(
AppStrings.settingsTitle,
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
@@ -93,8 +94,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
icon: const Icon(Icons.edit, color: AppColors.buttonColor),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Editar perfil'),
SnackBar(
content: Text(AppStrings.editProfile),
backgroundColor: AppColors.buttonColor,
),
);
@@ -116,7 +117,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
children: [
_buildSettingsItem(
icon: Icons.schedule,
title: 'Ajustar Data e Hora',
title: AppStrings.adjustDateTime,
onTap: () {
_showDatePicker(context);
},
@@ -124,7 +125,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.dark_mode,
title: 'Modo Noturno',
title: AppStrings.nightMode,
trailing: Switch(
value: _isNightMode,
activeThumbColor: AppColors.buttonColor,
@@ -138,7 +139,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.language,
title: 'Idioma',
title: AppStrings.language,
trailing: Text(
_selectedLanguage,
style: TextStyle(
@@ -153,11 +154,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.accessibility,
title: 'Acessibilidade',
title: AppStrings.accessibility,
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Acessibilidade'),
SnackBar(
content: Text(AppStrings.accessibility),
backgroundColor: AppColors.buttonColor,
),
);
@@ -166,7 +167,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.notifications,
title: 'Notificações',
title: AppStrings.notifications,
trailing: Switch(
value: _notificationsEnabled,
onChanged: (value) {
@@ -180,11 +181,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.privacy_tip,
title: 'Privacidade e Segurança',
title: AppStrings.privacySecurity,
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Privacidade e Segurança'),
SnackBar(
content: Text(AppStrings.privacySecurity),
backgroundColor: AppColors.buttonColor,
),
);
@@ -193,11 +194,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.description,
title: 'Termos de Uso',
title: AppStrings.termsOfUse,
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Termos de Uso'),
SnackBar(
content: Text(AppStrings.termsOfUse),
backgroundColor: AppColors.buttonColor,
),
);
@@ -206,7 +207,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_buildDivider(),
_buildSettingsItem(
icon: Icons.info,
title: 'Sobre',
title: AppStrings.about,
onTap: () {
_showAboutDialog(context);
},
@@ -231,9 +232,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'Sair',
style: TextStyle(
child: Text(
AppStrings.logout,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
@@ -287,7 +288,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
if (date != null && mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Data selecionada: ${date.toString().split(' ')[0]}'),
content: Text('${AppStrings.dateSelected}: ${date.toString().split(' ')[0]}'),
backgroundColor: AppColors.buttonColor,
),
);
@@ -300,9 +301,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
context: context,
builder: (context) => AlertDialog(
backgroundColor: AppColors.backgroundGrey,
title: const Text(
'Selecionar Idioma',
style: TextStyle(color: Colors.white),
title: Text(
AppStrings.selectLanguage,
style: const TextStyle(color: Colors.white),
),
content: Column(
mainAxisSize: MainAxisSize.min,
@@ -315,9 +316,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'Cancelar',
style: TextStyle(color: AppColors.buttonColor),
child: Text(
AppStrings.btnCancel,
style: const TextStyle(color: AppColors.buttonColor),
),
),
],
@@ -332,18 +333,25 @@ class _SettingsScreenState extends State<SettingsScreen> {
value: language,
groupValue: _selectedLanguage,
onChanged: (value) {
setState(() {
_selectedLanguage = value!;
});
Navigator.pop(context);
if (value != null) {
setState(() {
_selectedLanguage = value;
AppStrings.setLanguage(value);
});
Navigator.pop(context);
// Force rebuild of current screen to apply changes
setState(() {});
}
},
fillColor: WidgetStateProperty.all(AppColors.buttonColor),
),
onTap: () {
setState(() {
_selectedLanguage = language;
AppStrings.setLanguage(language);
});
Navigator.pop(context);
setState(() {});
},
);
}
@@ -353,33 +361,33 @@ class _SettingsScreenState extends State<SettingsScreen> {
context: context,
builder: (context) => AlertDialog(
backgroundColor: AppColors.backgroundGrey,
title: const Text('Sobre', style: TextStyle(color: Colors.white)),
content: const Column(
title: Text(AppStrings.about, style: const TextStyle(color: Colors.white)),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Run Vision Pro',
style: TextStyle(
AppStrings.appTitle,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 8),
Text('Versão: 1.0.0', style: TextStyle(color: Colors.white70)),
SizedBox(height: 8),
const SizedBox(height: 8),
Text('${AppStrings.version}: 1.0.0', style: const TextStyle(color: Colors.white70)),
const SizedBox(height: 8),
Text(
'Aplicativo de corrida com estatísticas e mapas',
style: TextStyle(color: Colors.white70),
AppStrings.appDescription,
style: const TextStyle(color: Colors.white70),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'OK',
style: TextStyle(color: AppColors.buttonColor),
child: Text(
AppStrings.btnOk,
style: const TextStyle(color: AppColors.buttonColor),
),
),
],
@@ -392,20 +400,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
context: context,
builder: (context) => AlertDialog(
backgroundColor: AppColors.backgroundGrey,
title: const Text(
'Confirmar Logout',
style: TextStyle(color: Colors.white),
title: Text(
AppStrings.confirmLogout,
style: const TextStyle(color: Colors.white),
),
content: const Text(
'Tem certeza que deseja sair?',
style: TextStyle(color: Colors.white70),
content: Text(
AppStrings.confirmLogoutMessage,
style: const TextStyle(color: Colors.white70),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
'Cancelar',
style: TextStyle(color: AppColors.buttonColor),
child: Text(
AppStrings.btnCancel,
style: const TextStyle(color: AppColors.buttonColor),
),
),
TextButton(
@@ -413,7 +421,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
Navigator.pop(context);
Navigator.pushReplacementNamed(context, '/');
},
child: const Text('Sair', style: TextStyle(color: Colors.red)),
child: Text(AppStrings.logout, style: const TextStyle(color: Colors.red)),
),
],
),