bbs_page.dart 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. // import 'package:amap_all_fluttify/amap_all_fluttify.dart';
  2. import 'package:amap_location_flutter_plugin/amap_location_flutter_plugin.dart';
  3. import 'package:amap_location_flutter_plugin/amap_location_option.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  6. import 'package:liftmanager/internal/bbs/model/news_comm_entity.dart';
  7. import 'package:liftmanager/internal/bbs/presenter/news_list_presenter.dart';
  8. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  9. import 'package:liftmanager/mvp/base_page_state.dart';
  10. import 'package:liftmanager/net/api_service.dart';
  11. import 'package:liftmanager/res/resources.dart';
  12. import 'package:liftmanager/routers/fluro_navigator.dart';
  13. import 'package:liftmanager/utils/toast.dart';
  14. import 'package:liftmanager/widgets/app_city_search_bar.dart';
  15. import 'package:liftmanager/widgets/load_image.dart';
  16. import 'package:liftmanager/widgets/my_refresh_list.dart';
  17. import 'package:liftmanager/widgets/state_layout.dart';
  18. import 'package:permission_handler/permission_handler.dart';
  19. import 'package:provider/provider.dart';
  20. import 'package:liftmanager/widgets/bbs_content.dart';
  21. import 'package:flutter_screenutil/flutter_screenutil.dart';
  22. import '../../../utils/toast.dart';
  23. import 'package:liftmanager/internal/means/means_router.dart';
  24. // import '../model/question_model.dart' as qItem;
  25. import 'dart:convert';
  26. import 'package:liftmanager/utils/fast_notification.dart';
  27. import 'package:liftmanager/internal/bbs/model/banner_model.dart';
  28. import 'package:flutter_spinkit/flutter_spinkit.dart';
  29. import 'package:liftmanager/utils/utils.dart';
  30. import 'package:flustars/flustars.dart' as FlutterStars;
  31. import 'package:liftmanager/internal/bbs/provide/websocket.dart';
  32. import 'package:liftmanager/common/common.dart';
  33. import 'package:liftmanager/internal/account/account_router.dart';
  34. import 'package:liftmanager/internal/news/news_router.dart';
  35. import 'package:uni_links/uni_links.dart';
  36. import 'package:liftmanager/utils/theme_utils.dart';
  37. import 'package:fluwx/fluwx.dart' as fluwx;
  38. import 'dart:async';
  39. class BbsPage extends StatefulWidget {
  40. @override
  41. BbsPageState createState() => BbsPageState();
  42. }
  43. const timeout = const Duration(seconds: 5);
  44. class BbsPageState extends BasePageState<BbsPage, NewsListPresenter>
  45. with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
  46. BaseListProvider<NewsItem> provider = BaseListProvider<NewsItem>();
  47. TabController _tabController;
  48. PageController _pageController = PageController();
  49. AmapLocationFlutterPlugin _locationPlugin = new AmapLocationFlutterPlugin();
  50. StreamSubscription<Map<String, Object>> _locationListener;
  51. Map<String, Object> _locationResult;
  52. int _index = 0;
  53. String _keyword;
  54. int _page = 1;
  55. List<String> menuTitle = ["案例中心", "视频学堂", "在线商城", "招聘专区", "资料库"];
  56. List<int> menuImage = [0xe674, 0xe600, 0xe680, 0xe705, 0xe648];
  57. List<String> menuColor = [
  58. "0xffFE6965",
  59. "0xff5C6BFA",
  60. "0xffFA8113",
  61. "0xff2EBA7F",
  62. "0xff118DFF"
  63. ];
  64. bool display = true;
  65. // Location _location;
  66. String cityName = "暂无定位";
  67. StateType _stateType = StateType.loading;
  68. ///获取定位权限
  69. Future<bool> requestPermission() async {
  70. final permissions = await PermissionHandler()
  71. .requestPermissions([PermissionGroup.location]);
  72. if (permissions[PermissionGroup.location] == PermissionStatus.granted) {
  73. return true;
  74. } else {
  75. toasts('需要定位权限!');
  76. return false;
  77. }
  78. }
  79. ///获取位置信息
  80. getLocation() async {
  81. if (await requestPermission()) {
  82. if (null != _locationPlugin) {
  83. _locationPlugin.startLocation();
  84. }
  85. }
  86. }
  87. // ///获取位置信息
  88. // getLocation() async {
  89. // if (await requestPermission()) {
  90. // final location = await AmapLocation.fetchLocation();
  91. // cityName = await location.city;
  92. // print(cityName + "456456465");
  93. // LatLng latlng = await location.latLng;
  94. // print(latlng.latitude);
  95. // print(latlng.longitude);
  96. // print(latlng);
  97. // setState(() {});
  98. // // getCity();
  99. // }
  100. // }
  101. // getCity() async {
  102. // LatLng latlng = await _location.latLng;
  103. // ApiService().getCity(latlng.latitude,latlng.longitude,onSuccess: (res){
  104. //
  105. // },onError: (code,msg){
  106. //
  107. // });
  108. // }
  109. @override
  110. void initState() {
  111. super.initState();
  112. _locationListener = _locationPlugin
  113. .onLocationChanged()
  114. .listen((Map<String, Object> result) {
  115. setState(() {
  116. _locationPlugin.stopLocation();
  117. _locationResult = result;
  118. // address latitude longitude
  119. lat = _locationResult["latitude"];
  120. lng = _locationResult["longitude"];
  121. cityName = _locationResult["city"];
  122. if(FlutterStars.SpUtil.getString(Constant.userId) != "-1") {
  123. isDelayAddress();
  124. }
  125. });
  126. });
  127. Provider.of<WebSocketProvide>(context,listen: false).createWebsocket(FlutterStars.SpUtil.getString(Constant.userId));
  128. getLocation();
  129. getBannerList();
  130. getNewsList();
  131. getQuestionList();
  132. getVideoList();
  133. getShopList();
  134. getPositionList();
  135. getNotificaList();
  136. _initFluwx();
  137. FastNotification.addListener("initNotice",(initThisNotice){
  138. if(mounted){
  139. setState(() {
  140. getNotificaList();
  141. });
  142. }
  143. });
  144. if(FlutterStars.SpUtil.getString(Constant.userId) == "-1"){
  145. isCustom = true;
  146. }
  147. }
  148. _initFluwx() async {
  149. await fluwx.registerWxApi(
  150. appId: "wx0f10e6386fb9969e",
  151. doOnAndroid: true,
  152. doOnIOS: true,
  153. universalLink: "https://www.edtyun.com/");
  154. var result = await fluwx.isWeChatInstalled();
  155. setState(() {});
  156. }
  157. Timer _timer;
  158. void startTimer(int intervalTime) {
  159. //设置 intervalTime 秒回调一次
  160. print(1234);
  161. Duration period = Duration(minutes: intervalTime);
  162. _timer = Timer.periodic(period, (timer) {
  163. print(1236);
  164. getStartDelayAddress();
  165. });
  166. }
  167. void cancelTimer() {
  168. if (_timer != null) {
  169. _timer.cancel();
  170. _timer = null;
  171. }
  172. }
  173. double lat;
  174. double lng;
  175. Widget bannerLastWidget;
  176. List<dynamic> bannerList;
  177. List<dynamic> questionsList;
  178. List<dynamic> newsList;
  179. List<dynamic> videoList;
  180. List<dynamic> shopList;
  181. List<dynamic> positionList;
  182. bool isCustom = false;
  183. Future isDelayAddress() async {
  184. await NewApiService().isDelayAddress(onSuccess: (res) {
  185. print("665-------------------////");
  186. print(res["id"]);
  187. print(jsonEncode(res));
  188. print("666-------------------////");
  189. if(res["isPush"]!=null && res["isPush"] == 1){
  190. getStartDelayAddress();
  191. startTimer(res["intervalTime"]);
  192. }
  193. //intervalTime:时间间隔分钟 ; isPush:1推送 2不推送
  194. }, onError: (code, msg) {
  195. toasts(msg);
  196. });
  197. }
  198. Future getStartDelayAddress() async {
  199. String position = lat.toString() +","+ lng.toString();
  200. await NewApiService().startDelayAddress(
  201. {
  202. "mobile":FlutterStars.SpUtil.getString(Constant.phone),
  203. "mtCompanyId":FlutterStars.SpUtil.getString(Constant.companyId)!=""?int.parse(FlutterStars.SpUtil.getString(Constant.companyId)):"",
  204. "position":position,
  205. "userId":int.parse(FlutterStars.SpUtil.getString(Constant.userId))
  206. }
  207. ,onSuccess: (res) {
  208. print("668-------------------////");
  209. }, onError: (code, msg) {
  210. toasts(msg);
  211. });
  212. }
  213. Future getBannerList() async {
  214. await NewApiService().getBanner(1, 10, onSuccess: (BannerModel res) {
  215. // print(jsonEncode(res));
  216. // print(JsonEncoder().convert(res.records));
  217. bannerList = res.records;
  218. bannerLastWidget = SwipeWidget(banners: bannerList,);
  219. // print(bannerList.length);
  220. setState(() {});
  221. }, onError: (code, msg) {
  222. toasts(msg);
  223. });
  224. }
  225. Future getNotificaList() async {
  226. display = true;
  227. await NewApiService().myNotificaList(1, 10, onSuccess: (res) {
  228. // print(jsonEncode(res));
  229. // print(JsonEncoder().convert(res.records));
  230. res.records.forEach((item){
  231. if(item.viewFlag == 0){
  232. setState(() {
  233. display = false;
  234. });
  235. return;
  236. }
  237. });
  238. // print(bannerList.length);
  239. setState(() {});
  240. }, onError: (code, msg) {
  241. toasts(msg);
  242. });
  243. }
  244. Future getNewsList() async {
  245. await NewApiService().newsList(1, 3, 1, "", cityName, onSuccess: (res) {
  246. newsList = res.topNews;
  247. // print(JsonEncoder().convert(res.topNews));
  248. setState(() {});
  249. }, onError: (code, msg) {
  250. toasts(msg);
  251. });
  252. }
  253. Future getQuestionList() async {
  254. await NewApiService().getQuestionList(1, 2, null, null, null,
  255. onSuccess: (res) {
  256. // res.records.forEach((item){
  257. // questionsList.addAll(item);
  258. // });
  259. questionsList = res.records;
  260. // print(JsonEncoder().convert(res.records));
  261. setState(() {});
  262. }, onError: (code, msg) {
  263. toasts(msg);
  264. });
  265. }
  266. Future getVideoList() async {
  267. await NewApiService().getVideoList(1, 3, null, null, null, "app",
  268. onSuccess: (res) {
  269. videoList = res.records;
  270. setState(() {});
  271. }, onError: (code, msg) {
  272. toasts(msg);
  273. });
  274. }
  275. Future getShopList() async {
  276. await NewApiService().getShopList(1, 2, null, null, onSuccess: (res) {
  277. shopList = res.records;
  278. setState(() {});
  279. }, onError: (code, msg) {
  280. toasts(msg);
  281. });
  282. }
  283. Future getPositionList() async {
  284. await NewApiService().getPositionList(1, 3, onSuccess: (res) {
  285. // res.records.forEach((item){
  286. // questionsList.addAll(item);
  287. // });
  288. positionList = res.records;
  289. // print(JsonEncoder().convert(res.records));
  290. setState(() {});
  291. }, onError: (code, msg) {
  292. toasts(msg);
  293. });
  294. }
  295. void _onPageChanged(int index) {
  296. _index = index;
  297. _tabController.animateTo(index);
  298. }
  299. @override
  300. void dispose() {
  301. _tabController?.dispose();
  302. // _timer.cancel();
  303. _pageController.dispose();
  304. ///移除定位监听
  305. if (null != _locationListener) {
  306. _locationListener.cancel();
  307. }
  308. ///销毁定位
  309. if (null != _locationPlugin) {
  310. _locationPlugin.destroy();
  311. }
  312. super.dispose();
  313. cancelTimer();
  314. }
  315. static const diagnosisObj = [
  316. {
  317. "title": "快速问诊",
  318. "img": "tab_first/Diagnosis_first",
  319. "desc": "搜电梯品牌 找专家咨询电梯疑问",
  320. },
  321. {
  322. "title": "出诊",
  323. "img": "tab_first/Diagnosis_second",
  324. "desc": "在线预约专家上门维修服务",
  325. },
  326. ];
  327. static const diagnosisObjMaster = [
  328. {
  329. "title": "工作台",
  330. "img": "tab_first/Diagnosis_third",
  331. "desc": "问诊、出诊工作快捷入口",
  332. },
  333. ];
  334. showAlertEvent(){
  335. showAlert(
  336. context,
  337. "提示",
  338. "确定登录?",
  339. "确定",
  340. () {
  341. NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  342. },
  343. txt2: "取消",
  344. onPre2: () {
  345. NavigatorUtils.goBack(context);
  346. },
  347. );
  348. }
  349. @override
  350. Widget build(BuildContext context) {
  351. return
  352. RefreshIndicator(
  353. onRefresh:()async{
  354. print("123----------------------------------");
  355. setState(() {
  356. bannerLastWidget = null;
  357. getLocation();
  358. getBannerList();
  359. getNewsList();
  360. getQuestionList();
  361. getVideoList();
  362. getShopList();
  363. getPositionList();
  364. });
  365. },
  366. child: ChangeNotifierProvider<BaseListProvider<NewsItem>>(
  367. create: (_) => provider,
  368. child: Scaffold(
  369. appBar: AppCitySearchAppBar(
  370. // city: "暂无定位",
  371. city: "${cityName}",
  372. display:display
  373. ),
  374. body: Container(
  375. color: ThemeUtils.getTabsBg(context),
  376. child: ListView(
  377. children: <Widget>[
  378. bannerLastWidget != null
  379. ? bannerLastWidget
  380. : Container(child: loadCircle()),
  381. Container(
  382. padding: EdgeInsets.only(top: 10),
  383. color: ThemeUtils.getTabsBg(context),
  384. child: _ToolsItem(menuTitle, menuImage, menuColor, (index) {
  385. if (index == 0) {
  386. if (!Utils.getAuthByRouter('question_center',false) && isCustom){
  387. showAlertEvent();
  388. }else if (Utils.getAuthByRouter('question_center')){
  389. NavigatorUtils.push(context, BbsRouter.questionList);
  390. }
  391. } else if (index == 1) {
  392. // if (Utils.getAuthByRouter('video_center')) {
  393. // NavigatorUtils.push(context, BbsRouter.videoList);
  394. // }else if (!Utils.getAuthByRouter('video_center',false) && isCustom){
  395. // showAlertEvent();
  396. // }
  397. if (!Utils.getAuthByRouter('video_center',false) && isCustom){
  398. showAlertEvent();
  399. }else if (Utils.getAuthByRouter('video_center')){
  400. NavigatorUtils.push(context, BbsRouter.videoList);
  401. }
  402. } else if (index == 2) {
  403. // if (Utils.getAuthByRouter('shopping_center')) {
  404. // NavigatorUtils.push(context, BbsRouter.productList);
  405. // }else if (!Utils.getAuthByRouter('shopping_center',false) && isCustom){
  406. // showAlertEvent();
  407. // }
  408. if (!Utils.getAuthByRouter('shopping_center',false) && isCustom){
  409. showAlertEvent();
  410. }else if (Utils.getAuthByRouter('shopping_center')){
  411. NavigatorUtils.push(context, BbsRouter.productList);
  412. }
  413. } else if (index == 3) {
  414. // if (Utils.getAuthByRouter('job_center')) {
  415. // NavigatorUtils.push(context, BbsRouter.positionList);
  416. // }else if (!Utils.getAuthByRouter('job_center',false) && isCustom){
  417. // showAlertEvent();
  418. // }
  419. if (!Utils.getAuthByRouter('job_center',false) && isCustom){
  420. showAlertEvent();
  421. }else if (Utils.getAuthByRouter('job_center')){
  422. NavigatorUtils.push(context, BbsRouter.positionList);
  423. }
  424. } else if (index == 4) {
  425. if (!Utils.getAuthByRouter('database',false) && isCustom){
  426. showAlertEvent();
  427. }else if (Utils.getAuthByRouter('database')){
  428. NavigatorUtils.push(context, MeansRouter.meansPage);
  429. }
  430. }
  431. }),
  432. ),
  433. Container(height: 5, color: ThemeUtils.getDialogTextFieldColor(context)),
  434. LableTitle(
  435. title: "新闻",
  436. userTap: () {
  437. if(isCustom){
  438. showAlertEvent();
  439. }else {
  440. NavigatorUtils.push(context, NewsRouter.newsTopList);
  441. }
  442. },
  443. ),
  444. Container(
  445. color: Colors.white,
  446. // padding: EdgeInsets.only(bottom: 20),
  447. child: newsList != null && newsList != []
  448. ? HotNews(newsList: newsList)
  449. : loadCircle()),
  450. Container(height: 5, color: ThemeUtils.getDialogTextFieldColor(context)),
  451. LableTitle(
  452. title: "问题",
  453. userTap: () {
  454. if (!Utils.getAuthByRouter('question_center',false) && isCustom){
  455. showAlertEvent();
  456. }
  457. else {
  458. if (Utils.getAuthByRouter('question_center')) {
  459. NavigatorUtils.push(context, BbsRouter.questionList);
  460. }
  461. }
  462. // NavigatorUtils.push(context, BbsRouter.chatRoom);
  463. },
  464. ),
  465. // Expanded(
  466. // flex: 1,
  467. // child: HotQuestion(),
  468. // )
  469. Container(
  470. child: questionsList != null && questionsList != []
  471. ? HotQuestion(initList: questionsList)
  472. : loadCircle()),
  473. Container(height: 5, color: ThemeUtils.getDialogTextFieldColor(context)),
  474. LableTitle(
  475. title: "学堂",
  476. userTap: () {
  477. if (!Utils.getAuthByRouter('video_center',false) && isCustom){
  478. showAlertEvent();
  479. }else {
  480. if (Utils.getAuthByRouter('video_center')) {
  481. NavigatorUtils.push(context, BbsRouter.videoList);
  482. }
  483. }
  484. },
  485. ),
  486. videoList != null && videoList != []
  487. ? Container(
  488. color: ThemeUtils.getTabsBg(context),
  489. height: ScreenUtil().setWidth(210),
  490. padding:
  491. EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  492. child: HotClass(initList: videoList),
  493. )
  494. : Container(child: loadCircle()),
  495. Container(height: 5, color: ThemeUtils.getDialogTextFieldColor(context)),
  496. LableTitle(
  497. title: "商品",
  498. userTap: () {
  499. // if(isCustom){
  500. // toasts("请登录");
  501. // NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  502. // }else {
  503. // if (Utils.getAuthByRouter('shopping_center')) {
  504. // NavigatorUtils.push(context, BbsRouter.productList);
  505. // }
  506. // }
  507. if (!Utils.getAuthByRouter('shopping_center',false) && isCustom){
  508. showAlertEvent();
  509. }
  510. else {
  511. if(Utils.getAuthByRouter('shopping_center')) {
  512. NavigatorUtils.push(context, BbsRouter.productList);
  513. }
  514. }
  515. },
  516. ),
  517. Container(
  518. child: shopList != null && shopList != []
  519. ? HotProduct(productList: shopList)
  520. : loadCircle()),
  521. Container(height: 5, color: ThemeUtils.getDialogTextFieldColor(context)),
  522. LableTitle(
  523. title: "职位",
  524. userTap: () {
  525. // if(isCustom){
  526. // toasts("请登录");
  527. // NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  528. // }else {
  529. // if (Utils.getAuthByRouter('job_center')) {
  530. // NavigatorUtils.push(context, BbsRouter.positionList);
  531. // }
  532. // }
  533. if (!Utils.getAuthByRouter('job_center',false) && isCustom){
  534. showAlertEvent();
  535. }else {
  536. if (Utils.getAuthByRouter('job_center')) {
  537. NavigatorUtils.push(context, BbsRouter.positionList);
  538. }
  539. }
  540. },
  541. ),
  542. Container(
  543. color: ThemeUtils.getTabsBg(context),
  544. padding: EdgeInsets.only(bottom: 20),
  545. child: positionList != null && positionList != []
  546. ? HotPosition(positionList: positionList)
  547. : loadCircle()),
  548. // Container(
  549. // child:GestureDetector(
  550. // child: Text("0000000"),
  551. // onTap: (){
  552. // Map<String,dynamic> cc = FlutterStars.SpUtil.getObj("vgfhvfk", (v){
  553. // return v;
  554. // });
  555. // print(cc);
  556. // print(6556);
  557. // Map<String,dynamic> res = {
  558. // "one3":"1"
  559. // };
  560. // Map<String,dynamic> a = FlutterStars.SpUtil.getObj("sessionIdObj", (v){
  561. // return v;
  562. // });
  563. // a.addAll(res);
  564. // FlutterStars.SpUtil.putObject("sessionIdObj", a);
  565. // print(a["one3"]);
  566. // print(123);
  567. // },
  568. // )
  569. // ),
  570. // SizedBox(
  571. // height:300,
  572. // ),
  573. // Container(
  574. // child:GestureDetector(
  575. // child: Text("11111111"),
  576. // onTap: (){
  577. // Map<String,dynamic> res = {
  578. // "two3":"2"
  579. // };
  580. // Map<String,dynamic> a = FlutterStars.SpUtil.getObj("sessionIdObj", (v){
  581. // return v;
  582. // });
  583. // a.addAll(res);
  584. // FlutterStars.SpUtil.putObject("sessionIdObj", a);
  585. // print(a);
  586. // print(123);
  587. // print(123);
  588. // },
  589. // )
  590. // ),
  591. ],
  592. ),
  593. ),
  594. )),
  595. )
  596. ;
  597. }
  598. Widget loadCircle() {
  599. return Container(
  600. padding: EdgeInsets.only(top: 10, bottom: 10),
  601. color: ThemeUtils.getTabsBg(context),
  602. child: Center(
  603. child: SpinKitFadingCircle(
  604. color: Colors.blueAccent,
  605. size: 30.0,
  606. ),
  607. ),
  608. );
  609. }
  610. @override
  611. NewsListPresenter createPresenter() {
  612. return NewsListPresenter();
  613. }
  614. bool get wantKeepAlive => true;
  615. }
  616. class _ToolsItem extends StatelessWidget {
  617. _ToolsItem(this.titles, this.imgs, this.colors, this.onTap, {Key key})
  618. : super(key: key);
  619. List<String> titles;
  620. List<int> imgs;
  621. List<String> colors;
  622. Function onTap;
  623. @override
  624. Widget build(BuildContext context) {
  625. return GridView.builder(
  626. shrinkWrap: true,
  627. padding: const EdgeInsets.fromLTRB(8.0, 0, 8.0, 0),
  628. physics: NeverScrollableScrollPhysics(),
  629. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  630. crossAxisCount: 5, childAspectRatio: 0.9, crossAxisSpacing: 2),
  631. itemCount: titles.length,
  632. itemBuilder: (_, index) {
  633. return InkWell(
  634. child: Column(
  635. mainAxisAlignment: MainAxisAlignment.center,
  636. children: <Widget>[
  637. Container(
  638. width: ScreenUtil().setWidth(40),
  639. height: ScreenUtil().setWidth(40),
  640. decoration: BoxDecoration(
  641. borderRadius: BorderRadius.circular(20.0),
  642. color: Color(
  643. int.parse(colors[index]),
  644. ),
  645. ),
  646. child: Icon(
  647. IconData(imgs[index], fontFamily: "myfont"),
  648. size: 22.0,
  649. color: Color.fromRGBO(255, 255, 255, 1),
  650. ),
  651. ),
  652. Gaps.vGap8,
  653. Text(
  654. titles[index],
  655. style: TextStyle(fontSize: ScreenUtil().setSp(12)),
  656. ),
  657. Gaps.vGap10,
  658. ],
  659. ),
  660. onTap: () {
  661. onTap(index);
  662. },
  663. );
  664. },
  665. );
  666. }
  667. }