mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-02 16:20:57 +02:00
refactor(core): reduce generated and duplicate code
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -216,16 +216,4 @@ class CacheStats {
|
||||
final int totalSizeBytes;
|
||||
|
||||
const CacheStats({required this.fileCount, required this.totalSizeBytes});
|
||||
|
||||
String get formattedSize {
|
||||
if (totalSizeBytes < 1024) {
|
||||
return '$totalSizeBytes B';
|
||||
} else if (totalSizeBytes < 1024 * 1024) {
|
||||
return '${(totalSizeBytes / 1024).toStringAsFixed(1)} KB';
|
||||
} else if (totalSizeBytes < 1024 * 1024 * 1024) {
|
||||
return '${(totalSizeBytes / (1024 * 1024)).toStringAsFixed(1)} MB';
|
||||
} else {
|
||||
return '${(totalSizeBytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:spotiflac_android/services/sqlite_helpers.dart' as sqlite;
|
||||
import 'package:spotiflac_android/utils/isrc_utils.dart' as isrc;
|
||||
import 'package:spotiflac_android/utils/logger.dart';
|
||||
import 'package:spotiflac_android/utils/path_match_keys.dart';
|
||||
|
||||
@@ -286,9 +287,7 @@ class HistoryDatabase {
|
||||
static String normalizeLookupText(String? value) =>
|
||||
sqlite.normalizeLookupText(value);
|
||||
|
||||
static String normalizeIsrc(String? value) {
|
||||
return (value ?? '').trim().toUpperCase().replaceAll(RegExp(r'[-\s]'), '');
|
||||
}
|
||||
static String normalizeIsrc(String? value) => isrc.normalizeIsrc(value);
|
||||
|
||||
static String normalizeSpotifyId(String? value) {
|
||||
return (value ?? '').trim().toLowerCase();
|
||||
|
||||
@@ -240,8 +240,6 @@ class LocalLibrarySource {
|
||||
|
||||
enum LocalLibrarySortMode { album, title, artist, latest, quality }
|
||||
|
||||
enum LocalLibraryFilterMode { all, albums, singles }
|
||||
|
||||
class LocalLibraryLookupIndex {
|
||||
final Set<String> isrcs;
|
||||
final Set<String> matchKeys;
|
||||
|
||||
@@ -254,13 +254,3 @@ void precacheCoverImage(BuildContext context, String? url) {
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
int coverImageCacheExtent(
|
||||
BuildContext context,
|
||||
double logicalSize, {
|
||||
int min = 64,
|
||||
int max = 512,
|
||||
}) {
|
||||
final dpr = MediaQuery.devicePixelRatioOf(context).clamp(1.0, 3.0).toDouble();
|
||||
return (logicalSize * dpr).round().clamp(min, max).toInt();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user