Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions lib/presentation/page/calendar_page/calendar_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import 'package:b201_app/app/core/themes/color_theme.dart';

import 'package:b201_app/presentation/widgets/calendar_widget/clean_calendar_widget.dart';
import 'package:flutter/material.dart';

class CalendarPage extends StatefulWidget {
const CalendarPage({super.key});

@override
State<StatefulWidget> createState() {
return _CalendarPageState();
}
}

class _CalendarPageState extends State<CalendarPage> {
final Map<DateTime, List<CleanCalendarEvent>> _events = {
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day): [
CleanCalendarEvent(
'Event A', 'Praktikum',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day, 10, 0),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day, 12, 0),
description: 'A special event',
color: ColorTheme.redColor,
// ignore: prefer_single_quotes
),
],
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 2):
[
CleanCalendarEvent('Event B', 'Jaga Lab',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 10, 0),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 12, 0),
color: Colors.orange),
CleanCalendarEvent('Event C', 'Praktikum',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.pink),
],
DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 3):
[
CleanCalendarEvent('Event B', 'Rapat',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 10, 0),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 12, 0),
color: Colors.orange),
CleanCalendarEvent('Event C', 'Lain',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.pink),
CleanCalendarEvent('Event D', 'Praktikum',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.amber),
CleanCalendarEvent('Event E', 'Lain',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.deepOrange),
CleanCalendarEvent('Event F', 'Workshop',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.green),
CleanCalendarEvent('Event G', 'Jamming',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.indigo),
CleanCalendarEvent('Event H', 'Jaga Lab',
startTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 14, 30),
endTime: DateTime(DateTime.now().year, DateTime.now().month,
DateTime.now().day + 2, 17, 0),
color: Colors.brown),
],
};

@override
void initState() {
super.initState();
// Force selection of today on first load, so that the list of today's events gets shown.
_handleNewDate(DateTime(
DateTime.now().year, DateTime.now().month, DateTime.now().day));
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Calendar(
startOnMonday: true,
weekDays: const ['SEN', 'SEL', 'RAB', 'KAM', 'JUM', 'SAB', 'MIN'],
events: _events,
isExpandable: true,
eventDoneColor: Colors.grey,
selectedColor: ColorTheme.redColor,
todayColor: ColorTheme.redColor,
hideTodayIcon: true,
locale: 'de_DE',
isExpanded: true,
expandableDateFormat: 'EEEE, dd. MMM yyyy',
dayOfWeekStyle: Theme.of(context).textTheme.subtitle2,
dateStyles: Theme.of(context).textTheme.headline1,
),
),
);
}

void _handleNewDate(date) {
// print('Date selected: $date');
}
}
8 changes: 4 additions & 4 deletions lib/presentation/widgets/calendar_widget/calendar_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CalendarTile extends StatelessWidget {
alignment: Alignment.center,
child: Text(
dayOfWeek ?? '',
style: dayOfWeekStyle,
style: dayOfWeekStyle!.copyWith(color: Colors.grey),
),
),
);
Expand All @@ -91,7 +91,7 @@ class CalendarTile extends StatelessWidget {
children: <Widget>[
// Date display
Container(
padding: const EdgeInsets.all(3),
padding: const EdgeInsets.all(2),
margin: const EdgeInsets.only(bottom: 2),
// If this tile is the selected date, draw a colored circle on it. The circle is filled with
// the color passed with the selectedColor parameter or red color.
Expand All @@ -108,8 +108,8 @@ class CalendarTile extends StatelessWidget {
child: Text(
date != null ? DateFormat('d').format(date!) : '',
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w400,
fontSize: 16.0,
fontWeight: FontWeight.w500,
color: isSelected && date != null
? Colors.white
: CalendarUtils.isSameDay(date!, DateTime.now())
Expand Down
35 changes: 26 additions & 9 deletions lib/presentation/widgets/calendar_widget/clean_calendar_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,33 @@ class CleanCalendarEvent {
String location;
DateTime startTime;
DateTime endTime;
String type;
Color color;
bool isAllDay;
bool isDone;

CleanCalendarEvent(this.summary,
{this.description = '',
this.location = '',
required this.startTime,
required this.endTime,
this.color = Colors.blue,
this.isAllDay = false,
this.isDone = false});
CleanCalendarEvent(
this.summary,
this.type, {
this.description = '',
this.location = '',
required this.startTime,
required this.endTime,
this.isAllDay = false,
this.isDone = false,
required Color color,
}) : color = type == 'Lain'
? const Color.fromARGB(255, 141, 153, 174)
: type == 'Rapat'
? const Color.fromARGB(255, 237, 29, 36)
: type == 'Jaga Lab'
? const Color.fromARGB(255, 216, 2, 100)
: type == 'Workshop'
? const Color.fromARGB(255, 165, 55, 139)
: type == 'Jamming'
? const Color.fromARGB(255, 102, 76, 145)
: type == 'Praktikum'
? const Color.fromARGB(255, 53, 79, 124)
: type == 'Mudah'
? const Color.fromARGB(255, 47, 72, 88)
: const Color.fromARGB(255, 141, 153, 174);
}
Loading