import 'package:flutter/material.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:go_router/go_router.dart'; 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'; class FriendTile extends StatelessWidget { const FriendTile({super.key, required this.friendId}); final String friendId; @override Widget build(BuildContext context) { return InkWell( onTap: () { if (friendId == getIt.get().id) { context.pushNamed('MainProfile'); } 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, ), getIt.get().friends[friendId]!.avatar.isEmpty ? const CircleAvatar( backgroundImage: AssetImage('assets/images/user_3.png'), ) : CircleAvatar( backgroundImage: CachedNetworkImageProvider( '$avatarsUrl/${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, ), const Chip( visualDensity: VisualDensity.compact, label: Text('状态'), ), const SizedBox( width: 10.0, ), ], ), ), ); } }