fix: iOS build

This commit is contained in:
Christian Pauly 2020-11-14 14:04:36 +01:00
commit 272641e016
10 changed files with 186 additions and 224 deletions

View file

@ -18,6 +18,8 @@ import '../matrix.dart';
import '../mouse_over_builder.dart';
import '../theme_switcher.dart';
enum ArchivedRoomAction { delete, rejoin }
class ChatListItem extends StatelessWidget {
final Room room;
final bool activeChat;
@ -51,37 +53,33 @@ class ChatListItem extends StatelessWidget {
}
if (room.membership == Membership.leave) {
await showDialog(
final action = await showModalActionSheet<ArchivedRoomAction>(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(L10n.of(context).archivedRoom),
content: Text(L10n.of(context).thisRoomHasBeenArchived),
actions: <Widget>[
FlatButton(
child: Text(L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: Text(L10n.of(context).delete.toUpperCase(),
style: TextStyle(color: Colors.red)),
onPressed: () async {
await archiveAction(context);
await Navigator.of(context).pop();
},
),
FlatButton(
child: Text(L10n.of(context).rejoin.toUpperCase(),
style: TextStyle(color: Colors.blue)),
onPressed: () async {
await SimpleDialogs(context)
.tryRequestWithLoadingDialog(room.join());
await Navigator.of(context).pop();
},
),
],
),
title: L10n.of(context).archivedRoom,
message: L10n.of(context).thisRoomHasBeenArchived,
actions: [
SheetAction(
label: L10n.of(context).rejoin,
key: ArchivedRoomAction.rejoin,
),
SheetAction(
label: L10n.of(context).delete,
key: ArchivedRoomAction.delete,
isDestructiveAction: true,
),
],
);
if (action != null) {
switch (action) {
case ArchivedRoomAction.delete:
await archiveAction(context);
break;
case ArchivedRoomAction.rejoin:
await SimpleDialogs(context)
.tryRequestWithLoadingDialog(room.join());
break;
}
}
}
if (room.membership == Membership.join) {

View file

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:android_path_provider/android_path_provider.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
@ -7,7 +8,6 @@ import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';
import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:mime_type/mime_type.dart';
import 'package:downloads_path_provider_28/downloads_path_provider_28.dart';
import 'package:permission_handler/permission_handler.dart';
extension MatrixFileExtension on MatrixFile {
@ -29,12 +29,12 @@ extension MatrixFileExtension on MatrixFile {
} else {
if (!(await Permission.storage.request()).isGranted) return;
final downloadsDir = PlatformInfos.isDesktop
? (await getDownloadsDirectory())
? (await getDownloadsDirectory()).path
: Platform.isAndroid
? (await DownloadsPathProvider.downloadsDirectory)
: (await getApplicationDocumentsDirectory());
? (await AndroidPathProvider.downloadsPath)
: (await getApplicationDocumentsDirectory()).path;
final file = File(downloadsDir.path + '/' + name.split('/').last);
final file = File(downloadsDir + '/' + name.split('/').last);
file.writeAsBytesSync(bytes);
await OpenFile.open(file.path);
}