基础组件库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wallet_data.dart 6.9 KiB

4 년 전
4 년 전
4 년 전
4 년 전
4 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. }