refactor: use ProxyImg widget

This commit is contained in:
2025-05-16 12:22:31 +01:00
parent 244a0aad38
commit dcf42e7a78
8 changed files with 73 additions and 63 deletions

View File

@ -23,17 +23,13 @@ class AvatarWidget extends StatelessWidget {
Widget build(BuildContext context) {
final thisSize = size ?? 40;
return ClipOval(
child: CachedNetworkImage(
fit: BoxFit.cover,
imageUrl: proxyImg(
context,
profile.picture ??
"https://nostr.api.v0l.io/api/v1/avatar/cyberpunks/${profile.pubKey}",
resize: thisSize.ceil(),
),
height: thisSize,
child: ProxyImg(
url:
profile.picture ??
"https://nostr.api.v0l.io/api/v1/avatar/cyberpunks/${profile.pubKey}",
resize: thisSize.ceil(),
width: thisSize,
errorWidget: (context, url, error) => Icon(Icons.error),
height: thisSize,
),
);
}

View File

@ -1,4 +1,3 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:collection/collection.dart';
import 'package:flutter/widgets.dart';
import 'package:zap_stream_flutter/imgproxy.dart';
@ -27,11 +26,7 @@ class CustomEmoji extends StatelessWidget {
(t) => t[0] == "emoji" && t[1] == cleanedEmojiName,
)?[2];
if (customEmoji != null) {
return CachedNetworkImage(
imageUrl: proxyImg(context, customEmoji),
height: size ?? 16,
width: size ?? 16,
);
return ProxyImg(url: customEmoji, width: size ?? 16, height: size ?? 16);
} else {
return Text(emoji);
}

View File

@ -77,16 +77,9 @@ class StreamCardsWidget extends StatelessWidget {
onTap: () {
launchUrl(Uri.parse(link));
},
child: CachedNetworkImage(
imageUrl: proxyImg(context, image!),
errorWidget:
(_, _, _) => SvgPicture.asset(
"assets/svg/logo.svg",
height: 40,
),
),
child: ProxyImg(url: link, placeholderSize: 40),
)
: CachedNetworkImage(imageUrl: proxyImg(context, image!)),
: ProxyImg(url: link, placeholderSize: 40),
),
MarkdownBody(
data: card.content,

View File

@ -31,22 +31,7 @@ class StreamTileWidget extends StatelessWidget {
aspectRatio: 16 / 9,
child: Stack(
children: [
Center(
child: CachedNetworkImage(
imageUrl: proxyImg(context, stream.info.image ?? ""),
fit: BoxFit.cover,
placeholder:
(ctx, url) => SvgPicture.asset(
"assets/svg/logo.svg",
height: 100,
),
errorWidget:
(context, url, error) => SvgPicture.asset(
"assets/svg/logo.svg",
height: 100,
),
),
),
Center(child: ProxyImg(url: stream.info.image ?? "", placeholderSize: 100,)),
if (stream.info.status != null)
Positioned(
right: 8,