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
|
|
|
import 'package:together_mobile/models/user_model.dart';
|
|
|
|
|
|
|
|
import 'package:together_mobile/request/server.dart';
|
|
|
|
import 'package:together_mobile/models/contact_model.dart';
|
|
|
|
import 'package:together_mobile/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) {
|
|
|
|
return InkWell(
|
2023-08-01 10:01:08 +08:00
|
|
|
onTap: () {
|
|
|
|
if (friendId == getIt.get<UserAccount>().id) {
|
|
|
|
context.pushNamed('MainProfile');
|
|
|
|
} 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-08-01 10:01:08 +08:00
|
|
|
getIt.get<ContactAccountProfile>().friends[friendId]!.avatar.isEmpty
|
|
|
|
? const CircleAvatar(
|
|
|
|
backgroundImage: AssetImage('assets/images/user_3.png'),
|
|
|
|
)
|
|
|
|
: CircleAvatar(
|
|
|
|
backgroundImage: CachedNetworkImageProvider(
|
2023-09-09 16:48:47 +08:00
|
|
|
'$userAvatarsUrl/${getIt.get<ContactAccountProfile>().friends[friendId]!.avatar}',
|
2023-08-01 10:01:08 +08:00
|
|
|
),
|
|
|
|
),
|
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,
|
|
|
|
),
|
|
|
|
const Chip(
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
label: Text('状态'),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 10.0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|