2023-06-21 17:44:28 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2023-08-01 10:01:08 +08:00
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
2023-06-21 17:44:28 +08:00
|
|
|
import 'package:go_router/go_router.dart';
|
2023-08-01 10:01:08 +08:00
|
|
|
|
2024-04-09 17:23:28 +08:00
|
|
|
import '/models/user_model.dart';
|
|
|
|
import '/request/server.dart';
|
|
|
|
import '/models/contact_model.dart';
|
|
|
|
import '/models/init_get_it.dart';
|
2023-06-21 17:44:28 +08:00
|
|
|
|
|
|
|
class FriendTile extends StatelessWidget {
|
2023-08-01 10:01:08 +08:00
|
|
|
const FriendTile({super.key, required this.friendId});
|
|
|
|
|
|
|
|
final String friendId;
|
2023-06-21 17:44:28 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-10-06 16:43:51 +08:00
|
|
|
final bool isMyself = friendId == getIt.get<UserAccount>().id;
|
|
|
|
|
2023-06-21 17:44:28 +08:00
|
|
|
return InkWell(
|
2023-08-01 10:01:08 +08:00
|
|
|
onTap: () {
|
|
|
|
if (friendId == getIt.get<UserAccount>().id) {
|
2023-10-21 21:25:09 +08:00
|
|
|
context.pushNamed('MyProfile');
|
2023-08-01 10:01:08 +08:00
|
|
|
} else {
|
|
|
|
context.pushNamed(
|
|
|
|
'FriendProfile',
|
|
|
|
queryParameters: {'friendId': friendId},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2023-06-21 17:44:28 +08:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
const SizedBox(
|
|
|
|
width: 10.0,
|
|
|
|
),
|
2023-10-21 21:25:09 +08:00
|
|
|
CircleAvatar(
|
|
|
|
backgroundImage: CachedNetworkImageProvider(
|
|
|
|
'$userAvatarsUrl/${getIt.get<ContactAccountProfile>().friends[friendId]!.avatar}',
|
|
|
|
),
|
|
|
|
),
|
2023-06-21 17:44:28 +08:00
|
|
|
const SizedBox(
|
|
|
|
width: 10.0,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2023-08-01 10:01:08 +08:00
|
|
|
// nickname
|
|
|
|
Text(
|
|
|
|
getIt.get<Contact>().friends[friendId]!.friendRemark.isEmpty
|
|
|
|
? getIt
|
|
|
|
.get<ContactAccountProfile>()
|
|
|
|
.friends[friendId]!
|
|
|
|
.nickname
|
|
|
|
: getIt.get<Contact>().friends[friendId]!.friendRemark,
|
|
|
|
style: const TextStyle(fontSize: 17),
|
2023-06-21 17:44:28 +08:00
|
|
|
),
|
2023-08-01 10:01:08 +08:00
|
|
|
// sign
|
2023-08-10 19:08:46 +08:00
|
|
|
if (getIt
|
|
|
|
.get<ContactAccountProfile>()
|
|
|
|
.friends[friendId]!
|
|
|
|
.sign
|
|
|
|
.isNotEmpty)
|
|
|
|
Text(
|
|
|
|
getIt
|
|
|
|
.get<ContactAccountProfile>()
|
|
|
|
.friends[friendId]!
|
|
|
|
.sign,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).textTheme.displayLarge?.color,
|
|
|
|
),
|
2023-06-21 17:44:28 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 10.0,
|
|
|
|
),
|
2023-10-06 16:43:51 +08:00
|
|
|
if (isMyself)
|
|
|
|
if (getIt.get<UserProfile>().status.isNotEmpty)
|
|
|
|
Chip(
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
label: Text(getIt.get<UserProfile>().status),
|
|
|
|
),
|
|
|
|
if (!isMyself)
|
|
|
|
if (getIt
|
|
|
|
.get<ContactAccountProfile>()
|
|
|
|
.friends[friendId]!
|
|
|
|
.status
|
|
|
|
.isNotEmpty)
|
|
|
|
Chip(
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
label: Text(getIt
|
|
|
|
.get<ContactAccountProfile>()
|
|
|
|
.friends[friendId]!
|
|
|
|
.status),
|
|
|
|
),
|
2023-06-21 17:44:28 +08:00
|
|
|
const SizedBox(
|
|
|
|
width: 10.0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|