From 70f96bfee84897112bc68c55e8c5856bb940f25d Mon Sep 17 00:00:00 2001 From: Avi0n <3853140-Avi0n@users.noreply.gitlab.com> Date: Mon, 18 Jan 2021 06:56:02 +0000 Subject: [PATCH] feat: Dismiss keyboard on view scroll. Added the ability for the software keyboard to be dismissed when scrolling on a ListView in a chat and the chat list. This will help iOS users since they don't have a back button like Android. --- lib/views/image_view.dart | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/views/image_view.dart b/lib/views/image_view.dart index 84637f0b..56ca2acb 100644 --- a/lib/views/image_view.dart +++ b/lib/views/image_view.dart @@ -3,8 +3,8 @@ import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/components/image_bubble.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:flutter/material.dart'; -import 'package:photo_view/photo_view.dart'; import '../utils/event_extension.dart'; +import '../utils/platform_infos.dart'; class ImageView extends StatelessWidget { final Event event; @@ -19,6 +19,8 @@ class ImageView extends StatelessWidget { @override Widget build(BuildContext context) { + var calcVelocity = MediaQuery.of(context).size.height * 1.50; + return Scaffold( backgroundColor: Colors.black, extendBodyBehindAppBar: true, @@ -43,19 +45,28 @@ class ImageView extends StatelessWidget { ), ], ), - body: PhotoView.customChild( + body: InteractiveViewer( + child: Center( + child: ImageBubble( + event, + tapToView: false, + onLoaded: onLoaded, + fit: BoxFit.contain, + backgroundColor: Colors.black, + maxSize: false, + radius: 0.0, + thumbnailOnly: false, + ), + ), minScale: 1.0, maxScale: 10.0, - child: ImageBubble( - event, - tapToView: false, - onLoaded: onLoaded, - fit: BoxFit.contain, - backgroundColor: Colors.black, - maxSize: false, - radius: 0.0, - thumbnailOnly: false, - ), + onInteractionEnd: (ScaleEndDetails endDetails) { + if (PlatformInfos.usesTouchscreen == false) { + if (endDetails.velocity.pixelsPerSecond.dy > calcVelocity) { + Navigator.of(context).pop(); + } + } + }, ), ); }