♻️ Refactor logging module

This commit is contained in:
2025-02-27 23:30:08 +08:00
parent 32bf834108
commit ae9743c84f
15 changed files with 230 additions and 91 deletions

View File

@ -133,7 +133,8 @@ extension AppPromptExtension on BuildContext {
),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrlString('https://kb.solsynth.dev/solar-network');
launchUrlString(
'https://kb.solsynth.dev/solar-network');
},
),
],
@ -157,7 +158,17 @@ extension ByteFormatter on int {
if (this == 0) return '0 Bytes';
const k = 1024;
final dm = decimals < 0 ? 0 : decimals;
final sizes = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
final sizes = [
'Bytes',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB'
];
final i = (math.log(this) / math.log(k)).floor().toInt();
return '${(this / math.pow(k, i)).toStringAsFixed(dm)} ${sizes[i]}';
}
@ -167,4 +178,15 @@ extension StringFormatter on String {
String capitalize() {
return "${this[0].toUpperCase()}${substring(1)}";
}
String capitalizeEachWord() {
if (isEmpty) {
return this;
}
return split(' ')
.map((word) => word.isNotEmpty
? '${word[0].toUpperCase()}${word.substring(1)}'
: '')
.join(' ');
}
}