mirror of
https://github.com/immich-app/immich.git
synced 2025-02-11 01:18:24 -05:00
fd99bd05cf
* setup ios * chore: succesfully sent media to the app * share from Android * wip: navigate to share screen * wip: UI for displaying upload candidate * wip: logic * wip: upload logic * wip: up up up we got it up * wip * wip * wip * upload state * feat: i18n * fix: release build ios' * feat: clear file cache * pr feedback * using const for checking download status --------- Co-authored-by: Alex <alex@pop-os.localdomain>
25 lines
684 B
Dart
25 lines
684 B
Dart
import 'dart:math';
|
|
|
|
String formatBytes(int bytes) {
|
|
const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB'];
|
|
|
|
int magnitude = 0;
|
|
double remainder = bytes.toDouble();
|
|
while (remainder >= 1024) {
|
|
if (magnitude + 1 < units.length) {
|
|
magnitude++;
|
|
remainder /= 1024;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
return "${remainder.toStringAsFixed(magnitude == 0 ? 0 : 1)} ${units[magnitude]}";
|
|
}
|
|
|
|
String formatHumanReadableBytes(int bytes, int decimals) {
|
|
if (bytes <= 0) return "0 B";
|
|
const suffixes = ["B", "KB", "MB", "GB", "TB"];
|
|
var i = (log(bytes) / log(1024)).floor();
|
|
return '${(bytes / pow(1024, i)).toStringAsFixed(decimals)} ${suffixes[i]}';
|
|
}
|