From 1e8200a86a6a941254a8c5f7f17531d87ca8ea61 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Tue, 1 Dec 2020 15:17:10 +0100 Subject: [PATCH] fix deleted message borderradius --- lib/src/deleted_message.dart | 63 ++++++++++++++++++++++-------------- lib/src/message_widget.dart | 1 + 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/src/deleted_message.dart b/lib/src/deleted_message.dart index 673d79c8..9181d985 100644 --- a/lib/src/deleted_message.dart +++ b/lib/src/deleted_message.dart @@ -1,6 +1,7 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:stream_chat_flutter/src/stream_chat_theme.dart'; -import 'package:stream_chat_flutter/src/stream_svg_icon.dart'; class DeletedMessage extends StatelessWidget { const DeletedMessage({ @@ -9,6 +10,7 @@ class DeletedMessage extends StatelessWidget { this.borderRadiusGeometry, this.shape, this.borderSide, + this.reverse = false, }) : super(key: key); /// The theme of the message @@ -23,33 +25,44 @@ class DeletedMessage extends StatelessWidget { /// The borderside of the message text final BorderSide borderSide; + /// If true the widget will be mirrored + final bool reverse; + @override Widget build(BuildContext context) { - return Material( - color: messageTheme.messageBackgroundColor, - shape: shape ?? - RoundedRectangleBorder( - borderRadius: borderRadiusGeometry ?? BorderRadius.zero, - side: borderSide ?? - BorderSide( - color: Theme.of(context).brightness == Brightness.dark - ? Colors.white.withAlpha(24) - : Colors.black.withAlpha(24), - ), + return Transform( + transform: Matrix4.rotationY(reverse ? pi : 0), + alignment: Alignment.center, + child: Material( + color: messageTheme.messageBackgroundColor, + shape: shape ?? + RoundedRectangleBorder( + borderRadius: borderRadiusGeometry ?? BorderRadius.zero, + side: borderSide ?? + BorderSide( + color: Theme.of(context).brightness == Brightness.dark + ? Colors.white.withAlpha(24) + : Colors.black.withAlpha(24), + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 8.0, + horizontal: 16, ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 8.0, - horizontal: 16, - ), - child: Text( - 'Message deleted', - style: messageTheme.messageText.copyWith( - fontStyle: FontStyle.italic, - color: (Theme.of(context).brightness == Brightness.dark - ? Colors.white - : Colors.black) - .withOpacity(.5), + child: Transform( + transform: Matrix4.rotationY(reverse ? pi : 0), + alignment: Alignment.center, + child: Text( + 'Message deleted', + style: messageTheme.messageText.copyWith( + fontStyle: FontStyle.italic, + color: (Theme.of(context).brightness == Brightness.dark + ? Colors.white + : Colors.black) + .withOpacity(.5), + ), + ), ), ), ), diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 45f3c62e..88a93d6f 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -286,6 +286,7 @@ class _MessageWidgetState extends State { transform: Matrix4.rotationY( widget.reverse ? pi : 0), child: DeletedMessage( + reverse: widget.reverse, borderRadiusGeometry: widget.borderRadiusGeometry, borderSide: widget.borderSide,