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/bil_detail_page/bil_detail_page.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: () {
              RouterUtil.route(
                  SkipModel.fromJson(json.decode(data['data'])), data, context);
            },
            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: 18,
                        height: 18,
                        fit: BoxFit.fill,
                      ),
                      SizedBox(
                        width: 7.5,
                      ),
                      Text(
                        model.bilText,
                        style: TextStyle(fontSize: 12),
                      ),
                    ],
                  ),
                  trailing: Text(
                    model.skipText,
                    style: TextStyle(color: Colors.grey),
                  ),
                )),
          );
  }
}
