diff --git a/lib/pages/llamada_page.dart b/lib/pages/llamada_page.dart index d80c391..db9a00d 100644 --- a/lib/pages/llamada_page.dart +++ b/lib/pages/llamada_page.dart @@ -1,10 +1,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:audioplayers/audioplayers.dart'; import 'package:google_fonts/google_fonts.dart'; import '../theme.dart'; -enum _EstadoLlamada { llamando, conectado, finalizado } +enum _EstadoLlamada { llamando, conectado } class LlamadaPage extends StatefulWidget { const LlamadaPage({Key? key}) : super(key: key); @@ -15,7 +14,6 @@ class LlamadaPage extends StatefulWidget { class _LlamadaPageState extends State with TickerProviderStateMixin { - final _player = AudioPlayer(); _EstadoLlamada _estado = _EstadoLlamada.llamando; Timer? _timerConexion; Timer? _timerDuracion; @@ -29,7 +27,6 @@ class _LlamadaPageState extends State void initState() { super.initState(); - // ── Animación de pulso (llamando) ────────────────────────────────────── _ringCtrl = AnimationController( vsync: this, duration: const Duration(milliseconds: 1400), @@ -39,42 +36,22 @@ class _LlamadaPageState extends State _ringOpacity = Tween(begin: 0.5, end: 0.0) .animate(CurvedAnimation(parent: _ringCtrl, curve: Curves.easeOut)); - _iniciarTono(); - // Simula que la central contesta tras 5 segundos _timerConexion = Timer(const Duration(seconds: 5), _conectar); } - Future _iniciarTono() async { - try { - await _player.setReleaseMode(ReleaseMode.loop); - await _player.play(AssetSource('recursos/tono_espera_llamada.wav')); - } catch (_) { - // Si el wav falla intentar mp3 - try { - await _player.play(AssetSource('recursos/tono_llamda_espera.mp3')); - } catch (_) {} - } - } - void _conectar() { if (!mounted) return; setState(() => _estado = _EstadoLlamada.conectado); - _player.stop(); _ringCtrl.stop(); - // Inicia contador de duración _timerDuracion = Timer.periodic(const Duration(seconds: 1), (_) { if (mounted) setState(() => _segundos++); }); } - Future _colgar() async { + void _colgar() { _timerConexion?.cancel(); _timerDuracion?.cancel(); - await _player.stop(); - if (!mounted) return; - setState(() => _estado = _EstadoLlamada.finalizado); - await Future.delayed(const Duration(milliseconds: 600)); if (mounted) Navigator.pop(context); } @@ -82,7 +59,6 @@ class _LlamadaPageState extends State void dispose() { _timerConexion?.cancel(); _timerDuracion?.cancel(); - _player.dispose(); _ringCtrl.dispose(); super.dispose(); } @@ -101,9 +77,11 @@ class _LlamadaPageState extends State child: Column( children: [ const SizedBox(height: 48), + // ── Badge proveedor ────────────────────────────────────────── Container( - padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6), + padding: + const EdgeInsets.symmetric(horizontal: 14, vertical: 6), decoration: BoxDecoration( color: AppColors.primary.withOpacity(0.12), borderRadius: BorderRadius.circular(99), @@ -127,7 +105,6 @@ class _LlamadaPageState extends State width: 160, height: 160, child: Stack(alignment: Alignment.center, children: [ - // Anillos de pulso (solo mientras llama) if (_estado == _EstadoLlamada.llamando) AnimatedBuilder( animation: _ringCtrl, @@ -146,7 +123,6 @@ class _LlamadaPageState extends State ), ), ), - // Avatar Container( width: 110, height: 110, @@ -180,13 +156,11 @@ class _LlamadaPageState extends State color: Colors.white)), const SizedBox(height: 8), - // ── Estado ─────────────────────────────────────────────────── + // ── Estado / cronómetro ────────────────────────────────────── Text( _estado == _EstadoLlamada.llamando ? 'Llamando...' - : _estado == _EstadoLlamada.conectado - ? _duracion - : 'Llamada finalizada', + : _duracion, style: GoogleFonts.inter( fontSize: 15, color: _estado == _EstadoLlamada.conectado @@ -196,9 +170,21 @@ class _LlamadaPageState extends State const Spacer(), - // ── Botones de control ─────────────────────────────────────── - if (_estado == _EstadoLlamada.conectado) _controlesConectado(), - const SizedBox(height: 32), + // ── Controles (solo conectado) ─────────────────────────────── + if (_estado == _EstadoLlamada.conectado) ...[ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 48), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _controlBtn(Icons.mic_off, 'Silenciar'), + _controlBtn(Icons.volume_up, 'Altavoz'), + _controlBtn(Icons.dialpad, 'Teclado'), + ], + ), + ), + const SizedBox(height: 32), + ], // ── Botón colgar ───────────────────────────────────────────── GestureDetector( @@ -207,13 +193,12 @@ class _LlamadaPageState extends State width: 72, height: 72, decoration: const BoxDecoration( - color: AppColors.error, - shape: BoxShape.circle, - ), + color: AppColors.error, shape: BoxShape.circle), child: const Icon(Icons.call_end_rounded, color: Colors.white, size: 32), ), ), + const SizedBox(height: 8), Text('Colgar', style: appLabel( size: 12, color: AppColors.onSurfaceVariant)), @@ -224,32 +209,20 @@ class _LlamadaPageState extends State ); } - Widget _controlesConectado() => Padding( - padding: const EdgeInsets.symmetric(horizontal: 48), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _controlBtn(Icons.mic_off, 'Silenciar', AppColors.surfaceHigh), - _controlBtn(Icons.volume_up, 'Altavoz', AppColors.surfaceHigh), - _controlBtn(Icons.dialpad, 'Teclado', AppColors.surfaceHigh), - ], - ), - ); - - Widget _controlBtn(IconData icon, String label, Color bg) => Column( + Widget _controlBtn(IconData icon, String label) => Column( mainAxisSize: MainAxisSize.min, children: [ Container( width: 56, height: 56, - decoration: - BoxDecoration(color: bg, shape: BoxShape.circle), + decoration: BoxDecoration( + color: AppColors.surfaceHigh, shape: BoxShape.circle), child: Icon(icon, color: AppColors.onSurface, size: 24), ), const SizedBox(height: 6), Text(label, - style: - appLabel(size: 11, color: AppColors.onSurfaceVariant)), + style: appLabel( + size: 11, color: AppColors.onSurfaceVariant)), ], ); } diff --git a/pubspec.yaml b/pubspec.yaml index 6b1aeac..e28c379 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,7 +38,6 @@ dependencies: crypto: ^3.0.2 shared_preferences: ^2.0.0 http: ^0.13.4 - audioplayers: ^1.1.0 dev_dependencies: flutter_test: @@ -72,9 +71,6 @@ flutter: assets: - lib/recursos/logo_app.png - - lib/recursos/tono_espera_llamada.wav - - lib/recursos/tono_llamda_espera.mp3 - - lib/recursos/tono_notificacion.mp3 # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware.