mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Display messages images
This commit is contained in:
parent
6ab75bbacd
commit
afd999400e
@ -23,6 +23,9 @@ class ConversationMessage implements Comparable {
|
|||||||
assert(message != null);
|
assert(message != null);
|
||||||
|
|
||||||
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timeInsert * 1000);
|
DateTime get date => DateTime.fromMillisecondsSinceEpoch(timeInsert * 1000);
|
||||||
|
bool get hasMessage => message != null && message.length > 0;
|
||||||
|
bool get hasImage => imageURL != null;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int compareTo(other) {
|
int compareTo(other) {
|
||||||
|
@ -30,7 +30,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
/// Build account image
|
/// Build account image
|
||||||
Widget _buildAccountImage() {
|
Widget _buildAccountImage() {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.all(5.0),
|
margin: EdgeInsets.all(10.0),
|
||||||
child: Material(
|
child: Material(
|
||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: userInfo.accountImageURL,
|
imageUrl: userInfo.accountImageURL,
|
||||||
@ -46,6 +46,39 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Build widget image
|
||||||
|
Widget _buildMessageImage() {
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.only(bottom: 2),
|
||||||
|
child: Material(
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: message.imageURL,
|
||||||
|
width: 200.0,
|
||||||
|
height: 200.0,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
placeholder: (c, s) => Container(
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
color: Colors.lightBlueAccent,
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
errorWidget: (c, s, o) => Container(
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
color: Colors.red,
|
||||||
|
child: Center(
|
||||||
|
child: Icon(Icons.error, color: Colors.white,)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Build message date
|
/// Build message date
|
||||||
Widget _buildMessageDate() {
|
Widget _buildMessageDate() {
|
||||||
return isLastMessage
|
return isLastMessage
|
||||||
@ -63,7 +96,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
/// Build a message of the current user
|
/// Build a message of the current user
|
||||||
Widget _buildRightMessage() {
|
Widget _buildRightMessage() {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(right: 5.0, bottom: isLastMessage ? 20.0 : 10.0),
|
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 10.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -71,19 +104,33 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// Text message
|
Column(
|
||||||
Container(
|
children: <Widget>[
|
||||||
child: Text(
|
// Text image
|
||||||
message.message,
|
Container(
|
||||||
textAlign: TextAlign.justify,
|
child: message.hasImage ? _buildMessageImage() : null,
|
||||||
style: TextStyle(color: Colors.white),
|
),
|
||||||
),
|
|
||||||
padding: EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
|
// Text message
|
||||||
width: 200.0,
|
Container(
|
||||||
decoration: BoxDecoration(
|
child: message.hasMessage
|
||||||
color: Colors.blueAccent,
|
? Container(
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
child: Text(
|
||||||
),
|
message.message,
|
||||||
|
textAlign: TextAlign.justify,
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
padding:
|
||||||
|
EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
|
||||||
|
width: 200.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.blueAccent,
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
// Account image
|
// Account image
|
||||||
@ -107,13 +154,13 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
/// Build a message of a peer user
|
/// Build a message of a peer user
|
||||||
Widget _buildLeftMessage() {
|
Widget _buildLeftMessage() {
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(left: 10.0, bottom: isLastMessage ? 20.0 : 5.0),
|
margin: EdgeInsets.only(bottom: isLastMessage ? 20.0 : 5.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
//User name
|
//User name
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(left: 45.0),
|
margin: EdgeInsets.only(left: 55.0),
|
||||||
child: isFirstMessage
|
child: isFirstMessage
|
||||||
? Text(
|
? Text(
|
||||||
userInfo.fullName,
|
userInfo.fullName,
|
||||||
@ -130,18 +177,28 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
|
|
||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
// Text image
|
||||||
|
Container(
|
||||||
|
child: message.hasImage ? _buildMessageImage() : null,
|
||||||
|
),
|
||||||
|
|
||||||
// Text message
|
// Text message
|
||||||
Container(
|
Container(
|
||||||
child: Text(
|
child: message.hasMessage
|
||||||
message.message,
|
? Container(
|
||||||
textAlign: TextAlign.justify,
|
child: Text(
|
||||||
),
|
message.message,
|
||||||
padding: EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
|
textAlign: TextAlign.justify,
|
||||||
width: 200.0,
|
),
|
||||||
decoration: BoxDecoration(
|
padding:
|
||||||
color: Colors.black12,
|
EdgeInsets.fromLTRB(15.0, 10.0, 15.0, 10.0),
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
width: 200.0,
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black12,
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -150,7 +207,7 @@ class ConversationMessageTile extends StatelessWidget {
|
|||||||
|
|
||||||
// Date
|
// Date
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(left: 45.0),
|
margin: EdgeInsets.only(left: 50.0),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: _buildMessageDate(),
|
child: _buildMessageDate(),
|
||||||
|
Loading…
Reference in New Issue
Block a user