fix: replace image zoom packages

This commit is contained in:
Matyáš Caras 2023-04-03 15:48:07 +02:00
parent 9f1f6ad0ff
commit 27dbbb9221
3 changed files with 41 additions and 12 deletions

View file

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:html/parser.dart'; import 'package:html/parser.dart';
@ -7,7 +9,7 @@ import 'package:voyagehandbook/api/classes.dart';
import 'package:voyagehandbook/util/styles.dart'; import 'package:voyagehandbook/util/styles.dart';
import 'package:voyagehandbook/util/widgets/warning.dart'; import 'package:voyagehandbook/util/widgets/warning.dart';
import 'package:html_unescape/html_unescape_small.dart'; import 'package:html_unescape/html_unescape_small.dart';
import 'package:zoom_pinch_overlay/zoom_pinch_overlay.dart'; import 'package:widget_zoom/widget_zoom.dart';
/* /*
Voyage Handbook - The open-source WikiVoyage reader Voyage Handbook - The open-source WikiVoyage reader
@ -275,6 +277,32 @@ class PageRenderer {
height: 10, height: 10,
), ),
); );
} else if (element.id == "thumbinner") {
var imgs = element.getElementsByTagName("img");
if (imgs.isEmpty) break;
var img = imgs[0];
var cap = element.getElementsByClassName("thumbcaption")[0];
out.add(const SizedBox(
height: 10,
));
out.add(
SizedBox(
width: width * 0.8,
height: height * 0.3,
child: WidgetZoom(
zoomWidget:
CachedNetworkImage(imageUrl: img.attributes["src"]!),
heroAnimationTag: 'tag',
),
),
);
out.add(const SizedBox(
height: 3,
));
out.add(Text(cap.text));
out.add(const SizedBox(
height: 10,
));
} }
break; break;
default: default:
@ -312,8 +340,9 @@ class PageRenderer {
// TODO: open wikimedia page? // TODO: open wikimedia page?
width: width * 0.8, width: width * 0.8,
height: height * 0.3, height: height * 0.3,
child: ZoomOverlay( child: WidgetZoom(
child: CachedNetworkImage( heroAnimationTag: 'img${Random().nextInt(999)}',
zoomWidget: CachedNetworkImage(
imageUrl: img.attributes["src"]!.replaceAll("//", "https://"), imageUrl: img.attributes["src"]!.replaceAll("//", "https://"),
progressIndicatorBuilder: (context, url, downloadProgress) => progressIndicatorBuilder: (context, url, downloadProgress) =>
LinearProgressIndicator(value: downloadProgress.progress), LinearProgressIndicator(value: downloadProgress.progress),

View file

@ -909,6 +909,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.0" version: "2.3.0"
widget_zoom:
dependency: "direct main"
description:
name: widget_zoom
sha256: f7c7352b5ea1f08e9419edddd938852239ad4c94ee70d29b5b5f142b04cb8eca
url: "https://pub.dev"
source: hosted
version: "0.0.1"
win32: win32:
dependency: transitive dependency: transitive
description: description:
@ -941,14 +949,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
zoom_pinch_overlay:
dependency: "direct main"
description:
name: zoom_pinch_overlay
sha256: cad0aef0127953e3a2ad65aa51660e9c86fa11906e286297f9a70aab69163f64
url: "https://pub.dev"
source: hosted
version: "1.4.1+3"
sdks: sdks:
dart: ">=2.19.4 <3.0.0" dart: ">=2.19.4 <3.0.0"
flutter: ">=3.4.0-17.0.pre" flutter: ">=3.4.0-17.0.pre"

View file

@ -45,7 +45,7 @@ dependencies:
url_launcher: ^6.1.10 url_launcher: ^6.1.10
cached_network_image: ^3.2.3 cached_network_image: ^3.2.3
html_unescape: ^2.0.0 html_unescape: ^2.0.0
zoom_pinch_overlay: ^1.4.1+3 widget_zoom: ^0.0.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: