Commit 3047763e authored by Wilko Manger's avatar Wilko Manger

Rename info to bubble

parent 07f47e5d
......@@ -47,10 +47,10 @@ class _ImageContentState extends State<ImageContent> {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
assert(info.message.event is ImageMessageEvent);
final bubble = MessageBubble.of(context);
assert(bubble.message.event is ImageMessageEvent);
final event = info.message.event as ImageMessageEvent;
final event = bubble.message.event as ImageMessageEvent;
final height = (event.content.info?.height ??
0 / (event.content.info?.width ?? 0 / _width))
......@@ -59,12 +59,12 @@ class _ImageContentState extends State<ImageContent> {
return Container(
width: _width,
height: height,
decoration: BoxDecoration(borderRadius: info.borderRadius),
decoration: BoxDecoration(borderRadius: bubble.borderRadius),
child: Stack(
children: <Widget>[
Positioned.fill(
child: ClipRRect(
borderRadius: info.borderRadius,
borderRadius: bubble.borderRadius,
child: Hero(
tag: event.id,
child: CachedNetworkImage(
......@@ -74,8 +74,8 @@ class _ImageContentState extends State<ImageContent> {
),
),
),
if (info.isEndOfGroup) _MessageInfo(),
if (info.message.isMine && info.isStartOfGroup) _Sender(),
if (bubble.isEndOfGroup) _MessageInfo(),
if (bubble.message.isMine && bubble.isStartOfGroup) _Sender(),
Positioned.fill(
child: Clickable(
extraMaterial: true,
......@@ -91,21 +91,21 @@ class _ImageContentState extends State<ImageContent> {
class _MessageInfo extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
var alignment, borderRadius;
if (info.message.isMine) {
if (bubble.message.isMine) {
alignment = Alignment.bottomRight;
borderRadius = info.borderRadius;
borderRadius = bubble.borderRadius;
} else {
alignment = Alignment.bottomLeft;
borderRadius = BorderRadius.all(info.borderRadius.bottomLeft);
borderRadius = BorderRadius.all(bubble.borderRadius.bottomLeft);
}
return Align(
alignment: alignment,
child: Padding(
padding: info.contentPadding,
padding: bubble.contentPadding,
child: Container(
decoration: BoxDecoration(
borderRadius: borderRadius,
......@@ -115,7 +115,7 @@ class _MessageInfo extends StatelessWidget {
padding: EdgeInsets.all(4),
child: DefaultTextStyle(
style: DefaultTextStyle.of(context).style.copyWith(
color: !info.message.isMine ? Colors.white : null,
color: !bubble.message.isMine ? Colors.white : null,
),
child: MessageInfo(),
),
......@@ -129,15 +129,15 @@ class _MessageInfo extends StatelessWidget {
class _Sender extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
return Align(
alignment: Alignment.topLeft,
child: Padding(
padding: info.contentPadding,
padding: bubble.contentPadding,
child: Container(
decoration: BoxDecoration(
borderRadius: info.borderRadius,
borderRadius: bubble.borderRadius,
color: Color(0x64000000),
),
child: Padding(
......
......@@ -28,13 +28,13 @@ import '../../message.dart';
class RedactedContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
return Clickable(
child: Padding(
padding: info.contentPadding,
padding: bubble.contentPadding,
child: Column(
crossAxisAlignment: info.message.isMine
crossAxisAlignment: bubble.message.isMine
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: <Widget>[
......@@ -43,12 +43,13 @@ class RedactedContent extends StatelessWidget {
style: TextStyle(
color: themed(
context,
light:
info.message.isMine ? Colors.grey[300] : Colors.grey[700],
dark: info.message.isMine ? Colors.white30 : Colors.white70,
light: bubble.message.isMine
? Colors.grey[300]
: Colors.grey[700],
dark: bubble.message.isMine ? Colors.white30 : Colors.white70,
),
),
child: Redacted(event: info.message.event),
child: Redacted(event: bubble.message.event),
),
SizedBox(height: 4),
MessageInfo()
......
......@@ -33,18 +33,19 @@ class TextContent extends StatelessWidget {
static const _replyLeftPadding = 12.0;
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
final needsBorder = info.isReply && info.message.inReplyTo?.isMine == true;
final needsBorder =
bubble.isReply && bubble.message.inReplyTo?.isMine == true;
return Clickable(
child: CustomPaint(
painter: needsBorder
? _ReplyBorderPainter(
color: info.message.isMine
color: bubble.message.isMine
? Colors.white
: info.message.event.sender.getColor(context),
borderRadius: info.borderRadius,
: bubble.message.event.sender.getColor(context),
borderRadius: bubble.borderRadius,
)
: null,
child: Padding(
......@@ -52,7 +53,7 @@ class TextContent extends StatelessWidget {
left: needsBorder ? _replyLeftPadding : null,
),
child: Column(
crossAxisAlignment: info.message.isMine
crossAxisAlignment: bubble.message.isMine
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: <Widget>[
......@@ -62,10 +63,10 @@ class TextContent extends StatelessWidget {
// Only build the replied-to message if this itself
// is not a replied-to message (to prevent very long
// reply chains)
if (info.message.inReplyTo != null && info.isReply)
if (bubble.message.inReplyTo != null && bubble.isReply)
Padding(
padding: EdgeInsets.only(
top: !info.message.isMine ? 4 : 0,
top: !bubble.message.isMine ? 4 : 0,
bottom: _replyMargin,
),
child: Container() // TODO: REPLY
......@@ -84,9 +85,9 @@ class TextContent extends StatelessWidget {
class _Content extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
assert(info.message.event is TextMessageEvent);
final event = info.message.event as TextMessageEvent;
final bubble = MessageBubble.of(context);
assert(bubble.message.event is TextMessageEvent);
final event = bubble.message.event as TextMessageEvent;
final html = Html(
data: event.content.formattedBody ?? '',
......@@ -94,7 +95,7 @@ class _Content extends StatelessWidget {
fillWidth: false,
linkStyle: TextStyle(
decoration: TextDecoration.underline,
color: !info.message.isMine
color: !bubble.message.isMine
? themed(
context,
light: Theme.of(context).primaryColor,
......
......@@ -288,10 +288,10 @@ class Clickable extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
final inkWell = InkWell(
customBorder: RoundedRectangleBorder(borderRadius: info.borderRadius),
customBorder: RoundedRectangleBorder(borderRadius: bubble.borderRadius),
onTap: onTap ?? _showContextMenu,
child: child,
);
......@@ -315,9 +315,9 @@ class MessageInfo extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
if (!info.isEndOfGroup) {
if (!bubble.isEndOfGroup) {
return Container(width: 0, height: 0);
}
......@@ -326,18 +326,18 @@ class MessageInfo extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
if (info.message.isMine)
if (bubble.message.isMine)
Icon(
info.message.event.sentState != SentState.sent
bubble.message.event.sentState != SentState.sent
? Icons.access_time
: Icons.check,
color: Colors.white,
size: 14,
),
SizedBox(width: 4),
if (info.isEndOfGroup)
if (bubble.isEndOfGroup)
Text(
formatAsTime(info.message.event.time),
formatAsTime(bubble.message.event.time),
style: DefaultTextStyle.of(context).style.apply(
fontSizeFactor: 0.8,
),
......@@ -364,11 +364,11 @@ class Sender extends StatelessWidget {
@override
Widget build(BuildContext context) {
final info = MessageBubble.of(context);
final bubble = MessageBubble.of(context);
final showSender = (info.isStartOfGroup ||
(info.isReply != null && !info.message.isMine)) &&
!info.message.room.isDirect;
final showSender = (bubble.isStartOfGroup ||
(bubble.isReply != null && !bubble.message.isMine)) &&
!bubble.message.room.isDirect;
if (!showSender) {
return Container(width: 0, height: 0);
......@@ -377,11 +377,11 @@ class Sender extends StatelessWidget {
return Padding(
padding: padding,
child: Text(
info.message.event.sender.displayName,
bubble.message.event.sender.displayName,
style: TextStyle(
fontWeight: FontWeight.bold,
color: personalizedColor
? info.message.event.sender.getColor(context)
? bubble.message.event.sender.getColor(context)
: null,
),
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment