mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 14:59:22 +00:00
54 lines
1.3 KiB
Dart
54 lines
1.3 KiB
Dart
|
import 'package:comunic/models/comment.dart';
|
||
|
import 'package:comunic/models/user.dart';
|
||
|
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||
|
import 'package:comunic/ui/widgets/network_image_widget.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
/// Single comment tile
|
||
|
///
|
||
|
/// @author Pierre HUBERT
|
||
|
|
||
|
class CommentTile extends StatelessWidget {
|
||
|
final Comment comment;
|
||
|
final User user;
|
||
|
|
||
|
const CommentTile({Key key, this.comment, this.user})
|
||
|
: assert(comment != null),
|
||
|
assert(user != null),
|
||
|
super(key: key);
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return ListTile(
|
||
|
leading: AccountImageWidget(
|
||
|
user: user,
|
||
|
),
|
||
|
title: Text(user.displayName,),
|
||
|
subtitle: _buildCommentContent(),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget _buildCommentContent() {
|
||
|
return Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||
|
children: <Widget>[
|
||
|
// Comment image
|
||
|
Container(
|
||
|
child: comment.hasImage
|
||
|
? NetworkImageWidget(
|
||
|
url: comment.imageURL,
|
||
|
allowFullScreen: true,
|
||
|
height: 100.0,
|
||
|
)
|
||
|
: null,
|
||
|
),
|
||
|
|
||
|
// Comment text
|
||
|
Container(
|
||
|
child: comment.hasContent ? Text(comment.content,) : null,
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
}
|