Refine schedule/todo UI and integrate Google Photos API
This commit is contained in:
@@ -73,7 +73,7 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Weekly Schedule',
|
||||
'주간 일정',
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -102,17 +102,31 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
if (_schedules.isEmpty) {
|
||||
// Correctly filter for current week (Sunday to Saturday)
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
// In Dart, weekday is 1 (Mon) to 7 (Sun).
|
||||
// To get Sunday: if Mon(1), subtract 1. if Sun(7), subtract 0.
|
||||
final daysToSubtract = now.weekday % 7;
|
||||
final startOfWeek = today.subtract(Duration(days: daysToSubtract));
|
||||
final endOfWeek = startOfWeek.add(const Duration(days: 6, hours: 23, minutes: 59, seconds: 59));
|
||||
|
||||
final filteredSchedules = _schedules.where((item) {
|
||||
// Overlap check: schedule starts before week ends AND schedule ends after week starts
|
||||
return item.startDate.isBefore(endOfWeek) && item.endDate.isAfter(startOfWeek);
|
||||
}).toList();
|
||||
|
||||
if (filteredSchedules.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'No schedules this week',
|
||||
'이번 주 일정이 없습니다',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Sort by date
|
||||
final sortedSchedules = List<ScheduleItem>.from(_schedules);
|
||||
final sortedSchedules = List<ScheduleItem>.from(filteredSchedules);
|
||||
sortedSchedules.sort((a, b) => a.startDate.compareTo(b.startDate));
|
||||
|
||||
return ListView.separated(
|
||||
@@ -121,41 +135,56 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
const Divider(color: Colors.white10),
|
||||
itemBuilder: (context, index) {
|
||||
final item = sortedSchedules[index];
|
||||
final timeStr = item.isAllDay
|
||||
? 'All Day'
|
||||
: DateFormat('HH:mm').format(item.startDate);
|
||||
|
||||
// Multi-day check
|
||||
final isMultiDay = item.startDate.year != item.endDate.year ||
|
||||
item.startDate.month != item.endDate.month ||
|
||||
item.startDate.day != item.endDate.day;
|
||||
|
||||
String? dateRangeStr;
|
||||
if (isMultiDay) {
|
||||
final startStr = DateFormat('MM/dd').format(item.startDate);
|
||||
final endStr = DateFormat('MM/dd').format(item.endDate);
|
||||
dateRangeStr = '$startStr ~ $endStr';
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
horizontal: 10,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white10,
|
||||
color: isMultiDay ? Colors.blue.withOpacity(0.2) : Colors.white10,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: isMultiDay ? Border.all(color: Colors.blue.withOpacity(0.5)) : null,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('d').format(item.startDate),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat('d').format(item.startDate),
|
||||
style: TextStyle(
|
||||
color: isMultiDay ? Colors.blue : Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
DateFormat('E').format(item.startDate),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
Text(
|
||||
DateFormat('E').format(item.startDate),
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
@@ -165,10 +194,15 @@ class _ScheduleListWidgetState extends State<ScheduleListWidget> {
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
timeStr,
|
||||
style: const TextStyle(color: Colors.white54),
|
||||
),
|
||||
subtitle: dateRangeStr != null
|
||||
? Text(
|
||||
dateRangeStr,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user