Files
Regroup/lib/Main_Screens/CalenderTab/CalenderTab.dart
2024-08-01 13:45:01 +05:30

856 lines
32 KiB
Dart

import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonBottomNavigationBar.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonTabBar.dart';
import 'package:regroup/Common/controller/MainScreen.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
import 'package:syncfusion_flutter_calendar/calendar.dart';
class CalenderTab extends StatefulWidget {
const CalenderTab({super.key});
@override
State<CalenderTab> createState() => _CalenderTabState();
}
class _CalenderTabState extends State<CalenderTab> {
List sessionData = [
{
"title": "Attending events",
"imagePath": "assets/images/png/Rectangle299.png",
"names": "Sports challenge"
},
{
"title": "Shown Interest",
"imagePath": "assets/images/png/Rectangle 25.png",
"names": "Ultimate athlete challenge"
},
{
"title": "Not going",
"imagePath": "assets/images/png/Rectangle 24.png",
"names": "Cyclotron challenge"
},
];
List communityData = [
{
"title": "Featured community",
"imagePath": "assets/images/png/Rectangle 24.png",
"names": "Sports challenge"
},
{
"title": "Featured community",
"imagePath": "assets/images/png/Rectangle 24.png",
"names": "Tri-sport challenge"
},
];
CalendarController? _sessionCalController;
CalendarController? _comCalController;
List<Appointment>? _appointments;
// final List<String> _nameCollection = <String>[];
// final List<String> _userImages = <String>[];
// DateTime? _startDate;
// DateTime? _endDate;
// bool _isRangeSelection = false;
@override
void initState() {
super.initState();
_sessionCalController = CalendarController();
_comCalController = CalendarController();
_appointments = <Appointment>[
Appointment(
startTime: DateTime(2024, 6, 26, 9, 0),
endTime: DateTime(2024, 6, 26, 10, 30),
subject: 'Development Meeting',
color: const Color(0XFFFC571D)),
Appointment(
startTime: DateTime(2024, 6, 26, 18, 0),
endTime: DateTime(2024, 6, 26, 18, 30),
subject: 'GeneralMeeting',
color: const Color(0xFF8B1FA9)),
Appointment(
startTime: DateTime(2024, 6, 28, 9, 0),
endTime: DateTime(2024, 6, 28, 10, 30),
subject: 'Lunch',
),
Appointment(
startTime: DateTime(2024, 6, 25, 10, 0),
endTime: DateTime(2024, 6, 25, 10, 30),
subject: 'Meeting',
),
Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(const Duration(hours: 3)),
subject: 'Match day',
),
Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(const Duration(hours: 3)),
subject: 'Muharram/Ashura',
),
];
}
DateTime selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
// key: _scaffoldKey1,
backgroundColor: const Color(0xFF222935),
extendBody: true,
appBar: AppBar(
scrolledUnderElevation: 0.0,
backgroundColor: const Color(0xff222935),
elevation: 0,
automaticallyImplyLeading: false,
title: text20700white("Sessions"),
actions: [
InkWell(
onTap: () {
Get.toNamed(RouteName.addEvent);
},
child: Container(
height: 35.h,
width: 35.w,
decoration: const BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0x40000000),
offset: Offset(0, 6),
blurRadius: 8,
spreadRadius: 0,
),
],
),
child: const Icon(Icons.add, color: Colors.white, weight: 2),
),
),
sizedBoxWidth(14.w),
InkWell(
onTap: () {
Get.toNamed(RouteName.setavailabillity);
},
child: Image.asset(
'assets/images/png/calender.png',
height: 22.h,
width: 22.w,
),
),
sizedBoxWidth(14.w),
InkWell(
onTap: () {
Get.toNamed(RouteName.managememberscal);
},
child: Image.asset(
'assets/images/png/Frame 9.png',
height: 25.h,
width: 25.w,
),
),
sizedBoxWidth(16.w),
],
),
body: Stack(children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill)),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(children: [
Expanded(
child: DefaultTabController(
length: 2,
// initialIndex: selectedIndex.value,
child: Column(
children: [
const CommonTabBar(tabs: [
Tab(
text: 'My sessions',
),
Tab(
text: 'Community session',
),
]),
Expanded(
child: TabBarView(
children: [
mySessionsTab(),
comSessionTab(),
],
),
),
sizedBoxHeight(90.h),
],
),
),
),
]))
]),
bottomNavigationBar: bottomnavigationbar(mainController),
);
}
Widget mySessionsTab() {
return SingleChildScrollView(
child: Column(
children: [
sizedBoxHeight(20.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: commonGlassUI(
width: double.infinity,
height: 136.h,
borderRadius: BorderRadius.circular(10.r) ,
borderwidth: 1,
customWidget: Row(
children: [
Padding(
padding: EdgeInsets.only(left: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 171.w,
child: text14w400_FCFCFC(
"Are you looking for resources ? We might have a solution"),
),
sizedBoxHeight(12.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.resourcepool);
},
child: text16w700_FCFCFCline("View resources"))
],
),
),
const Spacer(),
Image.asset("assets/images/png/Rectangle 45.png")
],
),
),
),
sizedBoxHeight(25.h),
Stack(children: [
commonGlassUI(
width: double.infinity,
height: 500.h,
borderRadius: BorderRadius.circular(1),
// borderw: 0,
customWidget: SfCalendar(
view: CalendarView.month,
appointmentTextStyle: const TextStyle(color: Colors.white),
headerStyle: const CalendarHeaderStyle(
textStyle: TextStyle(
color: Color(0xFFD90B2E),
)),
// blackoutDatesTextStyle: TextStyle(color: Colors.white),
weekNumberStyle: const WeekNumberStyle(
textStyle: TextStyle(color: Colors.white)),
viewHeaderStyle: const ViewHeaderStyle(
// backgroundColor: Colors.amber,
dateTextStyle: TextStyle(color: Colors.white),
dayTextStyle: TextStyle(
color: Color(0xFFD90B2E),
),
),
// blackoutDatesTextStyle: TextStyle(color: Colors.white),
// selectionDecoration: BoxDecoration(color: Colors.amber),
backgroundColor: Colors.transparent,
// firstDayOfWeek: 3,
cellBorderColor: Colors.white,
todayHighlightColor: const Color(0xFFD90B2E),
todayTextStyle: const TextStyle(color: Colors.white),
controller: _sessionCalController,
showNavigationArrow: true,
allowViewNavigation: true,
allowDragAndDrop: true,
showDatePickerButton: true,
monthViewSettings: const MonthViewSettings(
navigationDirection: MonthNavigationDirection.horizontal,
),
allowedViews: const [
CalendarView.month,
// CalendarView.day,
CalendarView.schedule,
],
viewNavigationMode: ViewNavigationMode.snap,
showCurrentTimeIndicator: true,
dataSource: MeetingDataSource(_appointments!),
onTap: calendarTapped,
timeSlotViewSettings: TimeSlotViewSettings(
// minimumAppointmentDuration: Duration(hours: 5),
timeTextStyle: const TextStyle(
color: Colors.white,
),
timelineAppointmentHeight: 60.h,
// timeIntervalWidth: 100,
// timeIntervalHeight: 50,
timeIntervalWidth: 70,
),
monthCellBuilder: (context, details) {
return Container(
decoration: const BoxDecoration(
color: Colors.transparent,
),
child: Center(
child: Text(
details.date.day.toString(),
style: const TextStyle(
color: Colors.white), // Set text color to white
),
),
);
},
resourceViewSettings: const ResourceViewSettings(
displayNameTextStyle:
TextStyle(color: Colors.white, fontSize: 10),
showAvatar: true,
),
// scheduleViewSettings: ScheduleViewSettings(
// appointmentTextStyle: TextStyle(color: Colors.red)),
scheduleViewSettings: const ScheduleViewSettings(
placeholderTextStyle: TextStyle(color: Colors.white),
dayHeaderSettings: DayHeaderSettings(
dateTextStyle: TextStyle(color: Colors.white),
dayTextStyle: TextStyle(color: Colors.white),
)),
appointmentBuilder: (context, details) {
final Appointment appointment = details.appointments.first;
return Container(
decoration: BoxDecoration(
color: details.appointments.first.color ?? Colors.blue,
borderRadius: BorderRadius.circular(4),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
appointment.subject,
style: TextStyle(
color: Colors.white, fontSize: 8.sp),
),
],
),
),
);
}),
),
Positioned(
top: 6.h,
left: 100.w,
child: InkWell(
onTap: () {
Get.toNamed(RouteName.availability);
},
child: Container(
height: 25.h,
decoration: BoxDecoration(
border: Border.all(
color: const Color(0xFFD90B2E),
),
borderRadius: BorderRadius.circular(15.r)),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 10.w,
),
child:
Center(child: text10400white("view availability")),
),
)
// Image.asset(
// "assets/images/png/calender.png",
// color: Colors.blue,
// height: 18.h,
// width: 18.w,
// ),
))
]),
// commonGlassContainer(
// width: double.infinity,
// height: 314.h,
// borderradius: 1,
// customWidget: CalendarDatePicker2(
// config: CalendarDatePicker2Config(
// calendarType: CalendarDatePicker2Type.range,
// weekdayLabels: [
// 'Sun',
// 'Mon',
// 'Tue',
// 'Wed',
// 'Thu',
// 'Fri',
// 'Sat'
// ],
// selectedYearTextStyle: TextStyle(color: Colors.white),
// yearTextStyle: TextStyle(color: Colors.white),
// selectedDayHighlightColor: Color(0xFFD90B2E),
// controlsTextStyle: TextStyle(color: Colors.white),
// dayTextStyle: TextStyle(color: Colors.white),
// monthTextStyle: TextStyle(color: Colors.white),
// weekdayLabelTextStyle: TextStyle(color: Colors.white),
// nextMonthIcon: Icon(
// Icons.arrow_forward_ios,
// color: Colors.white,
// ),
// lastMonthIcon: Icon(
// Icons.arrow_back_ios_new,
// color: Colors.white,
// ),
// ),
// value: [selectedDate],
// ),
// border: 0.9),
sizedBoxHeight(25.h),
// Column(
// children: List.generate(3, (index) {
// return sessionCard(
// imagePath: sessionData[index]["imagePath"],
// names: sessionData[index]["names"],
// title: sessionData[index]["title"]);
// }),
// )
],
),
);
}
Widget sessionCard({
required String title,
required String imagePath,
required String names,
}) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text18w700_FCFCFC(title),
sizedBoxHeight(25.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.eventDetails);
},
child: commonGlassUI(
width: double.infinity,
height: 300.h,
borderRadius: BorderRadius.circular( 10.r),
borderwidth: 1.w,
customWidget: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 151.h,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10.r),
topLeft: Radius.circular(10.r))),
child: Image.asset(
imagePath,
fit: BoxFit.cover,
)),
sizedBoxHeight(20.h),
Row(
children: [
sizedBoxWidth(16.w),
Image.asset(
"assets/images/png/calender.png",
color: Colors.white.withOpacity(0.8),
height: 12.h,
width: 12.w,
),
sizedBoxWidth(8.w),
text10w400_FCFCFC_blur("29th april 2024"),
sizedBoxWidth(10.w),
Container(
height: 15,
width: 1,
color: Colors.white.withOpacity(0.8),
),
sizedBoxWidth(10.w),
Image.asset(
"assets/images/png/clock.png",
color: Colors.white.withOpacity(0.8),
height: 12.h,
width: 12.w,
),
sizedBoxWidth(8.w),
text10w400_FCFCFC_blur("3:00 pm"),
sizedBoxWidth(10.w),
Container(
height: 15,
width: 1,
color: Colors.white.withOpacity(0.8),
),
sizedBoxWidth(10.w),
Image.asset(
"assets/images/png/Black.png",
color: Colors.white.withOpacity(0.8),
height: 12.h,
width: 12.w,
),
sizedBoxWidth(8.w),
text10w400_FCFCFC_blur("Iron titans fitness crew"),
],
),
sizedBoxHeight(15.h),
Padding(
padding: EdgeInsets.only(left: 16.w),
child: text18w700_FCFCFC(names),
),
sizedBoxHeight(15.h),
Row(
children: [
sizedBoxWidth(16.w),
CircleAvatar(
radius: 12.r,
backgroundImage: const AssetImage(
"assets/images/png/Ellipse 52.png"),
),
sizedBoxWidth(8.w),
text14w400_FCFCFC("Ryan dorwat"),
],
)
]),
),
)
],
),
);
}
Widget comSessionTab() {
return SingleChildScrollView(
child: Column(
children: [
sizedBoxHeight(25.h),
Stack(children: [
commonGlassUI(
width: double.infinity,
height: 530.h,
borderRadius: BorderRadius.circular(1),
// border: 0,
customWidget: SfCalendar(
view: CalendarView.month,
appointmentTextStyle: const TextStyle(color: Colors.white),
headerStyle: const CalendarHeaderStyle(
textStyle: TextStyle(
color: Color(0xFFD90B2E),
)),
// blackoutDatesTextStyle: TextStyle(color: Colors.white),
weekNumberStyle: const WeekNumberStyle(
textStyle: TextStyle(color: Colors.white)),
viewHeaderStyle: const ViewHeaderStyle(
// backgroundColor: Colors.amber,
dateTextStyle: TextStyle(color: Colors.white),
dayTextStyle: TextStyle(
color: Color(0xFFD90B2E),
),
),
// blackoutDatesTextStyle: TextStyle(color: Colors.white),
// selectionDecoration: BoxDecoration(color: Colors.amber),
backgroundColor: Colors.transparent,
// firstDayOfWeek: 3,
cellBorderColor: Colors.white,
todayHighlightColor: const Color(0xFFD90B2E),
todayTextStyle: const TextStyle(color: Colors.white),
controller: _comCalController,
showNavigationArrow: true,
allowViewNavigation: true,
allowDragAndDrop: true,
showDatePickerButton: true,
monthViewSettings: const MonthViewSettings(
navigationDirection: MonthNavigationDirection.horizontal,
),
allowedViews: const [
CalendarView.month,
// CalendarView.day,
CalendarView.schedule,
],
viewNavigationMode: ViewNavigationMode.snap,
showCurrentTimeIndicator: true,
dataSource: MeetingDataSource(_appointments!),
onTap: calendarTapped,
timeSlotViewSettings: TimeSlotViewSettings(
// minimumAppointmentDuration: Duration(hours: 5),
timeTextStyle: const TextStyle(
color: Colors.white,
),
timelineAppointmentHeight: 60.h,
// timeIntervalWidth: 100,
// timeIntervalHeight: 50,
timeIntervalWidth: 70,
),
monthCellBuilder: (context, details) {
return Container(
decoration: const BoxDecoration(
color: Colors.transparent,
),
child: Center(
child: Text(
details.date.day.toString(),
style: const TextStyle(
color: Colors.white), // Set text color to white
),
),
);
},
resourceViewSettings: const ResourceViewSettings(
displayNameTextStyle:
TextStyle(color: Colors.white, fontSize: 10),
showAvatar: true,
),
appointmentBuilder: (context, details) {
final Appointment appointment = details.appointments.first;
return Container(
decoration: BoxDecoration(
color: details.appointments.first.color ?? Colors.blue,
borderRadius: BorderRadius.circular(4),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
appointment.subject,
style: TextStyle(
color: Colors.white, fontSize: 8.sp),
),
],
),
),
);
}),
),
]),
// SfCalendar(
// view: CalendarView.month,
// controller: _calendarController,
// onSelectionChanged: (CalendarSelectionDetails details) {
// setState(() {
// _startDate = details.date!;
// _endDate = details.date!
// .add(Duration(days: 6)); // assuming a week range
// });
// },
// monthViewSettings: MonthViewSettings(
// showAgenda: true,
// ),
// ),
// commonGlassContainer(
// width: double.infinity,
// height: 314.h,
// borderradius: 1,
// customWidget: CalendarDatePicker2(
// config: CalendarDatePicker2Config(
// calendarType: CalendarDatePicker2Type.range,
// weekdayLabels: [
// 'Sun',
// 'Mon',
// 'Tue',
// 'Wed',
// 'Thu',
// 'Fri',
// 'Sat'
// ],
// selectedYearTextStyle: TextStyle(color: Colors.white),
// yearTextStyle: TextStyle(color: Colors.white),
// selectedDayHighlightColor: Color(0xFFD90B2E),
// controlsTextStyle: TextStyle(color: Colors.white),
// dayTextStyle: TextStyle(color: Colors.white),
// monthTextStyle: TextStyle(color: Colors.white),
// weekdayLabelTextStyle: TextStyle(color: Colors.white),
// nextMonthIcon: Icon(
// Icons.arrow_forward_ios,
// color: Colors.white,
// ),
// lastMonthIcon: Icon(
// Icons.arrow_back_ios_new,
// color: Colors.white,
// ),
// ),
// value: [selectedDate],
// ),
// border: 0.9),
sizedBoxHeight(25.h),
// Column(
// children: List.generate(communityData.length, (index) {
// return communitysessionCard(
// imagePath: communityData[index]["imagePath"],
// names: communityData[index]["names"],
// title: communityData[index]["title"]);
// }),
// )
],
),
);
}
Widget communitysessionCard({
required String title,
required String imagePath,
required String names,
}) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text18w700_FCFCFC(title),
sizedBoxHeight(25.h),
commonGlassUI(
width: double.infinity,
height: 290.h,
borderRadius: BorderRadius.circular( 10.r),
borderwidth: 1,
customWidget: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 151.h,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10.r),
topLeft: Radius.circular(10.r))),
child: Image.asset(
imagePath,
fit: BoxFit.cover,
)),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(16.h),
Row(
children: [
sizedBoxWidth(16.w),
Image.asset(
"assets/images/png/calender.png",
color: Colors.white.withOpacity(0.8),
height: 12.h,
width: 12.w,
),
sizedBoxWidth(8.w),
text10w400_FCFCFC_blur("29th april 2024"),
],
),
sizedBoxHeight(15.h),
Padding(
padding: EdgeInsets.only(left: 16.w),
child: text18w700_FCFCFC(names),
),
sizedBoxHeight(15.h),
Row(
children: [
sizedBoxWidth(16.w),
CircleAvatar(
radius: 12.r,
backgroundImage: const AssetImage(
"assets/images/png/Ellipse 52.png"),
),
sizedBoxWidth(8.w),
text14w400_FCFCFC("Ryan dorwat"),
],
),
]),
const Spacer(),
Container(
height: 138.h,
width: 143.w,
decoration: BoxDecoration(
color: const Color(0xFFD90B2E),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(10.r),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
text25700FCFCFC("14"),
text16w700_FCFCFCblur("April 2024"),
sizedBoxHeight(12.h),
text16w700_FCFCFC("3:00 pm")
],
),
)
],
),
],
),
)
],
),
);
}
void calendarTapped(CalendarTapDetails details) {
if (details.targetElement == CalendarElement.appointment) {
Appointment appointment = details.appointments![0];
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Event Details'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text('Event: ${appointment.subject}'),
Text('From: ${appointment.startTime}'),
Text('To: ${appointment.endTime}'),
],
),
actions: <Widget>[
ElevatedButton(
child: const Text('Close'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
}
class MeetingDataSource extends CalendarDataSource {
MeetingDataSource(
List<Appointment> source,
) {
appointments = source;
}
}