refactor(ui): consolidate file feedback and shared display helpers

This commit is contained in:
zarzet committed 2026-09-30 21:43:39 +07:00
1 parent c5789df87d
commit 377710ec22
17 files changed
+77 -164

No files matched your search

+2 -10
View File
@@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:spotiflac_android/l10n/l10n.dart';
import 'package:spotiflac_android/models/track.dart';
import 'package:spotiflac_android/providers/download_queue_provider.dart';
import 'package:spotiflac_android/providers/local_library_provider.dart';
import 'package:spotiflac_android/providers/playback_provider.dart';
import 'package:spotiflac_android/utils/file_access.dart';
import 'package:spotiflac_android/widgets/app_snack_bar.dart';
/// Plays [track] from download history or the local library when a matching
/// file already exists on disk.
@@ -71,15 +71,7 @@ Future<bool> playLocalIfAvailable(
return true;
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
context.l10n.snackbarCannotOpenFile(context.friendlyError(e)),
),
),
);
}
if (context.mounted) showCannotOpenFileSnackBar(context, e);
return true;
}
+16
View File
@@ -70,6 +70,22 @@ String formatBytes(int bytes) {
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
}
/// English month abbreviations indexed by `DateTime.month - 1`.
const List<String> shortMonthNames = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
];
/// "m:ss" clock formatting for track durations.
String formatClock(num seconds) {
final total = seconds.round();