feat: Sending multiple files at once
This commit is contained in:
parent
b328e95980
commit
b83503585f
6 changed files with 165 additions and 58 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -10,10 +11,29 @@ import 'package:matrix/matrix.dart';
|
|||
import 'uia_request_manager.dart';
|
||||
|
||||
extension LocalizedExceptionExtension on Object {
|
||||
static String _formatFileSize(int size) {
|
||||
if (size < 1024) return '$size B';
|
||||
final i = (log(size) / log(1024)).floor();
|
||||
final num = (size / pow(1024, i));
|
||||
final round = num.round();
|
||||
final numString = round < 10
|
||||
? num.toStringAsFixed(2)
|
||||
: round < 100
|
||||
? num.toStringAsFixed(1)
|
||||
: round.toString();
|
||||
return '$numString ${'kMGTPEZY'[i - 1]}B';
|
||||
}
|
||||
|
||||
String toLocalizedString(
|
||||
BuildContext context, [
|
||||
ExceptionContext? exceptionContext,
|
||||
]) {
|
||||
if (this is FileTooBigMatrixException) {
|
||||
final exception = this as FileTooBigMatrixException;
|
||||
return L10n.of(context)!.fileIsTooBigForServer(
|
||||
_formatFileSize(exception.maxFileSize),
|
||||
);
|
||||
}
|
||||
if (this is MatrixException) {
|
||||
switch ((this as MatrixException).error) {
|
||||
case MatrixError.M_FORBIDDEN:
|
||||
|
|
@ -30,9 +50,6 @@ extension LocalizedExceptionExtension on Object {
|
|||
if (this is InvalidPassphraseException) {
|
||||
return L10n.of(context)!.wrongRecoveryKey;
|
||||
}
|
||||
if (this is FileTooBigMatrixException) {
|
||||
return L10n.of(context)!.fileIsTooBigForServer;
|
||||
}
|
||||
if (this is BadServerVersionsException) {
|
||||
final serverVersions = (this as BadServerVersionsException)
|
||||
.serverVersions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue