Hibok
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

813 wiersze
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. textScaleFactor: 1.0,
  590. style:
  591. TextStyle(fontSize: 11, color: Constants.LightGreyTextColor)),
  592. title:
  593. RichTitle.getRichTitleWidget(userInfo, context, InfoType.Evaluation),
  594. callback: () {},
  595. );
  596. }
  597. String getReportTilte(bool isMyself, data) {
  598. String res = '';
  599. switch (data['ReportType']) {
  600. //举报用户
  601. case 1:
  602. if (isMyself) {
  603. res = data['Status'] == 1
  604. ? I18n.of(context)
  605. .report_success
  606. .replaceFirst('/s1', data['ReportedUserName'])
  607. : I18n.of(context)
  608. .report_failure
  609. .replaceFirst('/s1', data['ReportedUserName']);
  610. } else {
  611. res = I18n.of(context).coin_returen;
  612. }
  613. break;
  614. //举报节目
  615. case 2:
  616. break;
  617. //举报动态
  618. case 3:
  619. break;
  620. //举报评论
  621. case 4:
  622. break;
  623. default:
  624. }
  625. return res;
  626. }
  627. //系统通知
  628. Widget _buildSystemInfo(data) {
  629. bool isMyself = data['UserId'] == UserData().basicInfo.userId;
  630. String imgUrl = data['Type'] == 3
  631. ? (isMyself ? data['HeadImg'] : 'assets/images/chat/icon5.png')
  632. : 'assets/images/chat/icon5.png';
  633. var applyInfo = {
  634. 'applyId': data['Id'],
  635. 'userId': data['ApplyUserId'],
  636. 'name': data['Theme'],
  637. 'type': data['Type'],
  638. 'imgUrl': imgUrl,
  639. 'showUrl': data['HeadImg'],
  640. 'content': data['Content'],
  641. 'imgId': data['ApplyImg'],
  642. 'createTime': data['CreatTime'],
  643. 'isWatch': data['IsCheck'] == 1,
  644. 'links': data['Links'],
  645. 'state': data['Status'],
  646. };
  647. return _ConversationItem(
  648. conversation: Conversation(
  649. avatar: imgUrl,
  650. title: '',
  651. desc: WebData().getLoginTime(context, data['CreateTime']),
  652. updateAt: '17:20',
  653. ),
  654. showRight: data['Type'] == 6,
  655. applyInfo: data['Type'] == 6 ? applyInfo : null, // applyInfo,
  656. bgColor: Constants.ParkGradient,
  657. title: data['Type'] == 6
  658. ? Text(data['Theme'], textScaleFactor: 1.0)
  659. : RichTitle.getRichTitleWidget(data, context, InfoType.System),
  660. callback: () {
  661. if (data['Type'] == 4 && data['Status'] == 1) {
  662. ClipboardData clipboardData =
  663. new ClipboardData(text: data['Content']);
  664. Clipboard.setData(clipboardData);
  665. showToast(I18n.of(context).successful_copy);
  666. }
  667. if (data['Type'] == 3) {
  668. Navigator.of(context).push(
  669. new MaterialPageRoute(
  670. builder: (context) {
  671. return ProfilePage(
  672. userId: data['ReportedUserId'],
  673. );
  674. },
  675. ),
  676. );
  677. }
  678. if (data['Type'] == 6) {
  679. launch(applyInfo['links']);
  680. }
  681. },
  682. );
  683. }
  684. //电台消息
  685. Widget _buildRadioInfo(data) {
  686. String imgUrl = data['HeadImg'] == null || data['HeadImg'] == ''
  687. ? Constants.DefaultHeadImgUrl
  688. : data['HeadImg'];
  689. return _ConversationItem(
  690. conversation: Conversation(
  691. avatar: imgUrl,
  692. title: '',
  693. desc: WebData().getLoginTime(context, data['CreateTime']),
  694. updateAt: '17:20',
  695. ),
  696. title: RichTitle.getRichTitleWidget(data, context, InfoType.Radio),
  697. callback: () {
  698. Navigator.of(context).push(
  699. new MaterialPageRoute(
  700. builder: (context) {
  701. return ProgramDetailPage(
  702. programId: data['Id'],
  703. );
  704. },
  705. ),
  706. );
  707. },
  708. );
  709. }
  710. Widget _renderRow(BuildContext context, int index) {
  711. if (index < list.length) {
  712. var userInfo = list[index];
  713. Widget result = Container();
  714. switch (widget.type) {
  715. case InfoType.Apply:
  716. result = _buildApllayInfo(userInfo);
  717. break;
  718. case InfoType.Evaluation:
  719. result = _buildContentInfo(userInfo);
  720. break;
  721. case InfoType.System:
  722. result = _buildSystemInfo(userInfo);
  723. break;
  724. case InfoType.Radio:
  725. result = _buildRadioInfo(userInfo);
  726. break;
  727. case InfoType.IncomeMoney:
  728. result = _buildMoneyInfo(userInfo);
  729. break;
  730. default:
  731. }
  732. if (index == 0) {
  733. result = Padding(padding: EdgeInsets.only(top: 10), child: result);
  734. }
  735. return result;
  736. }
  737. return Container();
  738. }
  739. void _onLoading() async {
  740. _page++;
  741. getNewData(addList);
  742. }
  743. @override
  744. Widget build(BuildContext context) {
  745. var content = Scaffold(
  746. appBar: AppBar(
  747. backgroundColor: AppColors.NewAppbarBgColor,
  748. title: Text(
  749. widget.title,
  750. textScaleFactor: 1.0,
  751. style: TextStyle(color: AppColors.NewAppbarTextColor),
  752. ),
  753. leading: CustomUI.buildCustomLeading(context),
  754. centerTitle: true,
  755. ),
  756. body: SafeArea(
  757. child: SmartRefresher(
  758. enablePullDown: true,
  759. enablePullUp: true,
  760. header: MaterialClassicHeader(),
  761. footer: CustomUI.buildLoadingFooter(),
  762. controller: _refreshController,
  763. onRefresh: _onRefresh,
  764. onLoading: _onLoading,
  765. child: (_refreshController.headerStatus == RefreshStatus.completed &&
  766. list.length == 0)
  767. ? CustomUI.buildNoData(context)
  768. : ListView.builder(
  769. itemBuilder: _renderRow,
  770. itemCount: list.length,
  771. ),
  772. )));
  773. return content; // CustomUI.buildPageLoading(context, content, !isLoadingFish);
  774. }
  775. }