基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

339 lines
13 KiB

  1. import 'dart:convert';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:tab_indicator_styler/tab_indicator_styler.dart';
  5. import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart';
  6. import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page.dart';
  7. import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
  8. import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/model/wallet_detail_data_model.dart';
  9. import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/model/wallet_detail_model.dart';
  10. import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_bloc.dart';
  11. import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_sk.dart';
  12. import 'package:flutter_screenutil/flutter_screenutil.dart';
  13. import 'package:cached_network_image/cached_network_image.dart';
  14. import 'package:zhiying_comm/zhiying_comm.dart';
  15. class WalletDetail extends StatefulWidget {
  16. final Map<String, dynamic> data;
  17. const WalletDetail(
  18. this.data, {
  19. Key key,
  20. }) : super(key: key);
  21. @override
  22. _WalletDetailState createState() => _WalletDetailState();
  23. }
  24. class _WalletDetailState extends State<WalletDetail> with TickerProviderStateMixin {
  25. WalletDetailModel _model;
  26. TabController _tabController;
  27. WalletDetailBloc _bloc;
  28. @override
  29. void initState() {
  30. if (widget.data != null) {
  31. _model = WalletDetailModel.fromJson(json.decode(widget.data['data']));
  32. _tabController = TabController(length: _model.providers.length, vsync: this);
  33. }
  34. _bloc = new WalletDetailBloc();
  35. _bloc.loadData(_model.providers[0].type);
  36. super.initState();
  37. }
  38. @override
  39. Widget build(BuildContext context) {
  40. return StreamBuilder(
  41. stream: _bloc.outData,
  42. builder: (context, asyn) {
  43. if (_bloc.listDataModel.length == 0) {
  44. ///骨架图
  45. return WalletDetailSkeleton();
  46. }
  47. return Container(
  48. decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
  49. margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 15.h, bottom: 15.h),
  50. padding: const EdgeInsets.only(bottom: 13),
  51. child: Column(
  52. children: <Widget>[
  53. Container(
  54. padding: EdgeInsets.only(top: 12),
  55. child: TabBar(
  56. indicatorWeight: 3,
  57. indicator: MaterialIndicator(
  58. height: 2,
  59. bottomLeftRadius: 1,
  60. bottomRightRadius: 1,
  61. horizontalPadding: 0,
  62. topLeftRadius: 1,
  63. topRightRadius: 1,
  64. color: HexColor.fromHex(_model.providers[0].selectColor),
  65. ),
  66. isScrollable: true,
  67. unselectedLabelColor: HexColor.fromHex(_model.providers[0].unselectColor),
  68. labelColor: HexColor.fromHex(_model.providers[0].selectColor),
  69. controller: _tabController,
  70. indicatorColor: HexColor.fromHex(_model.providers[0].selectColor),
  71. indicatorSize: TabBarIndicatorSize.label,
  72. onTap: (index) {
  73. ///变更平台
  74. changeProvider(_model.providers[index].type);
  75. },
  76. tabs: _buildTabs()),
  77. ),
  78. ///日期选择
  79. Container(
  80. height: 100.h,
  81. alignment: Alignment.center,
  82. child: ListView.builder(
  83. padding: EdgeInsets.only( left: 16.w),
  84. itemCount: _model.dateList.length,
  85. scrollDirection: Axis.horizontal,
  86. itemBuilder: _buildTimeItem,
  87. ),
  88. ),
  89. /// 数据
  90. Container(
  91. height: 126.h,
  92. margin: EdgeInsets.only(top: 16, left: 30.w, right: 30.w),
  93. width: double.infinity,
  94. decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(_model.providerDashbord.finish.bgImg), fit: BoxFit.fill)),
  95. child: Column(
  96. mainAxisAlignment: MainAxisAlignment.center,
  97. children: <Widget>[
  98. _model.providerDashbord.finish.isShow == "1"
  99. ? Container()
  100. : Padding(
  101. padding: const EdgeInsets.all(8.0),
  102. child: Text(
  103. _model.providerDashbord.finish.text,
  104. style: TextStyle(fontSize: 28.sp, color: HexColor.fromHex(_model.providerDashbord.finish.textColor)),
  105. ),
  106. ),
  107. Row(
  108. mainAxisAlignment: MainAxisAlignment.center,
  109. children: <Widget>[
  110. Text(
  111. _model.providerDashbord.finish.text ?? "",
  112. style: TextStyle(color: Colors.black, fontSize: 22.sp),
  113. ),
  114. InkWell(
  115. child: Padding(
  116. padding: const EdgeInsets.all(8.0),
  117. child: CachedNetworkImage(
  118. imageUrl: _model.providerDashbord.finish.tipIcon ?? "",
  119. width: 20.h,
  120. height: 20.h,
  121. fit: BoxFit.fill,
  122. ),
  123. ),
  124. onTap: () {
  125. ///显示弹窗
  126. showTipDialog(null, _model.providerDashbord.finish.tipText);
  127. })
  128. ],
  129. ),
  130. Text(
  131. _bloc.selectDateData.finish ?? "",
  132. style: TextStyle(color: Colors.red, fontSize: 40.sp, fontFamily: 'Din', package: 'zhiying_base_widget', fontWeight: FontWeight.bold),
  133. )
  134. ],
  135. ),
  136. ),
  137. Container(
  138. child: ListView.builder(
  139. padding: EdgeInsets.all(0),
  140. itemCount: 3,
  141. shrinkWrap: true,
  142. physics: NeverScrollableScrollPhysics(),
  143. itemBuilder: (context, index) {
  144. return _buildBottomItem(context, index, _model.providerDashbord);
  145. }),
  146. )
  147. ],
  148. ),
  149. );
  150. },
  151. );
  152. }
  153. ///平台选择
  154. _buildTabs() {
  155. List<Widget> listWidget = List();
  156. for (var item in _model.providers) {
  157. listWidget.add(Text(
  158. item.name,
  159. style: TextStyle(fontSize: 14, ),
  160. ));
  161. }
  162. return listWidget;
  163. }
  164. Widget _buildTimeItem(BuildContext context, int index) {
  165. var item = _model.dateList[index];
  166. return InkWell(
  167. child: Container(
  168. margin: EdgeInsets.only(top: 0, left: 8, right: 8),
  169. decoration: BoxDecoration(
  170. image: DecorationImage(image: CachedNetworkImageProvider(item.type == _bloc.selectDateData.type ? item.btnImg ?? "" : item.btnNoColorImg ?? ""), fit: BoxFit.fitWidth),
  171. ),
  172. child: Padding(
  173. padding: const EdgeInsets.only(left: 16, right: 16),
  174. child: Center(
  175. child: Text(
  176. item.text,
  177. style: TextStyle(fontSize: 22.sp, color: HexColor.fromHex(item.type == _bloc.selectDateData.type ? item.textSelectColor : item.textUnselectColor)),
  178. )),
  179. ),
  180. ),
  181. onTap: () {
  182. for (var select in _bloc.listDataModel) {
  183. if (select.type == item.type) {
  184. _bloc.selectDay = item.type;
  185. _bloc.refresh();
  186. return;
  187. }
  188. }
  189. },
  190. );
  191. }
  192. ///底部显示
  193. Widget _buildBottomItem(BuildContext context, int index, ProviderDashbord dashbord) {
  194. SelfBuy item;
  195. if (index == 0) {
  196. item = dashbord.selfBuy;
  197. } else if (index == 1) {
  198. item = dashbord.directPromote;
  199. } else {
  200. item = dashbord.indirectPromote;
  201. }
  202. var dataMap = _bloc.selectDateData.toJson();
  203. return Container(
  204. child: Column(
  205. children: <Widget>[
  206. SizedBox(
  207. height: 15.h,
  208. ),
  209. item.isShow == "0"
  210. ? Container()
  211. : Text(
  212. item.title,
  213. style: TextStyle(color: HexColor.fromHex(item.titleColor), fontSize: 28.sp),
  214. ),
  215. SizedBox(
  216. height: 15.h,
  217. ),
  218. Row(
  219. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  220. children: <Widget>[
  221. Expanded(
  222. child: Container(
  223. height: 123.h,
  224. margin: EdgeInsets.only(right: 8, left: 30.w),
  225. padding: EdgeInsets.only(left: 20.w),
  226. decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(item.itemList[0].bgImg ?? ""), fit: BoxFit.fill)),
  227. child: Column(
  228. mainAxisAlignment: MainAxisAlignment.center,
  229. crossAxisAlignment: CrossAxisAlignment.start,
  230. children: <Widget>[
  231. Row(
  232. children: <Widget>[
  233. Text(
  234. item.itemList[0].text ?? "",
  235. style: TextStyle(fontSize: 22.sp, color: HexColor.fromHex(item.itemList[0].textColor)),
  236. ),
  237. InkWell(
  238. child: Padding(
  239. padding: const EdgeInsets.all(8.0),
  240. child: CachedNetworkImage(
  241. imageUrl: item.itemList[0].tipIcon,
  242. width: 20.h,
  243. height: 20.h,
  244. fit: BoxFit.fill,
  245. ),
  246. ),
  247. onTap: () {
  248. //弹窗
  249. showTipDialog(null, item.itemList[0].tipText);
  250. },
  251. )
  252. ],
  253. ),
  254. Text(dataMap[item.itemList[0].vauleKey],
  255. style: TextStyle(
  256. fontFamily: 'Din',
  257. package: 'zhiying_base_widget',
  258. fontWeight: FontWeight.bold,
  259. fontSize: 34.sp,
  260. color: HexColor.fromHex(item.itemList[1].valueColor),
  261. ))
  262. ],
  263. )),
  264. ),
  265. Expanded(
  266. child: Container(
  267. height: 123.h,
  268. margin: EdgeInsets.only(left: 8, right: 30.w),
  269. padding: EdgeInsets.only(left: 20.w),
  270. decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(item.itemList[1].bgImg ?? ""), fit: BoxFit.fill)),
  271. child: Column(
  272. mainAxisAlignment: MainAxisAlignment.center,
  273. crossAxisAlignment: CrossAxisAlignment.start,
  274. children: <Widget>[
  275. Row(
  276. children: <Widget>[
  277. Text(
  278. item.itemList[1].text ?? "",
  279. style: TextStyle(fontSize: 22.sp, color: HexColor.fromHex(item.itemList[1].textColor)),
  280. ),
  281. InkWell(
  282. child: Padding(
  283. padding: const EdgeInsets.all(8.0),
  284. child: CachedNetworkImage(
  285. imageUrl: item.itemList[1].tipIcon,
  286. width: 20.h,
  287. height: 20.h,
  288. fit: BoxFit.fill,
  289. ),
  290. ),
  291. onTap: () {
  292. //弹窗
  293. showTipDialog(null, item.itemList[1].tipText);
  294. },
  295. )
  296. ],
  297. ),
  298. Text(
  299. dataMap[item.itemList[1].vauleKey],
  300. style: TextStyle(
  301. fontSize: 34.sp, color: HexColor.fromHex(item.itemList[1].valueColor), fontFamily: 'Din', package: 'zhiying_base_widget', fontWeight: FontWeight.bold),
  302. )
  303. ],
  304. ),
  305. ))
  306. ],
  307. )
  308. ],
  309. ),
  310. );
  311. }
  312. ///变更平台
  313. void changeProvider(String type) {
  314. _bloc.loadData(type);
  315. }
  316. ///显示提示框
  317. void showTipDialog(String title, String content) {
  318. showDialog(context: context, child: TipDialog(content: content));
  319. }
  320. }