//@dart=2.12 import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart'; class MessageDownloadContent extends StatelessWidget { final Event event; final Color textColor; const MessageDownloadContent(this.event, this.textColor, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { final filename = event.content.tryGet('filename') ?? event.body; final filetype = (filename.contains('.') ? filename.split('.').last.toUpperCase() : event.content .tryGetMap('info') ?.tryGet('mimetype') ?.toUpperCase() ?? 'UNKNOWN'); final sizeString = event.sizeString; return InkWell( onTap: () => event.saveFile(context), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Row( children: [ Icon( Icons.file_download_outlined, color: Theme.of(context).colorScheme.secondary, ), const SizedBox(width: 8), Expanded( child: Text( filename, maxLines: 1, style: TextStyle( color: Theme.of(context).colorScheme.secondary, fontWeight: FontWeight.bold, ), ), ), ], ), const Divider(), Row( children: [ Text( filetype, style: TextStyle( color: textColor, ), ), const Spacer(), if (sizeString != null) Text( sizeString, style: TextStyle( color: textColor, ), ), ], ), ], ), ); } }