mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
Merge branch 'fix_775_room_avatar_flickers' into 'main'
Fix #775: Don't request new thumbnail resolution on every window resize Closes #775 See merge request famedly/fluffychat!798
This commit is contained in:
commit
a72b54d9ad
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
@ -27,17 +29,7 @@ class ContentBanner extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final mediaQuery = MediaQuery.of(context);
|
|
||||||
final bannerSize =
|
|
||||||
(mediaQuery.size.width * mediaQuery.devicePixelRatio).toInt();
|
|
||||||
final onEdit = this.onEdit;
|
final onEdit = this.onEdit;
|
||||||
final src = mxContent?.getThumbnail(
|
|
||||||
client ?? Matrix.of(context).client,
|
|
||||||
width: bannerSize,
|
|
||||||
height: bannerSize,
|
|
||||||
method: ThumbnailMethod.scale,
|
|
||||||
animated: true,
|
|
||||||
);
|
|
||||||
return Container(
|
return Container(
|
||||||
height: height,
|
height: height,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
@ -53,12 +45,29 @@ class ContentBanner extends StatelessWidget {
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: opacity,
|
opacity: opacity,
|
||||||
child: (!loading && src != null)
|
child: (!loading)
|
||||||
? CachedNetworkImage(
|
? LayoutBuilder(builder:
|
||||||
imageUrl: src.toString(),
|
(BuildContext context, BoxConstraints constraints) {
|
||||||
height: 300,
|
// #775 don't request new image resolution on every resize
|
||||||
fit: BoxFit.cover,
|
// by rounding up to the next multiple of stepSize
|
||||||
)
|
const stepSize = 300;
|
||||||
|
final bannerSize =
|
||||||
|
constraints.maxWidth * window.devicePixelRatio;
|
||||||
|
final steppedBannerSize =
|
||||||
|
(bannerSize / stepSize).ceil() * stepSize;
|
||||||
|
final src = mxContent?.getThumbnail(
|
||||||
|
client ?? Matrix.of(context).client,
|
||||||
|
width: steppedBannerSize,
|
||||||
|
height: steppedBannerSize,
|
||||||
|
method: ThumbnailMethod.scale,
|
||||||
|
animated: true,
|
||||||
|
);
|
||||||
|
return CachedNetworkImage(
|
||||||
|
imageUrl: src.toString(),
|
||||||
|
height: 300,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
);
|
||||||
|
})
|
||||||
: Icon(defaultIcon, size: 200),
|
: Icon(defaultIcon, size: 200),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user