conversation_item.dart 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:liftmanager/internal/friends/friends_router.dart';
  4. import '../../common/style/style.dart' show AppColors,Constants,ICons;
  5. import 'package:liftmanager/routers/fluro_navigator.dart';
  6. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  7. import 'package:liftmanager/internal/friends/model/friend_model.dart';
  8. import 'package:liftmanager/utils/time_format.dart';
  9. import 'package:liftmanager/widgets/load_image.dart';
  10. import 'package:liftmanager/utils/theme_utils.dart';
  11. // import '../../routers/application.dart';
  12. class ConversationItem extends StatelessWidget {
  13. ConversationItem(this.conversationItemData)
  14. :assert(conversationItemData != null);
  15. final Records conversationItemData;
  16. var tapPos;
  17. @override
  18. Widget build(BuildContext context) {
  19. return Material(
  20. color: ThemeUtils.getTabsBg(context),
  21. child: InkWell(
  22. onTap: (){
  23. print('打开会话:${conversationItemData.userName}');
  24. // conversationItemData.sessionid
  25. // NavigatorUtils.push(context, "${FriendsRouter.chatRoom}");
  26. if(conversationItemData.dataTable == 3){
  27. NavigatorUtils.push(context, "${BbsRouter.chatRoom}?id=${conversationItemData.sessionid}&type=nearToOne");
  28. }else {
  29. NavigatorUtils.push(context, "${BbsRouter.chatRoom}?id=${conversationItemData.sessionid}&type=oneToOne");
  30. }
  31. // NavigatorUtils.push(context, "${BbsRouter.chatRoom}?id=${conversationItemData.sessionid}&type=oneToOne");
  32. },
  33. onTapDown: (TapDownDetails details) {
  34. tapPos = details.globalPosition;
  35. },
  36. onLongPress: (){
  37. print('hehe');
  38. },
  39. child: Container(
  40. height: ScreenUtil().setHeight(120),
  41. child: Row(
  42. mainAxisAlignment: MainAxisAlignment.center,
  43. children: <Widget>[
  44. avatarContainer(conversationItemData),
  45. Content(),
  46. ],
  47. ),
  48. ),
  49. ),
  50. );
  51. }
  52. Widget Content(){
  53. return Expanded(
  54. child: Container(
  55. height: ScreenUtil().setHeight(130),
  56. margin: EdgeInsets.only(left:ScreenUtil().setWidth(20.0)),
  57. decoration: BoxDecoration(
  58. border: Border(
  59. bottom: BorderSide(width: 0.5,color: Color(AppColors.DividerColor),)
  60. )
  61. ),
  62. child: Row(
  63. children: <Widget>[
  64. Title(conversationItemData),
  65. // Tip(conversationItemData)
  66. ],
  67. ),
  68. ),
  69. );
  70. }
  71. Widget ClipRRectImg(){
  72. return ClipRRect(
  73. borderRadius: BorderRadius.circular(50.0),
  74. child: LoadNetworkImage(conversationItemData.avatarUrl),
  75. );
  76. }
  77. Widget Avatar(conversationItemData){
  78. return Container(
  79. margin: EdgeInsets.only(left:ScreenUtil().setWidth(20.0)),
  80. child: ClipRRectImg(),
  81. width: ScreenUtil().setWidth(43),
  82. height: ScreenUtil().setWidth(43)
  83. );
  84. }
  85. getCaseType(type){
  86. String str;
  87. if(type == 1){
  88. str = "问诊服务";
  89. }else if (type == 2){
  90. str = "出诊服务";
  91. }else if (type == 3){
  92. str = "附近的人";
  93. }
  94. return str;
  95. }
  96. Widget Title(conversationItemData){
  97. return Expanded(
  98. child: Column(
  99. mainAxisAlignment: MainAxisAlignment.center,
  100. crossAxisAlignment: CrossAxisAlignment.start,
  101. children: <Widget>[
  102. Row(
  103. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  104. children: <Widget>[
  105. Expanded(
  106. child: Text(
  107. conversationItemData.userName??"",
  108. style: TextStyle(fontSize: ScreenUtil().setSp(15.0),fontWeight:FontWeight.w400),
  109. maxLines: 1,
  110. overflow: TextOverflow.ellipsis,
  111. ),
  112. ),
  113. Tip(conversationItemData)
  114. ],
  115. ),
  116. SizedBox(height: ScreenUtil().setHeight(10.0),),
  117. Row(
  118. crossAxisAlignment: CrossAxisAlignment.end,
  119. mainAxisAlignment: MainAxisAlignment.start,
  120. children: <Widget>[
  121. Container(
  122. child:Text(
  123. conversationItemData.dataTable!=null?getCaseType(conversationItemData.dataTable):"",
  124. style: TextStyle(fontSize: ScreenUtil().setSp(12.0),color: Color(0xff0388FD)),
  125. ),
  126. ),
  127. SizedBox(width: ScreenUtil().setWidth(5.0),),
  128. Expanded(
  129. child: Text(
  130. conversationItemData.name??"",
  131. style: TextStyle(fontSize: ScreenUtil().setSp(12.0),color: Color(AppColors.DesTextColor)),
  132. maxLines: 1,
  133. overflow: TextOverflow.ellipsis,
  134. ),
  135. )
  136. ],
  137. ),
  138. SizedBox(height: ScreenUtil().setHeight(10.0),),
  139. conversationItemData.dataTable!=3? Text(
  140. "问题描述:" + (conversationItemData.expression!=null?conversationItemData.expression:""),
  141. style: TextStyle(fontSize: ScreenUtil().setSp(12.0),color: Color(AppColors.DesTextColor)),
  142. maxLines: 1,
  143. overflow: TextOverflow.ellipsis,
  144. ):Container(child:null),
  145. conversationItemData.dataTable!=3?SizedBox(height: ScreenUtil().setHeight(10.0),):Container(child:null),
  146. Text(
  147. conversationItemData.msg??"",
  148. style: TextStyle(fontSize: ScreenUtil().setSp(12.0),color: Color(AppColors.DesTextColor)),
  149. maxLines: 1,
  150. overflow: TextOverflow.ellipsis,
  151. ),
  152. ],
  153. ),
  154. );
  155. }
  156. Widget Tip(conversationItemData){
  157. var _rightArea =<Widget>[
  158. Text(
  159. conversationItemData.time!=null?DateUtils.instance.getFormartData(timeSamp: conversationItemData.time,format: "yyyy-MM-dd HH:mm:ss"):(conversationItemData.createTime!=null?DateUtils.instance.getFormartData(timeSamp: conversationItemData.createTime,format: "yyyy-MM-dd HH:mm:ss"):""),
  160. style:TextStyle(fontSize: ScreenUtil().setSp(12.0),color: Color(AppColors.DesTextColor))),
  161. // SizedBox(height: ScreenUtil().setHeight(15.0),)
  162. ];
  163. // if(conversationItemData.isMute){
  164. // _rightArea.add(new Icon(ICons.MUTE_ICON,color: Color(AppColors.ConversationMuteIcon),size: ScreenUtil().setSp(15),));
  165. // }else{
  166. // _rightArea.add(new Icon(ICons.MUTE_ICON,color: Colors.transparent,size: ScreenUtil().setSp(15),));
  167. // }
  168. return Container(
  169. width:ScreenUtil().setWidth(130),
  170. margin: EdgeInsets.only(right: ScreenUtil().setWidth(10.0)),
  171. child: Column(
  172. mainAxisAlignment: MainAxisAlignment.center,
  173. children: _rightArea
  174. ),
  175. );
  176. }
  177. Widget avatarContainer(conversationItemData){
  178. // if(conversationItemData.statuz > 0){
  179. // return Stack(
  180. // overflow: Overflow.visible,
  181. // children: <Widget>[
  182. // Avatar(conversationItemData),
  183. // Positioned(
  184. // right:-3.0 ,
  185. // top: -3.0,
  186. // child: unreadMsgCountText(conversationItemData),
  187. // )
  188. // ],
  189. // );
  190. // }else{
  191. // return Avatar(conversationItemData);
  192. // }
  193. return Avatar(conversationItemData);
  194. }
  195. Widget unreadMsgCountText(conversationItemData){
  196. return Container(
  197. width: ScreenUtil().setWidth(16.0),
  198. height: ScreenUtil().setWidth(16.0),
  199. alignment: Alignment.center,
  200. decoration: BoxDecoration(
  201. borderRadius: BorderRadius.circular(35.0),
  202. color: Color(AppColors.NotifyDotBg)
  203. ),
  204. child: Text(conversationItemData.statuz.toString(),style:TextStyle(fontSize: ScreenUtil().setSp(15),color: Color(AppColors.NotifyDotText))),
  205. );
  206. }
  207. Widget muteIcon(){
  208. return new Icon(ICons.MUTE_ICON);
  209. }
  210. }