main_friend_item.dart 6.6 KB

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