|
@@ -1,4 +1,5 @@
|
|
|
import 'package:calendar_view/calendar_controller/controller.dart';
|
|
|
+import 'package:calendar_view/calendar_page/month_calendar/schedule_item.dart';
|
|
|
import 'package:calendar_view/utils/calendar_util.dart';
|
|
|
import 'package:calendar_view/utils/chinese_calendar_utils.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
@@ -29,17 +30,29 @@ class MoreSchedulePopupState extends State<MoreSchedulePopup> {
|
|
|
calendarController.scheduleListFilter(widget.scheduleData.scheduleList);
|
|
|
}
|
|
|
|
|
|
+ @override
|
|
|
+ void didUpdateWidget(covariant MoreSchedulePopup oldWidget) {
|
|
|
+ super.didUpdateWidget(oldWidget);
|
|
|
+ _scheduleDataList =
|
|
|
+ calendarController.scheduleListFilter(widget.scheduleData.scheduleList);
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- return Container(
|
|
|
- padding: const EdgeInsets.all(10),
|
|
|
- child: Column(
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
- children: [
|
|
|
- _buildScheduleHead(),
|
|
|
- _buildScheduleTypeList(),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ return ListView(
|
|
|
+ shrinkWrap: true,
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ padding: const EdgeInsets.all(10),
|
|
|
+ child: Column(
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: [
|
|
|
+ _buildScheduleHead(),
|
|
|
+ _buildScheduleList(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -67,7 +80,7 @@ class MoreSchedulePopupState extends State<MoreSchedulePopup> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _buildScheduleTypeList() {
|
|
|
+ Widget _buildScheduleList() {
|
|
|
return ListView.builder(
|
|
|
shrinkWrap: true,
|
|
|
addAutomaticKeepAlives: false,
|
|
@@ -75,76 +88,19 @@ class MoreSchedulePopupState extends State<MoreSchedulePopup> {
|
|
|
itemExtent: _itemHeight,
|
|
|
itemCount: _scheduleDataList.length,
|
|
|
itemBuilder: (context, index) {
|
|
|
- return _buildScheduleTypeItem(index);
|
|
|
+ return _buildScheduleItem(index);
|
|
|
},
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _buildScheduleTypeItem(int scheduleIndex) {
|
|
|
- ScheduleType scheduleType = _scheduleDataList[scheduleIndex].type;
|
|
|
+ Widget _buildScheduleItem(int scheduleIndex) {
|
|
|
Schedule schedule = _scheduleDataList[scheduleIndex];
|
|
|
- return Material(
|
|
|
- color: Colors.transparent,
|
|
|
- child: InkWell(
|
|
|
- customBorder: RoundedRectangleBorder(
|
|
|
- borderRadius: BorderRadius.circular(5),
|
|
|
- ),
|
|
|
- onTap: () {
|
|
|
- ScaffoldMessenger.of(context).showSnackBar(
|
|
|
- SnackBar(
|
|
|
- backgroundColor: scheduleType.color,
|
|
|
- duration: const Duration(milliseconds: 500),
|
|
|
- content: Text('点击了${scheduleType.typeName}'),
|
|
|
- ),
|
|
|
- );
|
|
|
- },
|
|
|
- hoverColor: const Color.fromARGB(255, 227, 228, 228),
|
|
|
- child: Container(
|
|
|
- height: _itemHeight,
|
|
|
- padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0),
|
|
|
- decoration: BoxDecoration(
|
|
|
- // color: scheduleType.isSelected
|
|
|
- // ? scheduleType.color.withOpacity(0.2)
|
|
|
- // : Colors.transparent,
|
|
|
- borderRadius: BorderRadius.circular(5),
|
|
|
- ),
|
|
|
- child: Row(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- width: 6,
|
|
|
- height: 6,
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: scheduleType.color,
|
|
|
- borderRadius: BorderRadius.circular(5),
|
|
|
- ),
|
|
|
- ),
|
|
|
- const SizedBox(width: 5),
|
|
|
- Expanded(
|
|
|
- child: Text(
|
|
|
- breakWord(schedule.title),
|
|
|
- style: const TextStyle(fontSize: 12),
|
|
|
- overflow: TextOverflow.ellipsis,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
+ return SchedualItem(
|
|
|
+ scheduleData: schedule,
|
|
|
+ itemHeight: _itemHeight,
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- static String breakWord(String text) {
|
|
|
- if (text.isEmpty) {
|
|
|
- return text;
|
|
|
- }
|
|
|
- String breakWord = ' ';
|
|
|
- for (var element in text.runes) {
|
|
|
- breakWord += String.fromCharCode(element);
|
|
|
- breakWord += '\u200B';
|
|
|
- }
|
|
|
- return breakWord;
|
|
|
- }
|
|
|
-
|
|
|
String _getLunarDay(DateTime date) {
|
|
|
CalendarInfo lunarDate = CalendarUtils.getInfo(date);
|
|
|
return lunarDate.term ?? lunarDate.lunarDayName ?? '';
|