import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:go_router/go_router.dart'; import '/models/user_model.dart'; import '/request/server.dart'; import '/models/contact_model.dart'; import '/models/init_get_it.dart'; class FriendTile extends StatelessWidget { const FriendTile({super.key, required this.friendId}); final String friendId; @override Widget build(BuildContext context) { final bool isMyself = friendId == getIt.get().id; return InkWell( onTap: () { if (friendId == getIt.get().id) { context.pushNamed('MyProfile'); } else { context.pushNamed( 'FriendProfile', queryParameters: {'friendId': friendId}, ); } }, child: Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ const SizedBox( width: 10.0, ), CircleAvatar( backgroundImage: CachedNetworkImageProvider( '$userAvatarsUrl/${getIt.get().friends[friendId]!.avatar}', ), ), const SizedBox( width: 10.0, ), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ // nickname Text( getIt.get().friends[friendId]!.friendRemark.isEmpty ? getIt .get() .friends[friendId]! .nickname : getIt.get().friends[friendId]!.friendRemark, style: const TextStyle(fontSize: 17), ), // sign if (getIt .get() .friends[friendId]! .sign .isNotEmpty) Text( getIt .get() .friends[friendId]! .sign, overflow: TextOverflow.ellipsis, style: TextStyle( color: Theme.of(context).textTheme.displayLarge?.color, ), ), ], ), ), const SizedBox( width: 10.0, ), if (isMyself) if (getIt.get().status.isNotEmpty) Chip( visualDensity: VisualDensity.compact, label: Text(getIt.get().status), ), if (!isMyself) if (getIt .get() .friends[friendId]! .status .isNotEmpty) Chip( visualDensity: VisualDensity.compact, label: Text(getIt .get() .friends[friendId]! .status), ), const SizedBox( width: 10.0, ), ], ), ), ); } }