-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-131: send-one-image-without-caption
- Loading branch information
1 parent
c1d00f0
commit e55dd51
Showing
12 changed files
with
375 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:fluffychat/di/base_di.dart'; | ||
import 'package:fluffychat/domain/usecase/send_image_interactor.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
|
||
class SendImageDi extends BaseDI { | ||
@override | ||
String get scopeName => "Send image"; | ||
|
||
@override | ||
void setUp(GetIt get) { | ||
get.registerFactory<SendImageInteractor>(() => SendImageInteractor()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import 'package:fluffychat/presentation/extensions/room_extension.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
import 'package:photo_manager/photo_manager.dart'; | ||
import 'package:fluffychat/presentation/extensions/asset_entity_extension.dart'; | ||
|
||
class SendImageInteractor { | ||
Future<void> execute({ | ||
required Room room, | ||
required AssetEntity entity, | ||
String? txId, | ||
Event? inReplyTo, | ||
String? editEventId, | ||
int? shrinkImageMaxDimension, | ||
MatrixImageFile? thumbnail, | ||
Map<String, dynamic>? extraContent, | ||
}) async { | ||
final matrixFile = await entity.toMatrixFile(); | ||
if (matrixFile != null) { | ||
try { | ||
final mxcUri = await room.sendImageFileEvent( | ||
matrixFile, | ||
txid: txId, | ||
editEventId: editEventId, | ||
inReplyTo: inReplyTo, | ||
shrinkImageMaxDimension: shrinkImageMaxDimension, | ||
thumbnail: MatrixImageFile(bytes: matrixFile.bytes, name: matrixFile.name), | ||
extraContent: extraContent, | ||
); | ||
} catch(error) { | ||
Logs().d("SendImageInteractor: execute(): $error"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:fluffychat/pages/chat/events/message_content_style.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class SendingImageWidget extends StatelessWidget { | ||
const SendingImageWidget({ | ||
super.key, | ||
required this.sendingImageData, | ||
}); | ||
|
||
final Uint8List sendingImageData; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ClipRRect( | ||
borderRadius: BorderRadius.circular(12.0), | ||
child: Image.memory( | ||
sendingImageData, | ||
width: MessageContentStyle.imageBubbleWidth, | ||
height: MessageContentStyle.imageBubbleHeight, | ||
fit: BoxFit.cover, | ||
filterQuality: FilterQuality.medium, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.