基础组件库
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.
 
 
 
 
 

177 lines
6.9 KiB

  1. import 'dart:convert';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart';
  6. import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart';
  7. import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart';
  8. import 'package:zhiying_comm/zhiying_comm.dart';
  9. class WalletData extends StatefulWidget {
  10. final Map<String, dynamic> data;
  11. const WalletData(this.data, {Key key}) : super(key: key);
  12. @override
  13. _WalletDataState createState() => _WalletDataState();
  14. }
  15. class _WalletDataState extends State<WalletData> {
  16. Map<String, dynamic> data;
  17. WalletDataBloc _bloc;
  18. Map<String, dynamic> dataModel;
  19. @override
  20. void initState() {
  21. data = widget.data;
  22. _bloc = WalletDataBloc();
  23. _bloc.loadHeaderData();
  24. super.initState();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. print(data);
  29. WalletHeaderModel model;
  30. return StreamBuilder(
  31. stream: _bloc.outData,
  32. builder: (context, asn) {
  33. dataModel = asn.data;
  34. if (data.containsKey('data')) {
  35. Map<String, dynamic> temp = json.decode(data['data']);
  36. model = WalletHeaderModel.fromJson(temp);
  37. } else {
  38. return WalletDataSkeleton();
  39. }
  40. return Container(
  41. width: double.infinity,
  42. child: dataModel == null
  43. ? WalletDataSkeleton()
  44. : Container(
  45. margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10),
  46. padding: EdgeInsets.only(left: 36.w, right: 26.w),
  47. decoration: BoxDecoration(
  48. image: DecorationImage(
  49. image: CachedNetworkImageProvider(
  50. model?.headerImg ?? ""),
  51. fit: BoxFit.fill)),
  52. height: 290.h,
  53. child: Column(
  54. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  55. children: <Widget>[
  56. Row(
  57. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  58. children: <Widget>[
  59. Row(
  60. children: <Widget>[
  61. CachedNetworkImage(
  62. imageUrl: model?.headerAvatar ?? "",
  63. height: 66.h,
  64. width: 52.h,
  65. fit: BoxFit.fill,
  66. ),
  67. Padding(
  68. padding: const EdgeInsets.all(8.0),
  69. child: Column(
  70. crossAxisAlignment:
  71. CrossAxisAlignment.start,
  72. children: <Widget>[
  73. Text(
  74. model?.headerCashOutText ?? "",
  75. style: TextStyle(
  76. fontSize: 25.sp,
  77. color: HexColor.fromHex(
  78. model?.headerCashOutTextColor ??
  79. "")),
  80. ),
  81. Text(
  82. dataModel.containsKey(
  83. model.headerCashOutKey)
  84. ? dataModel[model.headerCashOutKey]
  85. : "",
  86. style: TextStyle(
  87. fontSize: 40.sp,
  88. color: HexColor.fromHex(
  89. model.headerCashOutTextColor),
  90. fontFamily: 'Din-Bold',
  91. package: 'zhiying_base_widget',
  92. ),
  93. ),
  94. ],
  95. ),
  96. )
  97. ],
  98. ),
  99. GestureDetector(
  100. onTap: () {
  101. RouterUtil.route(
  102. model, model.toJson(), context);
  103. },
  104. child: Container(
  105. decoration: BoxDecoration(
  106. borderRadius: BorderRadius.circular(10),
  107. image: DecorationImage(
  108. image: CachedNetworkImageProvider(
  109. model.headerCashOutBtnImg ?? ''),
  110. fit: BoxFit.fill),
  111. ),
  112. child: Padding(
  113. padding: EdgeInsets.only(
  114. left: 29.w,
  115. right: 29.w,
  116. top: 20.w,
  117. bottom: 20.w),
  118. child: Text(
  119. "提现",
  120. style: TextStyle(color: Colors.white),
  121. ),
  122. ),
  123. ),
  124. )
  125. ],
  126. ),
  127. Divider(
  128. height: 1,
  129. ),
  130. Row(
  131. mainAxisAlignment: MainAxisAlignment.spaceAround,
  132. children: _buildTopListItem(model))
  133. ],
  134. ),
  135. ));
  136. },
  137. );
  138. }
  139. ///构建顶部Item
  140. _buildTopListItem(WalletHeaderModel model) {
  141. List<Widget> listWidget = List();
  142. for (var item in model.headerBottomList) {
  143. listWidget.add(Column(
  144. mainAxisSize: MainAxisSize.min,
  145. children: <Widget>[
  146. Text(
  147. dataModel.containsKey(item.valueKey)
  148. ? dataModel[item.valueKey]
  149. : "",
  150. style: TextStyle(
  151. color: HexColor.fromHex(item.valueColor),
  152. fontSize: 30.sp,
  153. fontFamily: 'Din-Bold',
  154. package: 'zhiying_base_widget'),
  155. ),
  156. Text(
  157. item.text,
  158. style: TextStyle(
  159. color: HexColor.fromHex(item.textColor), fontSize: 22.sp),
  160. ),
  161. ],
  162. ));
  163. }
  164. return listWidget;
  165. }
  166. }