// import 'package:flutter/material.dart';
// import 'package:intl/intl.dart';
// import 'package:provider/provider.dart';
// import 'package:table_calendar/table_calendar.dart';
// import 'package:test_sa/extensions/context_extension.dart';
// import 'package:test_sa/extensions/int_extensions.dart';
// import 'package:test_sa/extensions/text_extensions.dart';
// import 'package:test_sa/extensions/widget_extensions.dart';
// import 'package:test_sa/new_views/app_style/app_color.dart';
// todo delete
// import '../../../../controllers/providers/api/all_requests_provider.dart';
// import '../requests/asset_item_view.dart';
// import '../requests/gas_refill_item_view.dart';
// import '../requests/ppm_item_view.dart';
// import '../requests/service_request_item_view.dart';
// import 'calender_days_card.dart';
//
// class WeeklyFragment extends StatefulWidget {
//   const WeeklyFragment({Key? key}) : super(key: key);
//
//   @override
//   _WeeklyFragmentState createState() {
//     return _WeeklyFragmentState();
//   }
// }
//
// class _WeeklyFragmentState extends State<WeeklyFragment> {
//   late DateTime _initialDate, _firstDate, _lastDate;
//
//   @override
//   void initState() {
//     super.initState();
//     _initialDate = DateTime.now();
//     _firstDate = DateTime.utc(2010, 10, 16);
//     _lastDate = DateTime.utc(2030, 3, 14);
//     Provider.of<AllRequestsProvider>(context, listen: false)
//         .getCalendarRequests(from: DateTime.now().subtract(Duration(days: DateTime.now().weekday)), to: DateTime.now().add(Duration(days: DateTime.daysPerWeek - DateTime.now().weekday - 1)));
//   }
//
//   @override
//   Widget build(BuildContext context) {
//     return SingleChildScrollView(
//       padding: const EdgeInsets.only(left: 16, right: 16),
//       child: Consumer<AllRequestsProvider>(builder: (context, snapshot, _) {
//         return Column(
//           mainAxisSize: MainAxisSize.min,
//           children: [
//             TableCalendar(
//               firstDay: _firstDate,
//               lastDay: _lastDate,
//               focusedDay: _initialDate,
//               calendarFormat: CalendarFormat.week,
//               weekendDays: const [],
//               onCalendarCreated: (controller) {},
//               onPageChanged: (date) {
//                 if (!snapshot.isCalendarLoading) {
//                   _initialDate = date;
//
//                   Provider.of<AllRequestsProvider>(context, listen: false)
//                       .getCalendarRequests(from: date.subtract(Duration(days: date.weekday)), to: date.add(Duration(days: DateTime.daysPerWeek - date.weekday - 1)));
//                 }
//               },
//               calendarBuilders: CalendarBuilders(
//                 headerTitleBuilder: (context, dateTime) => Column(
//                   crossAxisAlignment: CrossAxisAlignment.stretch,
//                   children: [
//                     DateFormat("EEEE, d MMMM, yyyy", context.isAr ? "ar" : "en").format(dateTime).heading5(context),
//                     8.height,
//                     const Divider().defaultStyle(context),
//                   ],
//                 ),
//                 dowBuilder: (context, dateTime) {
//                   final day = DateFormat("EE", context.isAr ? "ar" : "en").format(dateTime).toUpperCase();
//                   return Align(alignment: Alignment.center, child: day.bodyText(context).custom(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50));
//                 },
//                 defaultBuilder: (context, dateTime, _) {
//                   final day = DateFormat("d").format(dateTime);
//                   return CalendarDaysCard(
//                     day: day,
//                     fill: snapshot.calendarRequests!.requestsDetails?.firstWhere(
//                           (element) => (element.date != null) && (DateTime.tryParse(element.date!)?.day == (dateTime).day),
//                           orElse: null,
//                         ) !=
//                         null,
//                   ).toShimmer(isShow: snapshot.isCalendarLoading);
//                 },
//                 outsideBuilder: (context, dateTime, _) {
//                   final day = DateFormat("d").format(dateTime);
//                   return CalendarDaysCard(
//                     day: day,
//                     fill: snapshot.calendarRequests!.requestsDetails?.firstWhere(
//                           (element) => (element.date != null) && (DateTime.tryParse(element.date!)?.day == (dateTime).day),
//                       orElse:  null,
//                         ) !=
//                         null,
//                   ).toShimmer(isShow: snapshot.isCalendarLoading);
//                 },
//               ),
//               daysOfWeekHeight: 35.toScreenHeight,
//               headerStyle: const HeaderStyle(leftChevronVisible: false, rightChevronVisible: false, formatButtonVisible: false),
//               calendarStyle: CalendarStyle(
//                 isTodayHighlighted: false,
//                 defaultTextStyle: AppTextStyles.bodyText,
//                 defaultDecoration: const BoxDecoration(shape: BoxShape.circle, color: AppColor.neutral30),
//               ),
//             ),
//             if (snapshot.calendarRequests?.requestsDetails?.isNotEmpty ?? false) const Divider().defaultStyle(context),
//             ListView.separated(
//               shrinkWrap: true,
//               physics: const NeverScrollableScrollPhysics(),
//               itemBuilder: (cxt, index) {
//                 final list = snapshot.calendarRequests!.requestsDetails!;
//                 if (snapshot.isCalendarLoading) return const SizedBox().toRequestShimmer(cxt, snapshot.isCalendarLoading);
//                 bool isServiceRequest = list[index].nameOfType == "ServiceRequest";
//                 bool isGasRefill = list[index].nameOfType == "GasRefill";
//                 bool isAssetTransfer = list[index].nameOfType == "AssetTransfer";
//                 bool isPPMs = list[index].nameOfType == "PPMs";
//
//                 return isServiceRequest
//                     ? ServiceRequestItemView(list[index], showShadow: false)
//                     : isGasRefill
//                         ? GasRefillItemView(list[index], showShadow: false)
//                         : isPPMs
//                             ? PpmItemView(list[index], showShadow: false)
//                             : isAssetTransfer
//                                 ? AssetItemView(list[index], showShadow: false)
//                                 : Container(
//                                     height: 100,
//                                     width: double.infinity,
//                                     color: Colors.grey,
//                                   );
//               },
//               separatorBuilder: (cxt, index) => const Divider().defaultStyle(context),
//               itemCount: snapshot.isCalendarLoading ? 6 : snapshot.calendarRequests!.requestsDetails!.length,
//             ),
//           ],
//         ).toShadowContainer(context);
//       }),
//     );
//   }
//
//   BoxDecoration cellDecoration({Color? color}) => BoxDecoration(color: color ?? Colors.transparent, shape: BoxShape.circle);
// }
