video_list.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/gaps.dart';
  3. import 'package:liftmanager/net/api_service.dart';
  4. import 'package:liftmanager/utils/toast.dart';
  5. import 'package:liftmanager/widgets/app_bar.dart';
  6. import 'package:liftmanager/internal/search/search_router.dart';
  7. import 'package:liftmanager/widgets/app_search_bar.dart';
  8. import 'package:liftmanager/res/resources.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  12. import 'package:flutter_screenutil/flutter_screenutil.dart';
  13. import 'package:liftmanager/widgets/bbs_content.dart';
  14. import 'package:liftmanager/mvp/base_page_state.dart';
  15. import 'package:liftmanager/internal/bbs/presenter/video_list_presenter.dart';
  16. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  17. import 'package:liftmanager/internal/bbs/model/mix_model.dart';
  18. import 'package:liftmanager/widgets/state_layout.dart';
  19. import 'package:liftmanager/widgets/my_refresh_list.dart';
  20. import 'package:liftmanager/utils/url.dart';
  21. import 'package:flutter_spinkit/flutter_spinkit.dart';
  22. import 'package:provider/provider.dart';
  23. import 'package:liftmanager/utils/utils.dart';
  24. import 'package:liftmanager/utils/theme_utils.dart';
  25. class VideoList extends StatefulWidget {
  26. // QuestionList(this.index);
  27. // final String index;
  28. @override
  29. VideoListState createState() => VideoListState();
  30. // State<StatefulWidget> createState() {
  31. // return VideoListState();
  32. // }
  33. }
  34. class VideoListState
  35. extends BasePageState<VideoList, VideoListPresenterSeconds> {
  36. // class VideoListState extends State<VideoList> {
  37. // NewsDetailItem item = NewsDetailItem();
  38. BaseListProvider<Records> provider = BaseListProvider<Records>();
  39. int _page = 1;
  40. int brandIdss;
  41. int exprtyIdss;
  42. bool sortBool = true;
  43. String checkTypeName;
  44. String checkType;
  45. String brandName = "品牌";
  46. String masterName = "专家";
  47. ScrollController _scrollController = new ScrollController();
  48. String searchWord;
  49. List<dynamic> typeList;
  50. List<dynamic> brandList;
  51. Future getBrandList() async {
  52. await NewApiService().getBrandListNoPage(
  53. onSuccess: (res) {
  54. if (res != null) {
  55. brandList = res;
  56. typeList = brandList;
  57. setState(() {});
  58. }
  59. }, onError: (code, msg) {
  60. toasts(msg);
  61. });
  62. }
  63. List<dynamic> expertList;
  64. Future getExpertList() async {
  65. await NewApiService().getExpertListNoPage(
  66. onSuccess: (res) {
  67. if (res != null) {
  68. expertList = res;
  69. typeList = expertList;
  70. setState(() {});
  71. }
  72. }, onError: (code, msg) {
  73. toasts(msg);
  74. });
  75. }
  76. @override
  77. void initState() {
  78. provider.setStateTypeNotNotify(StateType.loading);
  79. super.initState();
  80. _onRefresh();
  81. }
  82. @override
  83. void dispose() {
  84. _scrollController.dispose();
  85. super.dispose();
  86. }
  87. @override
  88. Widget build(BuildContext context) {
  89. double width = MediaQuery.of(context).size.width;
  90. double height = MediaQuery.of(context).size.height;
  91. return ChangeNotifierProvider<BaseListProvider<Records>>(
  92. create: (_) => provider,
  93. child: Scaffold(
  94. appBar: SearchAppBar2(
  95. searchWidth:width*0.7,
  96. onPressed: (text) {
  97. searchWord = text;
  98. _onRefresh();
  99. },
  100. actions: <Widget>[
  101. FlatButton(
  102. child: Text(
  103. "上传",
  104. style: TextStyle(
  105. color: Colors.white, fontSize: ScreenUtil().setSp(15)),
  106. ),
  107. textColor: Colours.dark_text,
  108. highlightColor: Colors.transparent,
  109. onPressed: () {
  110. NavigatorUtils.push(context, BbsRouter.videoUpload);
  111. },
  112. )
  113. // Utils.getAuthByRouter('upload_video', false) ?
  114. // FlatButton(
  115. // child: Text(
  116. // "上传",
  117. // style: TextStyle(
  118. // color: Colors.white, fontSize: ScreenUtil().setSp(15)),
  119. // ),
  120. // textColor: Colours.dark_text,
  121. // highlightColor: Colors.transparent,
  122. // onPressed: () {
  123. // NavigatorUtils.push(context, BbsRouter.videoUpload);
  124. // },
  125. // )
  126. // : Container()
  127. ],
  128. ),
  129. body: Container(
  130. child:Stack(
  131. children: <Widget>[
  132. Column(
  133. children: <Widget>[
  134. Container(
  135. width: width,
  136. height: ScreenUtil().setWidth(50),
  137. decoration: BoxDecoration(
  138. border: Border(
  139. bottom: BorderSide(width: 0.5, color: Colours.line),
  140. ),
  141. ),
  142. padding: EdgeInsets.only(
  143. left: ScreenUtil().setWidth(15),
  144. right: ScreenUtil().setWidth(15)),
  145. // color: Color(0xFFF1F4FC),
  146. child: Row(
  147. children: <Widget>[
  148. GestureDetector(
  149. onTap: (){
  150. typeList = [];
  151. getBrandList();
  152. setState(() {
  153. sortBool = false;
  154. checkTypeName = "品牌";
  155. checkType = "brand";
  156. });
  157. },
  158. child: Row(
  159. children: <Widget>[
  160. Text(
  161. brandName,
  162. style: TextStyle(
  163. fontSize: ScreenUtil().setSp(16)),
  164. textAlign: TextAlign.start,
  165. ),
  166. Container(
  167. padding: EdgeInsets.only(top: 3),
  168. child: Icon(
  169. Icons.keyboard_arrow_down,
  170. size: 26.0,
  171. ),
  172. )
  173. ],
  174. ),
  175. ),
  176. SizedBox(width: ScreenUtil().setWidth(30)),
  177. // GestureDetector(
  178. // onTap: (){
  179. // typeList = [];
  180. // getExpertList();
  181. // setState(() {
  182. // sortBool = false;
  183. // checkTypeName = "专家";
  184. // checkType = "master";
  185. // });
  186. // },
  187. // child: Row(
  188. // children: <Widget>[
  189. // Text(
  190. // masterName,
  191. // style: TextStyle(
  192. // color: Color(0xff333333),
  193. // fontSize: ScreenUtil().setSp(16)),
  194. // textAlign: TextAlign.start,
  195. // ),
  196. // Container(
  197. // padding: EdgeInsets.only(top: 3),
  198. // child: Icon(
  199. // Icons.keyboard_arrow_down,
  200. // size: 26.0,
  201. // color: Color(0xff333333),
  202. // ),
  203. // )
  204. // ],
  205. // ),
  206. // ),
  207. ],
  208. )),
  209. Expanded(
  210. flex: 1,
  211. child: Consumer<BaseListProvider<Records>>(
  212. builder: (_, provider, __) {
  213. return MyListView(
  214. key: Key('video_list'),
  215. itemCount: provider.list.length,
  216. stateType: provider.stateType,
  217. onRefresh: _onRefresh,
  218. pageSize:10,
  219. loadMore: _loadMore,
  220. hasMore: provider.hasMore,
  221. itemBuilder: (_, index) {
  222. return GestureDetector(
  223. child: Container(
  224. padding: EdgeInsets.only(
  225. left: ScreenUtil().setWidth(15),
  226. // right: ScreenUtil().setWidth(15),
  227. top: ScreenUtil().setHeight(10),
  228. bottom: ScreenUtil().setHeight(10)),
  229. decoration: BoxDecoration(
  230. border: Border(
  231. bottom: BorderSide(
  232. width: 0.5, color: Colours.line),
  233. ),
  234. ),
  235. child:
  236. Row(
  237. crossAxisAlignment: CrossAxisAlignment.start,
  238. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  239. children: <Widget>[
  240. Container(
  241. padding: EdgeInsets.only(top:ScreenUtil().setWidth(8),bottom:ScreenUtil().setWidth(8)),
  242. height: width*0.24,
  243. child: Column(
  244. crossAxisAlignment: CrossAxisAlignment.start,
  245. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  246. children: <Widget>[
  247. Container(
  248. width:width*0.5,
  249. child: Text(
  250. "${provider.list[index].title??""}",
  251. style: TextStyle(
  252. fontWeight: FontWeight.w600,
  253. fontSize: ScreenUtil().setSp(17)),
  254. textAlign: TextAlign.start,
  255. maxLines: 1,
  256. overflow: TextOverflow.ellipsis,
  257. ),
  258. ),
  259. Container(
  260. width:width*0.5,
  261. child: Text(
  262. "${provider.list[index].descr??""}",
  263. style: TextStyle(
  264. fontSize: ScreenUtil().setSp(15)),
  265. textAlign: TextAlign.start,
  266. maxLines: 1,
  267. overflow: TextOverflow.ellipsis,
  268. ),
  269. ),
  270. Container(
  271. width: width*0.5,
  272. child: Row(
  273. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  274. children: <Widget>[
  275. Container(
  276. width:width*0.18,
  277. child: Text(
  278. "${provider.list[index].brandName??""}",
  279. style: TextStyle(
  280. color: Color(0xff999999),
  281. fontSize: ScreenUtil().setSp(14)),
  282. textAlign: TextAlign.start,
  283. maxLines: 1,
  284. overflow: TextOverflow.ellipsis,
  285. ),
  286. ),
  287. SizedBox(
  288. width:5
  289. ),
  290. Row(
  291. crossAxisAlignment: CrossAxisAlignment.start,
  292. children: <Widget>[
  293. Text(
  294. "${provider.list[index].likeNum??"0"}",
  295. style: TextStyle(
  296. color: Color(0xff999999),
  297. fontSize: ScreenUtil().setSp(14)),
  298. textAlign: TextAlign.start,
  299. ),
  300. SizedBox(
  301. width:3
  302. ),
  303. Icon(
  304. IconData(0xe7cd,
  305. fontFamily: "myfont"),
  306. size: 14.0,
  307. color: Color(0xff999999),
  308. ),
  309. ],
  310. ),
  311. SizedBox(
  312. width:5
  313. ),
  314. Row(
  315. crossAxisAlignment: CrossAxisAlignment.start,
  316. children: <Widget>[
  317. Text(
  318. "${provider.list[index].browseNum??"0"}",
  319. style: TextStyle(
  320. color: Color(0xff999999),
  321. fontSize: ScreenUtil().setSp(14)),
  322. textAlign: TextAlign.start,
  323. ),
  324. SizedBox(
  325. width:3
  326. ),
  327. Icon(
  328. IconData(0xe610,
  329. fontFamily: "myfont"),
  330. size: 14.0,
  331. color: Color(0xff999999),
  332. ),
  333. ],
  334. ),
  335. ],
  336. ),
  337. )
  338. ]),
  339. ),
  340. Container(
  341. padding: EdgeInsets.only(right:10),
  342. child: Stack(
  343. children: <Widget>[
  344. ClipRRect(
  345. borderRadius:
  346. BorderRadius.circular(1),
  347. child: Container(
  348. child: LoadNetworkImage(
  349. // imgFontUrl +
  350. // provider.list[index].cover,
  351. provider.list[index].cover,
  352. width: width*0.38,
  353. height: width*0.24,
  354. isWater: true,
  355. ),
  356. ),
  357. ),
  358. Positioned(
  359. left: width*0.17,
  360. top: width*0.08,
  361. child: Icon(
  362. IconData(0xe607,
  363. fontFamily: "myfont"),
  364. size: 26.0,
  365. color: Colors.white,
  366. ),
  367. )
  368. ],
  369. )),
  370. ],
  371. )
  372. ),
  373. onTap: () {
  374. NavigatorUtils.push(context,
  375. "${BbsRouter.videoDetail}?id=${provider.list[index].id.toString()}");
  376. },
  377. );
  378. },
  379. );
  380. }))
  381. ],
  382. ),
  383. !sortBool?
  384. Positioned(
  385. top:0,
  386. left:0,
  387. child: GestureDetector(
  388. onTap: (){
  389. setState(() {
  390. sortBool = true;
  391. });
  392. },
  393. child: Container(
  394. width:width,
  395. height:height,
  396. color: Color.fromRGBO(0, 0, 0, 0.5)
  397. ),
  398. )
  399. )
  400. :Container(
  401. child:null
  402. ),
  403. !sortBool?
  404. Positioned(
  405. top:0,
  406. left:0,
  407. child:Container(
  408. width: width,
  409. height:height/2,
  410. color: ThemeUtils.getDialogTextFieldColor(context),
  411. padding: EdgeInsets.all(10),
  412. child:ListView(
  413. children:<Widget>[
  414. GestureDetector(
  415. onTap: (){
  416. if(checkType=="brand"){
  417. setState(() {
  418. brandIdss = null;
  419. brandName = '品牌';
  420. sortBool = true;
  421. _onRefresh();
  422. });
  423. }else if (checkType=="master"){
  424. setState(() {
  425. exprtyIdss = null;
  426. masterName = '专家';
  427. sortBool = true;
  428. _onRefresh();
  429. });
  430. }
  431. },
  432. child:Container(
  433. padding: EdgeInsets.only(left:5,top:5,bottom:10),
  434. child:Text(
  435. checkTypeName,
  436. style: TextStyle(
  437. color:Color(0xff666666),
  438. fontSize:ScreenUtil().setSp(16)
  439. ),
  440. textAlign:TextAlign.start,
  441. ),
  442. )
  443. ),
  444. typeList!=null&&typeList!=[]?Container(
  445. child: Wrap(
  446. alignment: WrapAlignment.start,
  447. crossAxisAlignment: WrapCrossAlignment.center,
  448. children: typeList.asMap().keys.map((index){
  449. return InkWell(
  450. onTap: (){
  451. print("666");
  452. setState(() {
  453. sortBool = true;
  454. if(checkType=="brand"){
  455. brandName = typeList[index].name??"";
  456. brandIdss = typeList[index].id;
  457. provider.setStateTypeNotNotify(StateType.loading);
  458. _onRefresh();
  459. }else if(checkType=="master"){
  460. masterName= typeList[index].name??'';
  461. exprtyIdss= typeList[index].userId;
  462. provider.setStateTypeNotNotify(StateType.loading);
  463. _onRefresh();
  464. }
  465. });
  466. },
  467. child: Container(
  468. width: width/4-15,
  469. padding: EdgeInsets.only(bottom:ScreenUtil().setWidth(10),top:ScreenUtil().setWidth(10)),
  470. margin: EdgeInsets.only(left:5,right:5,bottom:5,top:5),
  471. decoration: BoxDecoration(
  472. // border: Border(
  473. // bottom: BorderSide(width: 0.5, color: Colours.line),
  474. // ),
  475. color: Color(0xfff5f5f5)
  476. ),
  477. child:Text(
  478. typeList[index].name??"",
  479. style: TextStyle(
  480. color: typeList[index].id == brandIdss?Color(0xffff0000):Color(0xff666666),
  481. fontSize:ScreenUtil().setSp(15)
  482. ),
  483. textAlign:TextAlign.center,
  484. ),
  485. ),
  486. );
  487. }).toList(),
  488. )
  489. ):loadCircle()
  490. ],
  491. )
  492. )
  493. ):
  494. Container(
  495. child:null
  496. ),
  497. ],
  498. )
  499. )
  500. )
  501. );
  502. }
  503. Widget loadCircle() {
  504. return Container(
  505. padding: EdgeInsets.only(top: 10, bottom: 10),
  506. color: ThemeUtils.getTabsBg(context),
  507. child: Center(
  508. child: SpinKitFadingCircle(
  509. color: Colors.blueAccent,
  510. size: 30.0,
  511. ),
  512. ),
  513. );
  514. }
  515. Future _onRefresh() async {
  516. _page = 1;
  517. await presenter.getVideoList(_page,brandIdss,searchWord);
  518. }
  519. Future _loadMore() async {
  520. _page++;
  521. await presenter.getVideoList(_page,brandIdss,searchWord);
  522. }
  523. @override
  524. VideoListPresenterSeconds createPresenter() {
  525. return VideoListPresenterSeconds();
  526. }
  527. }