✨ Stickers auto resize
This commit is contained in:
parent
035b92d9b8
commit
98c3bb912d
@ -24,6 +24,10 @@ class MarkdownTextContent extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context) {
|
||||||
|
final emojiMatch = RegExp(r':([a-z0-9_+-]+):').allMatches(content);
|
||||||
|
final isOnlyEmoji =
|
||||||
|
content.replaceAll(RegExp(r':([a-z0-9_+-]+):'), '').trim().isEmpty;
|
||||||
|
|
||||||
return Markdown(
|
return Markdown(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
@ -79,14 +83,24 @@ class MarkdownTextContent extends StatelessWidget {
|
|||||||
imageBuilder: (uri, title, alt) {
|
imageBuilder: (uri, title, alt) {
|
||||||
var url = uri.toString();
|
var url = uri.toString();
|
||||||
double? width, height;
|
double? width, height;
|
||||||
|
BoxFit? fit;
|
||||||
if (url.startsWith('solink://')) {
|
if (url.startsWith('solink://')) {
|
||||||
final segments = url.replaceFirst('solink://', '').split('/');
|
final segments = url.replaceFirst('solink://', '').split('/');
|
||||||
switch (segments[0]) {
|
switch (segments[0]) {
|
||||||
case 'stickers':
|
case 'stickers':
|
||||||
final StickerProvider sticker = Get.find();
|
final StickerProvider sticker = Get.find();
|
||||||
url = sticker.aliasImageMapping[segments[1]]!;
|
url = sticker.aliasImageMapping[segments[1]]!;
|
||||||
|
if (emojiMatch.length <= 1 && isOnlyEmoji) {
|
||||||
|
width = 112;
|
||||||
|
height = 112;
|
||||||
|
} else if (emojiMatch.length <= 3 && isOnlyEmoji) {
|
||||||
|
width = 56;
|
||||||
|
height = 56;
|
||||||
|
} else {
|
||||||
width = 28;
|
width = 28;
|
||||||
height = 28;
|
height = 28;
|
||||||
|
}
|
||||||
|
fit = BoxFit.fill;
|
||||||
break;
|
break;
|
||||||
case 'attachments':
|
case 'attachments':
|
||||||
const radius = BorderRadius.all(Radius.circular(8));
|
const radius = BorderRadius.all(Radius.circular(8));
|
||||||
@ -105,8 +119,18 @@ class MarkdownTextContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return PlatformInfo.canCacheImage
|
return PlatformInfo.canCacheImage
|
||||||
? CachedNetworkImage(imageUrl: url, width: width, height: height)
|
? CachedNetworkImage(
|
||||||
: Image.network(url, width: width, height: height);
|
imageUrl: url,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
fit: fit,
|
||||||
|
)
|
||||||
|
: Image.network(
|
||||||
|
url,
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
fit: fit,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user