-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from 90lucasgabriel/09-message-info
09 - Chat message info
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class ChatMessage extends StatelessWidget { | ||
/// Props | ||
/// Message info | ||
final Map<String, dynamic> data; | ||
|
||
/// Check if message is mine | ||
final bool isOwner; | ||
|
||
/// Constructor | ||
ChatMessage(this.data, this.isOwner); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
margin: EdgeInsets.symmetric(vertical: 8, horizontal: 8), | ||
child: Row( | ||
children: [ | ||
if (!isOwner) | ||
Container( | ||
padding: EdgeInsets.only(right: 8), | ||
child: CircleAvatar( | ||
backgroundImage: NetworkImage(data['senderPhotoUrl']), | ||
), | ||
), | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: | ||
isOwner ? CrossAxisAlignment.end : CrossAxisAlignment.start, | ||
children: [ | ||
data['imageUrl'] != null | ||
? Image.network( | ||
data['imageUrl'], | ||
width: 250, | ||
) | ||
: Text( | ||
data['value'], | ||
textAlign: isOwner ? TextAlign.end : TextAlign.start, | ||
style: TextStyle(fontSize: 14), | ||
), | ||
Text( | ||
data['senderName'], | ||
style: TextStyle(fontSize: 10, fontWeight: FontWeight.w300), | ||
), | ||
], | ||
), | ||
), | ||
if (isOwner) | ||
Container( | ||
padding: EdgeInsets.only(left: 8), | ||
child: CircleAvatar( | ||
backgroundImage: NetworkImage(data['senderPhotoUrl']), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters