Skip to content

Commit

Permalink
Update background color for file tile
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdat committed Oct 16, 2024
1 parent 9a946b1 commit 720a9da
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ class MessageContentWithTimestampBuilder extends StatelessWidget {
borderRadius: MessageStyle.bubbleBorderRadius,
color: event.isOwnMessage
? LinagoraRefColors.material().primary[95]
: LinagoraSysColors.material().onPrimary,
border: !event.isOwnMessage
: responsiveUtils.isMobile(context)
? LinagoraSysColors.material().onPrimary
: Theme.of(context)
.colorScheme
.surfaceContainerHighest,
border: !event.isOwnMessage && responsiveUtils.isMobile(context)
? Border.all(
color: MessageStyle.borderColorReceivedBubble,
)
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/chat/events/message_download_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class _MessageDownloadContentState extends State<MessageDownloadContent>
highlightText: widget.highlightText,
sizeString: sizeString,
style: const MessageFileTileStyle(),
ownMessage: event.isOwnMessage,
),
);
} else if (state is DownloadingPresentationState ||
Expand All @@ -72,6 +73,7 @@ class _MessageDownloadContentState extends State<MessageDownloadContent>
const NotDownloadPresentationState();
downloadManager.cancelDownload(widget.event.eventId);
},
ownMessage: event.isOwnMessage,
hasError: state is DownloadErrorPresentationState,
);
}
Expand All @@ -85,6 +87,7 @@ class _MessageDownloadContentState extends State<MessageDownloadContent>
highlightText: widget.highlightText,
sizeString: sizeString,
downloadFileStateNotifier: downloadFileStateNotifier,
ownMessage: event.isOwnMessage,
style: const MessageFileTileStyle(),
),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/chat/events/message_download_content_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class _MessageDownloadContentWebState extends State<MessageDownloadContentWeb>
const NotDownloadPresentationState();
downloadManager.cancelDownload(widget.event.eventId);
},
ownMessage: event.isOwnMessage,
hasError: state is DownloadErrorPresentationState,
);
} else if (state is FileWebDownloadedPresentationState) {
Expand All @@ -101,6 +102,7 @@ class _MessageDownloadContentWebState extends State<MessageDownloadContentWeb>
highlightText: widget.highlightText,
sizeString: sizeString,
style: const MessageFileTileStyle(),
ownMessage: event.isOwnMessage,
),
);
}
Expand All @@ -114,6 +116,7 @@ class _MessageDownloadContentWebState extends State<MessageDownloadContentWeb>
highlightText: widget.highlightText,
sizeString: sizeString,
style: const MessageFileTileStyle(),
ownMessage: event.isOwnMessage,
),
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat/events/message_upload_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _MessageUploadingContentState extends State<MessageUploadingContent>
return Container(
padding: widget.style.paddingFileTileAll,
decoration: ShapeDecoration(
color: widget.style.backgroundColor,
color: widget.style.backgroundColor(context, ownMessage: event.isOwnMessage),
shape: RoundedRectangleBorder(
borderRadius: widget.style.borderRadius,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class ChatDetailsFileTileStyle extends FileTileWidgetStyle {
static const double textTopMargin = 4.0;

@override
Color get backgroundColor => Colors.transparent;
Color backgroundColor(BuildContext context, {bool ownMessage = false}) {
return Colors.transparent;
}

@override
BorderRadiusGeometry get borderRadius => BorderRadius.circular(8);
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/file_widget/base_file_tile_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class BaseFileTileWidget extends StatelessWidget {
this.fileTileIcon,
this.imageBytes,
this.style = const FileTileWidgetStyle(),
this.ownMessage = false,
required this.subTitle,
});

Expand All @@ -31,13 +32,14 @@ class BaseFileTileWidget extends StatelessWidget {
final String? fileTileIcon;
final FileTileWidgetStyle style;
final Widget Function(BuildContext) subTitle;
final bool ownMessage;

@override
Widget build(BuildContext context) {
return Container(
padding: style.paddingFileTileAll,
decoration: ShapeDecoration(
color: backgroundColor ?? style.backgroundColor,
color: backgroundColor ?? style.backgroundColor(context, ownMessage: ownMessage),
shape: RoundedRectangleBorder(
borderRadius: style.borderRadius,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/file_widget/download_file_tile_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DownloadFileTileWidget extends StatelessWidget {
this.sizeString,
required this.downloadFileStateNotifier,
this.onCancelDownload,
this.ownMessage = false,
this.hasError = false,
});

Expand All @@ -29,13 +30,14 @@ class DownloadFileTileWidget extends StatelessWidget {
final ValueNotifier<DownloadPresentationState> downloadFileStateNotifier;
final VoidCallback? onCancelDownload;
final bool hasError;
final bool ownMessage;

@override
Widget build(BuildContext context) {
return Container(
padding: style.paddingFileTileAll,
decoration: ShapeDecoration(
color: style.backgroundColor,
color: style.backgroundColor(context, ownMessage: ownMessage),
shape: RoundedRectangleBorder(
borderRadius: style.borderRadius,
),
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/file_widget/downloading_file_tile_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DownloadingFileTileWidget extends StatelessWidget {
this.fileType,
this.sizeString,
required this.downloadFileStateNotifier,
this.ownMessage = false,
this.onCancelDownload,
});

Expand All @@ -27,13 +28,14 @@ class DownloadingFileTileWidget extends StatelessWidget {
final String? fileType;
final ValueNotifier<DownloadPresentationState> downloadFileStateNotifier;
final VoidCallback? onCancelDownload;
final bool ownMessage;

@override
Widget build(BuildContext context) {
return Container(
padding: style.paddingFileTileAll,
decoration: ShapeDecoration(
color: style.backgroundColor,
color: style.backgroundColor(context, ownMessage: ownMessage),
shape: RoundedRectangleBorder(
borderRadius: style.borderRadius,
),
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/file_widget/file_tile_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FileTileWidget extends BaseFileTileWidget {
super.fileTileIcon,
super.imageBytes,
super.style = const FileTileWidgetStyle(),
super.ownMessage = false,
}) : super(
subTitle: (context) => Row(
children: [
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/file_widget/file_tile_widget_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class FileTileWidgetStyle {
EdgeInsets get paddingFileTileAll =>
const EdgeInsets.only(left: 8.0, right: 16.0);

Color get backgroundColor =>
LinagoraSysColors.material().surfaceTint.withOpacity(0.08);
Color backgroundColor(BuildContext context, {bool ownMessage = false}) => ownMessage
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.onSurface.withOpacity(0.08);

BorderRadiusGeometry get borderRadius => BorderRadius.circular(12);

Expand Down

0 comments on commit 720a9da

Please sign in to comment.