Files
Regroup/lib/Feed Module/Main_Screens/CalenderTab/CalenderTab.dart
2024-06-28 19:11:00 +05:30

839 lines
30 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/CustomTextformfield.dart';
import 'package:regroup/Utils/Common/blureffect.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? _calendarController;
List<Appointment>? _appointments;
List<CalendarResource> _employeeCollection = <CalendarResource>[];
// final List<String> _nameCollection = <String>[];
// final List<String> _userImages = <String>[];
@override
void initState() {
super.initState();
_calendarController = CalendarController();
_appointments = <Appointment>[
Appointment(
startTime: DateTime(2024, 6, 26, 9, 0),
endTime: DateTime(2024, 6, 26, 10, 30),
subject: 'Development Meeting',
resourceIds: [4],
color: Color(0XFFFC571D)),
Appointment(
startTime: DateTime(2024, 6, 26, 18, 0),
endTime: DateTime(2024, 6, 26, 18, 30),
subject: 'GeneralMeeting',
resourceIds: [2],
color: Color(0xFF8B1FA9)),
Appointment(
startTime: DateTime(2024, 6, 28, 9, 0),
endTime: DateTime(2024, 6, 28, 10, 30),
subject: 'Lunch',
resourceIds: [1],
),
Appointment(
startTime: DateTime(2024, 6, 25, 10, 0),
endTime: DateTime(2024, 6, 25, 10, 30),
subject: 'Meeting',
resourceIds: [2],
),
Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 3)),
subject: 'Match day',
resourceIds: [3],
),
Appointment(
startTime: DateTime.now(),
endTime: DateTime.now().add(Duration(hours: 3)),
subject: 'Muharram/Ashura',
resourceIds: [3],
),
];
_employeeCollection = <CalendarResource>[
CalendarResource(
id: 1,
image: AssetImage("assets/images/png/cimg1.png"),
displayName: 'Kaylly Vaccaro',
color: Colors.transparent,
),
CalendarResource(
id: 2,
image: AssetImage("assets/images/png/cimg2.png"),
displayName: 'Ryan Dorwart',
color: Colors.transparent,
),
CalendarResource(
id: 3,
image: AssetImage("assets/images/png/cimg3.png"),
displayName: 'Ahmad Rhiel',
color: Colors.transparent,
),
CalendarResource(
id: 4,
image: AssetImage("assets/images/png/cimg3.png"),
displayName: 'Ahmad Rhiel',
color: Colors.transparent,
),
];
}
DateTime selectedDate = DateTime.now();
@override
Widget build(BuildContext context) {
return Scaffold(
// key: _scaffoldKey1,
backgroundColor: Color(0xFF222935),
extendBody: true,
appBar: AppBar(
scrolledUnderElevation: 0.0,
backgroundColor: 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: BoxDecoration(
color: Color(0xFFD90B2E),
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0x40000000),
offset: Offset(0, 6),
blurRadius: 8,
spreadRadius: 0,
),
],
),
child: 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: [
const CommonBlurLeftRed(),
const CommonBlurRightRed(),
const CommonBlurLeft(),
const CommonBlurRight(),
Stack(children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(children: [
Expanded(
child: DefaultTabController(
length: 2,
// initialIndex: selectedIndex.value,
child: Column(
children: [
CommonTabBar(tabs: const [
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: commonGlassContainer(
width: double.infinity,
height: 136.h,
borderradius: 10.r,
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"))
],
),
),
Spacer(),
Image.asset("assets/images/png/Rectangle 45.png")
],
),
border: 1),
),
sizedBoxHeight(25.h),
commonGlassContainer(
width: double.infinity,
height: 350.h,
borderradius: 1,
border: 0,
customWidget: SfCalendar(
view: CalendarView.month,
appointmentTextStyle: TextStyle(color: Colors.white),
headerStyle: CalendarHeaderStyle(
textStyle: TextStyle(
color: Colors.blue,
)),
// blackoutDatesTextStyle: TextStyle(color: Colors.white),
weekNumberStyle:
WeekNumberStyle(textStyle: TextStyle(color: Colors.white)),
viewHeaderStyle: 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: Color(0xFFD90B2E),
todayTextStyle: const TextStyle(color: Colors.white),
controller: _calendarController,
showNavigationArrow: true,
allowViewNavigation: true,
showDatePickerButton: true,
monthViewSettings: MonthViewSettings(
navigationDirection: MonthNavigationDirection.horizontal,
),
allowedViews: [
CalendarView.month,
CalendarView.day,
CalendarView.schedule,
CalendarView.timelineMonth,
CalendarView.timelineDay
],
viewNavigationMode: ViewNavigationMode.snap,
showCurrentTimeIndicator: true,
dataSource:
MeetingDataSource(_appointments!, _employeeCollection),
onTap: calendarTapped,
timeSlotViewSettings: TimeSlotViewSettings(
// minimumAppointmentDuration: Duration(hours: 5),
timeTextStyle: TextStyle(
color: Colors.white,
),
timelineAppointmentHeight: 60.h,
// timeIntervalWidth: 100,
// timeIntervalHeight: 50,
timeIntervalWidth: 70,
),
monthCellBuilder: (context, details) {
return Container(
decoration: BoxDecoration(
color: Colors.transparent,
),
child: Center(
child: Text(
details.date.day.toString(),
style: TextStyle(
color: Colors.white), // Set text color to white
),
),
);
},
resourceViewSettings: 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),
),
],
),
),
);
}),
),
// 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: commonGlassContainer(
width: double.infinity,
height: 300.h,
borderradius: 10.r,
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:
AssetImage("assets/images/png/Ellipse 52.png"),
),
sizedBoxWidth(8.w),
text14w400_FCFCFC("Ryan dorwat"),
],
)
]),
border: 1),
)
],
),
);
}
Widget ComSessionTab() {
return SingleChildScrollView(
child: Column(
children: [
sizedBoxHeight(20.h),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: CustomTextFormField(
leadingIcon: SizedBox(
height: 23,
width: 23,
child: Center(
child: Image.asset(
"assets/images/png/ion_search-outline.png",
height: 23,
width: 23,
),
),
),
hintText: "Search community sessions",
),
),
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: commonGlassContainer(
width: double.infinity,
height: 136.h,
borderradius: 10.r,
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"))
],
),
),
Spacer(),
Image.asset("assets/images/png/Rectangle 45.png")
],
),
border: 1),
),
sizedBoxHeight(25.h),
// 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),
commonGlassContainer(
width: double.infinity,
height: 290.h,
borderradius: 10.r,
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: AssetImage(
"assets/images/png/Ellipse 52.png"),
),
sizedBoxWidth(8.w),
text14w400_FCFCFC("Ryan dorwat"),
],
),
]),
Spacer(),
Container(
height: 138.h,
width: 143.w,
decoration: BoxDecoration(
color: 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")
],
),
)
],
),
],
),
border: 1)
],
),
);
}
void calendarTapped(CalendarTapDetails details) {
if (details.targetElement == CalendarElement.appointment) {
Appointment appointment = details.appointments![0];
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: 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: Text('Close'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}
// void _addResources() {
// final Random random = Random();
// for (int i = 0; i < _nameCollection.length; i++) {
// _employeeCollection.add(CalendarResource(
// displayName: _nameCollection[i],
// id: '000' + i.toString(),
// color: Color.fromRGBO(
// random.nextInt(255), random.nextInt(255), random.nextInt(255), 1),
// image:
// i < _userImages.length ? ExactAssetImage(_userImages[i]) : null));
// }
// }
}
// void _addResourceDetails() {
// _nameCollection.add('John');
// _nameCollection.add('Bryan');
// _nameCollection.add('Robert');
// _nameCollection.add('Kenny');
// _nameCollection.add('Tia');
// _nameCollection.add('Theresa');
// _nameCollection.add('Edith');
// _nameCollection.add('Brooklyn');
// _nameCollection.add('James William');
// _nameCollection.add('Sophia');
// _nameCollection.add('Elena');
// _nameCollection.add('Stephen');
// _nameCollection.add('Zoey Addison');
// _nameCollection.add('Daniel');
// _nameCollection.add('Emilia');
// _nameCollection.add('Kinsley Elena');
// _nameCollection.add('Daniel');
// _nameCollection.add('William');
// _nameCollection.add('Addison');
// _nameCollection.add('Ruby');
// _userImages.add('images/People_Circle5.png');
// _userImages.add('images/People_Circle8.png');
// _userImages.add('images/People_Circle18.png');
// _userImages.add('images/People_Circle23.png');
// _userImages.add('images/People_Circle25.png');
// _userImages.add('images/People_Circle20.png');
// _userImages.add('images/People_Circle13.png');
// _userImages.add('images/People_Circle11.png');
// _userImages.add('images/People_Circle27.png');
// _userImages.add('images/People_Circle26.png');
// _userImages.add('images/People_Circle24.png');
// _userImages.add('images/People_Circle15.png');
// }
class MeetingDataSource extends CalendarDataSource {
MeetingDataSource(
List<Appointment> source, List<CalendarResource> resourceColl) {
appointments = source;
resources = resourceColl;
}
}