import 'package:flutter/material.dart';
import 'package:liftmanager/res/colors.dart';
import 'package:liftmanager/widgets/app_bar.dart';
import 'package:liftmanager/utils/time_format.dart';
import 'package:liftmanager/internal/wode/model/wallet_model.dart';

class WalletDetailPage extends StatefulWidget {
  WalletDetailPage(this.model, this.typeTitle);
  Records model;
  String typeTitle;
  // int id;
  @override
  State<StatefulWidget> createState() {
    return WalletDetailPageState();
  }
}

class WalletDetailPageState extends State<WalletDetailPage>
    with AutomaticKeepAliveClientMixin {
  @override
  void initState() {
    super.initState();
  }

  // getDetail() {
  //   NewApiService().getMoneyDetail(widget.id, onSuccess: (res) {
  //     detail = MoneyDetailModel.fromJson(res);
  //     // getUserInfo();
  //     setState(() {});
  //   }, onError: (code, msg) {
  //     toasts(msg);
  //   });
  // }

  @override
  void dispose() {
    // provider.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomPadding: false,
        appBar: MyAppBar(
          centerTitle: "零钱明细",
        ),
        body: Container(
            // color: Colors.red,
            child: Column(
          children: [
            Column(
              children: [
                SizedBox(
                  height: 35,
                ),
                Text(
                  '${widget.typeTitle}',
                  style: TextStyle(fontSize: 18),
                ),
                Text(
                  '${widget.model.descr ?? ''}',
                  style: TextStyle(fontSize: 13, color: Colours.text_gray),
                ),
                SizedBox(
                  height: 35,
                ),
                Text(
                  '¥${widget.model.amount ?? ''}',
                  style: TextStyle(fontSize: 24, color: Colors.red),
                ),
                SizedBox(
                  height: 35,
                ),
              ],
            ),
            Column(
              children: [
                cell('类型', '${widget.model.type == 1 ? '支出' : '收入'}'),
                cell('时间',
                    '${DateUtils.instance.getFormartData(timeSamp: widget.model.createTime, format: "yyyy-MM-dd HH:mm")}'),
                cell('交易单号', '${widget.model.flowNum ?? ''}'),
                cell('余额', '${widget.model.balance ?? ''}'),
                cell('备注', '${widget.model.descr ?? ''}'),
              ],
            ),
            SizedBox(
              height: 30,
            ),
            Expanded(
                child: Container(
              color: Colours.bg_gray,
            ))
          ],
        )));
  }

  cell(title, value) {
    return Container(
      padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
      child: Row(
        children: [
          Container(
            width: 70,
            child: Text(
              title,
              style: TextStyle(color: Colours.text_gray, fontSize: 13),
            ),
          ),
          SizedBox(
            width: 20,
          ),
          Text(
            value,
            style: TextStyle(color: Colours.text, fontSize: 13),
          )
        ],
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
