main_friend_item.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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) {
  74. return Container(
  75. width: 336.w,
  76. height: 86.w,
  77. decoration: BoxDecoration(
  78. color: ColorName.white,
  79. borderRadius: BorderRadius.all(Radius.circular(20.w))),
  80. child: Row(
  81. children: [
  82. SizedBox(width: 7.w),
  83. Image(
  84. image: userInfo.isMine == true
  85. ? Assets.images.iconDefaultMineAvatar.provider()
  86. : Assets.images.iconDefaultFriendAvatar.provider(),
  87. width: 50.w,
  88. height: 50.w),
  89. SizedBox(width: 5.w),
  90. Expanded(
  91. child: Container(
  92. margin: EdgeInsets.symmetric(vertical: 15.w),
  93. child: Column(
  94. mainAxisAlignment: MainAxisAlignment.center,
  95. crossAxisAlignment: CrossAxisAlignment.start,
  96. children: [
  97. Row(
  98. children: [
  99. Text(
  100. userInfo.getUserNickName(),
  101. style: TextStyle(
  102. fontWeight: FontWeight.bold,
  103. fontSize: 16.sp,
  104. color: '#202020'.color),
  105. ),
  106. SizedBox(width: 7.w),
  107. RelativeTimeText(
  108. timestamp:
  109. userInfo.lastLocation.value?.lastUpdateTime,
  110. updateInterval: Duration(minutes: 1),
  111. style: TextStyle(
  112. fontSize: 12.sp, color: '#A7A7A7'.color)),
  113. Spacer(),
  114. Container(
  115. margin: EdgeInsets.only(right: 16.w),
  116. decoration: getPrimaryBtnDecoration(32.w),
  117. padding: EdgeInsets.symmetric(
  118. horizontal: 21.w, vertical: 5.w),
  119. child: Text(StringName.locationTrace,
  120. style: TextStyle(
  121. fontSize: 15.sp, color: Colors.white)))
  122. ],
  123. ),
  124. Expanded(
  125. child: Container(
  126. margin: EdgeInsets.only(right: 17.w),
  127. child: ImageFiltered(
  128. enabled: userInfo.blockedMe == true,
  129. imageFilter: ImageFilter.blur(
  130. sigmaX: Constants.blurredX,
  131. sigmaY: Constants.blurredY,
  132. ),
  133. child: userInfo.blockedMe == true
  134. ? Text(
  135. addressCheck(
  136. userInfo.lastLocation.value?.address),
  137. style: TextStyle(
  138. fontSize: 13.sp, color: ColorName.black50))
  139. : MarqueeText.marquee(
  140. text: addressCheck(
  141. userInfo.lastLocation.value?.address),
  142. textStyle: TextStyle(
  143. fontSize: 13.sp, color: ColorName.black50),
  144. containerWidth: 244.w),
  145. ),
  146. ),
  147. )
  148. // Text('广东省广州市天河区XX街街XX街区XX村XX')
  149. ],
  150. ),
  151. ),
  152. )
  153. ],
  154. ));
  155. }