notebook_item_widget.dart 5.24 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/v_empty_view.dart';

class NoteBookItem extends StatefulWidget {
  final num index;
  final Notebook notebook;

  NoteBookItem(this.notebook, this.index);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new NotebookItemState();
  }
}

class NotebookItemState extends State<NoteBookItem> {
  _onOperateClick() {
    if (widget.notebook.operationText == "通知客户") {
      NavigatorUtil.goInvicationPage(
          context,
          widget.notebook.id,
          widget.notebook.tableinfoStr,
          widget.notebook.ddate,
          widget.notebook.ddateStr,
      widget.notebook.phone
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    Notebook notebook = widget.notebook;

    Color textColor = (notebook.status == "3" ||
            notebook.status == "4" ||
            notebook.status == "6")
        ? MyColours.color_bfbfbf
        : MyColours.color_353535;

    return Container(
      width: double.infinity,
      height: ScreenUtil().setWidth(120),
      color: (widget.index % 2 == 0)
          ? MyColours.color_f7fdfd
          : MyColours.color_ffffff,
      child: Row(
        children: <Widget>[
          GestureDetector(
            behavior: HitTestBehavior.translucent,
            onTap: () {
              NavigatorUtil.goNotebookDetailPage(context, notebook.id);
            },
            child: Row(
              children: <Widget>[
                Container(
                  width: ScreenUtil().setWidth(171),
                  padding: EdgeInsets.symmetric(
                      horizontal: ScreenUtil().setWidth(24)),
                  alignment: Alignment.center,
                  child: Text(
                    notebook.tableinfoStr?.trim(),
                    maxLines: 3,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        color: textColor,
                        // fontWeight: FontWeight.bold,
                        fontSize: ScreenUtil().setSp(30)),
                  ),
                ),
                MyDivider(
                  ScreenUtil().setWidth(1),
                  ScreenUtil().setHeight(90),
                  color: MyColours.color_ededed,
                ),
                Container(
                  width: ScreenUtil().setWidth(230),
                  alignment: Alignment.center,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      Text(
                        notebook.rnameStr,
                        // 'nnnnnnnnnnnnnn',
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            color: textColor,
                            // fontWeight: FontWeight.bold,
                            fontSize: ScreenUtil().setSp(30)),
                      ),
                      VEmptyView(10),
                      Text(
                        notebook.phoneStr,
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            color: textColor,
                            // fontWeight: FontWeight.bold,
                            fontSize: ScreenUtil().setSp(26)),
                      )
                    ],
                  ),
                ),
                MyDivider(
                  ScreenUtil().setWidth(1),
                  ScreenUtil().setHeight(90),
                  color: MyColours.color_ededed,
                ),
                Container(
                  width: ScreenUtil().setWidth(159),
                  alignment: Alignment.center,
                  child: Text(
                    notebook.ddateStr,
                    style: TextStyle(
                        color: textColor,
                        // fontWeight: FontWeight.bold,
                        fontSize: ScreenUtil().setSp(30)),
                  ),
                ),
              ],
            ),
          ),
          MyDivider(
            ScreenUtil().setWidth(1),
            ScreenUtil().setHeight(90),
            color: MyColours.color_ededed,
          ),
          GestureDetector(
            onTap: _onOperateClick,
            child: Container(
              width: ScreenUtil().setWidth(184),
              alignment: Alignment.center,
              child: Text(
                notebook.operationText,
                style: TextStyle(
                    color: (notebook.status == "3" ||
                            notebook.status == "4" ||
                            notebook.status == "6")
                        ? MyColours.color_bfbfbf
                        : MyColours.color_2bb5b7,
                    // fontWeight: FontWeight.bold,
                    fontSize: ScreenUtil().setSp(30)),
              ),
            ),
          ),
        ],
      ),
    );
  }
}