my_video.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. import 'package:flustars/flustars.dart' as flustars;
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:liftmanager/common/common.dart';
  5. import 'package:liftmanager/internal/bbs/model/mix_model.dart';
  6. import 'package:liftmanager/internal/bbs/presenter/video_list_presenter.dart';
  7. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  8. import 'package:liftmanager/internal/wode/wode_router.dart';
  9. import 'package:liftmanager/mvp/base_page_state.dart';
  10. import 'package:liftmanager/res/resources.dart';
  11. import 'package:liftmanager/routers/fluro_navigator.dart';
  12. import 'package:liftmanager/utils/fast_notification.dart';
  13. import 'package:liftmanager/widgets/app_bar.dart';
  14. import 'package:liftmanager/widgets/load_image.dart';
  15. import 'package:liftmanager/widgets/my_refresh_list.dart';
  16. import 'package:liftmanager/widgets/state_layout.dart';
  17. import 'package:provider/provider.dart';
  18. class MyVideo extends StatefulWidget {
  19. // QuestionList(this.index);
  20. // final String index;
  21. @override
  22. MyVideoState createState() => MyVideoState();
  23. }
  24. class MyVideoState extends BasePageState<MyVideo, MyVideoListPresenter>
  25. with AutomaticKeepAliveClientMixin {
  26. // NewsDetailItem item = NewsDetailItem();
  27. BaseListProvider<Records> provider = BaseListProvider<Records>();
  28. ScrollController _scrollController = new ScrollController();
  29. int _page = 1;
  30. String searchWord;
  31. @override
  32. void initState() {
  33. provider.setStateTypeNotNotify(StateType.loading);
  34. super.initState();
  35. _onRefresh();
  36. print(66666);
  37. FastNotification.addListener("initMyVideo", (initThisMyVideo) {
  38. if (mounted) {
  39. _onRefresh();
  40. }
  41. });
  42. }
  43. getCheckFlag(checkFlag) {
  44. String str;
  45. if (checkFlag == 0) {
  46. str = "已驳回";
  47. } else if (checkFlag == 1) {
  48. str = "审核通过";
  49. } else if (checkFlag == 2) {
  50. str = "待审核";
  51. }
  52. return str;
  53. }
  54. @override
  55. void dispose() {
  56. _scrollController.dispose();
  57. super.dispose();
  58. }
  59. @override
  60. Widget build(BuildContext context) {
  61. double width = MediaQuery.of(context).size.width;
  62. return ChangeNotifierProvider<BaseListProvider<Records>>(
  63. create: (_) => provider,
  64. child: Scaffold(
  65. appBar: MyAppBar(
  66. centerTitle: '我的视频',
  67. // searchWidth: width * 0.7,
  68. // onPressed: (text) {
  69. // searchWord = text;
  70. // _onRefresh();
  71. // },
  72. actions: <Widget>[
  73. FlatButton(
  74. child: Text(
  75. "上传",
  76. style: TextStyle(color: Colours.text, fontSize: 14),
  77. ),
  78. // textColor: Colours.text,
  79. // highlightColor: Colors.transparent,
  80. onPressed: () {
  81. // NavigatorUtils.push(context, BbsRouter.videoUpload);
  82. NavigatorUtils.push(
  83. context, "${WodeRouter.videoUpload}?id=");
  84. },
  85. )
  86. ],
  87. ),
  88. body: Container(
  89. child: Stack(
  90. children: <Widget>[
  91. Column(
  92. children: <Widget>[
  93. Expanded(
  94. flex: 1,
  95. child: Consumer<BaseListProvider<Records>>(
  96. builder: (_, provider, __) {
  97. return MyListView(
  98. key: Key('video_list'),
  99. itemCount: provider.list.length,
  100. stateType: provider.stateType,
  101. onRefresh: _onRefresh,
  102. pageSize: 10,
  103. loadMore: _loadMore,
  104. hasMore: provider.hasMore,
  105. itemBuilder: (_, index) {
  106. return GestureDetector(
  107. child: Container(
  108. padding: EdgeInsets.only(
  109. left: 15,
  110. // right: ScreenUtil().setWidth(15),
  111. top: 10,
  112. bottom: 10),
  113. decoration: BoxDecoration(
  114. border: Border(
  115. bottom: BorderSide(
  116. width: 0.5, color: Colours.line),
  117. ),
  118. ),
  119. child: Row(
  120. // crossAxisAlignment:
  121. // CrossAxisAlignment.start,
  122. // mainAxisAlignment:
  123. // MainAxisAlignment.spaceBetween,
  124. children: <Widget>[
  125. Expanded(
  126. // color: Colors.red,
  127. // height: width * 0.24,
  128. child: Column(
  129. crossAxisAlignment:
  130. CrossAxisAlignment.start,
  131. // mainAxisAlignment:
  132. // MainAxisAlignment
  133. // .spaceBetween,
  134. children: <Widget>[
  135. Container(
  136. // width: width * 0.5,
  137. child: Text(
  138. "${provider.list[index].title ?? ""}",
  139. style: TextStyle(
  140. fontWeight:
  141. FontWeight.w400,
  142. color:
  143. Color(0xff222222),
  144. fontSize: 15),
  145. textAlign: TextAlign.start,
  146. maxLines: 1,
  147. overflow:
  148. TextOverflow.ellipsis,
  149. ),
  150. ),
  151. Container(
  152. // width: width * 0.5,
  153. child: Text(
  154. "${provider.list[index].descr ?? ""}",
  155. style: TextStyle(
  156. fontWeight:
  157. FontWeight.w600,
  158. color:
  159. Color(0xff999999),
  160. fontSize: 12),
  161. textAlign: TextAlign.start,
  162. maxLines: 1,
  163. overflow:
  164. TextOverflow.ellipsis,
  165. ),
  166. ),
  167. SizedBox(
  168. height: 30,
  169. ),
  170. // Expanded(child: Container()),
  171. Row(
  172. // crossAxisAlignment: CrossAxisAlignment.baseline,
  173. mainAxisAlignment:
  174. MainAxisAlignment
  175. .spaceBetween,
  176. children: <Widget>[
  177. Container(
  178. alignment:
  179. Alignment.center,
  180. padding:
  181. EdgeInsets.fromLTRB(
  182. 5, 0, 5, 2),
  183. // width: width * 0.35,
  184. decoration:
  185. new BoxDecoration(
  186. //背景
  187. color:
  188. Color(0x215887FF),
  189. //设置四周圆角 角度
  190. borderRadius:
  191. BorderRadius.all(
  192. Radius.circular(
  193. 4.0)),
  194. //设置四周边框
  195. ),
  196. child: Text(
  197. "${provider.list[index].brandName ?? ""}",
  198. style: TextStyle(
  199. color: Color(
  200. 0xff999999),
  201. fontSize: 11),
  202. textAlign:
  203. TextAlign.start,
  204. maxLines: 1,
  205. overflow: TextOverflow
  206. .ellipsis,
  207. ),
  208. ),
  209. // SizedBox(width: 5),
  210. // Expanded(child: Container()),
  211. Row(
  212. // mainAxisAlignment:
  213. // MainAxisAlignment
  214. // .spaceBetween,
  215. children: <Widget>[
  216. Container(
  217. // width: width * 0.15,
  218. child: Text(
  219. "${provider.list[index].browseNum ?? "0"}浏览·${provider.list[index].likeNum ?? "0"}赞",
  220. style: TextStyle(
  221. color: Color(
  222. 0xffCCCCCC),
  223. fontSize: 11),
  224. textAlign:
  225. TextAlign.right,
  226. maxLines: 1,
  227. overflow:
  228. TextOverflow
  229. .ellipsis,
  230. ),
  231. ),
  232. SizedBox(
  233. width: 10,
  234. )
  235. ],
  236. ),
  237. ],
  238. )
  239. ]),
  240. ),
  241. // Expanded(child: Container()),
  242. Container(
  243. padding: EdgeInsets.only(right: 10),
  244. child: Stack(
  245. children: <Widget>[
  246. ClipRRect(
  247. borderRadius:
  248. BorderRadius.circular(7),
  249. child: Container(
  250. child: LoadNetworkImage(
  251. // imgFontUrl +
  252. // provider.list[index].cover,
  253. provider
  254. .list[index].cover,
  255. width: 140,
  256. height: 85,
  257. isWater: false,
  258. ),
  259. ),
  260. ),
  261. Positioned(
  262. left: width * 0.17,
  263. top: width * 0.08,
  264. child: Icon(
  265. const IconData(0xe8e0,
  266. fontFamily: "Iconfont"),
  267. size: 26.0,
  268. color: Colors.white,
  269. ),
  270. ),
  271. Positioned(
  272. right: 0,
  273. top: 0,
  274. child: Container(
  275. padding:
  276. EdgeInsets.fromLTRB(
  277. 5, 2, 5, 2),
  278. decoration:
  279. new BoxDecoration(
  280. //背景
  281. color:
  282. Color(0x4c000000),
  283. //设置四周圆角 角度
  284. borderRadius:
  285. BorderRadius.all(
  286. Radius.circular(
  287. 4.0)),
  288. //设置四周边框
  289. // border: new Border.all(width: 1, color: Colors.red),
  290. ),
  291. child: Text(
  292. provider.list[index]
  293. .checkFlag !=
  294. null
  295. ? getCheckFlag(
  296. provider
  297. .list[index]
  298. .checkFlag)
  299. : "",
  300. style: TextStyle(
  301. color: Colors.white,
  302. fontSize: 10),
  303. textAlign:
  304. TextAlign.start,
  305. ),
  306. ))
  307. ],
  308. )),
  309. ],
  310. )),
  311. onTap: () {
  312. NavigatorUtils.push(context,
  313. "${WodeRouter.videoDetail}?id=${provider.list[index].id.toString()}");
  314. },
  315. );
  316. },
  317. );
  318. }))
  319. ],
  320. ),
  321. ],
  322. ))));
  323. }
  324. Future _onRefresh() async {
  325. _page = 1;
  326. await presenter.getVideoList(_page,
  327. int.parse(flustars.SpUtil.getString(Constant.userId)), searchWord);
  328. }
  329. Future _loadMore() async {
  330. _page++;
  331. await presenter.getVideoList(_page,
  332. int.parse(flustars.SpUtil.getString(Constant.userId)), searchWord);
  333. }
  334. @override
  335. MyVideoListPresenter createPresenter() {
  336. return MyVideoListPresenter();
  337. }
  338. bool get wantKeepAlive => true;
  339. }