mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-28 05:40:29 +02:00
refactor(metadata): move cover resolution to extensions
This commit is contained in:
@@ -52,15 +52,6 @@ class MetadataSettingsPage extends ConsumerWidget {
|
||||
settings.artistTagMode,
|
||||
),
|
||||
),
|
||||
SettingsSwitchItem(
|
||||
icon: Icons.image,
|
||||
title: context.l10n.optionsMaxQualityCover,
|
||||
subtitle: context.l10n.optionsMaxQualityCoverSubtitle,
|
||||
value: settings.maxQualityCover,
|
||||
onChanged: (v) => ref
|
||||
.read(settingsProvider.notifier)
|
||||
.setMaxQualityCover(v),
|
||||
),
|
||||
SettingsSwitchItem(
|
||||
icon: Icons.graphic_eq,
|
||||
title: context.l10n.optionsReplayGain,
|
||||
|
||||
@@ -233,12 +233,6 @@ class SettingsSearchCatalog {
|
||||
title: l10n.optionsArtistTagMode,
|
||||
keywords: const ['artist separator', 'multiple artists'],
|
||||
),
|
||||
SettingsSearchEntry(
|
||||
icon: Icons.image,
|
||||
title: l10n.optionsMaxQualityCover,
|
||||
subtitle: l10n.optionsMaxQualityCoverSubtitle,
|
||||
keywords: const ['artwork', 'album art', 'cover size'],
|
||||
),
|
||||
SettingsSearchEntry(
|
||||
icon: Icons.graphic_eq,
|
||||
title: l10n.optionsReplayGain,
|
||||
|
||||
@@ -37,11 +37,11 @@ class _MetadataCandidateArtworkState extends State<_MetadataCandidateArtwork> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.coverUrl?.isNotEmpty == true) {
|
||||
unawaited(_loadMaxQualityCover());
|
||||
unawaited(_loadCover());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadMaxQualityCover() async {
|
||||
Future<void> _loadCover() async {
|
||||
final tempDir = await Directory.systemTemp.createTemp(
|
||||
'metadata_candidate_cover_',
|
||||
);
|
||||
@@ -50,7 +50,6 @@ class _MetadataCandidateArtworkState extends State<_MetadataCandidateArtwork> {
|
||||
final result = await PlatformBridge.downloadCoverToFile(
|
||||
widget.coverUrl!,
|
||||
path,
|
||||
maxQuality: true,
|
||||
);
|
||||
if (result['error'] != null || !await File(path).exists()) {
|
||||
await tempDir.delete(recursive: true);
|
||||
@@ -588,11 +587,7 @@ class _EditMetadataSheetState extends State<_EditMetadataSheet> {
|
||||
);
|
||||
final coverPath = '${tempDir.path}${Platform.pathSeparator}cover.jpg';
|
||||
try {
|
||||
await PlatformBridge.downloadCoverToFile(
|
||||
coverUrl,
|
||||
coverPath,
|
||||
maxQuality: true,
|
||||
);
|
||||
await PlatformBridge.downloadCoverToFile(coverUrl, coverPath);
|
||||
final file = File(coverPath);
|
||||
if (!await file.exists() || await file.length() <= 0) {
|
||||
await tempDir.delete(recursive: true);
|
||||
|
||||
@@ -685,14 +685,12 @@ extension _TrackMetadataLyricsAndSaving on _TrackMetadataScreenState {
|
||||
result = await PlatformBridge.downloadCoverToFile(
|
||||
_coverUrl!,
|
||||
tempOutput,
|
||||
maxQuality: true,
|
||||
);
|
||||
}
|
||||
} else if (_coverUrl != null && _coverUrl!.isNotEmpty) {
|
||||
result = await PlatformBridge.downloadCoverToFile(
|
||||
_coverUrl!,
|
||||
tempOutput,
|
||||
maxQuality: true,
|
||||
);
|
||||
} else {
|
||||
if (mounted) {
|
||||
@@ -781,14 +779,12 @@ extension _TrackMetadataLyricsAndSaving on _TrackMetadataScreenState {
|
||||
result = await PlatformBridge.downloadCoverToFile(
|
||||
_coverUrl!,
|
||||
outputPath,
|
||||
maxQuality: true,
|
||||
);
|
||||
}
|
||||
} else if (_coverUrl != null && _coverUrl!.isNotEmpty) {
|
||||
result = await PlatformBridge.downloadCoverToFile(
|
||||
_coverUrl!,
|
||||
outputPath,
|
||||
maxQuality: true,
|
||||
);
|
||||
} else {
|
||||
if (mounted) {
|
||||
@@ -996,7 +992,6 @@ extension _TrackMetadataLyricsAndSaving on _TrackMetadataScreenState {
|
||||
final request = <String, dynamic>{
|
||||
'file_path': cleanFilePath,
|
||||
'cover_url': _coverUrl ?? '',
|
||||
'max_quality': true,
|
||||
'embed_lyrics': settings.embedLyrics,
|
||||
'lyrics_mode': settings.lyricsMode,
|
||||
'artist_tag_mode': artistTagMode,
|
||||
|
||||
Reference in New Issue
Block a user