Created
January 13, 2019 13:13
-
-
Save amsokol/0f4efe0deae48e4f83baa2905d60897f to your computer and use it in GitHub Desktop.
flutter-grpc-tutorial.flutter_client.lib.chat_message_incoming.dart
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
import 'chat_message.dart'; | |
/// Incoming message author name | |
const String _server = "Server"; | |
/// ChatMessageIncoming is widget to display incoming from server message | |
class ChatMessageIncoming extends StatelessWidget implements ChatMessage { | |
/// Incoming message content | |
final Message message; | |
/// Controller of animation for message widget | |
final AnimationController animationController; | |
/// Constructor | |
ChatMessageIncoming({this.message, this.animationController}) | |
: super(key: new ObjectKey(message.id)); | |
@override | |
Widget build(BuildContext context) { | |
return SizeTransition( | |
sizeFactor: | |
CurvedAnimation(parent: animationController, curve: Curves.easeOut), | |
axisAlignment: 0.0, | |
child: Container( | |
margin: EdgeInsets.symmetric(vertical: 10.0), | |
child: Row( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Expanded( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.end, | |
children: <Widget>[ | |
Text(_server, style: Theme.of(context).textTheme.subhead), | |
Container( | |
margin: EdgeInsets.only(top: 5.0), | |
child: Text(message.text), | |
), | |
], | |
), | |
), | |
Container( | |
margin: EdgeInsets.only(left: 16.0), | |
child: CircleAvatar( | |
backgroundColor: Colors.pink.shade600, | |
child: Text(_server[0])), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment