123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_slidable/flutter_slidable.dart';
- import '../../common/style/style.dart' show AppColors, Constants, ICons;
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/internal/bbs/bbs_router.dart';
- import 'package:liftmanager/internal/friends/model/friend_model.dart';
- import 'package:liftmanager/utils/time_format.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import '../../friends_router.dart';
- import '../near_detail.dart';
- class ConversationItem extends StatelessWidget {
- ConversationItem(
- {this.conversationItemData,
- this.onTap,
- this.onDeleting,
- this.onPinning,
- this.onTapAvatar})
- : assert(conversationItemData != null);
- final Records conversationItemData;
- final Function onTap;
- final Function onTapAvatar;
- final Function onDeleting;
- final Function onPinning;
- var tapPos;
- @override
- Widget build(BuildContext context) {
- return Slidable(
- key: UniqueKey(),
- actionPane: SlidableDrawerActionPane(),
- actionExtentRatio: 0.2,
- secondaryActions: <Widget>[
- Container(
- color: Color(0xff555555),
- alignment: Alignment.center,
- child: GestureDetector(
- onTap: () {
- if (onPinning != null) {
- onPinning();
- }
- },
- child: Text(
- '置顶',
- style: TextStyle(fontSize: 14, color: Colors.white),
- ),
- ),
- ),
- Container(
- color: Color(0xffF94F45),
- alignment: Alignment.center,
- child: GestureDetector(
- onTap: () {
- if (onDeleting != null) {
- onDeleting();
- }
- },
- child: Text(
- '删除',
- style: TextStyle(fontSize: 14, color: Colors.white),
- ),
- ),
- )
- ],
- child: Material(
- color: ThemeUtils.getTabsBg(context),
- child: InkWell(
- onTap: () {
- onTap();
- },
- onTapDown: (TapDownDetails details) {
- tapPos = details.globalPosition;
- },
- onLongPress: () {},
- child: Container(
- height: 80,
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(width: .5, color: Color(0xffeeeeee))),
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- SizedBox(width: 10),
- GestureDetector(
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) =>
- NearDetail(friendModel: conversationItemData)));
- },
- child: Container(
- child: ClipRRect(
- borderRadius: BorderRadius.circular(45.0),
- child: LoadNetworkImage(conversationItemData.avatarUrl),
- ),
- width: 45,
- height: 45,
- ),
- ),
- SizedBox(width: 10),
- Expanded(
- child: Container(
- child: contentBody(conversationItemData),
- ),
- ),
- SizedBox(width: 10),
- ],
- ),
- ),
- ),
- ),
- );
- }
- getCaseType(type) {
- String str;
- if (type == 1) {
- str = "问诊服务";
- } else if (type == 2) {
- str = "出诊服务";
- } else if (type == 3) {
- str = "附近的人";
- }
- return str;
- }
- Widget contentBody(conversationItemData) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- children: <Widget>[
- Text(
- conversationItemData.remarks ??
- conversationItemData.userName ??
- "",
- style: TextStyle(
- fontSize: 16,
- color: Colors.black,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- SizedBox(
- width: 10,
- ),
- Container(
- padding: EdgeInsets.all(2),
- decoration: BoxDecoration(
- color: Color(0xffF3F7FF),
- borderRadius: BorderRadius.circular(4),
- ),
- child: Text(
- conversationItemData.dataTable != null
- ? getCaseType(conversationItemData.dataTable)
- : "",
- style: TextStyle(
- fontSize: 12,
- color: Color(0xff5589FF),
- ),
- ),
- ),
- Spacer(),
- tips(conversationItemData)
- ],
- ),
- // SizedBox(height: 10),
- // Row(
- // children: <Widget>[
- // Text(
- // conversationItemData.name ?? "",
- // style: TextStyle(
- // fontSize: ScreenUtil().setSp(12.0),
- // color: Colors.black,
- // ),
- // maxLines: 1,
- // overflow: TextOverflow.ellipsis,
- // ),
- // ],
- // ),
- // SizedBox(
- // height: ScreenUtil().setHeight(10.0),
- // ),
- if (conversationItemData.dataTable != 3)
- Text(
- conversationItemData?.expression ?? "",
- style: TextStyle(
- fontSize: 13,
- color: Color(0xff666666),
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- if (conversationItemData.msg != null ||
- conversationItemData.lastMsg != null)
- Text(
- processMsg(
- conversationItemData.lastMsg ?? conversationItemData.msg),
- style: TextStyle(
- fontSize: 13,
- color: Color(0xff666666),
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- if (conversationItemData.isRed == 1)
- Row(
- children: [
- Spacer(),
- unreadMsgCountText(conversationItemData),
- ],
- )
- ],
- );
- }
- String processMsg(String msg) {
- if (msg == null) {
- return "";
- }
- if (msg.endsWith('.aac')) {
- return '「语音」';
- } else
- if (msg.contains('http://')) {
- return '「图片」';
- } else {
- return msg;
- }
- }
- Widget tips(conversationItemData) {
- var _rightArea = <Widget>[
- Text(
- conversationItemData.time != null
- ? DateUtils.instance.getFormartData(
- timeSamp: conversationItemData.time,
- format: "yyyy-MM-dd HH:mm:ss")
- : (conversationItemData.lastTime != null
- ? DateUtils.instance.getFormartData(
- timeSamp: conversationItemData.lastTime,
- format: "yyyy-MM-dd HH:mm:ss")
- : ""),
- style: TextStyle(
- fontSize: ScreenUtil().setSp(12.0),
- color: Color(AppColors.DesTextColor))),
- // SizedBox(height: ScreenUtil().setHeight(15.0),)
- ];
- // if(conversationItemData.isMute){
- // _rightArea.add(new Icon(ICons.MUTE_ICON,color: Color(AppColors.ConversationMuteIcon),size: ScreenUtil().setSp(15),));
- // }else{
- // _rightArea.add(new Icon(ICons.MUTE_ICON,color: Colors.transparent,size: ScreenUtil().setSp(15),));
- // }
- return Container(
- // width: ScreenUtil().setWidth(130),
- // margin: EdgeInsets.only(right: ScreenUtil().setWidth(10.0)),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center, children: _rightArea),
- );
- }
- Widget unreadMsgCountText(conversationItemData) {
- return Container(
- width: ScreenUtil().setWidth(8.0),
- height: ScreenUtil().setWidth(8.0),
- alignment: Alignment.center,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(16.0),
- color: Color(AppColors.NotifyDotBg)),
- // child: Text(conversationItemData.statuz.toString(),style:TextStyle(fontSize: ScreenUtil().setSp(15),color: Color(AppColors.NotifyDotText))),
- );
- }
- Widget muteIcon() {
- return new Icon(ICons.MUTE_ICON);
- }
- }
|