Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
3.2 KiB

import 'package:flutter/material.dart';
import '/components/custom_circle_avatar.dart';
import '/models/conversations.dart';
import '/views/main/conversation/detail.dart';
class ConversationListItem extends StatefulWidget{
final Conversation conversation;
const ConversationListItem({
Key? key,
required this.conversation,
}) : super(key: key);
@override
_ConversationListItemState createState() => _ConversationListItemState();
}
class _ConversationListItemState extends State<ConversationListItem> {
late Conversation conversation;
bool loaded = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
loaded ? Navigator.push(context, MaterialPageRoute(builder: (context){
return ConversationDetail(
conversation: conversation,
);
})).then(onGoBack) : null;
},
child: Container(
padding: const EdgeInsets.only(left: 16,right: 16,top: 10,bottom: 10),
child: !loaded ? null : Row(
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
CustomCircleAvatar(
initials: conversation.name[0].toUpperCase(),
imagePath: null,
),
const SizedBox(width: 16),
Expanded(
child: Align(
alignment: Alignment.centerLeft,
child: Container(
color: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
conversation.name,
style: const TextStyle(fontSize: 16)
),
//Text(widget.messageText,style: TextStyle(fontSize: 13,color: Colors.grey.shade600, fontWeight: widget.isMessageRead?FontWeight.bold:FontWeight.normal),),
],
),
),
),
),
],
),
),
],
),
),
);
}
@override
void initState() {
super.initState();
conversation = widget.conversation;
loaded = true;
setState(() {});
}
onGoBack(dynamic value) async {
conversation = await getConversationById(widget.conversation.id);
setState(() {});
}
}