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.
This commit is contained in:
Avi0n 2021-01-18 06:56:02 +00:00 committed by Krille Fear
parent 3174fb6bdd
commit 70f96bfee8
1 changed files with 23 additions and 12 deletions

View File

@ -3,8 +3,8 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/image_bubble.dart'; import 'package:fluffychat/components/image_bubble.dart';
import 'package:fluffychat/components/matrix.dart'; import 'package:fluffychat/components/matrix.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import '../utils/event_extension.dart'; import '../utils/event_extension.dart';
import '../utils/platform_infos.dart';
class ImageView extends StatelessWidget { class ImageView extends StatelessWidget {
final Event event; final Event event;
@ -19,6 +19,8 @@ class ImageView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var calcVelocity = MediaQuery.of(context).size.height * 1.50;
return Scaffold( return Scaffold(
backgroundColor: Colors.black, backgroundColor: Colors.black,
extendBodyBehindAppBar: true, 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, minScale: 1.0,
maxScale: 10.0, maxScale: 10.0,
child: ImageBubble( onInteractionEnd: (ScaleEndDetails endDetails) {
event, if (PlatformInfos.usesTouchscreen == false) {
tapToView: false, if (endDetails.velocity.pixelsPerSecond.dy > calcVelocity) {
onLoaded: onLoaded, Navigator.of(context).pop();
fit: BoxFit.contain, }
backgroundColor: Colors.black, }
maxSize: false, },
radius: 0.0,
thumbnailOnly: false,
),
), ),
); );
} }