fix(ci): resolve premium UI analyzer errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
@@ -47,7 +47,8 @@ class _SeccionEcualizador extends StatelessWidget {
|
||||
builder: (ctx, estado, _) {
|
||||
final disponible = estado.ecualizadorDisponible;
|
||||
final emisoraActual = estado.emisoraActual;
|
||||
final mostrarModoPorEmisora = emisoraActual != null && estado.emisoraActualEsFavorita;
|
||||
final mostrarModoPorEmisora =
|
||||
emisoraActual != null && estado.emisoraActualEsFavorita;
|
||||
final usandoEqPropio = estado.emisoraActualTienePresetPropio;
|
||||
|
||||
return PluriGlassSurface(
|
||||
@@ -58,7 +59,10 @@ class _SeccionEcualizador extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.equalizer),
|
||||
const SizedBox(width: 12),
|
||||
Text('Ecualizador', style: Theme.of(ctx).textTheme.titleMedium),
|
||||
Text(
|
||||
'Ecualizador',
|
||||
style: Theme.of(ctx).textTheme.titleMedium,
|
||||
),
|
||||
const Spacer(),
|
||||
if (!disponible)
|
||||
const Chip(
|
||||
@@ -78,7 +82,11 @@ class _SeccionEcualizador extends StatelessWidget {
|
||||
: 'Usando EQ principal para ${emisoraActual.nombre}',
|
||||
),
|
||||
value: usandoEqPropio,
|
||||
onChanged: (usarPropio) => estado.cambiarModoEcualizadorEmisoraActual(usarPropio: usarPropio),
|
||||
onChanged:
|
||||
(usarPropio) =>
|
||||
estado.cambiarModoEcualizadorEmisoraActual(
|
||||
usarPropio: usarPropio,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
@@ -115,7 +123,10 @@ class _SeccionEmisoras extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.add_circle_outline),
|
||||
const SizedBox(width: 12),
|
||||
Text('Emisoras personalizadas', style: Theme.of(context).textTheme.titleMedium),
|
||||
Text(
|
||||
'Emisoras personalizadas',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.add),
|
||||
@@ -127,7 +138,10 @@ class _SeccionEmisoras extends StatelessWidget {
|
||||
if (custom.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 8),
|
||||
child: Text('No hay emisoras personalizadas.', style: TextStyle(color: Colors.grey)),
|
||||
child: Text(
|
||||
'No hay emisoras personalizadas.',
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
)
|
||||
else
|
||||
for (final emisora in custom)
|
||||
@@ -135,19 +149,27 @@ class _SeccionEmisoras extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const Icon(Icons.radio),
|
||||
title: Text(emisora.nombre),
|
||||
subtitle: Text(emisora.url, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
subtitle: Text(
|
||||
emisora.url,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.play_arrow),
|
||||
tooltip: 'Reproducir',
|
||||
onPressed: () => context.read<EstadoRadio>().reproducir(emisora),
|
||||
onPressed:
|
||||
() => context.read<EstadoRadio>().reproducir(emisora),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
tooltip: 'Eliminar',
|
||||
onPressed: () => context.read<EstadoRadio>().eliminarEmitoraCustom(emisora.uuid),
|
||||
onPressed:
|
||||
() => context
|
||||
.read<EstadoRadio>()
|
||||
.eliminarEmitoraCustom(emisora.uuid),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -214,12 +236,22 @@ class _FormularioEmisoraState extends State<_FormularioEmisora> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text('Añadir emisora', style: Theme.of(context).textTheme.titleLarge),
|
||||
Text(
|
||||
'Añadir emisora',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _nombreCtrl,
|
||||
decoration: const InputDecoration(labelText: 'Nombre *', border: OutlineInputBorder()),
|
||||
validator: (v) => v == null || v.trim().isEmpty ? 'Campo obligatorio' : null,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nombre *',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator:
|
||||
(v) =>
|
||||
v == null || v.trim().isEmpty
|
||||
? 'Campo obligatorio'
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
@@ -240,14 +272,22 @@ class _FormularioEmisoraState extends State<_FormularioEmisora> {
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _paisCtrl,
|
||||
decoration: const InputDecoration(labelText: 'País (opcional)', border: OutlineInputBorder()),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'País (opcional)',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
FilledButton(
|
||||
onPressed: _guardando ? null : _guardar,
|
||||
child: _guardando
|
||||
? const SizedBox(height: 20, width: 20, child: CircularProgressIndicator(strokeWidth: 2))
|
||||
: const Text('Guardar emisora'),
|
||||
child:
|
||||
_guardando
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Text('Guardar emisora'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -272,44 +312,68 @@ class _SeccionBackup extends StatelessWidget {
|
||||
await Share.shareXFiles(
|
||||
[XFile(file.path)],
|
||||
subject: 'PluriWave — copia de seguridad',
|
||||
text: 'Configuración de PluriWave exportada el ${DateTime.now().toLocal()}',
|
||||
text:
|
||||
'Configuración de PluriWave exportada el ${DateTime.now().toLocal()}',
|
||||
);
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error al exportar: $e')));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Error al exportar: $e')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _importar(BuildContext context) async {
|
||||
try {
|
||||
final result = await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['json']);
|
||||
final result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['json'],
|
||||
);
|
||||
if (result == null || result.files.single.path == null) return;
|
||||
|
||||
final file = File(result.files.single.path!);
|
||||
final json = jsonDecode(await file.readAsString()) as Map<String, dynamic>;
|
||||
final json =
|
||||
jsonDecode(await file.readAsString()) as Map<String, dynamic>;
|
||||
|
||||
if (context.mounted) {
|
||||
final confirmar = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Importar configuración'),
|
||||
content: const Text('Esto añadirá los favoritos, emisoras y presets del fichero. ¿Continuar?'),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancelar')),
|
||||
FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Importar')),
|
||||
],
|
||||
),
|
||||
builder:
|
||||
(ctx) => AlertDialog(
|
||||
title: const Text('Importar configuración'),
|
||||
content: const Text(
|
||||
'Esto añadirá los favoritos, emisoras y presets del fichero. ¿Continuar?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Cancelar'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
child: const Text('Importar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmar != true) return;
|
||||
if (context.mounted) {
|
||||
await context.read<EstadoRadio>().importarConfig(json);
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Configuración importada correctamente')));
|
||||
final estado = context.read<EstadoRadio>();
|
||||
final messenger = ScaffoldMessenger.of(context);
|
||||
await estado.importarConfig(json);
|
||||
messenger.showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Configuración importada correctamente'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error al importar: $e')));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Error al importar: $e')));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,7 +388,10 @@ class _SeccionBackup extends StatelessWidget {
|
||||
children: [
|
||||
const Icon(Icons.backup_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text('Copia de seguridad', style: Theme.of(context).textTheme.titleMedium),
|
||||
Text(
|
||||
'Copia de seguridad',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
ListTile(
|
||||
@@ -338,7 +405,9 @@ class _SeccionBackup extends StatelessWidget {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const Icon(Icons.download_outlined),
|
||||
title: const Text('Importar configuración'),
|
||||
subtitle: const Text('Restaurar desde un fichero de copia de seguridad'),
|
||||
subtitle: const Text(
|
||||
'Restaurar desde un fichero de copia de seguridad',
|
||||
),
|
||||
onTap: () => _importar(context),
|
||||
),
|
||||
],
|
||||
@@ -353,41 +422,49 @@ class _SeccionInfo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<EstadoRadio>(
|
||||
builder: (ctx, estado, _) => PluriGlassSurface(
|
||||
child: Column(
|
||||
children: [
|
||||
const ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: PluriIcon(glyph: PluriIconGlyph.settings, variant: PluriIconVariant.filled),
|
||||
title: Text('PluriWave'),
|
||||
subtitle: Text('v0.3.0 — Radio mundial'),
|
||||
builder:
|
||||
(ctx, estado, _) => PluriGlassSurface(
|
||||
child: Column(
|
||||
children: [
|
||||
const ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: PluriIcon(
|
||||
glyph: PluriIconGlyph.settings,
|
||||
variant: PluriIconVariant.filled,
|
||||
),
|
||||
title: Text('PluriWave'),
|
||||
subtitle: Text('v0.3.0 — Radio mundial'),
|
||||
),
|
||||
FutureBuilder<int>(
|
||||
future: estado.favoritos.obtenerTodos().then((l) => l.length),
|
||||
builder:
|
||||
(ctx, snap) => ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const Icon(Icons.favorite_outline),
|
||||
title: const Text('Favoritos guardados'),
|
||||
trailing: Text(
|
||||
snap.data?.toString() ?? '—',
|
||||
style: Theme.of(ctx).textTheme.bodyLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
const ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(Icons.verified_outlined),
|
||||
title: Text('Filtro de emisoras'),
|
||||
subtitle: Text('Solo emisoras verificadas como activas'),
|
||||
trailing: Icon(Icons.check_circle, color: Colors.green),
|
||||
),
|
||||
const ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(Icons.music_note_outlined),
|
||||
title: Text('Audio en background'),
|
||||
subtitle: Text('Continúa al apagar la pantalla'),
|
||||
trailing: Icon(Icons.check_circle, color: Colors.green),
|
||||
),
|
||||
],
|
||||
),
|
||||
FutureBuilder<int>(
|
||||
future: estado.favoritos.obtenerTodos().then((l) => l.length),
|
||||
builder: (ctx, snap) => ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const Icon(Icons.favorite_outline),
|
||||
title: const Text('Favoritos guardados'),
|
||||
trailing: Text(snap.data?.toString() ?? '—', style: Theme.of(ctx).textTheme.bodyLarge),
|
||||
),
|
||||
),
|
||||
const ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(Icons.verified_outlined),
|
||||
title: Text('Filtro de emisoras'),
|
||||
subtitle: Text('Solo emisoras verificadas como activas'),
|
||||
trailing: Icon(Icons.check_circle, color: Colors.green),
|
||||
),
|
||||
const ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Icon(Icons.music_note_outlined),
|
||||
title: Text('Audio en background'),
|
||||
subtitle: Text('Continúa al apagar la pantalla'),
|
||||
trailing: Icon(Icons.check_circle, color: Colors.green),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user