Skip to content

Commit

Permalink
fixup! fixup! fixup! TW-403: add share screen
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn committed Aug 28, 2023
1 parent 14d7644 commit f93f1c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/pages/chat_list/receive_sharing_intent_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {

void _processIncomingSharedFiles(List<SharedMediaFile> files) {
if (files.isEmpty) return;
final file = File(files.first.path.replaceFirst('file://', ''));
final shareFile = files.first;
final path = Uri.decodeFull(shareFile.path.replaceFirst('file://', ''));
final file = File(path);
Matrix.of(context).shareContent = {
'msgtype': 'chat.fluffy.shared_file',
'file': MatrixFile(
bytes: file.readAsBytesSync(),
name: file.path,
filePath: file.path,
).detectFileType,
'thumbnailPath': shareFile.thumbnail,
};
context.go('/share');
context.push('/share');
}

void _processIncomingSharedText(String? text) {
Expand All @@ -46,12 +48,12 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
'msgtype': 'm.text',
'body': text,
};
context.go('/share');
context.push('/share');
}

void _processIncomingUris(String? text) async {
if (text == null) return;
context.go('/share');
context.push('/share');
WidgetsBinding.instance.addPostFrameCallback((_) {
UrlLauncher(context, text).openMatrixToUrl();
});
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/share/share.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:fluffychat/domain/usecase/send_image_interactor.dart';
import 'package:fluffychat/pages/share/share_view.dart';
import 'package:fluffychat/presentation/extensions/send_file_extension.dart';
import 'package:fluffychat/presentation/mixins/send_files_mixin.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
Expand Down Expand Up @@ -52,9 +53,8 @@ class ShareController extends State<Share> with SendFilesMixin {
if (shareContent.tryGet<String>('msgtype') == 'chat.fluffy.shared_file' &&
shareFile != null &&
shareFile.filePath != null) {
context.go('/rooms/${room.id}');
final txId = Matrix.of(context).client.generateUniqueTransactionId();
room.sendingFilePlaceholders[txId] = shareFile;
room.sendingFilePlaceholders[txId] = shareFile.detectFileType;
room.sendFileEvent(
FileInfo(shareFile.name, shareFile.filePath!, shareFile.size),
msgType: shareFile.msgType,
Expand All @@ -63,6 +63,7 @@ class ShareController extends State<Share> with SendFilesMixin {
} else {
room.sendEvent(shareContent);
}
context.go('/rooms/${room.id}');
Matrix.of(context).shareContent = null;
}
}
Expand Down

0 comments on commit f93f1c1

Please sign in to comment.