FurryChat/lib/components/list_items/chat_list_item.dart

119 lines
3.8 KiB
Dart
Raw Normal View History

2020-01-01 18:10:13 +00:00
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/message_content.dart';
2020-01-03 08:20:30 +00:00
import 'package:fluffychat/utils/chat_time.dart';
2020-01-01 18:10:13 +00:00
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart';
import '../avatar.dart';
class ChatListItem extends StatelessWidget {
final Room room;
final bool activeChat;
const ChatListItem(this.room, {this.activeChat = false});
@override
Widget build(BuildContext context) {
return Material(
color: activeChat ? Color(0xFFE8E8E8) : Colors.white,
child: ListTile(
leading: Avatar(room.avatar),
2020-01-03 08:09:14 +00:00
title: Row(
children: <Widget>[
Expanded(
child: Text(
room.displayname,
maxLines: 1,
2020-01-03 11:04:24 +00:00
overflow: TextOverflow.ellipsis,
),
),
SizedBox(width: 16),
Text(
ChatTime(room.timeCreated).toEventTimeString(),
style: TextStyle(
color: Color(0xFF555555),
2020-01-03 13:44:39 +00:00
fontSize: 13,
2020-01-03 08:09:14 +00:00
),
),
],
),
subtitle: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(child: MessageContent(room.lastEvent, textOnly: true)),
SizedBox(width: 8),
room.pushRuleState == PushRuleState.notify
? Container()
: Icon(
Icons.notifications_off,
color: Colors.grey,
2020-01-03 13:44:39 +00:00
size: 16,
2020-01-03 08:09:14 +00:00
),
room.notificationCount > 0
? Container(
2020-01-03 13:44:39 +00:00
padding: EdgeInsets.symmetric(horizontal: 5),
2020-01-03 08:09:14 +00:00
height: 20,
decoration: BoxDecoration(
color: room.highlightCount > 0
? Colors.red
2020-01-03 10:57:00 +00:00
: Theme.of(context).primaryColor,
2020-01-03 08:09:14 +00:00
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
room.notificationCount.toString(),
style: TextStyle(color: Colors.white),
),
),
)
: Text(" "),
],
2020-01-02 22:38:46 +00:00
),
2020-01-01 18:10:13 +00:00
onTap: () {
2020-01-02 21:31:39 +00:00
if (activeChat) {
2020-01-01 18:10:13 +00:00
Navigator.pushReplacement(
context,
AppRoute.defaultRoute(context, Chat(room.id)),
);
2020-01-02 21:31:39 +00:00
} else {
2020-01-01 18:10:13 +00:00
Navigator.push(
context,
AppRoute.defaultRoute(context, Chat(room.id)),
);
2020-01-02 21:31:39 +00:00
}
2020-01-01 18:10:13 +00:00
},
onLongPress: () {},
2020-01-03 08:09:14 +00:00
/*trailing: Container(
2020-01-01 18:10:13 +00:00
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
2020-01-02 14:10:21 +00:00
Text(ChatTime(room.timeCreated).toEventTimeString()),
2020-01-01 18:10:13 +00:00
room.notificationCount > 0
? Container(
width: 20,
height: 20,
margin: EdgeInsets.only(top: 3),
decoration: BoxDecoration(
color: room.highlightCount > 0
? Colors.red
2020-01-03 10:57:00 +00:00
: Theme.of(context).primaryColor,
2020-01-01 18:10:13 +00:00
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
room.notificationCount.toString(),
style: TextStyle(color: Colors.white),
),
),
)
: Text(" "),
],
),
2020-01-03 08:09:14 +00:00
),*/
2020-01-01 18:10:13 +00:00
),
);
}
}