| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import 'package:e2ee_chat/common/global.dart';
- import 'package:e2ee_chat/presenter/chat_list.dart';
- import 'package:e2ee_chat/presenter/user_chat.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_slidable/flutter_slidable.dart';
- import 'package:provider/provider.dart';
- class ChatListItem extends StatelessWidget {
- final UserChatPresenter model;
- ChatListItem(this.model);
- @override
- Widget build(BuildContext context) {
- final message = model.lastMessage;
- return Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- model.avatar ?? Global.defaultAvatar,
- Expanded(
- child: Column(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.symmetric(vertical: 8),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Expanded(
- child: Text(
- model.chatName,
- style: TextStyle(fontSize: 34),
- overflow: TextOverflow.ellipsis,
- ),
- ),
- Text(
- _formatDate(),
- style: TextStyle(fontSize: 26),
- overflow: TextOverflow.ellipsis,
- ),
- ],
- ),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Expanded(
- child: RichText(
- text: TextSpan(children: [
- TextSpan(
- text: model.isAtYou ? "[@你]" : "",
- style: TextStyle(fontSize: 28),
- ),
- TextSpan(
- text: model.isSpecialAttention ? "[特别关注]" : "",
- style: TextStyle(fontSize: 28),
- ),
- TextSpan(
- text: model.isAtAll ? "[@所有人]" : "",
- style: TextStyle(fontSize: 28),
- ),
- TextSpan(
- text: model.lastMessage?.plaintext ?? "",
- style: TextStyle(fontSize: 28),
- )
- ]),
- overflow: TextOverflow.ellipsis,
- ),
- ),
- (model.unReadCount > 0 && !model.isDND)
- ? Container(
- width: 32,
- height: 32,
- alignment: Alignment.center,
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(20)),
- child: Text(
- model.unReadCount.toString(),
- style: TextStyle(color: Colors.white, fontSize: 26),
- ))
- : Container(),
- model.isDND
- ? Row(
- children: <Widget>[
- Icon(Icons.visibility_off),
- model.unReadCount > 0
- ? Icon(
- Icons.chat_bubble,
- color: Colors.red,
- ) // TODO: 小红点
- : Container()
- ],
- )
- : Container()
- ],
- )
- ],
- ),
- )
- ],
- );
- }
- String _formatDate() {
- return "1234";
- }
- }
|