main_friend_item.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'dart:ui';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:location/data/bean/user_info.dart';
  6. import 'package:location/resource/colors.gen.dart';
  7. import 'package:location/utils/common_expand.dart';
  8. import '../../utils/common_style.dart';
  9. import '../../utils/common_util.dart';
  10. import '../../widget/marquee_text.dart';
  11. Widget mainFriendItem(UserInfo userInfo, bool isSelected,
  12. {required VoidCallback onTap}) {
  13. return GestureDetector(
  14. onTap: onTap,
  15. child: Container(
  16. margin: EdgeInsets.only(right: 12.w),
  17. child: Stack(
  18. children: [
  19. Container(
  20. decoration: BoxDecoration(
  21. color: ColorName.white,
  22. shape: BoxShape.circle,
  23. border: isSelected
  24. ? Border.all(color: ColorName.colorPrimary, width: 2.w)
  25. : null),
  26. width: 52.w,
  27. height: 52.w,
  28. child: Center(
  29. child: buildCustomAvatarOrDefaultAvatarView(
  30. size: 44.w,
  31. avatar: userInfo.avatar,
  32. isMine: userInfo.isMine == true))),
  33. Positioned(
  34. left: 3.w,
  35. bottom: 0,
  36. right: 3.w,
  37. child: Container(
  38. height: 16.w,
  39. padding: EdgeInsets.symmetric(horizontal: 2.w),
  40. decoration: BoxDecoration(
  41. color: ColorName.white,
  42. borderRadius: BorderRadius.circular(10.w),
  43. border: Border.all(color: '#E8E8E8'.color, width: 1.w),
  44. ),
  45. child: Builder(builder: (context) {
  46. String nickName = userNickName(
  47. userInfo.remark, userInfo.phoneNumber, !isSelected);
  48. TextStyle style =
  49. TextStyle(fontSize: 10.sp, color: ColorName.black80);
  50. return Center(
  51. child: isSelected
  52. ? MarqueeText.marquee(
  53. text: nickName,
  54. containerWidth: 45.w,
  55. textStyle: TextStyle(
  56. fontSize: 10.sp, color: ColorName.black80))
  57. : Text(nickName, style: style),
  58. );
  59. }),
  60. ),
  61. )
  62. ],
  63. ),
  64. ),
  65. );
  66. }