schedule_popup.dart 6.8 KB

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