mirror of https://github.com/CympleTech/ESSE.git
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.
93 lines
3.2 KiB
93 lines
3.2 KiB
import 'package:flutter/material.dart'; |
|
import 'package:provider/provider.dart'; |
|
|
|
import 'package:esse/utils/adaptive.dart'; |
|
import 'package:esse/l10n/localizations.dart'; |
|
import 'package:esse/models/friend.dart'; |
|
import 'package:esse/pages/friend.dart'; |
|
import 'package:esse/provider/account.dart'; |
|
|
|
class ListFriend extends StatelessWidget { |
|
final Friend friend; |
|
|
|
const ListFriend({Key key, this.friend}) : super(key: key); |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
final color = Theme.of(context).colorScheme; |
|
final lang = AppLocalizations.of(context); |
|
final isDesktop = isDisplayDesktop(context); |
|
|
|
return GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
context.read<AccountProvider>().updateActivedFriend(friend.id, isDesktop); |
|
if (!isDesktop) { |
|
Navigator.push( |
|
context, |
|
MaterialPageRoute( |
|
builder: (_) => ChatPage(), |
|
), |
|
); |
|
} |
|
}, |
|
child: Container( |
|
height: 55.0, |
|
child: Row( |
|
children: [ |
|
Container( |
|
width: 45.0, |
|
height: 45.0, |
|
margin: const EdgeInsets.only(left: 20.0, right: 15.0), |
|
child: friend.showAvatar(), |
|
), |
|
Expanded( |
|
child: Container( |
|
height: 55.0, |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
children: [ |
|
Expanded( |
|
child: Text(friend.name, |
|
maxLines: 1, |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle(fontSize: 16.0)) |
|
), |
|
Container( |
|
margin: const EdgeInsets.only(left: 15.0, right: 20.0), |
|
child: Text(friend.lastMessageTime.toString(), |
|
style: const TextStyle(color: Color(0xFFADB0BB), fontSize: 12.0), |
|
), |
|
) |
|
]), |
|
SizedBox(height: 5.0), |
|
Row( |
|
children: [ |
|
Expanded( |
|
child: Text(friend.lastMessageContent, |
|
maxLines: 1, |
|
overflow: TextOverflow.ellipsis, |
|
style: const TextStyle(color: Color(0xFFADB0BB), fontSize: 12.0)), |
|
), |
|
if (this.friend.isClosed) |
|
Container( |
|
margin: const EdgeInsets.only(left: 15.0, right: 20.0), |
|
child: Text(lang.unfriended, |
|
style: TextStyle(color: color.primary, fontSize: 12.0), |
|
), |
|
) |
|
]), |
|
], |
|
), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
); |
|
} |
|
}
|
|
|