-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! TW-1650: reorganize image_builder folder
- Loading branch information
1 parent
dbc66fb
commit eef4d7b
Showing
5 changed files
with
97 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
lib/pages/chat/events/images_builder/image_placeholder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'package:fluffychat/config/app_config.dart'; | ||
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_blurhash/flutter_blurhash.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
|
||
class ImagePlaceholder extends StatelessWidget { | ||
const ImagePlaceholder({ | ||
super.key, | ||
required this.event, | ||
required this.width, | ||
required this.height, | ||
required this.fit, | ||
}); | ||
|
||
final Event event; | ||
final double width; | ||
final double height; | ||
final BoxFit fit; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (event.messageType == MessageTypes.Sticker) { | ||
return const Center( | ||
child: CircularProgressIndicator.adaptive(), | ||
); | ||
} | ||
final String blurHashString = | ||
event.blurHash ?? AppConfig.defaultImageBlurHash; | ||
final ratio = event.infoMap['w'] is int && event.infoMap['h'] is int | ||
? event.infoMap['w'] / event.infoMap['h'] | ||
: 1.0; | ||
var width = 32; | ||
var height = 32; | ||
if (ratio > 1.0) { | ||
height = (width / ratio).round(); | ||
} else { | ||
width = (height * ratio).round(); | ||
} | ||
return ClipRRect( | ||
borderRadius: BorderRadius.zero, | ||
child: SizedBox( | ||
width: this.width, | ||
height: this.height, | ||
child: BlurHash( | ||
hash: blurHashString, | ||
decodingWidth: width, | ||
decodingHeight: height, | ||
imageFit: fit, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/pages/chat/events/images_builder/unencrypted_image_builder_web.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters