123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import 'package:flutter/material.dart';
- import 'package:liftmanager/res/colors.dart';
- import 'package:liftmanager/utils/utils.dart';
- class CalendarTile extends StatelessWidget {
- final VoidCallback onDateSelected;
- final DateTime date;
- final String dayOfWeek;
- final bool isDayOfWeek;
- final bool isSelected;
- final TextStyle dayOfWeekStyles;
- final TextStyle dateStyles;
- final Widget child;
- final Color weekBgColor;
- final Color weekTextColor;
- final int mtState; //0:无状态 1:待完成 2:正常 3:超期
- CalendarTile(
- {this.onDateSelected,
- this.date,
- this.child,
- this.dateStyles,
- this.dayOfWeek,
- this.dayOfWeekStyles,
- this.isDayOfWeek: false,
- this.isSelected: false,
- this.weekBgColor,
- this.weekTextColor,
- this.mtState = 0});
- Widget renderDateOrDayOfWeek(BuildContext context) {
- if (isDayOfWeek) {
- return new InkWell(
- child: new Container(
- height: 45,
- alignment: Alignment.center,
- child: new Text(
- dayOfWeek,
- style: dayOfWeekStyles,
- ),
- ),
- );
- } else {
- return new InkWell(
- onTap: onDateSelected,
- child: new Container(
- color: Colors.white,
- height: 45,
- alignment: Alignment.center,
- child: Container(
- width: 35,
- height: 35,
- decoration: isSelected
- ? BoxDecoration(
- shape: BoxShape.circle, color: Colours.app_main)
- : mtState == 1
- ? BoxDecoration(
- borderRadius: BorderRadius.circular(18),
- border: Border.all(
- color: Colours.text_gray,
- style: BorderStyle.solid,
- width: 2))
- : mtState == 2
- ? BoxDecoration(
- borderRadius: BorderRadius.circular(18),
- border: Border.all(
- color: Colors.yellow,
- style: BorderStyle.solid,
- width: 2))
- : mtState == 3
- ? BoxDecoration(
- borderRadius:
- BorderRadius.circular(18),
- border: Border.all(
- color: Color(0xFF9CD19E),
- style: BorderStyle.solid,
- width: 2))
- : mtState == 4
- ? BoxDecoration(
- borderRadius:
- BorderRadius.circular(18),
- border: Border.all(
- color: Colors.red,
- style: BorderStyle.solid,
- width: 2))
- : BoxDecoration(),
- alignment: Alignment.center,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Text(
- Utils.formatDay(date).toString(),
- style: isSelected
- ? new TextStyle(color: Colors.white)
- : dateStyles,
- textAlign: TextAlign.center,
- ),
- ],
- )),
- ),
- );
- }
- }
- @override
- Widget build(BuildContext context) {
- if (child != null) {
- return new InkWell(
- child: child,
- onTap: onDateSelected,
- );
- }
- return new Container(
- child: renderDateOrDayOfWeek(context),
- );
- }
- }
|