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

wallet_data.dart 6.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import 'dart:convert';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart';
  5. import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart';
  6. import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart';
  7. import 'package:cached_network_image/cached_network_image.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. ),
  91. ],
  92. ),
  93. )
  94. ],
  95. ),
  96. GestureDetector(
  97. child: Container(
  98. decoration: BoxDecoration(
  99. color: Colors.red,
  100. borderRadius: BorderRadius.circular(10),
  101. image: DecorationImage(
  102. image: CachedNetworkImageProvider(""),
  103. fit: BoxFit.fill)),
  104. child: Padding(
  105. padding: EdgeInsets.only(
  106. left: 29.w,
  107. right: 29.w,
  108. top: 20.w,
  109. bottom: 20.w),
  110. child: Text(
  111. "提现",
  112. style: TextStyle(color: Colors.white),
  113. ),
  114. ),
  115. ),
  116. )
  117. ],
  118. ),
  119. Divider(
  120. height: 1,
  121. ),
  122. Row(
  123. mainAxisAlignment: MainAxisAlignment.spaceAround,
  124. children: _buildTopListItem(model))
  125. ],
  126. ),
  127. ));
  128. },
  129. );
  130. }
  131. ///构建顶部Item
  132. _buildTopListItem(WalletHeaderModel model) {
  133. List<Widget> listWidget = List();
  134. for (var item in model.headerBottomList) {
  135. listWidget.add(Column(
  136. mainAxisSize: MainAxisSize.min,
  137. children: <Widget>[
  138. Text(
  139. dataModel.containsKey(item.valueKey)
  140. ? dataModel[item.valueKey]
  141. : "",
  142. style: TextStyle(
  143. color: HexColor.fromHex(item.valueColor), fontSize: 30.sp),
  144. ),
  145. Text(
  146. item.text,
  147. style: TextStyle(
  148. color: HexColor.fromHex(item.textColor), fontSize: 22.sp),
  149. ),
  150. ],
  151. ));
  152. }
  153. return listWidget;
  154. }
  155. }