mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-02 22:26:52 +02:00
refactor(ui): consolidate file feedback and shared display helpers
This commit is contained in:
1 parent
c5789df87d
commit
377710ec22
17 files changed
+77
-164
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user