mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 10:25:11 +00:00
refactor: Sticker widget code
This commit is contained in:
parent
989c6146ce
commit
935e7215e4
3 changed files with 5 additions and 50 deletions
|
@ -90,7 +90,9 @@ class ImageBubble extends StatelessWidget {
|
||||||
fit: fit,
|
fit: fit,
|
||||||
animated: animated,
|
animated: animated,
|
||||||
isThumbnail: thumbnailOnly,
|
isThumbnail: thumbnailOnly,
|
||||||
placeholder: _buildPlaceholder,
|
placeholder: event.messageType == MessageTypes.Sticker
|
||||||
|
? null
|
||||||
|
: _buildPlaceholder,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -22,7 +22,6 @@ import 'html_message.dart';
|
||||||
import 'image_bubble.dart';
|
import 'image_bubble.dart';
|
||||||
import 'map_bubble.dart';
|
import 'map_bubble.dart';
|
||||||
import 'message_download_content.dart';
|
import 'message_download_content.dart';
|
||||||
import 'sticker.dart';
|
|
||||||
|
|
||||||
class MessageContent extends StatelessWidget {
|
class MessageContent extends StatelessWidget {
|
||||||
final Event event;
|
final Event event;
|
||||||
|
@ -108,6 +107,8 @@ class MessageContent extends StatelessWidget {
|
||||||
case EventTypes.Sticker:
|
case EventTypes.Sticker:
|
||||||
switch (event.messageType) {
|
switch (event.messageType) {
|
||||||
case MessageTypes.Image:
|
case MessageTypes.Image:
|
||||||
|
case MessageTypes.Sticker:
|
||||||
|
if (event.redacted) continue textmessage;
|
||||||
const maxSize = 256.0;
|
const maxSize = 256.0;
|
||||||
final w = event.content
|
final w = event.content
|
||||||
.tryGetMap<String, Object?>('info')
|
.tryGetMap<String, Object?>('info')
|
||||||
|
@ -132,12 +133,6 @@ class MessageContent extends StatelessWidget {
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
);
|
);
|
||||||
case MessageTypes.Sticker:
|
|
||||||
if (event.redacted) continue textmessage;
|
|
||||||
return Sticker(
|
|
||||||
event,
|
|
||||||
borderRadius: borderRadius,
|
|
||||||
);
|
|
||||||
case CuteEventContent.eventType:
|
case CuteEventContent.eventType:
|
||||||
return CuteContent(event);
|
return CuteContent(event);
|
||||||
case MessageTypes.Audio:
|
case MessageTypes.Audio:
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
||||||
import 'package:matrix/matrix.dart';
|
|
||||||
|
|
||||||
import '../../../config/app_config.dart';
|
|
||||||
import 'image_bubble.dart';
|
|
||||||
|
|
||||||
class Sticker extends StatefulWidget {
|
|
||||||
final Event event;
|
|
||||||
final BorderRadius borderRadius;
|
|
||||||
|
|
||||||
const Sticker(this.event, {required this.borderRadius, super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
StickerState createState() => StickerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class StickerState extends State<Sticker> {
|
|
||||||
bool? animated;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ImageBubble(
|
|
||||||
widget.event,
|
|
||||||
width: 256,
|
|
||||||
height: 256,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
borderRadius: widget.borderRadius,
|
|
||||||
onTap: () {
|
|
||||||
setState(() => animated = true);
|
|
||||||
showOkAlertDialog(
|
|
||||||
context: context,
|
|
||||||
message: widget.event.body,
|
|
||||||
okLabel: L10n.of(context)!.ok,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
animated: animated ?? AppConfig.autoplayImages,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue