Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ command:
stream_core_flutter:
git:
url: https://github.com/GetStream/stream-core-flutter.git
ref: 8057a775c2ed764dbd5cbabd2dd60d3cd68d2f08
ref: 492f6f4ef8c73c64b3f399f92c5e508b7fb39e55
path: packages/stream_core_flutter
synchronized: ^3.1.0+1
thumblr: ^0.0.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ extension StreamImagePickerX on StreamAttachmentPickerController {

extraDataMap['file_size'] = file.size!;

if (type == AssetType.video) {
extraDataMap['duration'] = asset.videoDuration.inSeconds;
}

final attachment = Attachment(
id: asset.id,
file: file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,11 @@ class StreamMediaAttachmentBuilder extends StatelessWidget {

@override
Widget build(BuildContext context) {
final durationSecs = attachment.extraData['duration'] as num?;
final videoDuration = durationSecs != null ? Duration(seconds: durationSecs.round()) : null;

final mediaBadge = attachment.type == AttachmentType.video
? const StreamMediaBadge(type: MediaBadgeType.video)
? StreamMediaBadge(type: MediaBadgeType.video, duration: videoDuration)
: null;

return Container(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,16 @@ class StreamPhotoGalleryTile extends StatelessWidget {
child: _GallerySelectedIndicator(selected: selected),
),
),
if (media.type == AssetType.video) ...[
if (media.type == AssetType.video)
Positioned(
left: 8,
bottom: 10,
child: Icon(context.streamIcons.videoSolid),
),
Positioned(
right: 4,
bottom: 10,
child: Text(
media.videoDuration.format(),
style: TextStyle(
color: chatThemeData.colorTheme.barsBg,
),
bottom: 8,
child: StreamMediaBadge(
type: MediaBadgeType.video,
duration: media.videoDuration,
durationFormat: MediaBadgeDurationFormat.exact,
),
),
],
// https://stackoverflow.com/a/59317162/10036882
Positioned.fill(
child: Material(
Expand Down Expand Up @@ -176,17 +169,6 @@ class _GallerySelectedIndicator extends StatelessWidget {
}
}

extension on Duration {
String format() {
final s = '$this'.split('.')[0].padLeft(8, '0');
if (s.startsWith('00:')) {
return s.replaceFirst('00:', '');
}

return s;
}
}

/// {@template mediaThumbnailProvider}
/// Builds a thumbnail using [ImageProvider].
/// {@endtemplate}
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies:
stream_core_flutter:
git:
url: https://github.com/GetStream/stream-core-flutter.git
ref: 8057a775c2ed764dbd5cbabd2dd60d3cd68d2f08
ref: 492f6f4ef8c73c64b3f399f92c5e508b7fb39e55
path: packages/stream_core_flutter
svg_icon_widget: ^0.0.1
synchronized: ^3.1.0+1
Expand Down
Loading