calendar_item.dart 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import 'package:fast/constants.dart';
  2. import 'package:fast/model/model.dart';
  3. import 'package:fast/utils/size_fit.dart';
  4. import 'package:flutter/material.dart';
  5. // GlobalKey todayKey = GlobalKey();
  6. // ignore: must_be_immutable
  7. class CalendarItem extends StatelessWidget {
  8. CalendarItemBean bean;
  9. CalendarItem({Key? key, required this.bean}) : super(key: key);
  10. @override
  11. Widget build(BuildContext context) {
  12. SizeFit.initialize(context);
  13. return Opacity(
  14. opacity: (bean.isHighlight || bean.isToday) ? 1.0 : 0.5,
  15. child: Container(
  16. // key: bean.isToday ? todayKey : null,
  17. alignment: Alignment.center,
  18. width: 50.px,
  19. height: 50.px,
  20. decoration: BoxDecoration(
  21. border: Border.all(
  22. color: bean.isToday ? Colors.white : Colors.transparent,
  23. width: 2.px),
  24. borderRadius: BorderRadius.all(Radius.circular(25.px))),
  25. child: bean.day != null ? dayContent() : const Text('')));
  26. }
  27. dayContent() {
  28. return Stack(
  29. children: [
  30. if (bean.isIng && bean.finishDayBean == null)
  31. Container(
  32. width: 36.px,
  33. height: 36.px,
  34. margin: EdgeInsets.only(left: 5.px, top: 5.px),
  35. decoration: BoxDecoration(
  36. color: Colors.transparent,
  37. border: Border.all(color: kThemeColor, width: 2.px),
  38. borderRadius: BorderRadius.all(Radius.circular(18.px))),
  39. ),
  40. if (bean.showCircle)
  41. Container(
  42. width: 36.px,
  43. height: 36.px,
  44. margin: EdgeInsets.only(left: 5.px, top: 5.px),
  45. decoration: const BoxDecoration(
  46. image: DecorationImage(
  47. image: AssetImage('assets/images/dash_circle.png'),
  48. fit: BoxFit.cover)),
  49. ),
  50. if (bean.finishDayBean != null)
  51. Container(
  52. width: 36.px,
  53. height: 36.px,
  54. margin: EdgeInsets.only(left: 5.px, top: 5.px),
  55. decoration: BoxDecoration(
  56. color: kThemeColor,
  57. borderRadius: BorderRadius.all(Radius.circular(18.px))),
  58. ),
  59. if (bean.finishDayBean != null && bean.isIng)
  60. Stack(
  61. children: [
  62. Container(
  63. width: 36.px,
  64. height: 36.px,
  65. margin: EdgeInsets.only(left: 2.px, top: 5.px),
  66. decoration: BoxDecoration(
  67. color: kThemeColor,
  68. borderRadius: BorderRadius.all(Radius.circular(18.px))),
  69. ),
  70. Container(
  71. width: 36.px,
  72. height: 36.px,
  73. margin: EdgeInsets.only(left: 6.px, top: 5.px),
  74. decoration: BoxDecoration(
  75. color: const Color(0xFF000D1F),
  76. border: Border.all(color: kThemeColor, width: 2.px),
  77. boxShadow: [
  78. BoxShadow(
  79. offset: Offset(-2.px, 0.px),
  80. blurRadius: 4.px,
  81. color: const Color(0x80000D1F))
  82. ],
  83. borderRadius: BorderRadius.all(Radius.circular(18.px))),
  84. )
  85. ],
  86. ),
  87. if (bean.finishDayBean != null && bean.finishDayBean!.challenge_count + bean.finishDayBean!.single_count > 1 && bean.isIng==false)
  88. Stack(
  89. children: [
  90. Container(
  91. width: 36.px,
  92. height: 36.px,
  93. margin: EdgeInsets.only(left: 3.px, top: 5.px),
  94. decoration: BoxDecoration(
  95. color: kThemeColor,
  96. borderRadius: BorderRadius.all(Radius.circular(18.px))),
  97. ),
  98. Container(
  99. width: 36.px,
  100. height: 36.px,
  101. margin: EdgeInsets.only(left: 7.px, top: 5.px),
  102. decoration: BoxDecoration(
  103. color: kThemeColor,
  104. boxShadow: [
  105. BoxShadow(
  106. offset: Offset(-2.px, 0.px),
  107. blurRadius: 4.px,
  108. color: const Color(0x80000D1F))
  109. ],
  110. borderRadius: BorderRadius.all(Radius.circular(18.px))),
  111. )
  112. ],
  113. ),
  114. Container(
  115. width: 46.px,
  116. height: 46.px,
  117. alignment: Alignment.center,
  118. padding: EdgeInsets.only(
  119. bottom: (bean.finishDayBean != null &&
  120. bean.finishDayBean!.win_stone > 0)
  121. ? 5.px
  122. : 0,
  123. left: ((bean.finishDayBean != null && bean.isIng) ||
  124. (bean.finishDayBean != null &&
  125. bean.finishDayBean!.challenge_count +
  126. bean.finishDayBean!.single_count >
  127. 0))
  128. ? 2.px
  129. : 0),
  130. child: Text(
  131. bean.day.toString(),
  132. style: TextStyle(
  133. shadows: [
  134. Shadow(
  135. offset: Offset(0.0, 2.px),
  136. blurRadius: 4.px,
  137. color: kBgColor)
  138. ],
  139. color: Colors.white,
  140. fontSize: 16.px,
  141. fontWeight: FontWeight.w600,
  142. height: 1.0,
  143. fontFamily: 'Exo2'),
  144. ),
  145. ),
  146. if (bean.finishDayBean != null && bean.finishDayBean!.win_stone > 0)
  147. Positioned(
  148. bottom: 2.px,
  149. left: 9.px,
  150. child: Container(
  151. width: 28.px,
  152. height: 14.px,
  153. alignment: Alignment.center,
  154. decoration: BoxDecoration(
  155. color: const Color(0xFF050F1A),
  156. borderRadius: BorderRadius.all(Radius.circular(7.px))),
  157. child: Row(
  158. mainAxisAlignment: MainAxisAlignment.center,
  159. children: [
  160. Text(
  161. '+${bean.finishDayBean!.win_stone}',
  162. style: TextStyle(
  163. color: Colors.white,
  164. fontFamily: 'Exo2',
  165. fontWeight: FontWeight.w600,
  166. fontSize: 8.px),
  167. ),
  168. SizedBox(
  169. width: 2.px,
  170. ),
  171. Image.asset(
  172. 'assets/images/stone.png',
  173. width: 10.px,
  174. height: 10.px,
  175. )
  176. ],
  177. ),
  178. ))
  179. ],
  180. );
  181. }
  182. }