refactor: Use adaptive dialog action

This commit is contained in:
Krille 2024-10-18 15:49:46 +02:00
commit d1e211adee
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
9 changed files with 60 additions and 25 deletions

View file

@ -8,6 +8,7 @@ import 'package:matrix/matrix.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/widgets/adaptive_dialog_action.dart';
class ErrorReporter {
final BuildContext context;
@ -34,17 +35,17 @@ class ErrorReporter {
),
),
actions: [
TextButton(
AdaptiveDialogAction(
onPressed: () => Navigator.of(context).pop(),
child: Text(L10n.of(context).close),
),
TextButton(
AdaptiveDialogAction(
onPressed: () => Clipboard.setData(
ClipboardData(text: text),
),
child: Text(L10n.of(context).copy),
),
TextButton(
AdaptiveDialogAction(
onPressed: () => launchUrl(
AppConfig.newIssueUrl.resolveUri(
Uri(

View file

@ -1,18 +1,21 @@
extension SizeString on num {
String get sizeString {
var size = toDouble();
if (size < 1000000) {
if (size < 1000) {
return '${size.round()} Bytes';
}
if (size < 1000 * 1000) {
size = size / 1000;
size = (size * 10).round() / 10;
return '${size.toString()} KB';
} else if (size < 1000000000) {
}
if (size < 1000 * 1000 * 1000) {
size = size / 1000000;
size = (size * 10).round() / 10;
return '${size.toString()} MB';
} else {
size = size / 1000000000;
size = (size * 10).round() / 10;
return '${size.toString()} GB';
}
size = size / 1000 * 1000 * 1000 * 1000;
size = (size * 10).round() / 10;
return '${size.toString()} GB';
}
}