videoPlaceholder method

dynamic videoPlaceholder(
  1. dynamic context,
  2. String roomId,
  3. dynamic mediaState,
  4. dynamic ref,
)

Implementation

Widget videoPlaceholder(
  BuildContext context,
  String roomId,
  MediaChatState mediaState,
  WidgetRef ref,
) {
  return InkWell(
    onTap: () async {
      if (mediaState.mediaFile != null) {
        showAdaptiveDialog(
          context: context,
          barrierDismissible: false,
          useRootNavigator: false,
          builder: (context) => VideoDialog(
            title: message.name,
            videoFile: mediaState.mediaFile!,
          ),
        );
      } else {
        await ref
            .read(
              mediaChatStateProvider(
                (messageId: message.remoteId ?? message.id, roomId: roomId),
              ).notifier,
            )
            .downloadMedia();
      }
    },
    child: SizedBox(
      width: 200,
      height: 150,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          const Icon(
            Icons.download,
            size: 28,
          ),
          const SizedBox(height: 8),
          Container(
            decoration: BoxDecoration(
              color: Theme.of(context).colorScheme.surface,
              borderRadius: BorderRadius.circular(8),
            ),
            padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
            child: Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                const Icon(
                  Icons.video_library_rounded,
                  size: 18,
                ),
                const SizedBox(width: 5),
                Text(
                  formatBytes(message.size.truncate()),
                  style: Theme.of(context).textTheme.bodySmall,
                ),
              ],
            ),
          ),
        ],
      ),
    ),
  );
}