mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-22 05:22:34 +01:00
feat: Tapping on stickers shows the sticker body
This commit is contained in:
parent
ab90755fdc
commit
3bc5979845
@ -24,6 +24,7 @@ class ImageBubble extends StatefulWidget {
|
|||||||
final double width;
|
final double width;
|
||||||
final double height;
|
final double height;
|
||||||
final void Function() onLoaded;
|
final void Function() onLoaded;
|
||||||
|
final void Function() onTap;
|
||||||
|
|
||||||
const ImageBubble(
|
const ImageBubble(
|
||||||
this.event, {
|
this.event, {
|
||||||
@ -36,6 +37,7 @@ class ImageBubble extends StatefulWidget {
|
|||||||
this.onLoaded,
|
this.onLoaded,
|
||||||
this.width = 400,
|
this.width = 400,
|
||||||
this.height = 300,
|
this.height = 300,
|
||||||
|
this.onTap,
|
||||||
Key key,
|
Key key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -386,6 +388,10 @@ class _ImageBubbleState extends State<ImageBubble> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onTap(BuildContext context) {
|
void onTap(BuildContext context) {
|
||||||
|
if (widget.onTap != null) {
|
||||||
|
widget.onTap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!widget.tapToView) return;
|
if (!widget.tapToView) return;
|
||||||
showDialog(
|
showDialog(
|
||||||
context: Matrix.of(context).navigatorContext,
|
context: Matrix.of(context).navigatorContext,
|
||||||
|
@ -6,6 +6,7 @@ import 'package:fluffychat/widgets/event_content/image_bubble.dart';
|
|||||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
|
||||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
||||||
import 'package:fluffychat/pages/key_verification_dialog.dart';
|
import 'package:fluffychat/pages/key_verification_dialog.dart';
|
||||||
|
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
@ -76,13 +77,19 @@ class MessageContent extends StatelessWidget {
|
|||||||
case EventTypes.Sticker:
|
case EventTypes.Sticker:
|
||||||
switch (event.messageType) {
|
switch (event.messageType) {
|
||||||
case MessageTypes.Image:
|
case MessageTypes.Image:
|
||||||
|
if (event.showThumbnail) {
|
||||||
|
return ImageBubble(
|
||||||
|
event,
|
||||||
|
width: 400,
|
||||||
|
height: 300,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return MessageDownloadContent(event, textColor);
|
||||||
case MessageTypes.Sticker:
|
case MessageTypes.Sticker:
|
||||||
if (event.showThumbnail) {
|
if (event.showThumbnail) {
|
||||||
// normal images should have a ratio of 4:3
|
|
||||||
var ratio = 4.0 / 3.0;
|
|
||||||
if (event.messageType == MessageTypes.Sticker) {
|
|
||||||
// stickers should default to a ratio of 1:1
|
// stickers should default to a ratio of 1:1
|
||||||
ratio = 1.0;
|
var ratio = 1.0;
|
||||||
// if a width and a height is specified for stickers, use those!
|
// if a width and a height is specified for stickers, use those!
|
||||||
if (event.infoMap['w'] is int && event.infoMap['h'] is int) {
|
if (event.infoMap['w'] is int && event.infoMap['h'] is int) {
|
||||||
ratio = event.infoMap['w'] / event.infoMap['h'];
|
ratio = event.infoMap['w'] / event.infoMap['h'];
|
||||||
@ -94,14 +101,16 @@ class MessageContent extends StatelessWidget {
|
|||||||
ratio = 0.9;
|
ratio = 0.9;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ImageBubble(
|
return ImageBubble(
|
||||||
event,
|
event,
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 400 / ratio,
|
height: 400 / ratio,
|
||||||
fit: event.messageType == MessageTypes.Sticker && ratio <= 1.0
|
fit: ratio <= 1.0 ? BoxFit.contain : BoxFit.cover,
|
||||||
? BoxFit.contain
|
onTap: () => showOkAlertDialog(
|
||||||
: BoxFit.cover,
|
context: context,
|
||||||
|
message: event.body,
|
||||||
|
okLabel: L10n.of(context).ok,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return MessageDownloadContent(event, textColor);
|
return MessageDownloadContent(event, textColor);
|
||||||
|
Loading…
Reference in New Issue
Block a user