schedule_popup.dart 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import 'package:calendar_view/calendar_controller/controller.dart';
  2. import 'package:calendar_view/utils/calendar_util.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:get/get.dart';
  5. class SchedulePopup extends StatefulWidget {
  6. const SchedulePopup({
  7. Key? key,
  8. required this.scheduleData,
  9. }) : super(key: key);
  10. /// 日程数据
  11. final MonthViewDayStructure scheduleData;
  12. @override
  13. SchedulePopupState createState() => SchedulePopupState();
  14. }
  15. class SchedulePopupState extends State<SchedulePopup> {
  16. static const double _itemHeight = 28;
  17. List<Schedule> _scheduleDataList = [];
  18. CalendarController calendarController = Get.find<CalendarController>();
  19. @override
  20. void initState() {
  21. super.initState();
  22. _scheduleDataList =
  23. calendarController.scheduleListFilter(widget.scheduleData.scheduleList);
  24. }
  25. @override
  26. void didUpdateWidget(covariant SchedulePopup oldWidget) {
  27. super.didUpdateWidget(oldWidget);
  28. _scheduleDataList =
  29. calendarController.scheduleListFilter(widget.scheduleData.scheduleList);
  30. }
  31. @override
  32. Widget build(BuildContext context) {
  33. return ListView(
  34. shrinkWrap: true,
  35. children: [
  36. Container(
  37. padding: const EdgeInsets.all(10),
  38. child: _buildScheduleList(),
  39. ),
  40. ],
  41. );
  42. }
  43. /// 构建icon
  44. Widget _buildIcon({
  45. required IconData icon,
  46. required double size,
  47. }) {
  48. return Icon(
  49. icon,
  50. size: size,
  51. color: const Color.fromRGBO(116, 118, 119, 1),
  52. );
  53. }
  54. /// 构建icon按钮
  55. Widget _buildIconButton({
  56. required VoidCallback onPressed,
  57. required IconData icon,
  58. }) {
  59. return IconButton(
  60. onPressed: () => onPressed,
  61. icon: _buildIcon(
  62. icon: icon,
  63. size: 20,
  64. ),
  65. );
  66. }
  67. Map<int, String> weekMap = {
  68. 1: '星期一',
  69. 2: '星期二',
  70. 3: '星期三',
  71. 4: '星期四',
  72. 5: '星期五',
  73. 6: '星期六',
  74. 7: '星期天',
  75. };
  76. /// 日程卡片视图列表
  77. Widget _buildScheduleList() {
  78. final currentDate = widget.scheduleData.date;
  79. return Column(
  80. mainAxisSize: MainAxisSize.min,
  81. children: [
  82. _buildScheduleHeadActionBar(),
  83. _buildScheduleLayoutItem(
  84. iconWidget: const SizedBox(
  85. width: 18,
  86. child: CircleAvatar(
  87. radius: 6,
  88. backgroundColor: Colors.red,
  89. ),
  90. ),
  91. scheduleItemWidget: const Text(
  92. '杏聆荟每日站会',
  93. ),
  94. ),
  95. _buildScheduleLayoutItem(
  96. iconWidget: _buildIcon(
  97. icon: Icons.av_timer_rounded,
  98. size: 18,
  99. ),
  100. scheduleItemWidget: Text(
  101. currentDate.month.toString() +
  102. '月' +
  103. currentDate.day.toString() +
  104. '日 周 ' +
  105. weekMap[currentDate.weekday]! +
  106. ' 10:00-10:30',
  107. ),
  108. ),
  109. _buildScheduleLayoutItem(
  110. iconWidget: _buildIcon(
  111. icon: Icons.personal_injury_rounded,
  112. size: 18,
  113. ),
  114. scheduleItemWidget: const Text('组织人'),
  115. ),
  116. _buildScheduleLayoutItem(
  117. iconWidget: _buildIcon(
  118. icon: Icons.people_alt_outlined,
  119. size: 18,
  120. ),
  121. scheduleItemWidget: Row(
  122. mainAxisSize: MainAxisSize.max,
  123. children: const [
  124. Text(
  125. '邀请7人,5人接受',
  126. ),
  127. Expanded(child: SizedBox()),
  128. Text(
  129. '查看全部',
  130. style: TextStyle(
  131. fontSize: 12,
  132. color: Colors.grey,
  133. ),
  134. ),
  135. ],
  136. ),
  137. ),
  138. Row(
  139. mainAxisAlignment: MainAxisAlignment.start,
  140. children: [
  141. const SizedBox(
  142. width: 30,
  143. ),
  144. _buildHeadPortraitItem(),
  145. _buildHeadPortraitItem(),
  146. _buildHeadPortraitItem(),
  147. _buildHeadPortraitItem(),
  148. _buildHeadPortraitItem(),
  149. ],
  150. ),
  151. SizedBox(
  152. height: 15,
  153. ),
  154. Divider(),
  155. _buildSchedulebottomActionBar(),
  156. ],
  157. );
  158. }
  159. /// 日程卡片顶部操作栏
  160. Widget _buildScheduleHeadActionBar() {
  161. return SizedBox(
  162. height: 35,
  163. child: Row(
  164. mainAxisAlignment: MainAxisAlignment.end,
  165. children: [
  166. _buildIconButton(
  167. onPressed: () {},
  168. icon: Icons.delete_outlined,
  169. ),
  170. _buildIconButton(
  171. onPressed: () {},
  172. icon: Icons.launch_rounded,
  173. ),
  174. _buildIconButton(
  175. onPressed: () {},
  176. icon: Icons.close,
  177. ),
  178. ],
  179. ),
  180. );
  181. }
  182. /// 日程卡片底部操作栏
  183. Widget _buildSchedulebottomActionBar() {
  184. return SizedBox(
  185. height: 35,
  186. child: Row(
  187. children: [
  188. Container(
  189. margin: EdgeInsets.only(
  190. left: 5,
  191. ),
  192. child: Text('查看详情'),
  193. ),
  194. Expanded(
  195. child: Row(
  196. mainAxisAlignment: MainAxisAlignment.end,
  197. children: [
  198. _buildIconButton(
  199. onPressed: () {},
  200. icon: Icons.check_circle_outlined,
  201. ),
  202. ],
  203. ),
  204. ),
  205. ],
  206. ),
  207. );
  208. }
  209. /// 日程卡片单行布局
  210. Widget _buildScheduleLayoutItem({
  211. required Widget iconWidget,
  212. required Widget scheduleItemWidget,
  213. }) {
  214. return Container(
  215. padding: const EdgeInsets.only(
  216. left: 10,
  217. bottom: 10,
  218. right: 10,
  219. ),
  220. child: Row(
  221. children: [
  222. Container(
  223. margin: const EdgeInsets.only(
  224. left: 5,
  225. right: 10,
  226. ),
  227. child: iconWidget,
  228. ),
  229. Expanded(child: scheduleItemWidget),
  230. ],
  231. ),
  232. );
  233. }
  234. Widget _buildHeadPortraitItem() {
  235. return Container(
  236. width: 55,
  237. height: 55,
  238. child: Column(
  239. mainAxisAlignment: MainAxisAlignment.center,
  240. children: [
  241. Container(
  242. width: 30,
  243. height: 30,
  244. decoration: BoxDecoration(
  245. borderRadius: BorderRadius.circular(
  246. 4,
  247. ),
  248. color: Colors.red,
  249. ),
  250. ),
  251. Text(
  252. '11222qwwqqwww2',
  253. overflow: TextOverflow.ellipsis,
  254. ),
  255. ],
  256. ),
  257. );
  258. }
  259. }