notebook_item_f_simple.dart 9.67 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/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/v_empty_view.dart';

/**
 * 简易模式
*/
class NoteBookItemSimple extends StatefulWidget {
  final num index;
  final Notebook notebook;

  NoteBookItemSimple(this.notebook, this.index);

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

class NoteBookItemSimpleState extends State<NoteBookItemSimple> {
  _onOperateClick() {
    if (widget.notebook.operationText == "通知客户") {
      //  String _nameStr = '';
      //                                               String _tid = '';
      //                                               for (int i = 0;
      //                                                   i <
      //                                                       detailEntity
      //                                                           .tables.length;
      //                                                   i++) {
      //                                                 _nameStr +=
      //                                                     '${detailEntity.tables[i].name},';

      //                                                 _tid +=
      //                                                     '${detailEntity.tables[i].id},';
      //                                               }
      //                                               if (_tid.endsWith(',')) {
      //                                                 _tid = _tid.substring(
      //                                                     0, _tid.length - 1);
      //                                               }
      //                                               if (_nameStr
      //                                                   .endsWith(',')) {
      //                                                 _nameStr =
      //                                                     _nameStr.substring(
      //                                                         0,
      //                                                         _nameStr.length -
      //                                                             1);
      //                                               }
      NavigatorUtil.goInvicationPage(
          context,
          widget.notebook.id,
          widget.notebook.tableinfoStr,
          widget.notebook.ddate,
          widget.notebook.ddateStr,
          widget.notebook.phone,
          widget.notebook.ddate_solt,
          widget.notebook.rname == null ? '' : widget.notebook.rname,
          widget.notebook.sex == null ? '' : widget.notebook.sex,
          tid: widget.notebook.tid);
    }
  }

  @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 Stack(
      children: [
        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, notebook.uid);
                },
                child: Row(
                  children: <Widget>[
                    Container(
                      width: ScreenUtil().setWidth(86 * 2),
                      padding: EdgeInsets.symmetric(
                          horizontal: ScreenUtil().setWidth(14),
                          vertical: ScreenUtil().setWidth(40)),
                      alignment: Alignment.center,
                      child: Column(
                        children: [
                          Text(
                            '${notebook.tableinfoStr?.trim()}',
                            maxLines: 30,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: textColor,
                                // fontWeight: FontWeight.bold,
                                fontSize: ScreenUtil().setSp(30)),
                          ),
                          notebook.type == '1'
                              ? Text('online',
                                  style: TextStyle(
                                      color: Colors.blue,
                                      // fontWeight: FontWeight.bold,
                                      fontSize: ScreenUtil().setSp(26)))
                              : SizedBox()
                        ],
                      ),
                    ),
                    MyDivider(
                      ScreenUtil().setWidth(1),
                      ScreenUtil().setHeight(90),
                      color: MyColours.color_ededed,
                    ),
                    Container(
                      width: ScreenUtil().setWidth(230),
                      alignment: Alignment.center,
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text(
                            notebook.rnameStr,
                            // 'nnnnnnnnnnnnnn',
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: textColor,
                                // fontWeight: FontWeight.bold,
                                fontSize: ScreenUtil().setSp(30)),
                          ),
                          notebook.phoneStr.isNotEmpty
                              ? Padding(
                                  padding: EdgeInsets.only(
                                      top: ScreenUtil().setWidth(10)),
                                  child: Text(
                                    notebook.phoneStr,
                                    maxLines: 1,
                                    overflow: TextOverflow.ellipsis,
                                    style: TextStyle(
                                        color: textColor,
                                        // fontWeight: FontWeight.bold,
                                        fontSize: ScreenUtil().setSp(26)),
                                  ))
                              : Container()
                        ],
                      ),
                    ),
                    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,
                behavior: HitTestBehavior.opaque,
                child: Container(
                  padding:
                      EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(20)),
                  width: ScreenUtil().setWidth(184),
                  // color: Colors.red,
                  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)),
                  ),
                ),
              ),
            ],
          ),
        ),
        notebook.orderInfo != null && notebook.orderInfo.status == '3'
            ? Container(
                alignment: Alignment.center,
                width: ScreenUtil().setWidth(52 * 2),
                height: ScreenUtil().setWidth(19 * 2),
                decoration: BoxDecoration(
                  color: MyColours.color_F59A23,
                  borderRadius: BorderRadius.only(
                      bottomRight: Radius.circular(ScreenUtil().setWidth(10))),
                ),
                child: Text(
                  '已买单',
                  style: TextStyle(
                      fontSize: ScreenUtil().setSp(24),
                      color: MyColours.color_ffffff,
                      fontWeight: FontWeight.bold),
                ))
            : Container()
      ],
    );
  }
}