mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 08:08:39 +00:00
Merge pull request #359 from twonlyapp/dev
Some checks failed
Publish on Github / build_and_publish (push) Has been cancelled
Some checks failed
Publish on Github / build_and_publish (push) Has been cancelled
- Fixes the issue where black/blank images were sometimes received - Fixes an issue in the image editor
This commit is contained in:
commit
6a104e9468
8 changed files with 58 additions and 29 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 0.0.81
|
||||
|
||||
- Fixes the issue where black/blank images were sometimes received
|
||||
- Fixes an issue in the image editor
|
||||
|
||||
## 0.0.80
|
||||
|
||||
- Share images/videos directly from other applications
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ Future<MediaFileService?> initializeMediaUpload(
|
|||
Future<void> insertMediaFileInMessagesTable(
|
||||
MediaFileService mediaService,
|
||||
List<String> groupIds,
|
||||
Future<Uint8List?>? imageStoreAwait,
|
||||
) async {
|
||||
await twonlyDB.mediaFilesDao.updateAllMediaFiles(
|
||||
const MediaFilesCompanion(
|
||||
|
|
@ -118,13 +117,6 @@ Future<void> insertMediaFileInMessagesTable(
|
|||
}
|
||||
}
|
||||
|
||||
if (imageStoreAwait != null) {
|
||||
if (await imageStoreAwait == null) {
|
||||
Log.error('image store as original did return false...');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unawaited(startBackgroundMediaUpload(mediaService));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class BackgroundLayerData extends Layer {
|
|||
required this.image,
|
||||
});
|
||||
ImageItem image;
|
||||
bool imageLoaded = false;
|
||||
}
|
||||
|
||||
class FilterLayerData extends Layer {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:twonly/src/views/camera/image_editor/data/layer.dart';
|
||||
|
||||
/// Main layer
|
||||
class BackgroundLayer extends StatefulWidget {
|
||||
const BackgroundLayer({
|
||||
required this.layerData,
|
||||
|
|
@ -23,7 +22,17 @@ class _BackgroundLayerState extends State<BackgroundLayer> {
|
|||
height: widget.layerData.image.height.toDouble(),
|
||||
// color: Theme.of(context).colorScheme.surface,
|
||||
padding: EdgeInsets.zero,
|
||||
child: Image.memory(widget.layerData.image.bytes),
|
||||
child: Image.memory(
|
||||
widget.layerData.image.bytes,
|
||||
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
|
||||
if (wasSynchronouslyLoaded || frame != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.layerData.imageLoaded = true;
|
||||
});
|
||||
}
|
||||
return child;
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
VideoPlayerController? videoController;
|
||||
ImageItem currentImage = ImageItem();
|
||||
ScreenshotController screenshotController = ScreenshotController();
|
||||
Timer? _imageLoadingTimer;
|
||||
|
||||
MediaFileService get mediaService => widget.mediaFileService;
|
||||
MediaFile get media => widget.mediaFileService.mediaFile;
|
||||
|
|
@ -120,6 +121,7 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
isDraftMedia: Value(false),
|
||||
),
|
||||
);
|
||||
_imageLoadingTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
|
@ -449,6 +451,10 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
x.showCustomButtons = false;
|
||||
}
|
||||
setState(() {});
|
||||
|
||||
// Make a short delay, so the setState does have its effect...
|
||||
await Future.delayed(const Duration(milliseconds: 10));
|
||||
|
||||
final image = await screenshotController.capture(
|
||||
pixelRatio: pixelRatio,
|
||||
);
|
||||
|
|
@ -531,16 +537,34 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
}
|
||||
});
|
||||
|
||||
layers.insert(
|
||||
0,
|
||||
BackgroundLayerData(
|
||||
key: GlobalKey(),
|
||||
image: currentImage,
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
sendingOrLoadingImage = false;
|
||||
loadingImage = false;
|
||||
layers.insert(
|
||||
0,
|
||||
BackgroundLayerData(
|
||||
key: GlobalKey(),
|
||||
image: currentImage,
|
||||
),
|
||||
);
|
||||
});
|
||||
// It is important that the user can sending the image only when the image is fully loaded otherwise if the user
|
||||
// will click on send before the image is painted the screenshot will be transparent..
|
||||
_imageLoadingTimer =
|
||||
Timer.periodic(const Duration(milliseconds: 10), (timer) {
|
||||
final imageLayer = layers.first;
|
||||
if (imageLayer is BackgroundLayerData) {
|
||||
if (imageLayer.imageLoaded) {
|
||||
timer.cancel();
|
||||
Future.delayed(const Duration(milliseconds: 50), () {
|
||||
Log.info(imageLayer.imageLoaded);
|
||||
if (context.mounted) {
|
||||
setState(() {
|
||||
sendingOrLoadingImage = false;
|
||||
loadingImage = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -552,16 +576,16 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
|
||||
if (!context.mounted) return;
|
||||
|
||||
// must be awaited so the widget for the screenshot is not already disposed when sending..
|
||||
await storeImageAsOriginal();
|
||||
|
||||
// Insert media file into the messages database and start uploading process in the background
|
||||
unawaited(
|
||||
insertMediaFileInMessagesTable(
|
||||
mediaService,
|
||||
[widget.sendToGroup!.groupId],
|
||||
storeImageAsOriginal(),
|
||||
),
|
||||
await insertMediaFileInMessagesTable(
|
||||
mediaService,
|
||||
[widget.sendToGroup!.groupId],
|
||||
);
|
||||
|
||||
if (context.mounted) {
|
||||
if (mounted) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,6 @@ class _ShareImageView extends State<ShareImageView> {
|
|||
await insertMediaFileInMessagesTable(
|
||||
widget.mediaFileService,
|
||||
widget.selectedGroupIds.toList(),
|
||||
null,
|
||||
);
|
||||
|
||||
if (context.mounted) {
|
||||
|
|
|
|||
|
|
@ -151,7 +151,6 @@ class _MessageInputState extends State<MessageInput> {
|
|||
await insertMediaFileInMessagesTable(
|
||||
mediaFileService,
|
||||
[widget.group.groupId],
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec
|
|||
|
||||
publish_to: 'none'
|
||||
|
||||
version: 0.0.80+80
|
||||
version: 0.0.81+81
|
||||
|
||||
environment:
|
||||
sdk: ^3.6.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue