fix: Desktop images

This commit is contained in:
Christian Pauly 2020-10-04 16:11:18 +02:00
parent 4f419f65c7
commit 5409fe864b
9 changed files with 79 additions and 32 deletions

View File

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/string_color.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -41,7 +42,11 @@ class Avatar extends StatelessWidget {
onTap: onTap,
child: CircleAvatar(
radius: size / 2,
backgroundImage: !noPic ? CachedNetworkImageProvider(src) : null,
backgroundImage: !noPic
? PlatformInfos.isBetaDesktop
? NetworkImage(src)
: CachedNetworkImageProvider(src)
: null,
backgroundColor: noPic
? name?.lightColor ?? Theme.of(context).secondaryHeaderColor
: Theme.of(context).secondaryHeaderColor,

View File

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
@ -48,11 +49,17 @@ class ContentBanner extends StatelessWidget {
opacity: 0.75,
child: !loading
? mxContent != null
? CachedNetworkImage(
imageUrl: src,
height: 300,
fit: BoxFit.cover,
)
? PlatformInfos.isBetaDesktop
? Image.network(
src,
height: 300,
fit: BoxFit.cover,
)
: CachedNetworkImage(
imageUrl: src,
height: 300,
fit: BoxFit.cover,
)
: Icon(defaultIcon, size: 300)
: Icon(defaultIcon, size: 300),
),

View File

@ -1,5 +1,6 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/views/image_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
@ -121,15 +122,22 @@ class _ImageBubbleState extends State<ImageBubble> {
fit: widget.fit,
);
} else if (isUnencrypted) {
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,
);
final src = Uri.parse(widget.event.content['url']).getThumbnail(
widget.event.room.client,
width: 800,
height: 800,
method: ThumbnailMethod.scale);
renderWidget = PlatformInfos.isBetaDesktop
? Image.network(
src,
fit: widget.fit,
)
: CachedNetworkImage(
imageUrl: src,
placeholder: (context, url) =>
generatePlaceholderWidget(),
fit: widget.fit,
);
} else {
renderWidget = generatePlaceholderWidget();
}

View File

@ -1,3 +1,4 @@
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:famedlysdk/famedlysdk.dart';
@ -146,11 +147,17 @@ class InputBar extends StatelessWidget {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
CachedNetworkImage(
imageUrl: url,
width: size,
height: size,
),
PlatformInfos.isBetaDesktop
? Image.network(
url,
width: size,
height: size,
)
: CachedNetworkImage(
imageUrl: url,
width: size,
height: size,
),
SizedBox(width: 6),
Text(suggestion['name']),
Expanded(

View File

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
@ -92,10 +93,15 @@ class _Reaction extends StatelessWidget {
content = Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CachedNetworkImage(
imageUrl: src,
height: fontSize,
),
PlatformInfos.isBetaDesktop
? Image.network(
src,
height: fontSize,
)
: CachedNetworkImage(
imageUrl: src,
height: fontSize,
),
Container(width: 4),
Text(count.toString(),
style: TextStyle(

View File

@ -4,6 +4,12 @@ import 'package:flutter/foundation.dart';
abstract class PlatformInfos {
static bool get isWeb => kIsWeb;
static bool get isMobile => !kIsWeb && (Platform.isAndroid || Platform.isIOS);
/// For desktops which don't support ChachedNetworkImage yet
static bool get isBetaDesktop =>
!kIsWeb && (Platform.isWindows || Platform.isLinux);
static bool get usesTouchscreen => !isMobile;
}

View File

@ -1,6 +1,7 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -415,12 +416,19 @@ class _EmoteImage extends StatelessWidget {
height: size * devicePixelRatio,
method: ThumbnailMethod.scale,
);
return CachedNetworkImage(
imageUrl: url,
fit: BoxFit.contain,
width: size,
height: size,
);
return PlatformInfos.isBetaDesktop
? Image.network(
url,
fit: BoxFit.contain,
width: size,
height: size,
)
: CachedNetworkImage(
imageUrl: url,
fit: BoxFit.contain,
width: size,
height: size,
);
}
}

View File

@ -1053,5 +1053,5 @@ packages:
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.0-110 <2.11.0"
dart: ">=2.10.0-110 <=2.11.0-161.0.dev"
flutter: ">=1.20.0 <2.0.0"

View File

@ -33,7 +33,7 @@ dependencies:
memoryfilepicker: ^0.1.3
url_launcher: ^5.4.1
url_launcher_web: ^0.1.0
cached_network_image: ^2.3.1
cached_network_image: ^2.3.2+1
firebase_messaging: ^7.0.2
flutter_local_notifications: ^1.4.3
matrix_link_text: ^0.1.5