| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- import 'dart:ui';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get_rx/src/rx_types/rx_types.dart';
- import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
- import 'package:location/data/bean/member_status_info.dart';
- import 'package:location/data/bean/user_info.dart';
- import 'package:location/resource/colors.gen.dart';
- import 'package:location/utils/common_expand.dart';
- import '../../data/consts/constants.dart';
- import '../../resource/assets.gen.dart';
- import '../../resource/string.gen.dart';
- import '../../utils/common_style.dart';
- import '../../utils/common_util.dart';
- import '../../widget/marquee_text.dart';
- import '../../widget/relative_time_text.dart';
- typedef OnViewTraceClick = void Function(UserInfo userInfo);
- Widget buildSelectFriendInfoView(
- UserInfo userInfo, Rxn<MemberStatusInfo> memberStatusInfo,
- {OnViewTraceClick? onTraceClick}) {
- return Container(
- width: 336.w,
- height: 68.h,
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.all(Radius.circular(10.r))),
- child: Stack(
- children: [
- Positioned(
- top: 0,
- bottom: 0,
- right: 0,
- child: Assets.images.bgMainFriendCard
- .image(height: double.infinity)),
- Row(
- children: [
- SizedBox(width: 12.w),
- Container(
- width: 38.w,
- height: 38.w,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: Border.all(color: ColorName.black5, width: 0.5.w)),
- child: buildCustomAvatarOrDefaultAvatarView(
- size: double.infinity,
- avatar: userInfo.avatar,
- isMine: userInfo.isMine == true),
- ),
- SizedBox(width: 5.w),
- Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Spacer(),
- Row(
- children: [
- ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: 0.26.sw,
- ),
- child: Text(
- maxLines: 1,
- userInfo.getUserNickName(),
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 14.sp,
- color: '#202020'.color),
- ),
- ),
- SizedBox(width: 8.w),
- Obx(() {
- return RelativeTimeText(
- timestamp:
- userInfo.lastLocation.value?.lastUpdateTime,
- updateInterval: Duration(minutes: 1),
- style: TextStyle(
- fontSize: 11.sp, color: ColorName.black30));
- })
- ],
- ),
- SizedBox(height: 5.w),
- Expanded(
- child: Container(
- margin: EdgeInsets.only(right: 12.w),
- child: Obx(() {
- return ImageFiltered(
- enabled: userInfo.blockedMe == true ||
- ((memberStatusInfo.value == null ||
- memberStatusInfo.value?.expired ==
- true) &&
- !(userInfo.isMine == true)),
- imageFilter: ImageFilter.blur(
- sigmaX: Constants.blurredX,
- sigmaY: Constants.blurredY,
- ),
- child: userInfo.blockedMe == true ||
- ((memberStatusInfo.value == null ||
- memberStatusInfo.value?.expired ==
- true) &&
- !(userInfo.isMine == true))
- ? Text(
- addressCheck(
- userInfo.lastLocation.value?.address),
- style: TextStyle(
- fontSize: 12.sp,
- color: ColorName.black50))
- : MarqueeText(
- text: addressCheck(
- userInfo.lastLocation.value?.address),
- textStyle: TextStyle(
- fontSize: 12.sp,
- color: ColorName.black50)),
- );
- }),
- ),
- ),
- Spacer(),
- ],
- ),
- ),
- GestureDetector(
- onTap: () {
- onTraceClick?.call(userInfo);
- },
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8.w),
- gradient: LinearGradient(
- stops: [0.6, 1],
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- colors: [
- '#6567EA'.color,
- '#41E3C5'.color,
- ])),
- margin: EdgeInsets.only(right: 12.w),
- padding:
- EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Assets.images.iconMainTrackLocation
- .image(width: 8.w, height: 8.w),
- SizedBox(width: 2.w),
- Text(StringName.locationTrace,
- style:
- TextStyle(fontSize: 11.sp, color: Colors.white))
- ],
- )),
- ),
- ],
- )
- ],
- ));
- }
- Widget mainFriendItem(UserInfo userInfo, bool isSelected,
- {required VoidCallback onTap}) {
- return GestureDetector(
- onTap: onTap,
- child: Container(
- margin: EdgeInsets.only(right: 12.w),
- child: Stack(
- children: [
- Container(
- decoration: BoxDecoration(
- color: ColorName.white,
- shape: BoxShape.circle,
- border: isSelected
- ? Border.all(color: ColorName.colorPrimary, width: 2.w)
- : null),
- width: 52.w,
- height: 52.w,
- child: Center(
- child: buildCustomAvatarOrDefaultAvatarView(
- size: 44.w,
- avatar: userInfo.avatar,
- isMine: userInfo.isMine == true))),
- Positioned(
- left: 3.w,
- bottom: 0,
- right: 3.w,
- child: Container(
- height: 16.w,
- padding: EdgeInsets.symmetric(horizontal: 2.w),
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.circular(10.w),
- border: Border.all(color: '#E8E8E8'.color, width: 1.w),
- ),
- child: Builder(builder: (context) {
- String nickName = userNickName(
- userInfo.remark, userInfo.phoneNumber, !isSelected);
- TextStyle style =
- TextStyle(fontSize: 10.sp, color: ColorName.black80);
- return Center(
- child: isSelected
- ? MarqueeText(
- text: nickName,
- textStyle: TextStyle(
- fontSize: 10.sp, color: ColorName.black80))
- : Text(nickName, style: style),
- );
- }),
- ),
- )
- ],
- ),
- ),
- );
- }
|