diff --git a/lib/pages/register_page.dart b/lib/pages/register_page.dart new file mode 100644 index 0000000..b194c0d --- /dev/null +++ b/lib/pages/register_page.dart @@ -0,0 +1,152 @@ +import 'package:flutter/material.dart'; +import '../widgets/app_menu_button.dart'; + +class RegisterPage extends StatefulWidget { + const RegisterPage({Key? key}) : super(key: key); + + @override + State createState() => _RegisterPageState(); +} + +class _RegisterPageState extends State { + final _formKey = GlobalKey(); + final _nameController = TextEditingController(); + final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); + final _confirmPasswordController = TextEditingController(); + bool _obscurePassword = true; + bool _obscureConfirm = true; + + @override + void dispose() { + _nameController.dispose(); + _emailController.dispose(); + _passwordController.dispose(); + _confirmPasswordController.dispose(); + super.dispose(); + } + + void _handleRegister() { + if (_formKey.currentState!.validate()) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Registrando usuario...')), + ); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Registro'), + actions: const [AppMenuButton()], + ), + body: SingleChildScrollView( + padding: const EdgeInsets.all(24.0), + child: Form( + key: _formKey, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 16), + const Icon(Icons.person_add, size: 80, color: Colors.blue), + const SizedBox(height: 24), + TextFormField( + controller: _nameController, + decoration: const InputDecoration( + labelText: 'Nombre completo', + prefixIcon: Icon(Icons.person), + border: OutlineInputBorder(), + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor introduce tu nombre'; + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _emailController, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + labelText: 'Email', + prefixIcon: Icon(Icons.email), + border: OutlineInputBorder(), + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Por favor introduce tu email'; + } + if (!value.contains('@')) { + return 'Email no válido'; + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _passwordController, + obscureText: _obscurePassword, + decoration: InputDecoration( + labelText: 'Contraseña', + prefixIcon: const Icon(Icons.lock), + border: const OutlineInputBorder(), + suffixIcon: IconButton( + icon: Icon(_obscurePassword + ? Icons.visibility + : Icons.visibility_off), + onPressed: () => + setState(() => _obscurePassword = !_obscurePassword), + ), + ), + validator: (value) { + if (value == null || value.length < 6) { + return 'La contraseña debe tener al menos 6 caracteres'; + } + return null; + }, + ), + const SizedBox(height: 16), + TextFormField( + controller: _confirmPasswordController, + obscureText: _obscureConfirm, + decoration: InputDecoration( + labelText: 'Confirmar contraseña', + prefixIcon: const Icon(Icons.lock_outline), + border: const OutlineInputBorder(), + suffixIcon: IconButton( + icon: Icon(_obscureConfirm + ? Icons.visibility + : Icons.visibility_off), + onPressed: () => + setState(() => _obscureConfirm = !_obscureConfirm), + ), + ), + validator: (value) { + if (value != _passwordController.text) { + return 'Las contraseñas no coinciden'; + } + return null; + }, + ), + const SizedBox(height: 24), + ElevatedButton( + onPressed: _handleRegister, + style: ElevatedButton.styleFrom( + minimumSize: const Size(double.infinity, 50), + ), + child: const Text('Crear cuenta'), + ), + const SizedBox(height: 12), + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('¿Ya tienes cuenta? Inicia sesión'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart new file mode 100644 index 0000000..6fa60e8 --- /dev/null +++ b/lib/pages/settings_page.dart @@ -0,0 +1,238 @@ +import 'package:flutter/material.dart'; +import '../widgets/app_menu_button.dart'; + +class SettingsPage extends StatefulWidget { + const SettingsPage({Key? key}) : super(key: key); + + @override + State createState() => _SettingsPageState(); +} + +class _SettingsPageState extends State { + final _formKey = GlobalKey(); + + // Notificaciones + bool _soundEnabled = true; + bool _vibrationEnabled = true; + bool _notificationsEnabled = true; + double _volume = 0.8; + + // Alarma + int _snoozeMinutes = 5; + int _repeatTimes = 3; + String _selectedTone = 'Predeterminado'; + final List _tones = [ + 'Predeterminado', + 'Clásico', + 'Digital', + 'Suave', + 'Urgente', + ]; + + // Cuenta + final _nameController = TextEditingController(text: 'Usuario'); + final _emailController = TextEditingController(text: 'usuario@email.com'); + + @override + void dispose() { + _nameController.dispose(); + _emailController.dispose(); + super.dispose(); + } + + void _saveSettings() { + if (_formKey.currentState!.validate()) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Configuración guardada')), + ); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Configuración'), + actions: [ + TextButton( + onPressed: _saveSettings, + child: const Text('Guardar', style: TextStyle(color: Colors.white)), + ), + const AppMenuButton(), + ], + ), + body: Form( + key: _formKey, + child: ListView( + children: [ + _buildSectionHeader('Cuenta'), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: TextFormField( + controller: _nameController, + decoration: const InputDecoration( + labelText: 'Nombre', + prefixIcon: Icon(Icons.person), + border: OutlineInputBorder(), + ), + validator: (value) { + if (value == null || value.isEmpty) { + return 'El nombre no puede estar vacío'; + } + return null; + }, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: TextFormField( + controller: _emailController, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + labelText: 'Email', + prefixIcon: Icon(Icons.email), + border: OutlineInputBorder(), + ), + validator: (value) { + if (value == null || !value.contains('@')) { + return 'Email no válido'; + } + return null; + }, + ), + ), + _buildSectionHeader('Notificaciones'), + SwitchListTile( + title: const Text('Notificaciones'), + subtitle: const Text('Activar alertas del sistema'), + secondary: const Icon(Icons.notifications), + value: _notificationsEnabled, + onChanged: (val) => setState(() => _notificationsEnabled = val), + ), + SwitchListTile( + title: const Text('Sonido'), + subtitle: const Text('Reproducir sonido al activar alarma'), + secondary: const Icon(Icons.volume_up), + value: _soundEnabled, + onChanged: (val) => setState(() => _soundEnabled = val), + ), + if (_soundEnabled) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + children: [ + const Icon(Icons.volume_down, color: Colors.grey), + Expanded( + child: Slider( + value: _volume, + onChanged: (val) => setState(() => _volume = val), + ), + ), + const Icon(Icons.volume_up, color: Colors.grey), + ], + ), + ), + SwitchListTile( + title: const Text('Vibración'), + subtitle: const Text('Vibrar al activar alarma'), + secondary: const Icon(Icons.vibration), + value: _vibrationEnabled, + onChanged: (val) => setState(() => _vibrationEnabled = val), + ), + _buildSectionHeader('Alarma'), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: DropdownButtonFormField( + value: _selectedTone, + decoration: const InputDecoration( + labelText: 'Tono de alarma', + prefixIcon: Icon(Icons.music_note), + border: OutlineInputBorder(), + ), + items: _tones + .map((t) => DropdownMenuItem(value: t, child: Text(t))) + .toList(), + onChanged: (val) => setState(() => _selectedTone = val!), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + children: [ + const Icon(Icons.snooze, color: Colors.grey), + const SizedBox(width: 12), + const Text('Posponer (minutos):'), + const Spacer(), + DropdownButton( + value: _snoozeMinutes, + items: [1, 5, 10, 15, 30] + .map((m) => + DropdownMenuItem(value: m, child: Text('$m min'))) + .toList(), + onChanged: (val) => + setState(() => _snoozeMinutes = val!), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Row( + children: [ + const Icon(Icons.repeat, color: Colors.grey), + const SizedBox(width: 12), + const Text('Repeticiones:'), + const Spacer(), + DropdownButton( + value: _repeatTimes, + items: [1, 2, 3, 5, 10] + .map((n) => + DropdownMenuItem(value: n, child: Text('$n veces'))) + .toList(), + onChanged: (val) => + setState(() => _repeatTimes = val!), + ), + ], + ), + ), + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: OutlinedButton.icon( + onPressed: () { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Sesión cerrada')), + ); + Navigator.of(context).popUntil((route) => route.isFirst); + }, + icon: const Icon(Icons.logout, color: Colors.red), + label: const Text('Cerrar sesión', + style: TextStyle(color: Colors.red)), + style: OutlinedButton.styleFrom( + side: const BorderSide(color: Colors.red), + minimumSize: const Size(double.infinity, 50), + ), + ), + ), + const SizedBox(height: 24), + ], + ), + ), + ); + } + + Widget _buildSectionHeader(String title) { + return Padding( + padding: const EdgeInsets.fromLTRB(16, 20, 16, 4), + child: Text( + title.toUpperCase(), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.blue.shade700, + letterSpacing: 1.2, + ), + ), + ); + } +}