From a9202c6eb356580732071ff91f2d823973552f4e Mon Sep 17 00:00:00 2001 From: freetlab Date: Thu, 21 May 2026 22:16:06 +0200 Subject: [PATCH] fix(settings): show real version and map equalizer gains --- lib/pantallas/pantalla_ajustes.dart | 26 ++++++++++++++++++-------- lib/servicios/servicio_audio.dart | 25 +++++++++++++++++++++++-- pubspec.lock | 16 ++++++++++++++++ pubspec.yaml | 1 + 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/lib/pantallas/pantalla_ajustes.dart b/lib/pantallas/pantalla_ajustes.dart index 9c9bb6f..15526cc 100644 --- a/lib/pantallas/pantalla_ajustes.dart +++ b/lib/pantallas/pantalla_ajustes.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:share_plus/share_plus.dart' show Share, XFile; @@ -556,14 +557,23 @@ class _SeccionInfo extends StatelessWidget { (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( + future: PackageInfo.fromPlatform(), + builder: (ctx, snap) { + final version = + snap.hasData + ? 'v${snap.data!.version}+${snap.data!.buildNumber}' + : 'Cargando versión...'; + return ListTile( + contentPadding: EdgeInsets.zero, + leading: const PluriIcon( + glyph: PluriIconGlyph.settings, + variant: PluriIconVariant.filled, + ), + title: const Text('PluriWave'), + subtitle: Text('$version - Radio mundial'), + ); + }, ), FutureBuilder( future: estado.favoritos.obtenerTodos().then((l) => l.length), diff --git a/lib/servicios/servicio_audio.dart b/lib/servicios/servicio_audio.dart index 405a8ad..b19c8cb 100644 --- a/lib/servicios/servicio_audio.dart +++ b/lib/servicios/servicio_audio.dart @@ -374,7 +374,13 @@ class PluriWaveAudioHandler extends BaseAudioHandler with SeekHandler { i < params.bands.length && i < preset.bandas.length; i++ ) { - await params.bands[i].setGain(preset.bandas[i]); + await params.bands[i].setGain( + _mapearGananciaNativa( + preset.bandas[i], + minDecibels: params.minDecibels, + maxDecibels: params.maxDecibels, + ), + ); } } catch (_) {} } @@ -390,11 +396,26 @@ class PluriWaveAudioHandler extends BaseAudioHandler with SeekHandler { try { final params = await _eq.parameters; if (index < params.bands.length) { - await params.bands[index].setGain(db); + await params.bands[index].setGain( + _mapearGananciaNativa( + db, + minDecibels: params.minDecibels, + maxDecibels: params.maxDecibels, + ), + ); } } catch (_) {} } + double _mapearGananciaNativa( + double db, { + required double minDecibels, + required double maxDecibels, + }) { + final normalizado = ((db.clamp(-12.0, 12.0) + 12.0) / 24.0).clamp(0.0, 1.0); + return minDecibels + (normalizado * (maxDecibels - minDecibels)); + } + Future setEcualizadorActivo(bool activo) async { _ecualizadorActivo = activo; if (!_eqDisponible) return; diff --git a/pubspec.lock b/pubspec.lock index 3c3b953..8fb3194 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -493,6 +493,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968" + url: "https://pub.dev" + source: hosted + version: "8.3.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" + url: "https://pub.dev" + source: hosted + version: "3.2.1" path: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index be78304..774a35c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,6 +43,7 @@ dependencies: url_launcher: ^6.3.1 geolocator: ^13.0.4 geocoding: ^3.0.0 + package_info_plus: ^8.3.1 # Ads (activar cuando tengamos Ad Unit IDs) # google_mobile_ads: ^5.3.0