main_friend_item.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:location/data/bean/user_info.dart';
  5. import 'package:location/resource/assets.gen.dart';
  6. import 'package:location/resource/colors.gen.dart';
  7. import 'package:location/resource/string.gen.dart';
  8. import 'package:location/utils/common_expand.dart';
  9. import 'package:location/widget/relative_time_text.dart';
  10. import '../../utils/common_style.dart';
  11. import '../../utils/common_util.dart';
  12. import '../../widget/marquee_text.dart';
  13. Widget mainFriendItem(UserInfo userInfo, bool isSelected,
  14. {required VoidCallback onTap}) {
  15. return GestureDetector(
  16. onTap: onTap,
  17. child: Container(
  18. margin: EdgeInsets.only(right: 12.w),
  19. child: Stack(
  20. children: [
  21. Container(
  22. decoration: BoxDecoration(
  23. color: ColorName.white,
  24. shape: BoxShape.circle,
  25. border: isSelected
  26. ? Border.all(color: ColorName.colorPrimary, width: 2.w)
  27. : null),
  28. width: 52.w,
  29. height: 52.w,
  30. child: Center(
  31. child: Image.asset(
  32. userInfo.isMine == true
  33. ? Assets.images.iconDefaultMineAvatar.path
  34. : Assets.images.iconDefaultFriendAvatar.path,
  35. width: 44.w,
  36. height: 44.w))),
  37. Positioned(
  38. left: 3.w,
  39. bottom: 0,
  40. right: 3.w,
  41. child: Container(
  42. height: 16.w,
  43. padding: EdgeInsets.symmetric(horizontal: 2.w),
  44. decoration: BoxDecoration(
  45. color: ColorName.white,
  46. borderRadius: BorderRadius.circular(10.w),
  47. border: Border.all(color: '#E8E8E8'.color, width: 1.w),
  48. ),
  49. child: Builder(builder: (context) {
  50. String nickName = userNickName(
  51. userInfo.remark, userInfo.phoneNumber, !isSelected);
  52. TextStyle style =
  53. TextStyle(fontSize: 10.sp, color: ColorName.black80);
  54. return Center(
  55. child: isSelected
  56. ? MarqueeText.marquee(
  57. text: nickName,
  58. containerWidth: 45.w,
  59. textStyle: TextStyle(
  60. fontSize: 10.sp, color: ColorName.black80))
  61. : Text(nickName, style: style),
  62. );
  63. }),
  64. ),
  65. )
  66. ],
  67. ),
  68. ),
  69. );
  70. }
  71. Widget mainSelectedFriendItem(UserInfo userInfo) {
  72. return Container(
  73. width: 336.w,
  74. height: 86.w,
  75. decoration: BoxDecoration(
  76. color: ColorName.white,
  77. borderRadius: BorderRadius.all(Radius.circular(20.w))),
  78. child: Row(
  79. children: [
  80. SizedBox(width: 7.w),
  81. Image(
  82. image: userInfo.isMine == true
  83. ? Assets.images.iconDefaultMineAvatar.provider()
  84. : Assets.images.iconDefaultFriendAvatar.provider(),
  85. width: 50.w,
  86. height: 50.w),
  87. SizedBox(width: 5.w),
  88. Expanded(
  89. child: Container(
  90. margin: EdgeInsets.symmetric(vertical: 15.w),
  91. child: Column(
  92. mainAxisAlignment: MainAxisAlignment.center,
  93. crossAxisAlignment: CrossAxisAlignment.start,
  94. children: [
  95. Row(
  96. children: [
  97. Text(
  98. userInfo.getUserNickName(),
  99. style: TextStyle(
  100. fontWeight: FontWeight.bold,
  101. fontSize: 16.sp,
  102. color: '#202020'.color),
  103. ),
  104. SizedBox(width: 7.w),
  105. RelativeTimeText(
  106. timestamp:
  107. userInfo.lastLocation.value?.lastUpdateTime,
  108. updateInterval: Duration(minutes: 1),
  109. style: TextStyle(
  110. fontSize: 12.sp, color: '#A7A7A7'.color)),
  111. Spacer(),
  112. Container(
  113. margin: EdgeInsets.only(right: 16.w),
  114. decoration: getPrimaryBtnDecoration(32.w),
  115. padding: EdgeInsets.symmetric(
  116. horizontal: 21.w, vertical: 5.w),
  117. child: Text(StringName.locationTrace,
  118. style: TextStyle(
  119. fontSize: 15.sp, color: Colors.white)))
  120. ],
  121. ),
  122. Expanded(
  123. child: Container(
  124. margin: EdgeInsets.only(right: 17.w),
  125. child: MarqueeText.marquee(
  126. text: addressCheck(
  127. userInfo.lastLocation.value?.address),
  128. textStyle: TextStyle(
  129. fontSize: 13.sp, color: ColorName.black50),
  130. containerWidth: 244.w),
  131. ),
  132. )
  133. // Text('广东省广州市天河区XX街街XX街区XX村XX')
  134. ],
  135. ),
  136. ),
  137. )
  138. ],
  139. ));
  140. }