From bbca0c2beea0c3804d3c0a046afdb81a428e34f2 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Mon, 7 Sep 2020 17:08:01 +0200 Subject: [PATCH] chore: switch to cached_network_image --- lib/components/avatar.dart | 9 ++----- lib/components/content_banner.dart | 9 +++---- lib/components/image_bubble.dart | 20 +++++++--------- lib/components/input_bar.dart | 6 ++--- lib/components/message_reactions.dart | 11 ++++----- lib/views/image_view.dart | 4 ++-- lib/views/settings_emotes.dart | 9 +++---- pubspec.lock | 34 ++------------------------- pubspec.yaml | 8 ++----- 9 files changed, 29 insertions(+), 81 deletions(-) diff --git a/lib/components/avatar.dart b/lib/components/avatar.dart index c3d55a57..1d450b64 100644 --- a/lib/components/avatar.dart +++ b/lib/components/avatar.dart @@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/utils/string_color.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_advanced_networkimage/provider.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'matrix.dart'; @@ -41,12 +41,7 @@ class Avatar extends StatelessWidget { onTap: onTap, child: CircleAvatar( radius: size / 2, - backgroundImage: !noPic - ? AdvancedNetworkImage( - src, - useDiskCache: !kIsWeb, - ) - : null, + backgroundImage: !noPic ? CachedNetworkImageProvider(src) : null, backgroundColor: noPic ? name?.lightColor ?? Theme.of(context).secondaryHeaderColor : Theme.of(context).secondaryHeaderColor, diff --git a/lib/components/content_banner.dart b/lib/components/content_banner.dart index 43425343..40eefde7 100644 --- a/lib/components/content_banner.dart +++ b/lib/components/content_banner.dart @@ -1,7 +1,7 @@ import 'package:famedlysdk/famedlysdk.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_advanced_networkimage/provider.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'matrix.dart'; @@ -48,13 +48,10 @@ class ContentBanner extends StatelessWidget { opacity: 0.75, child: !loading ? mxContent != null - ? Image( + ? CachedNetworkImage( + imageUrl: src, height: 300, fit: BoxFit.cover, - image: AdvancedNetworkImage( - src, - useDiskCache: !kIsWeb, - ), ) : Icon(defaultIcon, size: 300) : Icon(defaultIcon, size: 300), diff --git a/lib/components/image_bubble.dart b/lib/components/image_bubble.dart index d6dbeb20..9c4444d2 100644 --- a/lib/components/image_bubble.dart +++ b/lib/components/image_bubble.dart @@ -5,8 +5,7 @@ import 'package:fluffychat/views/image_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_blurhash/flutter_blurhash.dart'; -import 'package:flutter_advanced_networkimage/provider.dart'; -import 'package:flutter_advanced_networkimage/transition.dart'; +import 'package:cached_network_image/cached_network_image.dart'; class ImageBubble extends StatefulWidget { final Event event; @@ -126,16 +125,13 @@ class _ImageBubbleState extends State { fit: widget.fit, ); } else if (isUnencrypted) { - renderWidget = TransitionToImage( - image: AdvancedNetworkImage( - Uri.parse(widget.event.content['url']).getThumbnail( - widget.event.room.client, - width: 800, - height: 800, - method: ThumbnailMethod.scale), - useDiskCache: !kIsWeb, - ), - loadingWidget: generatePlaceholderWidget(), + renderWidget = CachedNetworkImage( + imageUrl: Uri.parse(widget.event.content['url']).getThumbnail( + widget.event.room.client, + width: 800, + height: 800, + method: ThumbnailMethod.scale), + placeholder: (context, url) => generatePlaceholderWidget(), fit: widget.fit, ); } else { diff --git a/lib/components/input_bar.dart b/lib/components/input_bar.dart index dfb4b225..18107c7a 100644 --- a/lib/components/input_bar.dart +++ b/lib/components/input_bar.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; -import 'package:flutter_advanced_networkimage/provider.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'avatar.dart'; class InputBar extends StatelessWidget { @@ -146,8 +146,8 @@ class InputBar extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Image( - image: AdvancedNetworkImage(url, useDiskCache: !kIsWeb), + CachedNetworkImage( + imageUrl: url, width: size, height: size, ), diff --git a/lib/components/message_reactions.dart b/lib/components/message_reactions.dart index 8d4c5dd6..c6b65017 100644 --- a/lib/components/message_reactions.dart +++ b/lib/components/message_reactions.dart @@ -1,7 +1,6 @@ import 'package:famedlysdk/famedlysdk.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_advanced_networkimage/provider.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'matrix.dart'; @@ -89,13 +88,11 @@ class _Reaction extends StatelessWidget { content = Row( mainAxisSize: MainAxisSize.min, children: [ - Image( - image: AdvancedNetworkImage( - src, - useDiskCache: !kIsWeb, - ), + CachedNetworkImage( + imageUrl: src, height: fontSize, ), + Container(width: 4), Text(count.toString(), style: TextStyle( color: textColor, diff --git a/lib/views/image_view.dart b/lib/views/image_view.dart index dc067a54..72d2fbfb 100644 --- a/lib/views/image_view.dart +++ b/lib/views/image_view.dart @@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart'; import 'package:fluffychat/components/image_bubble.dart'; import 'package:fluffychat/components/matrix.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_advanced_networkimage/zoomable.dart'; +import 'package:photo_view/photo_view.dart'; import '../utils/event_extension.dart'; class ImageView extends StatelessWidget { @@ -41,7 +41,7 @@ class ImageView extends StatelessWidget { ), ], ), - body: ZoomableWidget( + body: PhotoView.customChild( minScale: 1.0, maxScale: 10.0, child: ImageBubble( diff --git a/lib/views/settings_emotes.dart b/lib/views/settings_emotes.dart index 73dbe2c2..d8cad917 100644 --- a/lib/views/settings_emotes.dart +++ b/lib/views/settings_emotes.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; -import 'package:flutter_advanced_networkimage/provider.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:famedlysdk/famedlysdk.dart'; import 'package:image_picker/image_picker.dart'; import 'package:bot_toast/bot_toast.dart'; @@ -329,11 +329,8 @@ class _EmoteImage extends StatelessWidget { height: size * devicePixelRatio, method: ThumbnailMethod.scale, ); - return Image( - image: AdvancedNetworkImage( - url, - useDiskCache: !kIsWeb, - ), + return CachedNetworkImage( + imageUrl: url, fit: BoxFit.contain, width: size, height: size, diff --git a/pubspec.lock b/pubspec.lock index 0d461ef4..2efd5067 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -79,7 +79,7 @@ packages: source: hosted version: "1.1.9+1" cached_network_image: - dependency: transitive + dependency: "direct main" description: name: cached_network_image url: "https://pub.dartlang.org" @@ -232,15 +232,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_advanced_networkimage: - dependency: "direct main" - description: - path: "." - ref: master - resolved-ref: f0f599fb89c494d9158fb6f13d4870582f8ecfcb - url: "https://github.com/mchome/flutter_advanced_networkimage" - source: git - version: "0.8.0" flutter_blurhash: dependency: "direct main" description: @@ -330,13 +321,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" - flutter_svg: - dependency: transitive - description: - name: flutter_svg - url: "https://pub.dartlang.org" - source: hosted - version: "0.18.0" flutter_test: dependency: "direct dev" description: flutter @@ -594,20 +578,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0-nullsafety" - path_drawing: - dependency: transitive - description: - name: path_drawing - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.1" - path_parsing: - dependency: transitive - description: - name: path_parsing - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.4" path_provider: dependency: "direct main" description: @@ -656,7 +626,7 @@ packages: name: photo_view url: "https://pub.dartlang.org" source: hosted - version: "0.9.2" + version: "0.10.2" platform: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 33b00970..108b13e1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,10 +34,7 @@ dependencies: memoryfilepicker: ^0.1.3 url_launcher: ^5.4.1 url_launcher_web: ^0.1.0 - flutter_advanced_networkimage: - git: - url: https://github.com/mchome/flutter_advanced_networkimage - ref: master + cached_network_image: ^2.3.1 firebase_messaging: ^6.0.13 flutter_local_notifications: ^1.4.3 matrix_link_text: ^0.1.5 @@ -49,7 +46,7 @@ dependencies: universal_html: ^1.1.12 receive_sharing_intent: ^1.3.3 flutter_slidable: ^0.5.4 - photo_view: ^0.9.2 + photo_view: ^0.10.2 flutter_sound: ^2.1.1 open_file: ^3.0.1 mime_type: ^0.3.0 @@ -71,7 +68,6 @@ dependencies: ref: master flutter_blurhash: ^0.5.0 - dev_dependencies: flutter_test: sdk: flutter