@@ -7,7 +7,6 @@ import 'package:flutter/rendering.dart';
77import 'package:html/dom.dart' as dom;
88import 'package:intl/intl.dart' as intl;
99
10- import '../api/core.dart' ;
1110import '../api/model/model.dart' ;
1211import '../generated/l10n/zulip_localizations.dart' ;
1312import '../model/content.dart' ;
@@ -16,6 +15,7 @@ import 'actions.dart';
1615import 'code_block.dart' ;
1716import 'dialog.dart' ;
1817import 'icons.dart' ;
18+ import 'image.dart' ;
1919import 'inset_shadow.dart' ;
2020import 'katex.dart' ;
2121import 'lightbox.dart' ;
@@ -1447,111 +1447,6 @@ void _launchUrl(BuildContext context, String urlString) async {
14471447 }
14481448}
14491449
1450- /// Like [Image.network] , but includes [authHeader] if [src] is on-realm.
1451- ///
1452- /// Use this to present image content in the ambient realm: avatars, images in
1453- /// messages, etc. Must have a [PerAccountStoreWidget] ancestor.
1454- ///
1455- /// If [src] is an on-realm URL (it has the same origin as the ambient
1456- /// [Auth.realmUrl] ), then an HTTP request to fetch the image will include the
1457- /// user's [authHeader] .
1458- ///
1459- /// If [src] is off-realm (e.g., a Gravatar URL), no auth header will be sent.
1460- ///
1461- /// The image will be cached according to the cache behavior of [Image.network] ,
1462- /// which may mean the cache is shared between realms.
1463- class RealmContentNetworkImage extends StatelessWidget {
1464- const RealmContentNetworkImage (
1465- this .src, {
1466- super .key,
1467- this .scale = 1.0 ,
1468- this .frameBuilder,
1469- this .loadingBuilder,
1470- this .errorBuilder,
1471- this .semanticLabel,
1472- this .excludeFromSemantics = false ,
1473- this .width,
1474- this .height,
1475- this .color,
1476- this .opacity,
1477- this .colorBlendMode,
1478- this .fit,
1479- this .alignment = Alignment .center,
1480- this .repeat = ImageRepeat .noRepeat,
1481- this .centerSlice,
1482- this .matchTextDirection = false ,
1483- this .gaplessPlayback = false ,
1484- this .filterQuality = FilterQuality .low,
1485- this .isAntiAlias = false ,
1486- // `headers` skipped
1487- this .cacheWidth,
1488- this .cacheHeight,
1489- });
1490-
1491- final Uri src;
1492-
1493- final double scale;
1494- final ImageFrameBuilder ? frameBuilder;
1495- final ImageLoadingBuilder ? loadingBuilder;
1496- final ImageErrorWidgetBuilder ? errorBuilder;
1497- final String ? semanticLabel;
1498- final bool excludeFromSemantics;
1499- final double ? width;
1500- final double ? height;
1501- final Color ? color;
1502- final Animation <double >? opacity;
1503- final BlendMode ? colorBlendMode;
1504- final BoxFit ? fit;
1505- final AlignmentGeometry alignment;
1506- final ImageRepeat repeat;
1507- final Rect ? centerSlice;
1508- final bool matchTextDirection;
1509- final bool gaplessPlayback;
1510- final FilterQuality filterQuality;
1511- final bool isAntiAlias;
1512- // `headers` skipped
1513- final int ? cacheWidth;
1514- final int ? cacheHeight;
1515-
1516- @override
1517- Widget build (BuildContext context) {
1518- final account = PerAccountStoreWidget .of (context).account;
1519-
1520- return Image .network (
1521- src.toString (),
1522-
1523- scale: scale,
1524- frameBuilder: frameBuilder,
1525- loadingBuilder: loadingBuilder,
1526- errorBuilder: errorBuilder,
1527- semanticLabel: semanticLabel,
1528- excludeFromSemantics: excludeFromSemantics,
1529- width: width,
1530- height: height,
1531- color: color,
1532- opacity: opacity,
1533- colorBlendMode: colorBlendMode,
1534- fit: fit,
1535- alignment: alignment,
1536- repeat: repeat,
1537- centerSlice: centerSlice,
1538- matchTextDirection: matchTextDirection,
1539- gaplessPlayback: gaplessPlayback,
1540- filterQuality: filterQuality,
1541- isAntiAlias: isAntiAlias,
1542- headers: {
1543- // Only send the auth header to the server `auth` belongs to.
1544- if (src.origin == account.realmUrl.origin) ...authHeader (
1545- email: account.email, apiKey: account.apiKey,
1546- ),
1547- ...userAgentHeader (),
1548- },
1549- cacheWidth: cacheWidth,
1550- cacheHeight: cacheHeight,
1551- );
1552- }
1553- }
1554-
15551450//
15561451// Small helpers.
15571452//
0 commit comments