mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 08:07:59 -06:00
WIP - started implementing quick search
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import 'dart:math';
|
||||
|
||||
String formatMaxCount(int? count, [int maxCount = 99]) {
|
||||
if ((count ?? 0) > maxCount) {
|
||||
return "$maxCount+";
|
||||
}
|
||||
return (count ?? 0).toString().padLeft(maxCount.toString().length);
|
||||
}
|
||||
|
||||
String formatBytes(int bytes, int decimals) {
|
||||
if (bytes <= 0) return "0 B";
|
||||
const suffixes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
var i = (log(bytes) / log(1024)).floor();
|
||||
return ((bytes / pow(1024, i)).toStringAsFixed(decimals)) + ' ' + suffixes[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user