1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class ChatItem extends StatelessWidget {
final String title;
final String subtitle;
final DateTime timestamp;
final int? unread;
final String? avatarURL;
final Function() onTap;
const ChatItem({
super.key,
required this.title,
required this.subtitle,
required this.onTap,
required this.timestamp,
this.unread = 0,
this.avatarURL,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 15),
child: InkWell(
onTap: onTap,
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(35),
child: CircleAvatar(
backgroundColor: Theme.of(context).colorScheme.primary,
backgroundImage:
avatarURL != null ? NetworkImage(avatarURL!) : null,
child: avatarURL == null
? Icon(
Icons.person,
color: Theme.of(context).colorScheme.onPrimary,
)
: null,
)),
Expanded(
flex: 12,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 17,
color: Colors.black,
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 10),
Text(
subtitle,
style: const TextStyle(
fontSize: 17,
color: Colors.black54,
),
overflow: TextOverflow.ellipsis,
),
],
),
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.only(right: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
DateFormat('kk:mm').format(timestamp),
style: const TextStyle(
fontSize: 15,
color: Colors.black54,
),
),
const SizedBox(height: 10),
unread != null && unread != 0
? Container(
height: 23,
width: 23,
alignment: Alignment.center,
decoration: BoxDecoration(
color: const Color(0xFF113753),
borderRadius: BorderRadius.circular(25),
),
child: Text(
unread!.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 17,
fontWeight: FontWeight.bold,
),
),
)
: const SizedBox.shrink(),
],
),
)
],
),
),
);
}
}
|