feat: Display file description on all file events
This commit is contained in:
parent
a5dc6db4e8
commit
f68a9de6bf
7 changed files with 213 additions and 142 deletions
|
|
@ -11,7 +11,9 @@ import 'package:universal_html/html.dart' as html;
|
|||
import 'package:video_player/video_player.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/chat/events/html_message.dart';
|
||||
import 'package:fluffychat/pages/chat/events/image_bubble.dart';
|
||||
import 'package:fluffychat/utils/file_description.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
|
|
@ -20,7 +22,8 @@ import '../../../utils/error_reporter.dart';
|
|||
|
||||
class EventVideoPlayer extends StatefulWidget {
|
||||
final Event event;
|
||||
const EventVideoPlayer(this.event, {super.key});
|
||||
final Color? textColor;
|
||||
const EventVideoPlayer(this.event, {this.textColor, super.key});
|
||||
|
||||
@override
|
||||
EventVideoPlayerState createState() => EventVideoPlayerState();
|
||||
|
|
@ -102,51 +105,75 @@ class EventVideoPlayerState extends State<EventVideoPlayer> {
|
|||
final blurHash = (widget.event.infoMap as Map<String, dynamic>)
|
||||
.tryGet<String>('xyz.amorgan.blurhash') ??
|
||||
fallbackBlurHash;
|
||||
final fileDescription = widget.event.fileDescription;
|
||||
final textColor = widget.textColor;
|
||||
|
||||
const width = 300.0;
|
||||
|
||||
final chewieManager = _chewieManager;
|
||||
return Material(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
child: SizedBox(
|
||||
height: 300,
|
||||
child: chewieManager != null
|
||||
? Center(child: Chewie(controller: chewieManager))
|
||||
: Stack(
|
||||
children: [
|
||||
if (hasThumbnail)
|
||||
Center(
|
||||
child: ImageBubble(
|
||||
widget.event,
|
||||
tapToView: false,
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Material(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
child: SizedBox(
|
||||
height: width,
|
||||
child: chewieManager != null
|
||||
? Center(child: Chewie(controller: chewieManager))
|
||||
: Stack(
|
||||
children: [
|
||||
if (hasThumbnail)
|
||||
Center(
|
||||
child: ImageBubble(
|
||||
widget.event,
|
||||
tapToView: false,
|
||||
textColor: widget.textColor,
|
||||
),
|
||||
)
|
||||
else
|
||||
BlurHash(
|
||||
blurhash: blurHash,
|
||||
width: width,
|
||||
height: width,
|
||||
),
|
||||
Center(
|
||||
child: IconButton(
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.surface,
|
||||
),
|
||||
icon: _isDownloading
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.play_circle_outlined),
|
||||
tooltip: _isDownloading
|
||||
? L10n.of(context).loadingPleaseWait
|
||||
: L10n.of(context).videoWithSize(
|
||||
widget.event.sizeString ?? '?MB',
|
||||
),
|
||||
onPressed: _isDownloading ? null : _downloadAction,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
BlurHash(blurhash: blurHash, width: 300, height: 300),
|
||||
Center(
|
||||
child: IconButton(
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.surface,
|
||||
),
|
||||
icon: _isDownloading
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator.adaptive(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: const Icon(Icons.play_circle_outlined),
|
||||
tooltip: _isDownloading
|
||||
? L10n.of(context).loadingPleaseWait
|
||||
: L10n.of(context).videoWithSize(
|
||||
widget.event.sizeString ?? '?MB',
|
||||
),
|
||||
onPressed: _isDownloading ? null : _downloadAction,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (fileDescription != null && textColor != null)
|
||||
SizedBox(
|
||||
width: width,
|
||||
child: HtmlMessage(
|
||||
html: fileDescription,
|
||||
textColor: textColor,
|
||||
room: widget.event.room,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue