Hibok
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

471 строка
15 KiB

  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:chat/data/WebData.dart';
  3. import 'package:chat/data/constants.dart';
  4. import 'package:chat/generated/i18n.dart';
  5. import 'package:chat/home/ProfilePage.dart';
  6. import 'package:chat/utils/LoveToggle.dart';
  7. import 'package:chat/utils/MessageMgr.dart';
  8. import 'package:chat/utils/screen.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter/material.dart' as prefix0;
  11. import 'package:oktoast/oktoast.dart';
  12. import '../utils/HttpUtil.dart';
  13. import 'package:dio/dio.dart';
  14. import "../data/UserData.dart";
  15. import 'TempUserChips.dart';
  16. class TempUserCard extends StatelessWidget {
  17. final String userName;
  18. final bool isReal;
  19. final String city; //城市
  20. final int age; //年龄
  21. final String constellation; //星座
  22. final String professional; //职业
  23. final String isOnline;
  24. final double distance;
  25. final int userId;
  26. final bool isLove;
  27. final bool isBalck;
  28. final String headUrl;
  29. final bool payImg;
  30. final int imgNum;
  31. final int sex;
  32. final bool isHidden;
  33. final int member;
  34. final bool hiddenDistince;
  35. final int nameSize;
  36. TempUserCard(
  37. {Key key,
  38. this.userName,
  39. this.isReal: false,
  40. this.city,
  41. this.age,
  42. this.constellation,
  43. this.professional,
  44. this.isOnline,
  45. this.distance,
  46. this.userId,
  47. this.isLove: false,
  48. this.sex,
  49. this.headUrl: '',
  50. this.payImg: false,
  51. this.imgNum: 0,
  52. this.isHidden: false,
  53. this.member: 0,
  54. this.hiddenDistince: false,
  55. this.nameSize = 8,
  56. this.isBalck: false})
  57. : super(key: key);
  58. @override
  59. Widget build(BuildContext context) {
  60. bool isVIP = member > 0;
  61. bool isSVIP = member == 2;
  62. //头像
  63. Widget headImg() {
  64. double height = Screen.width;
  65. return Stack(
  66. children: <Widget>[
  67. Container(
  68. height: height-40,
  69. width: height-40,
  70. child: ClipRRect(
  71. borderRadius: BorderRadius.only(
  72. topLeft: Radius.circular(15),
  73. topRight: Radius.circular(15)),
  74. child: headUrl == '' || headUrl == null
  75. ? Image.asset(
  76. Constants.DefaultHeadImgUrl,
  77. width: height-40,
  78. height: height-40,
  79. )
  80. : CachedNetworkImage(
  81. imageUrl: headUrl,
  82. placeholder: (context, url) => Image.asset(
  83. Constants.DefaultHeadImgUrl,
  84. width: height-40,
  85. height: height-40,
  86. ),
  87. fit: BoxFit.cover,
  88. )),
  89. ),
  90. Positioned(
  91. left: 0,
  92. bottom: 0,
  93. child: Container(
  94. height: 27,
  95. width: 54,
  96. decoration: BoxDecoration(
  97. color: Colors.black54,
  98. borderRadius: BorderRadius.only(
  99. topRight: Radius.circular(10))),
  100. child: Row(
  101. //mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  102. children: <Widget>[
  103. Padding(
  104. padding: EdgeInsets.only(left: 6),
  105. child:
  106. Icon(Icons.image, size: 15, color: Colors.white)),
  107. Padding(
  108. padding: EdgeInsets.only(left: 5, top: 2),
  109. child: fixedText(imgNum.toString(),
  110. color: Colors.white, fontSize: 14),
  111. ),
  112. ],
  113. ),
  114. ))
  115. ],
  116. );
  117. }
  118. //名字以及认证状态
  119. Widget nameState() {
  120. return Row(
  121. children: <Widget>[
  122. fixedText(WebData().subUserName(userName, size: nameSize),
  123. fontSize: 15),
  124. isReal && sex == 2
  125. ? Container(
  126. margin: EdgeInsets.only(left: 5),
  127. padding:
  128. EdgeInsets.only(top: 2, bottom: 2, left: 5, right: 5),
  129. alignment: Alignment.center,
  130. decoration: BoxDecoration(
  131. borderRadius: BorderRadius.circular(10),
  132. color: Constants.PurpleBackgroundColor,
  133. ),
  134. child: fixedText('Real', fontSize: 8, color: Colors.white))
  135. : Container(),
  136. isVIP && sex == 1
  137. ? Container(
  138. margin: EdgeInsets.only(left: 5),
  139. child: isSVIP ? Constants.svipIcon : Constants.vipIcon)
  140. : Container(),
  141. ],
  142. );
  143. }
  144. // void _selectValue(str) async {
  145. // if (str == 'collection') {
  146. // Map data = {
  147. // "userid": UserData().basicInfo.userId,
  148. // "type": 0,
  149. // "followUserId": this.userId,
  150. // };
  151. // data['sign'] = TokenMgr().getSign(data);
  152. // Response res = await HttpUtil()
  153. // .post('userfollow/follow/insert', data: data, isShowLoading: true);
  154. // Map resData = res.data;
  155. // if (resData['code'] == 0) {
  156. // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 0});
  157. // showToast(resData['msg']);
  158. // }
  159. // } else if (str == 'cancleCollection') {
  160. // Map data = {
  161. // "userid": UserData().basicInfo.userId,
  162. // "type": 0,
  163. // "followUserId": this.userId,
  164. // };
  165. // data['sign'] = TokenMgr().getSign(data);
  166. // Response res = await HttpUtil()
  167. // .post('userfollow/follow/cancel', data: data, isShowLoading: true);
  168. // Map resData = res.data;
  169. // if (resData['code'] == 0) {
  170. // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 2});
  171. // showToast(resData['msg']);
  172. // }
  173. // } else if (str == 'black') {
  174. // Map data = {
  175. // "userid": UserData().basicInfo.userId,
  176. // "type": 1,
  177. // "followUserId": this.userId,
  178. // };
  179. // data['sign'] = TokenMgr().getSign(data);
  180. // Response res =
  181. // await HttpUtil().post('userfollow/follow/insert', data: data);
  182. // Map resData = res.data;
  183. // showToast(resData['msg']);
  184. // if (resData['code'] == 0) {
  185. // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 1});
  186. // }
  187. // } else if (str == 'cancleBlack') {
  188. // var data = {
  189. // "userid": UserData().basicInfo.userId,
  190. // "type": 1,
  191. // "followUserId": this.userId,
  192. // };
  193. // data['sign'] = TokenMgr().getSign(data);
  194. // Response res =
  195. // await HttpUtil().post('userfollow/follow/cancel', data: data);
  196. // Map resData = res.data;
  197. // showToast(resData['msg']);
  198. // if (resData['code'] == 0) {
  199. // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 2});
  200. // }
  201. // }
  202. // }
  203. //距离、在线以及相册
  204. Widget otherWidget() {
  205. var greyColor = const Color(0xFFB2B2B2);
  206. return Row(
  207. children: <Widget>[
  208. InfoTile(
  209. icon: IconData(0xe630, fontFamily: Constants.IconFontFamily),
  210. title: hiddenDistince
  211. ? I18n.of(context).secrecy
  212. : (UserData().hasLocationPermission
  213. ? WebData().getDistanceString(distance)
  214. : I18n.of(context).unknown),
  215. titleColor: greyColor,
  216. isDivider: true),
  217. InfoTile(
  218. title: isOnline,
  219. titleColor: greyColor,
  220. isDivider: payImg || isHidden),
  221. isHidden
  222. ? InfoTile(
  223. icon: IconData(0xe645, fontFamily: 'iconfont'),
  224. iconHeight: 22,
  225. title: I18n.of(context).application_view,
  226. titleColor: greyColor,
  227. isDivider: false,
  228. onTap: () {
  229. print('click');
  230. })
  231. : Container(),
  232. payImg
  233. ? InfoTile(
  234. icon: IconData(0xe632, fontFamily: Constants.IconFontFamily),
  235. title: I18n.of(context).paid_photo,
  236. titleColor: greyColor,
  237. isDivider: false,
  238. onTap: () {
  239. print('click');
  240. })
  241. : Container(),
  242. ],
  243. );
  244. }
  245. return InkWell(
  246. onTap: () {
  247. // if (sex == UserData().basicInfo.sex) {
  248. // showToast(UserData().basicInfo.sex == 1
  249. // ? I18n.of(context).cant_see
  250. // : I18n.of(context).cant_see2);
  251. // return;
  252. // }
  253. Navigator.of(context).push(
  254. new MaterialPageRoute(
  255. builder: (context) {
  256. return ProfilePage(
  257. userId: userId,
  258. );
  259. },
  260. ),
  261. );
  262. },
  263. child: Container(alignment: Alignment.center,color: AppColors.NewAppbarBgColor,width: Screen.width,child: Container(width: Screen.width-40,child: Column(
  264. crossAxisAlignment: CrossAxisAlignment.center,
  265. children: <Widget>[
  266. SizedBox(height: 23,),
  267. headImg(),
  268. Container(decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.only(
  269. bottomLeft: Radius.circular(15),
  270. bottomRight: Radius.circular(15))) ,child: Column(children: <Widget>[
  271. Container(
  272. //背景
  273. padding: EdgeInsets.only(left: 15,right: 10, bottom: 14.5,top: 5),
  274. child: Column(children: <Widget>[
  275. Stack(
  276. children: <Widget>[
  277. Row(
  278. children: <Widget>[
  279. //头像图片
  280. //信息
  281. Container(
  282. width: MediaQuery.of(context).size.width - 104,
  283. child: Column(
  284. crossAxisAlignment: CrossAxisAlignment.start,
  285. mainAxisAlignment: MainAxisAlignment.end,
  286. children: <Widget>[
  287. nameState(), //名字以及状态
  288. //用户的信息标记
  289. Padding(padding: EdgeInsets.only(top: 9)),
  290. TempUserChips(
  291. city: city,
  292. age: age,
  293. constellation: constellation,
  294. professional: professional),
  295. Padding(padding: EdgeInsets.only(top: 4)),
  296. otherWidget(),
  297. ],
  298. )),
  299. ],
  300. ),
  301. ],
  302. )
  303. ],)),
  304. SizedBox(height: 5,),
  305. Container(
  306. child: //赞
  307. sex == UserData().basicInfo.sex
  308. ? InkWell(
  309. onTap: () {
  310. showToast(UserData().isMan()
  311. ? I18n.of(context).not_love
  312. : I18n.of(context).not_love2);
  313. },
  314. child: Container(
  315. width: 100,
  316. height: 30,
  317. decoration: BoxDecoration(border: Border.all(color: Color(0xFF878787), width: 1),borderRadius: BorderRadius.circular(16)) ,
  318. padding: EdgeInsets.only(
  319. left: 15, right: 15, bottom: 5,top: 5 ),
  320. child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
  321. Icon(
  322. IconData(
  323. 0xe625,
  324. fontFamily: Constants.IconFontFamily,
  325. ),
  326. size: 15,
  327. color: Color(0xffB2B2B2),
  328. ),
  329. SizedBox(width: 5,),
  330. Text('LOVE',style: prefix0.TextStyle(color: Color(0xffB2B2B2)),)
  331. ],)))
  332. : LoveToggle(isActive: isLove,onTap: (bool isActive) async {
  333. Map data = {
  334. "userid": UserData().basicInfo.userId,
  335. "type": 0,
  336. "followUserId": this.userId,
  337. };
  338. data['sign'] = TokenMgr().getSign(data);
  339. if (isActive) {
  340. Response res = await HttpUtil().post(
  341. 'userfollow/follow/insert',
  342. data: data,
  343. isShowLoading: true);
  344. Map resData = res.data;
  345. showToast(resData['msg']);
  346. if (resData['code'] == 0) {
  347. MessageMgr().emit('refresh_love_list',
  348. {'UserId': userId, 'flag': 0});
  349. showToast(resData['msg']);
  350. }
  351. } else {
  352. Response res = await HttpUtil().post(
  353. 'userfollow/follow/cancel',
  354. data: data,
  355. isShowLoading: true);
  356. Map resData = res.data;
  357. if (resData['code'] == 0) {
  358. MessageMgr().emit('refresh_love_list',
  359. {'UserId': userId, 'flag': 2});
  360. showToast(resData['msg']);
  361. }
  362. }
  363. }),
  364. ),
  365. SizedBox(height: 15,),
  366. ],),),
  367. ],
  368. ),),));
  369. }
  370. }
  371. const double TileHeight = 14;
  372. class InfoTile extends StatelessWidget {
  373. @required
  374. final String title;
  375. final Color titleColor;
  376. final IconData icon;
  377. final double iconHeight;
  378. final VoidCallback onTap;
  379. final bool isDivider;
  380. const InfoTile(
  381. {Key key,
  382. this.title,
  383. this.titleColor,
  384. this.icon,
  385. this.onTap,
  386. this.iconHeight: TileHeight,
  387. this.isDivider = false})
  388. : super(key: key);
  389. @override
  390. Widget build(BuildContext context) {
  391. List<Widget> elements = [];
  392. if (icon != null) {
  393. elements.add(Padding(
  394. padding: EdgeInsets.only(bottom: 2),
  395. child: Icon(icon, size: TileHeight, color: titleColor)));
  396. }
  397. elements.add(
  398. Container(
  399. constraints: BoxConstraints(maxWidth: 140),
  400. padding: EdgeInsets.only(right: 5),
  401. child: Text(title,
  402. textScaleFactor: 1.0,
  403. style: TextStyle(
  404. fontSize: 11,
  405. color: titleColor,
  406. fontWeight: FontWeight.normal),
  407. textAlign: TextAlign.center)),
  408. );
  409. if (isDivider) {
  410. elements.add(Container(
  411. height: 12,
  412. child: VerticalDivider(
  413. width: 1,
  414. indent: 0,
  415. endIndent: 0,
  416. color: Colors.black26,
  417. )));
  418. }
  419. var tileWidget = Container(
  420. padding: EdgeInsets.only(right: 5),
  421. child: Row(
  422. //crossAxisAlignment: CrossAxisAlignment.start,
  423. children: elements,
  424. ));
  425. if (onTap != null) {
  426. return InkWell(
  427. child: tileWidget,
  428. onTap: onTap,
  429. );
  430. } else {
  431. return tileWidget;
  432. }
  433. }
  434. }