import 'dart:convert';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/wallet_page/wallet_detail_page.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/model/wallet_bli_model.dart';
import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

///查看明细部件
class WalletBil extends StatelessWidget {
  Map<String, dynamic> data;

  WalletBil(this.data, {Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    WalletBilModel model;
    if (data != null) {
      model = WalletBilModel.fromJson(json.decode(data['data']));
    }
    return data == null
        ? WalletIncomeSkeleton()
        : GestureDetector(
            onTap: () {
              Navigator.push(
                context,
                CupertinoPageRoute(
                  builder: (context) => WalletDetailPage(),
                ),
              );
            },
            child: Container(
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(8)),
                margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10),
                child: ListTile(
                  title: Row(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      CachedNetworkImage(
                        imageUrl: model.bilIcon,
                        width: 36.w,
                        height: 36.w,
                        fit: BoxFit.fill,
                      ),
                      SizedBox(
                        width: 15.w,
                      ),
                      Text(
                        model.bilText,
                        style: TextStyle(fontSize: 24.sp),
                      ),
                    ],
                  ),
                  trailing: Text(
                    model.skipText,
                    style: TextStyle(color: Colors.grey),
                  ),
                )),
          );
  }
}