mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 09:08:40 +00:00
fix #145
This commit is contained in:
parent
aeabd9268f
commit
c460befea5
4 changed files with 24 additions and 13 deletions
|
|
@ -18,6 +18,7 @@ import 'package:twonly/src/views/components/media_view_sizing.dart';
|
|||
import 'package:twonly/src/views/components/permissions_view.dart';
|
||||
import 'package:twonly/src/utils/storage.dart';
|
||||
import 'package:twonly/src/views/camera/share_image_editor_view.dart';
|
||||
import 'package:twonly/src/views/home_view.dart';
|
||||
|
||||
class CameraPreviewView extends StatefulWidget {
|
||||
const CameraPreviewView({super.key, this.sendTo});
|
||||
|
|
@ -245,9 +246,12 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
|||
if (!context.mounted) return true;
|
||||
// shouldReturn is null when the user used the back button
|
||||
if (shoudReturn != null && shoudReturn) {
|
||||
if (!context.mounted) return true;
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(context);
|
||||
if (widget.sendTo == null) {
|
||||
globalUpdateOfHomeViewPageIndex(1);
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
selectCamera(cameraId);
|
||||
|
|
@ -381,9 +385,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (cameraId >= gCameras.length || controller == null) {
|
||||
return Center(
|
||||
child: Text("No camera found."),
|
||||
);
|
||||
return Container();
|
||||
}
|
||||
return MediaViewSizing(
|
||||
child: GestureDetector(
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
|
||||
Future pushShareImageView() async {
|
||||
Future<Uint8List?> imageBytes = getMergedImage();
|
||||
videoController?.pause();
|
||||
bool? wasSend = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
|
|
@ -304,6 +305,8 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
|
|||
if (wasSend != null && wasSend && context.mounted) {
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(context, true);
|
||||
} else {
|
||||
videoController?.play();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import 'package:twonly/src/views/components/verified_shield.dart';
|
|||
import 'package:twonly/src/database/daos/contacts_dao.dart';
|
||||
import 'package:twonly/src/database/twonly_database.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
import 'package:twonly/src/views/home_view.dart';
|
||||
|
||||
class ShareImageView extends StatefulWidget {
|
||||
const ShareImageView(
|
||||
|
|
@ -257,12 +256,13 @@ class _ShareImageView extends State<ShareImageView> {
|
|||
widget.mirrorVideo,
|
||||
);
|
||||
if (context.mounted) {
|
||||
if (widget.preselectedUser != null) {
|
||||
Navigator.pop(context, true);
|
||||
} else {
|
||||
Navigator.popUntil(context, (route) => route.isFirst);
|
||||
globalUpdateOfHomeViewPageIndex(1);
|
||||
}
|
||||
Navigator.pop(context, true);
|
||||
// if (widget.preselectedUser != null) {
|
||||
// Navigator.pop(context, true);
|
||||
// } else {
|
||||
// Navigator.popUntil(context, (route) => route.isFirst, true);
|
||||
// globalUpdateOfHomeViewPageIndex(1);
|
||||
// }
|
||||
}
|
||||
},
|
||||
style: ButtonStyle(
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
}
|
||||
|
||||
Future nextMediaOrExit() async {
|
||||
if (!isMounted) return;
|
||||
videoController?.dispose();
|
||||
nextMediaTimer?.cancel();
|
||||
progressTimer?.cancel();
|
||||
if (allMediaFiles.isNotEmpty) {
|
||||
|
|
@ -112,7 +114,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
}
|
||||
}
|
||||
if (allMediaFiles.isEmpty || allMediaFiles.length == 1) {
|
||||
if (context.mounted) {
|
||||
if (isMounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -122,6 +124,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
}
|
||||
|
||||
Future loadCurrentMediaFile({bool showTwonly = false}) async {
|
||||
if (!isMounted) return;
|
||||
await _noScreenshot.screenshotOff();
|
||||
if (!context.mounted || allMediaFiles.isEmpty) return nextMediaOrExit();
|
||||
|
||||
|
|
@ -394,6 +397,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
onPressed: () async {
|
||||
nextMediaTimer?.cancel();
|
||||
progressTimer?.cancel();
|
||||
videoController?.pause();
|
||||
await Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return CameraSendToView(widget.contact);
|
||||
|
|
@ -401,6 +405,8 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
));
|
||||
if (isMounted && maxShowTime != gMediaShowInfinite) {
|
||||
nextMediaOrExit();
|
||||
} else {
|
||||
videoController?.play();
|
||||
}
|
||||
},
|
||||
style: ButtonStyle(
|
||||
|
|
|
|||
Loading…
Reference in a new issue