ProfileScreen.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:flutter/material.dart';
  2. import 'package:prime_chat/basic/Entities.dart';
  3. import 'package:prime_chat/screens/AddFriendScreen.dart';
  4. import 'package:prime_chat/screens/components/Avatar.dart';
  5. import 'package:prime_chat/screens/components/UserProfileCard.dart';
  6. import '../basic/Method.dart';
  7. import 'ChatScreen.dart';
  8. class ProfileScreen extends StatelessWidget {
  9. const ProfileScreen({Key? key, required this.profile, required this.isFriend})
  10. : super(key: key);
  11. final bool isFriend;
  12. final Profile profile;
  13. @override
  14. Widget build(BuildContext context) {
  15. List<Widget> children = [
  16. UserProfileCard(load: () async => profile),
  17. const Divider(),
  18. ];
  19. if (isFriend) {
  20. children
  21. .add(_buildItem(context, Icons.messenger_outline, "发消息", onTap: () {
  22. Navigator.push(context,
  23. MaterialPageRoute(builder: (context) => ChatScreen(profile, method.directRoomId(profile.id))));
  24. }));
  25. } else {
  26. children.add(_buildItem(context, Icons.person_add_alt_outlined, "加好友", onTap: () {
  27. Navigator.push(context,
  28. MaterialPageRoute(builder: (context) => AddFriendScreen(profile)));
  29. }));
  30. }
  31. return Scaffold(
  32. appBar: AppBar(),
  33. body: Column(children: children),
  34. );
  35. }
  36. Widget _buildItem(BuildContext context, IconData icon, String title,
  37. {void Function()? onTap}) {
  38. return InkWell(
  39. onTap: onTap,
  40. child: Center(
  41. child: Row(
  42. mainAxisSize: MainAxisSize.min,
  43. crossAxisAlignment: CrossAxisAlignment.center,
  44. children: [
  45. Icon(
  46. icon,
  47. ),
  48. const SizedBox(
  49. width: 10,
  50. height: 50,
  51. ),
  52. Text(
  53. title,
  54. style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w300),
  55. ),
  56. ])),
  57. );
  58. }
  59. }