diff --git a/lib/ui/common/collectible_item.dart b/lib/ui/common/collectible_item.dart index c509ec4e..36a33026 100644 --- a/lib/ui/common/collectible_item.dart +++ b/lib/ui/common/collectible_item.dart @@ -8,7 +8,7 @@ import 'package:wonders/ui/screens/collectible_found/collectible_found_screen.da class CollectibleItem extends StatelessWidget with GetItMixin { CollectibleItem(this.collectible, {this.size = 64.0, Key? key}) : super(key: key) { // pre-fetch the image, so it's ready if we show the collectible found screen. - _imageProvider = NetworkImage(collectible.imageUrlSmall); + _imageProvider = NetworkImage(AppImage.maybeAddImgProxy(collectible.imageUrl)); _imageProvider.resolve(ImageConfiguration()).addListener(ImageStreamListener((_, __) {})); } diff --git a/lib/ui/common/controls/app_image.dart b/lib/ui/common/controls/app_image.dart index c3fc153a..2ce7537e 100644 --- a/lib/ui/common/controls/app_image.dart +++ b/lib/ui/common/controls/app_image.dart @@ -28,6 +28,14 @@ class AppImage extends StatefulWidget { final Color? color; final double? scale; + static String maybeAddImgProxy(String url) { + String proxyUrl = 'proxy.wonderous.app:8081/'; + if (!url.contains(proxyUrl) && (url.contains('images.metmuseum.org') || url.contains('img.youtube.com'))) { + url = 'https://$proxyUrl$url'; + } + return url; + } + @override State createState() => _AppImageState(); } @@ -54,18 +62,11 @@ class _AppImageState extends State { /// Apply proxy to MET api images if(kIsWeb && _sourceImage is NetworkImage){ final url = (_sourceImage as NetworkImage).url; - _sourceImage = NetworkImage(maybeAddMetProxy(url)); + _sourceImage = NetworkImage(AppImage.maybeAddImgProxy(url)); } _displayImage = _capImageSize(_addRetry(_sourceImage)); } - String maybeAddMetProxy(String url) { - if (url.contains('images.metmuseum.org')) { - url = 'https://proxy.wonderous.app:8081/$url'; - return url; - } - return url; - } @override Widget build(BuildContext context) { @@ -100,6 +101,8 @@ class _AppImageState extends State { } ImageProvider? _capImageSize(ImageProvider? image) { + // Disable resizing for web as it is currently single-threaded and causes the UI to lock up when resizing large images + if(kIsWeb) return image; // TODO: Remove this when the web engine is updated to support non-blocking image resizing if (image == null || widget.scale == null) return image; final MediaQueryData mq = MediaQuery.of(context); final Size screenSize = mq.size * mq.devicePixelRatio * widget.scale!; diff --git a/pubspec.lock b/pubspec.lock index 0f8283f3..98a82cd4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -308,10 +308,10 @@ packages: dependency: "direct main" description: name: google_maps_flutter - sha256: abefcb1e5e5c96bdd8084939dda555257af272c7972902ca46d5631092c1df68 + sha256: d4914cb38b3dcb62c39c085d968d434de0f8050f00f4d9f5ba4a7c7e004934cb url: "https://pub.dev" source: hosted - version: "2.2.8" + version: "2.5.0" google_maps_flutter_android: dependency: transitive description: @@ -340,10 +340,10 @@ packages: dependency: "direct main" description: name: google_maps_flutter_web - sha256: ed964ba9042472e851db5a6184d84c5ccb82c4c3729cff810bf6be1b0ac28e51 + sha256: f893d1542c6562bc8299ef768fbbe92ade83c220ab3209b9477ec9f81ad585e4 url: "https://pub.dev" source: hosted - version: "0.4.0+9" + version: "0.5.4+2" html: dependency: transitive description: @@ -822,13 +822,13 @@ packages: source: hosted version: "2.1.1" url_launcher: - dependency: transitive + dependency: "direct main" description: name: url_launcher - sha256: "781bd58a1eb16069412365c98597726cd8810ae27435f04b3b4d3a470bacd61e" + sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27" url: "https://pub.dev" source: hosted - version: "6.1.12" + version: "6.1.14" url_launcher_android: dependency: transitive description: @@ -1014,5 +1014,5 @@ packages: source: hosted version: "2.0.2" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=3.10.0" + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.13.0"