fix(settings): show real version and map equalizer gains
This commit is contained in:
@@ -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<PackageInfo>(
|
||||
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<int>(
|
||||
future: estado.favoritos.obtenerTodos().then((l) => l.length),
|
||||
|
||||
@@ -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<void> setEcualizadorActivo(bool activo) async {
|
||||
_ecualizadorActivo = activo;
|
||||
if (!_eqDisponible) return;
|
||||
|
||||
Reference in New Issue
Block a user