schedule_popup.dart 7.3 KB

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