Hibok
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

811 行
28 KiB

  1. import 'package:chat/data/UserData.dart';
  2. import 'package:chat/data/WebData.dart';
  3. import 'package:chat/generated/i18n.dart';
  4. import 'package:chat/home/ProfilePage.dart';
  5. import 'package:chat/home/rich_title.dart';
  6. import 'package:chat/utils/CustomUI.dart';
  7. import 'package:chat/utils/HttpUtil.dart';
  8. import 'package:chat/utils/MessageMgr.dart';
  9. import 'package:chat/utils/PicSwiper.dart';
  10. import 'package:chat/utils/TokenMgr.dart';
  11. import 'package:chat/utils/conversation_table.dart';
  12. import 'package:chat/utils/friend_list_mgr.dart';
  13. import 'package:chat/utils/screen.dart';
  14. import 'package:dio/dio.dart';
  15. import 'package:flutter/cupertino.dart';
  16. import 'package:flutter/material.dart';
  17. import 'package:flutter/services.dart';
  18. import 'package:oktoast/oktoast.dart';
  19. import 'package:pull_to_refresh/pull_to_refresh.dart';
  20. import 'package:url_launcher/url_launcher.dart';
  21. import '../data/constants.dart' show AppColors, Constants;
  22. import '../data/conversation.dart';
  23. import 'package:cached_network_image/cached_network_image.dart';
  24. import 'ProgramDetail.dart';
  25. class _ConversationItem extends StatelessWidget {
  26. const _ConversationItem(
  27. {Key key,
  28. this.conversation,
  29. this.callback,
  30. this.showRight = true,
  31. this.rightButton,
  32. this.applyInfo,
  33. this.bgColor,
  34. this.title})
  35. : assert(conversation != null),
  36. super(key: key);
  37. final Widget rightButton;
  38. final Conversation conversation;
  39. final callback;
  40. final bool showRight;
  41. final title;
  42. final applyInfo;
  43. final bgColor;
  44. @override
  45. Widget build(BuildContext context) {
  46. Widget avatar;
  47. double width = 53;
  48. if (conversation.isAvatarFromNet()) {
  49. avatar = ClipRRect(
  50. borderRadius: BorderRadius.circular(10),
  51. child: CachedNetworkImage(
  52. imageUrl: conversation.avatar,
  53. placeholder: (context, url) => Image.asset(
  54. Constants.DefaultHeadImgUrl,
  55. width: width,
  56. height: width,
  57. ),
  58. fit: BoxFit.cover,
  59. width: width,
  60. height: width,
  61. ));
  62. } else {
  63. avatar = ClipRRect(
  64. borderRadius: BorderRadius.circular(10),
  65. child: Container(
  66. width: width,
  67. height: width,
  68. alignment: Alignment.center,
  69. decoration: BoxDecoration(
  70. gradient: this.bgColor,
  71. borderRadius: BorderRadius.all(Radius.circular(50))),
  72. child: Image.asset(
  73. conversation.avatar,
  74. height: 27,
  75. )));
  76. }
  77. _buildBotton(str, callback) {
  78. return InkWell(
  79. onTap: callback,
  80. child: Container(
  81. padding: EdgeInsets.only(top: 5, left: 15, right: 15, bottom: 5),
  82. decoration: BoxDecoration(
  83. border:
  84. Border.all(color: Constants.ConfrimButtonColor, width: 1),
  85. color: Constants.ConfrimButtonColor,
  86. borderRadius: BorderRadius.all(Radius.circular(5))),
  87. child: fixedText(
  88. str,
  89. fontSize: 12,
  90. color: Colors.white,
  91. ),
  92. ));
  93. }
  94. void doApply(state, callback) async {
  95. Map data = {
  96. "id": applyInfo['applyId'],
  97. "userId": UserData().basicInfo.userId,
  98. "status": state,
  99. };
  100. data['sign'] = TokenMgr().getSign(data);
  101. Response res = await HttpUtil().post('user/handler/apply', data: data);
  102. if (res == null) {
  103. return;
  104. }
  105. var resData = res.data;
  106. if (resData['code'] == 0) {
  107. callback(resData['msg']);
  108. } else {}
  109. }
  110. void doFriendApply(state, callback) async {
  111. Map data = {
  112. "id": applyInfo['applyId'],
  113. "userId": UserData().basicInfo.userId,
  114. "status": state,
  115. };
  116. data['sign'] = TokenMgr().getSign(data);
  117. Response res =
  118. await HttpUtil().post('friendship/handler/apply', data: data);
  119. if (res == null) {
  120. return;
  121. }
  122. var resData = res.data;
  123. if (resData['code'] == 0) {
  124. callback(resData['msg']);
  125. } else {}
  126. }
  127. var bottomWiget = applyInfo == null
  128. ? Container()
  129. : Container(
  130. padding: EdgeInsets.only(left: 0, top: 10),
  131. decoration: BoxDecoration(
  132. color: Color(AppColors.ConversationItemBgColor),
  133. ),
  134. child: Row(
  135. crossAxisAlignment: CrossAxisAlignment.center,
  136. children: applyInfo['type'] == 0 || applyInfo['type'] == 6
  137. ? <Widget>[
  138. CustomUI.buildImgCover(
  139. applyInfo['imgId'],
  140. [
  141. PicSwiperItem(applyInfo['showUrl'],
  142. id: applyInfo['imgId'],
  143. type: applyInfo['type'] == 0
  144. ? PhotoType.destroy.index
  145. : PhotoType.free.index,
  146. isWatch: applyInfo['isWatch'],
  147. userId: applyInfo['userId'])
  148. ],
  149. applyInfo['showUrl'],
  150. 65,
  151. 10,
  152. applyInfo['isWatch'],
  153. context,
  154. applyInfo['type'] == 0
  155. ? PhotoType.destroy.index
  156. : PhotoType.free.index),
  157. Expanded(
  158. child: applyInfo['type'] == 0
  159. ? Container(
  160. alignment: Alignment.centerRight,
  161. padding: EdgeInsets.only(top: 40),
  162. child: applyInfo['state'] == 0
  163. ? Row(
  164. mainAxisAlignment:
  165. MainAxisAlignment.end,
  166. children: <Widget>[
  167. _buildBotton(I18n.of(context).aging,
  168. () {
  169. doApply(1, (msg) {
  170. showToast(msg);
  171. applyInfo['state'] = 1;
  172. MessageMgr()
  173. .emit('do_info_apply');
  174. });
  175. }),
  176. SizedBox(
  177. width: 10,
  178. ),
  179. _buildBotton(I18n.of(context).refuse,
  180. () {
  181. doApply(2, (msg) {
  182. showToast(msg);
  183. applyInfo['state'] = 2;
  184. MessageMgr()
  185. .emit('do_info_apply');
  186. });
  187. }),
  188. ],
  189. )
  190. : Padding(
  191. padding: EdgeInsets.only(right: 0),
  192. child: Text(
  193. applyInfo['state'] == 1
  194. ? I18n.of(context).passed
  195. : I18n.of(context).rejected,
  196. style: TextStyle(
  197. color: Constants.GreyTextColor,
  198. fontSize: 13),
  199. textScaleFactor: 1.0,
  200. ),
  201. ),
  202. )
  203. : Container(),
  204. )
  205. ]
  206. : [
  207. Expanded(child: Container()),
  208. Container(
  209. alignment: Alignment.centerRight,
  210. child: applyInfo['state'] == 0
  211. ? Row(
  212. mainAxisAlignment: MainAxisAlignment.end,
  213. children: <Widget>[
  214. _buildBotton(I18n.of(context).agree, () {
  215. doFriendApply(1, (msg) {
  216. showToast(msg);
  217. applyInfo['state'] = 1;
  218. var friendModel =
  219. FriendModel.fromServerJson({
  220. 'UserId': applyInfo['userId'],
  221. 'ImgUrl': applyInfo['imgUrl'],
  222. 'UserName': applyInfo['name']
  223. });
  224. FriendListMgr().addFriend(friendModel);
  225. MessageMgr().emit('do_info_apply');
  226. MessageMgr().emit('do_friend_apply', {
  227. 'userId': applyInfo['userId'],
  228. 'state': 1
  229. });
  230. MessageMgr().emit('Add friend');
  231. });
  232. }),
  233. SizedBox(
  234. width: 10,
  235. ),
  236. _buildBotton(I18n.of(context).refuse, () {
  237. doFriendApply(2, (msg) {
  238. showToast(msg);
  239. applyInfo['state'] = 2;
  240. MessageMgr().emit('do_info_apply');
  241. MessageMgr().emit('do_friend_apply', {
  242. 'userId': applyInfo['userId'],
  243. 'state': 2
  244. });
  245. });
  246. }),
  247. ],
  248. )
  249. : Padding(
  250. padding: EdgeInsets.only(right: 0),
  251. child: Text(
  252. applyInfo['state'] == 1
  253. ? I18n.of(context).passed
  254. : I18n.of(context).rejected,
  255. style: TextStyle(
  256. color: Constants.GreyTextColor,
  257. fontSize: 13),
  258. textScaleFactor: 1.0,
  259. ),
  260. ),
  261. ),
  262. ],
  263. ),
  264. );
  265. return InkWell(
  266. child: Container(
  267. padding:
  268. const EdgeInsets.only(left: 16.5, top: 11, bottom: 11, right: 14.5),
  269. decoration: BoxDecoration(
  270. color: Color(AppColors.ConversationItemBgColor),
  271. border: Border(
  272. bottom: BorderSide(
  273. color: AppColors.DividerColor,
  274. width: Constants.DividerWidth))),
  275. child: Column(
  276. children: <Widget>[
  277. Row(
  278. crossAxisAlignment: CrossAxisAlignment.start,
  279. children: <Widget>[
  280. avatar,
  281. Container(width: 19.0),
  282. Expanded(
  283. child: Container(
  284. child: Column(
  285. crossAxisAlignment: CrossAxisAlignment.start,
  286. children: <Widget>[
  287. Container(
  288. child: title == null
  289. ? Text(conversation.title,
  290. textScaleFactor: 1.0,
  291. style: TextStyle(
  292. fontSize: 12,
  293. color: Constants.LightGreyTextColor))
  294. : title),
  295. Container(
  296. padding: EdgeInsets.only(top: 5, bottom: 5),
  297. child: Row(
  298. children: <Widget>[
  299. Text(conversation.desc,
  300. textScaleFactor: 1.0,
  301. style: TextStyle(
  302. fontSize: 11,
  303. color: Constants.LightGreyTextColor)),
  304. showRight
  305. ? Expanded(
  306. child: Container(
  307. alignment: Alignment.centerRight,
  308. child: rightButton == null
  309. ? Text(
  310. '${I18n.of(context).go_see}>',
  311. textScaleFactor: 1.0,
  312. style: TextStyle(
  313. fontSize: 11,
  314. color: Constants
  315. .LightGreyTextColor))
  316. : rightButton,
  317. ),
  318. )
  319. : Container()
  320. ],
  321. )),
  322. applyInfo != null && applyInfo['content'] != null
  323. ? Container(
  324. child: Text(applyInfo['content'],
  325. textScaleFactor: 1.0,
  326. style: TextStyle(
  327. fontSize: 14,
  328. color: Constants.LightGreyTextColor)))
  329. : Container(),
  330. ],
  331. ),
  332. )),
  333. ],
  334. ),
  335. bottomWiget
  336. ],
  337. ),
  338. ),
  339. onTap: () {
  340. callback();
  341. },
  342. );
  343. }
  344. }
  345. class InfoListPage extends StatefulWidget {
  346. @required
  347. final String title;
  348. @required
  349. final int type;
  350. InfoListPage({Key key, this.title = "", this.type = 1}) : super(key: key);
  351. _InfoListPageState createState() => _InfoListPageState();
  352. }
  353. class _InfoListPageState extends State<InfoListPage>
  354. with SingleTickerProviderStateMixin {
  355. List list = new List(); //列表要展示的数据
  356. RefreshController _refreshController =
  357. RefreshController(initialRefresh: true);
  358. int _page = 1; //加载的页数
  359. int rows = 20;
  360. @override
  361. void initState() {
  362. super.initState();
  363. messageOn();
  364. }
  365. void initList(data) {
  366. list.clear();
  367. if (data != null) {
  368. list.addAll(data);
  369. }
  370. if (mounted) setState(() {});
  371. }
  372. void addList(data) {
  373. if (data == null || data.length == 0) {
  374. _page--;
  375. _refreshController.loadNoData();
  376. } else {
  377. list.addAll(data);
  378. _refreshController.loadComplete();
  379. }
  380. setState(() {});
  381. }
  382. messageApply(data) {
  383. _onRefresh();
  384. }
  385. msgPhoto(id) {
  386. for (int i = 0; i < list.length; i++) {
  387. if (list[i]['ApplyImg'] == id) {
  388. setState(() {
  389. list[i]['IsCheck'] = 1;
  390. });
  391. break;
  392. }
  393. }
  394. }
  395. void messageOn() {
  396. MessageMgr().on('do_info_apply', messageApply);
  397. MessageMgr().on('refresh_photo', msgPhoto);
  398. }
  399. void messageOff() {
  400. MessageMgr().off('do_info_apply', messageApply);
  401. MessageMgr().off('refresh_photo', msgPhoto);
  402. }
  403. getNewData(callback) {
  404. switch (widget.type) {
  405. case InfoType.Apply: //获取申请通知
  406. getData('user/check/realecords', callback);
  407. break;
  408. case InfoType.Evaluation: //获取评价通知
  409. getData('evaluate/user/realecordslist', callback);
  410. break;
  411. case InfoType.System: //获取系统通知
  412. getData('message/center/list', callback);
  413. break;
  414. case InfoType.Radio: //获取电台消息
  415. getData('message/center/cast', callback);
  416. break;
  417. case InfoType.IncomeMoney: //获取钱包通知
  418. getData('wallet/balance/detail', callback);
  419. break;
  420. default:
  421. }
  422. }
  423. Future getData(url, callback) async {
  424. Map data = {
  425. "userId": UserData().basicInfo.userId,
  426. };
  427. if (widget.type == InfoType.System) {
  428. data['type'] = UserData().basicInfo.sex;
  429. }
  430. if (widget.type == InfoType.IncomeMoney) {
  431. data['type'] = 2;
  432. }
  433. data['sign'] = TokenMgr().getSign(data);
  434. data["page"] = _page;
  435. data['rows'] = rows;
  436. Response res = await HttpUtil()
  437. .post(url, data: data, failback: () => Navigator.of(context).pop());
  438. _refreshController.refreshCompleted();
  439. var resData = res.data;
  440. print(resData);
  441. if (resData['code'] == 0) {
  442. callback(resData['data']);
  443. } else {
  444. showToast(resData['msg']);
  445. }
  446. }
  447. /*
  448. * 下拉刷新方法,为list重新赋值
  449. */
  450. Future<Null> _onRefresh() async {
  451. _page = 1;
  452. getNewData(initList);
  453. }
  454. @override
  455. void dispose() {
  456. _refreshController.dispose();
  457. messageOff();
  458. super.dispose();
  459. }
  460. //钱包通知
  461. Widget _buildMoneyInfo(data) {
  462. String imgUrl = data['HeadImg'] == null ||
  463. data['HeadImg'] == '' ||
  464. data['ChangeUserId'] == 0
  465. ? UserData().basicInfo.headimgurl
  466. : data['HeadImg'];
  467. return _ConversationItem(
  468. conversation: Conversation(
  469. avatar: imgUrl,
  470. title: '',
  471. desc: WebData().getLoginTime(context, data['CreateTime']),
  472. updateAt: '',
  473. ),
  474. bgColor: Constants.MoneyGradient,
  475. showRight: false,
  476. // isInCome: widget.type == 2,
  477. // money: isAdd(data['DetailType']) ? data['Value'] : -data['Value'],
  478. title: RichTitle.getRichTitleWidget(data, context,
  479. widget.type == 1 ? InfoType.MyMoney : InfoType.IncomeMoney,
  480. titleStyle: TextStyle(fontSize: 12, color: const Color(0XFF7F7F7F)),
  481. nameStyle: TextStyle(
  482. fontWeight: FontWeight.normal,
  483. fontSize: 13,
  484. color: Constants.BlackTextColor)),
  485. callback: () {
  486. // if (data['ChangeUserId'] != 0) {
  487. // Navigator.of(context).push(
  488. // new MaterialPageRoute(
  489. // builder: (context) {
  490. // return ProfilePage(
  491. // userId: data['UserId'] == UserData().basicInfo.userId
  492. // ? data['ChangeUserId']
  493. // : data['UserId'],
  494. // );
  495. // },
  496. // ),
  497. // );
  498. // }
  499. },
  500. );
  501. }
  502. //申请列表
  503. Widget _buildApllayInfo(userInfo) {
  504. bool isMyself = userInfo['ApplyUserId'] == UserData().basicInfo.userId;
  505. String name = isMyself ? userInfo['UserName'] : userInfo['ApplyName'];
  506. String imgUrl = isMyself ? userInfo['UserUrl'] : userInfo['ApplyUrl'];
  507. var applyInfo = {
  508. 'applyId': userInfo['Id'],
  509. 'userId': userInfo['ApplyUserId'],
  510. 'name': name,
  511. 'type': userInfo['Type'],
  512. 'imgUrl': imgUrl,
  513. 'showUrl': userInfo['ImgUrl'],
  514. 'content': userInfo['Content'],
  515. 'imgId': userInfo['ApplyImg'],
  516. 'createTime': userInfo['CreatTime'],
  517. 'isWatch': userInfo['IsCheck'] == 1,
  518. 'state': userInfo['Status'],
  519. };
  520. return _ConversationItem(
  521. conversation: Conversation(
  522. avatar: imgUrl == null || imgUrl == ''
  523. ? Constants.DefaultHeadImgUrl
  524. : imgUrl,
  525. title: '',
  526. desc: WebData().getLoginTime(context, userInfo['CreatTime']),
  527. updateAt: '17:20',
  528. ),
  529. title: RichTitle.getRichTitleWidget(userInfo, context, InfoType.Apply),
  530. applyInfo: isMyself ? null : applyInfo,
  531. callback: () {
  532. Navigator.of(context).push(
  533. new MaterialPageRoute(
  534. builder: (context) {
  535. return ProfilePage(
  536. userId: isMyself ? userInfo['UserId'] : userInfo['ApplyUserId'],
  537. );
  538. },
  539. ),
  540. );
  541. },
  542. );
  543. }
  544. //评价列表
  545. Widget _buildContentInfo(userInfo) {
  546. Widget botton = InkWell(
  547. onTap: () async {
  548. var data = {
  549. "userid": UserData().basicInfo.userId,
  550. "evaluateuserid": userInfo['EvaluateUserId'],
  551. };
  552. data['sign'] = TokenMgr().getSign(data);
  553. Response res =
  554. await HttpUtil().post('evaluate/user/appeal', data: data);
  555. if (res == null) {
  556. return;
  557. }
  558. Map resData = res.data;
  559. if (resData['code'] == 0) {
  560. setState(() {
  561. userInfo['Status'] = 1;
  562. });
  563. }
  564. },
  565. child: Container(
  566. padding: EdgeInsets.only(top: 2, left: 5, right: 5, bottom: 2),
  567. decoration: BoxDecoration(
  568. border:
  569. Border.all(color: Constants.LightBlueButtonColor, width: 1),
  570. color: Constants.LightBlueButtonColor,
  571. borderRadius: BorderRadius.all(Radius.circular(5))),
  572. child: fixedText(
  573. I18n.of(context).appeal,
  574. fontSize: 9,
  575. color: Colors.white,
  576. ),
  577. ));
  578. return _ConversationItem(
  579. conversation: Conversation(
  580. avatar: 'assets/images/chat/icon6.png',
  581. title: '',
  582. desc: WebData().getLoginTime(context, userInfo['CreateTime']),
  583. updateAt: '17:20',
  584. ),
  585. bgColor: Constants.EvaGradient,
  586. rightButton: userInfo['Status'] == 0 || userInfo['Status'] == 3
  587. ? botton
  588. : Text(userInfo['Status'] == 1 ? I18n.of(context).appealed : "",
  589. style:
  590. TextStyle(fontSize: 11, color: Constants.LightGreyTextColor)),
  591. title:
  592. RichTitle.getRichTitleWidget(userInfo, context, InfoType.Evaluation),
  593. callback: () {},
  594. );
  595. }
  596. String getReportTilte(bool isMyself, data) {
  597. String res = '';
  598. switch (data['ReportType']) {
  599. //举报用户
  600. case 1:
  601. if (isMyself) {
  602. res = data['Status'] == 1
  603. ? I18n.of(context)
  604. .report_success
  605. .replaceFirst('/s1', data['ReportedUserName'])
  606. : I18n.of(context)
  607. .report_failure
  608. .replaceFirst('/s1', data['ReportedUserName']);
  609. } else {
  610. res = I18n.of(context).coin_returen;
  611. }
  612. break;
  613. //举报节目
  614. case 2:
  615. break;
  616. //举报动态
  617. case 3:
  618. break;
  619. //举报评论
  620. case 4:
  621. break;
  622. default:
  623. }
  624. return res;
  625. }
  626. //系统通知
  627. Widget _buildSystemInfo(data) {
  628. bool isMyself = data['UserId'] == UserData().basicInfo.userId;
  629. String imgUrl = data['Type'] == 3
  630. ? (isMyself ? data['HeadImg'] : 'assets/images/chat/icon5.png')
  631. : 'assets/images/chat/icon5.png';
  632. var applyInfo = {
  633. 'applyId': data['Id'],
  634. 'userId': data['ApplyUserId'],
  635. 'name': data['Theme'],
  636. 'type': data['Type'],
  637. 'imgUrl': imgUrl,
  638. 'showUrl': data['HeadImg'],
  639. 'content': data['Content'],
  640. 'imgId': data['ApplyImg'],
  641. 'createTime': data['CreatTime'],
  642. 'isWatch': data['IsCheck'] == 1,
  643. 'links': data['Links'],
  644. 'state': data['Status'],
  645. };
  646. return _ConversationItem(
  647. conversation: Conversation(
  648. avatar: imgUrl,
  649. title: '',
  650. desc: WebData().getLoginTime(context, data['CreateTime']),
  651. updateAt: '17:20',
  652. ),
  653. showRight: data['Type'] == 6,
  654. applyInfo: data['Type'] == 6 ? applyInfo : null, // applyInfo,
  655. bgColor: Constants.ParkGradient,
  656. title: data['Type'] == 6
  657. ? Text(data['Theme'])
  658. : RichTitle.getRichTitleWidget(data, context, InfoType.System),
  659. callback: () {
  660. if (data['Type'] == 4 && data['Status'] == 1) {
  661. ClipboardData clipboardData =
  662. new ClipboardData(text: data['Content']);
  663. Clipboard.setData(clipboardData);
  664. showToast(I18n.of(context).successful_copy);
  665. }
  666. if (data['Type'] == 3) {
  667. Navigator.of(context).push(
  668. new MaterialPageRoute(
  669. builder: (context) {
  670. return ProfilePage(
  671. userId: data['ReportedUserId'],
  672. );
  673. },
  674. ),
  675. );
  676. }
  677. if (data['Type'] == 6) {
  678. launch(applyInfo['links']);
  679. }
  680. },
  681. );
  682. }
  683. //电台消息
  684. Widget _buildRadioInfo(data) {
  685. String imgUrl = data['HeadImg'] == null || data['HeadImg'] == ''
  686. ? Constants.DefaultHeadImgUrl
  687. : data['HeadImg'];
  688. return _ConversationItem(
  689. conversation: Conversation(
  690. avatar: imgUrl,
  691. title: '',
  692. desc: WebData().getLoginTime(context, data['CreateTime']),
  693. updateAt: '17:20',
  694. ),
  695. title: RichTitle.getRichTitleWidget(data, context, InfoType.Radio),
  696. callback: () {
  697. Navigator.of(context).push(
  698. new MaterialPageRoute(
  699. builder: (context) {
  700. return ProgramDetailPage(
  701. programId: data['Id'],
  702. );
  703. },
  704. ),
  705. );
  706. },
  707. );
  708. }
  709. Widget _renderRow(BuildContext context, int index) {
  710. if (index < list.length) {
  711. var userInfo = list[index];
  712. Widget result = Container();
  713. switch (widget.type) {
  714. case InfoType.Apply:
  715. result = _buildApllayInfo(userInfo);
  716. break;
  717. case InfoType.Evaluation:
  718. result = _buildContentInfo(userInfo);
  719. break;
  720. case InfoType.System:
  721. result = _buildSystemInfo(userInfo);
  722. break;
  723. case InfoType.Radio:
  724. result = _buildRadioInfo(userInfo);
  725. break;
  726. case InfoType.IncomeMoney:
  727. result = _buildMoneyInfo(userInfo);
  728. break;
  729. default:
  730. }
  731. if (index == 0) {
  732. result = Padding(padding: EdgeInsets.only(top: 10), child: result);
  733. }
  734. return result;
  735. }
  736. return Container();
  737. }
  738. void _onLoading() async {
  739. _page++;
  740. getNewData(addList);
  741. }
  742. @override
  743. Widget build(BuildContext context) {
  744. var content = Scaffold(
  745. appBar: AppBar(
  746. backgroundColor: AppColors.NewAppbarBgColor,
  747. title: Text(
  748. widget.title,
  749. style: TextStyle(color: AppColors.NewAppbarTextColor),
  750. ),
  751. leading: CustomUI.buildCustomLeading(context),
  752. centerTitle: true,
  753. ),
  754. body: SafeArea(
  755. child: SmartRefresher(
  756. enablePullDown: true,
  757. enablePullUp: true,
  758. header: MaterialClassicHeader(),
  759. footer: CustomUI.buildLoadingFooter(),
  760. controller: _refreshController,
  761. onRefresh: _onRefresh,
  762. onLoading: _onLoading,
  763. child: (_refreshController.headerStatus == RefreshStatus.completed &&
  764. list.length == 0)
  765. ? CustomUI.buildNoData(context)
  766. : ListView.builder(
  767. itemBuilder: _renderRow,
  768. itemCount: list.length,
  769. ),
  770. )));
  771. return content; // CustomUI.buildPageLoading(context, content, !isLoadingFish);
  772. }
  773. }