基础组件库
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

369 Zeilen
13 KiB

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