table_manage_area_item.dart 2.34 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/area.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/h_empty_view.dart';

class TableManageAreaItem extends StatefulWidget {
  final String? currentArea; //当前选中区域名称
  final Area area;
  final ValueChanged selectCallback;

  TableManageAreaItem(
    this.area,
    this.currentArea,
    this.selectCallback,
  );

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

class TableManageAreaItemState extends State<TableManageAreaItem> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    Area area = widget.area;
    bool isSelected = area.name == widget.currentArea;
    return GestureDetector(
      onTap: () {
        if (widget.selectCallback != null) {
          widget.selectCallback(widget.area);
        }
      },
      child:
          // Stack(
          //   overflow: Overflow.visible,
          //   alignment: Alignment.topLeft,
          //   children: <Widget>[
          Container(
        // width: ScreenUtil().setWidth(104 * 2),
        height: ScreenUtil().setWidth(60),
        margin: EdgeInsets.only(
          right: ScreenUtil().setWidth(24),
          top: ScreenUtil().setWidth(20),
        ),
        padding: EdgeInsets.symmetric(
          horizontal: ScreenUtil().setWidth(16),
          // vertical: ScreenUtil().setWidth(4)
        ),
        alignment: Alignment.center,
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)),
            color: isSelected ? MyColours.color_438E93 : MyColours.color_ffffff,
            border: Border.all(
                color: isSelected
                    ? MyColours.color_438E93
                    : MyColours.color_999999,
                width: ScreenUtil().setWidth(2))),
        child: Text(
          area.name!,
          overflow: TextOverflow.ellipsis,
          style: TextStyle(
              color:
                  isSelected ? MyColours.color_ffffff : MyColours.color_999999,
              fontSize: ScreenUtil().setSp(32),
              decoration: TextDecoration.none,
              fontWeight: FontWeight.normal),
        ),
      ),
    );
  }
}