From b51555c2f48978bc087b120ce7476acd06eee2db Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Sun, 12 Nov 2023 15:14:20 +0300 Subject: [PATCH] improvements. --- .../calender_fragments/daily_fragment.dart | 2 +- .../calender_fragments/monthly_fragment.dart | 106 +++++++++--------- .../calender_fragments/weekly_fragment.dart | 82 +++++++------- .../notifications/notifications_list.dart | 48 +++----- 4 files changed, 109 insertions(+), 129 deletions(-) diff --git a/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart index a2acd887..35166848 100644 --- a/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/daily_fragment.dart @@ -41,7 +41,7 @@ class _DailyFragmentState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - snapshot.isCalendarLoading ? const Center(child: CircularProgressIndicator()) : DateFormat("EEEE, d MMMM, yyyy", context.isAr? "ar" : "en").format(DateTime.now()).heading5(context), + DateFormat("EEEE, d MMMM, yyyy", context.isAr ? "ar" : "en").format(DateTime.now()).heading5(context), if (snapshot.calendarRequests?.requestsDetails?.isNotEmpty ?? false) const Divider().defaultStyle(context), ListView.separated( shrinkWrap: true, diff --git a/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart index ace1b1a2..c06e504c 100644 --- a/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/monthly_fragment.dart @@ -41,60 +41,58 @@ class _MonthlyFragmentState extends State { child: Column( children: [ Consumer( - builder: (context, snapshot, _) => snapshot.isCalendarLoading - ? const Center(child: CircularProgressIndicator()) - : TableCalendar( - firstDay: _firstDate, - lastDay: _lastDate, - focusedDay: _initialDate, - calendarFormat: CalendarFormat.month, - weekendDays: const [], - rowHeight: 45, - availableGestures: AvailableGestures.none, - calendarBuilders: CalendarBuilders( - headerTitleBuilder: (context, dateTime) => CalendarHeader(dateFormat: DateFormat("MMMM, yyyy", context.isAr? "ar" : "en"), dateTime: dateTime).onPress(() async { - final result = await showDatePicker( - context: context, - initialDate: _initialDate, - firstDate: _firstDate, - lastDate: _lastDate, - initialDatePickerMode: DatePickerMode.year, - ); - await snapshot.getCalenderRequests(from: DateTime(result.year, result.month), to: DateTime.now()); - if (result != null) { - _initialDate = result; - setState(() {}); - } - }), - 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: 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)?.difference(dateTime)?.inDays == 0), - orElse: () => null, - ) != - null, - ); - }, - ), - daysOfWeekHeight: 35.toScreenHeight, - headerStyle: const HeaderStyle( - leftChevronVisible: false, - rightChevronVisible: false, - formatButtonVisible: false, - headerPadding: EdgeInsets.all(0), - ), - calendarStyle: CalendarStyle( - isTodayHighlighted: false, - defaultTextStyle: AppTextStyles.bodyText, - defaultDecoration: const BoxDecoration(shape: BoxShape.circle, color: AppColor.neutral30), - ), - ), + builder: (context, snapshot, _) => TableCalendar( + firstDay: _firstDate, + lastDay: _lastDate, + focusedDay: _initialDate, + calendarFormat: CalendarFormat.month, + weekendDays: const [], + rowHeight: 45, + availableGestures: AvailableGestures.none, + calendarBuilders: CalendarBuilders( + headerTitleBuilder: (context, dateTime) => CalendarHeader(dateFormat: DateFormat("MMMM, yyyy", context.isAr ? "ar" : "en"), dateTime: dateTime).onPress(() async { + final result = await showDatePicker( + context: context, + initialDate: _initialDate, + firstDate: _firstDate, + lastDate: _lastDate, + initialDatePickerMode: DatePickerMode.year, + ); + await snapshot.getCalenderRequests(from: DateTime(result.year, result.month), to: DateTime.now()); + if (result != null) { + _initialDate = result; + setState(() {}); + } + }), + 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: 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)?.difference(dateTime)?.inDays == 0), + orElse: () => null, + ) != + null, + ).toShimmer(isShow: snapshot.isCalendarLoading); + }, + ), + daysOfWeekHeight: 35.toScreenHeight, + headerStyle: const HeaderStyle( + leftChevronVisible: false, + rightChevronVisible: false, + formatButtonVisible: false, + headerPadding: EdgeInsets.all(0), + ), + calendarStyle: CalendarStyle( + isTodayHighlighted: false, + defaultTextStyle: AppTextStyles.bodyText, + defaultDecoration: const BoxDecoration(shape: BoxShape.circle, color: AppColor.neutral30), + ), + ), ), Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart b/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart index 62dde8b7..f98a9f39 100644 --- a/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart +++ b/lib/new_views/pages/land_page/calender_fragments/weekly_fragment.dart @@ -48,48 +48,46 @@ class _WeeklyFragmentState extends State { return Column( mainAxisSize: MainAxisSize.min, children: [ - snapshot.isCalendarLoading - ? const Center(child: CircularProgressIndicator()) - : TableCalendar( - firstDay: _firstDate, - lastDay: _lastDate, - focusedDay: _initialDate, - calendarFormat: CalendarFormat.week, - weekendDays: const [], - onCalendarCreated: (controller) {}, - 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: 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)?.difference(dateTime)?.inDays == 0), - orElse: () => null, - ) != - null, - ); - }, - ), - 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), - ), - ), + TableCalendar( + firstDay: _firstDate, + lastDay: _lastDate, + focusedDay: _initialDate, + calendarFormat: CalendarFormat.week, + weekendDays: const [], + onCalendarCreated: (controller) {}, + 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: 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)?.difference(dateTime)?.inDays == 0), + 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, diff --git a/lib/views/pages/user/notifications/notifications_list.dart b/lib/views/pages/user/notifications/notifications_list.dart index 95e12f6e..41824107 100644 --- a/lib/views/pages/user/notifications/notifications_list.dart +++ b/lib/views/pages/user/notifications/notifications_list.dart @@ -24,38 +24,22 @@ class NotificationsList extends StatelessWidget { onLazyLoad: onLazyLoad, child: SingleChildScrollView( padding: const EdgeInsets.all(16), - child: Container( - decoration: ShapeDecoration( - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - shadows: const [ - BoxShadow( - color: Color(0x07000000), - blurRadius: 14, - offset: Offset(0, 0), - spreadRadius: 0, - ) - ], - ), - child: ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - padding: const EdgeInsets.all(16), - itemCount: notifications.length, - separatorBuilder: (context, itemIndex) => 1.divider.paddingOnly(top: 16, bottom: 16), - itemBuilder: (context, itemIndex) { - return NotificationItem( - notification: notifications[itemIndex], - onPressed: (notification) { - // todo @sikander, check notifications payload, because notification model is different to need to check from backend - //Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId); - }, - ); - }, - ).toShadowContainer(context), - ), + child: ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.all(0), + itemCount: notifications.length, + separatorBuilder: (context, itemIndex) => 1.divider.paddingOnly(top: 16, bottom: 16), + itemBuilder: (context, itemIndex) { + return NotificationItem( + notification: notifications[itemIndex], + onPressed: (notification) { + // todo @sikander, check notifications payload, because notification model is different to need to check from backend + //Navigator.of(context).pushNamed(FutureRequestServiceDetails.id, arguments: notification.requestId); + }, + ); + }, + ).toShadowContainer(context), ), ); }