|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- import 'dart:convert';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart';
- import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart';
- import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart';
- import 'package:cached_network_image/cached_network_image.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
-
- class WalletData extends StatefulWidget {
- final Map<String, dynamic> data;
-
- const WalletData(this.data, {Key key}) : super(key: key);
-
- @override
- _WalletDataState createState() => _WalletDataState();
- }
-
- class _WalletDataState extends State<WalletData> {
- Map<String, dynamic> data;
- WalletDataBloc _bloc;
-
- Map<String, dynamic> dataModel;
-
- @override
- void initState() {
- data = widget.data;
- _bloc = WalletDataBloc();
- _bloc.loadHeaderData();
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- print(data);
- WalletHeaderModel model;
-
- return StreamBuilder(
- stream: _bloc.outData,
- builder: (context, asn) {
- dataModel = asn.data;
- if (data.containsKey('data')) {
- Map<String, dynamic> temp = json.decode(data['data']);
- model = WalletHeaderModel.fromJson(temp);
- } else {
- return WalletDataSkeleton();
- }
- return Container(
- width: double.infinity,
- child: dataModel == null
- ? WalletDataSkeleton()
- : Container(
- margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10),
- padding: EdgeInsets.only(left: 36.w, right: 26.w),
- decoration: BoxDecoration(
- image: DecorationImage(
- image: CachedNetworkImageProvider(
- model?.headerImg ?? ""),
- fit: BoxFit.fill)),
- height: 290.h,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: <Widget>[
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Row(
- children: <Widget>[
- CachedNetworkImage(
- imageUrl: model?.headerAvatar ?? "",
- height: 66.h,
- width: 52.h,
- fit: BoxFit.fill,
- ),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- model?.headerCashOutText ?? "",
- style: TextStyle(
- fontSize: 25.sp,
- color: HexColor.fromHex(
- model?.headerCashOutTextColor ??
- "")),
- ),
- Text(
- dataModel.containsKey(
- model.headerCashOutKey)
- ? dataModel[model.headerCashOutKey]
- : "",
- style: TextStyle(
- fontSize: 40.sp,
- color: HexColor.fromHex(
- model.headerCashOutTextColor)),
- ),
- ],
- ),
- )
- ],
- ),
- GestureDetector(
- child: Container(
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius: BorderRadius.circular(10),
- image: DecorationImage(
- image: CachedNetworkImageProvider(""),
- fit: BoxFit.fill)),
- child: Padding(
- padding: EdgeInsets.only(
- left: 29.w,
- right: 29.w,
- top: 20.w,
- bottom: 20.w),
- child: Text(
- "提现",
- style: TextStyle(color: Colors.white),
- ),
- ),
- ),
- )
- ],
- ),
- Divider(
- height: 1,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: _buildTopListItem(model))
- ],
- ),
- ));
- },
- );
- }
-
- ///构建顶部Item
- _buildTopListItem(WalletHeaderModel model) {
- List<Widget> listWidget = List();
- for (var item in model.headerBottomList) {
- listWidget.add(Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text(
- dataModel.containsKey(item.valueKey)
- ? dataModel[item.valueKey]
- : "",
- style: TextStyle(
- color: HexColor.fromHex(item.valueColor), fontSize: 30.sp),
- ),
- Text(
- item.text,
- style: TextStyle(
- color: HexColor.fromHex(item.textColor), fontSize: 22.sp),
- ),
- ],
- ));
- }
- return listWidget;
- }
- }
|