mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 04:32:32 +00:00
NEW - [Tautulli] View Activity - [Tautulli] View activity details - [Tautulli] View list of users - [Tautulli] Ability to backup configuration & database - [Tautulli] Ability to delete cache & image cache - [Drawer] Ability to set the initial expanded state of categories (automation, clients, & monitoring) TWEAKS - [UI/Loader] New loading indicator - [Home/Calendar] Separate calendar view type into its own preference - [Home/Calendar] Show no modules enabled message when there are no automation modules enabled, not just no modules overall FIXES - [Profiles] Safeguarded fetching of enabled module
24 lines
1.3 KiB
Dart
24 lines
1.3 KiB
Dart
import 'package:lunasea/core/constants.dart';
|
|
|
|
extension IntegerBytesExtension on int {
|
|
String _bytesToString({ int decimals = 2, position = 0, bool bytes = true }) {
|
|
if(this == null || this <= 0) return '${0.toStringAsFixed(decimals)} B';
|
|
int chunk = bytes ? 1024 : 1000;
|
|
double size = this.toDouble();
|
|
while(size > chunk) {
|
|
size /= chunk;
|
|
position++;
|
|
}
|
|
return '${size.toStringAsFixed(decimals)} ${bytes ? Constants.BYTE_SIZES[position] : Constants.BIT_SIZES[position]}';
|
|
}
|
|
|
|
// ignore: non_constant_identifier_names
|
|
String lsBytes_BytesToString({ int decimals = 2, bool bytes = true }) => _bytesToString(decimals: decimals, position: 0, bytes: bytes);
|
|
// ignore: non_constant_identifier_names
|
|
String lsBytes_KilobytesToString({ int decimals = 2, bool bytes = true }) => _bytesToString(decimals: decimals, position: 1, bytes: bytes);
|
|
// ignore: non_constant_identifier_names
|
|
String lsBytes_MegabytesToString({ int decimals = 2, bool bytes = true }) => _bytesToString(decimals: decimals, position: 2, bytes: bytes);
|
|
// ignore: non_constant_identifier_names
|
|
String lsBytes_GigabytesToString({ int decimals = 2, bool bytes = true }) => _bytesToString(decimals: decimals, position: 3, bytes: bytes);
|
|
}
|