1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Fix files background color

This commit is contained in:
2021-03-11 00:23:11 +01:00
parent 75a80b1018
commit 0458d5431c
3 changed files with 41 additions and 19 deletions

View File

@ -11,9 +11,11 @@ const _AreaSize = 150.0;
class ConversationFileWidget extends StatefulWidget {
final int messageID;
final ConversationMessageFile file;
final Color defaultBackgroundColor;
const ConversationFileWidget({
Key key,
@required this.defaultBackgroundColor,
@required this.messageID,
@required this.file,
}) : assert(messageID != null),
@ -28,8 +30,11 @@ class _ConversationFileWidgetState extends State<ConversationFileWidget> {
ConversationMessageFile get file => widget.file;
@override
Widget build(BuildContext context) =>
Container(width: _AreaSize, height: _AreaSize, child: _buildContent());
Widget build(BuildContext context) => Container(
width: _AreaSize,
height: _AreaSize,
child: _buildContent(),
);
Widget _buildContent() {
switch (file.fileType) {
@ -45,20 +50,23 @@ class _ConversationFileWidgetState extends State<ConversationFileWidget> {
// The file is not downloadable, we open it in the browser
default:
return Center(
child: MaterialButton(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Spacer(flex: 2),
Icon(file.icon, color: Colors.white),
Spacer(),
Text(file.name, textAlign: TextAlign.center),
Spacer(flex: 2),
],
return Container(
color: widget.defaultBackgroundColor,
child: Center(
child: MaterialButton(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Spacer(flex: 2),
Icon(file.icon, color: Colors.white),
Spacer(),
Text(file.name, textAlign: TextAlign.center),
Spacer(flex: 2),
],
),
onPressed: () => launch(file.url),
),
onPressed: () => launch(file.url),
),
);
break;