From 67a7fcfe54c569bfd92b013aec514110fe58ca47 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 8 Nov 2023 14:05:14 +0300 Subject: [PATCH 1/4] improvements. --- .../providers/api/all_requests_provider.dart | 47 ++++++++ lib/main.dart | 2 + .../pages/land_page/calendar_page.dart | 7 +- .../calender_fragments/monthly_fragment.dart | 113 ++++++++++-------- .../land_page/contact_us_bottom_sheet.dart | 80 +++++-------- 5 files changed, 143 insertions(+), 106 deletions(-) create mode 100644 lib/controllers/providers/api/all_requests_provider.dart diff --git a/lib/controllers/providers/api/all_requests_provider.dart b/lib/controllers/providers/api/all_requests_provider.dart new file mode 100644 index 00000000..20bf362e --- /dev/null +++ b/lib/controllers/providers/api/all_requests_provider.dart @@ -0,0 +1,47 @@ +import 'package:flutter/widgets.dart'; +import 'package:http/http.dart'; + +class AllRequestsProvider extends ChangeNotifier { + bool isLoading; + +// Future getAllRequests() async { +// if (isLoading == true) return -2; +// isLoading = true; +// if (serviceRequests?.isEmpty ?? false) notifyListeners(); +// Response response; +// try { +// Map body = {}; +// body.addAll(search.toMap()); +// body["pageNumber"] = (serviceRequests?.length ?? 0) ~/ pageItemNumber + 1; +// body["pageSize"] = pageItemNumber; +// +// response = await ApiManager.instance.post( +// URLs.getServiceRequests, +// body: body, +// ); +// +// stateCode = response.statusCode; +// if (response.statusCode >= 200 && response.statusCode < 300) { +// // client's request was successfully received +// List requestsListJson = json.decode(response.body)["data"]; +// List serviceRequestsPage = requestsListJson.map((request) => ServiceRequest.fromJson(request)).toList(); +// serviceRequests ??= []; +// serviceRequests.addAll(serviceRequestsPage); +// notifyListeners(); +// if (serviceRequestsPage.length == pageItemNumber) { +// nextPage = true; +// } else { +// nextPage = false; +// } +// } +// isLoading = false; +// notifyListeners(); +// return response.statusCode; +// } catch (error) { +// isLoading = false; +// stateCode = -1; +// notifyListeners(); +// return -1; +// } +// } +} diff --git a/lib/main.dart b/lib/main.dart index 2eaafa3c..060cdb56 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,6 +6,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:localization/localization.dart'; import 'package:provider/provider.dart'; +import 'package:test_sa/controllers/providers/api/all_requests_provider.dart'; import 'package:test_sa/controllers/providers/api/asset_transfer_provider.dart'; import 'package:test_sa/controllers/providers/api/comments_provider.dart'; import 'package:test_sa/controllers/providers/api/departments_provider.dart'; @@ -139,6 +140,7 @@ class MyApp extends StatelessWidget { ChangeNotifierProvider(create: (_) => SiteProvider()), ChangeNotifierProvider(create: (_) => HospitalsProvider()), ChangeNotifierProvider(create: (_) => AssetProvider()), + ChangeNotifierProvider(create: (_) => AllRequestsProvider()), ChangeNotifierProvider(create: (_) => ServiceRequestsProvider()), ChangeNotifierProvider(create: (_) => DepartmentsProvider()), ChangeNotifierProvider(create: (_) => NotificationsProvider()), diff --git a/lib/new_views/pages/land_page/calendar_page.dart b/lib/new_views/pages/land_page/calendar_page.dart index 22fd80e9..677815b9 100644 --- a/lib/new_views/pages/land_page/calendar_page.dart +++ b/lib/new_views/pages/land_page/calendar_page.dart @@ -44,9 +44,10 @@ class _CalendarPageState extends State with SingleTickerProviderSt "09:00 to 18:00".bodyText(context).custom(color: AppColor.neutral50), ], ).toShadowContainer, - ), + ).paddingOnly(start: 16, end: 16), 16.height, Container( + margin: const EdgeInsets.only(left: 16, right: 16), decoration: BoxDecoration(color: AppColor.neutral30, borderRadius: BorderRadius.circular(16)), child: TabBar( controller: _tabController, @@ -67,7 +68,7 @@ class _CalendarPageState extends State with SingleTickerProviderSt ), 8.height, TabBarView( - physics: const NeverScrollableScrollPhysics(), + //physics: const NeverScrollableScrollPhysics(), controller: _tabController, children: const [ MonthlyFragment(), @@ -76,7 +77,7 @@ class _CalendarPageState extends State with SingleTickerProviderSt ], ).expanded, ], - ).paddingAll(16), + ), ), ); } 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 10152d24..3928e598 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 @@ -18,64 +18,71 @@ class MonthlyFragment extends StatefulWidget { class _MonthlyFragmentState extends State { PageController _controller; + @override Widget build(BuildContext context) { - return Card( - child: SingleChildScrollView( - child: Column( - children: [ - TableCalendar( - firstDay: DateTime.utc(2010, 10, 16), - lastDay: DateTime.utc(2030, 3, 14), - focusedDay: DateTime.now(), - calendarFormat: CalendarFormat.month, - weekendDays: const [], - onCalendarCreated: (controller) { - _controller = controller; + return SingleChildScrollView( + //physics: BouncingScrollPhysics(), + padding: const EdgeInsets.all(16), + child: Column( + children: [ + TableCalendar( + firstDay: DateTime.utc(2010, 10, 16), + lastDay: DateTime.utc(2030, 3, 14), + focusedDay: DateTime.now(), + calendarFormat: CalendarFormat.month, + weekendDays: const [], + availableGestures: AvailableGestures.none, + onCalendarCreated: (controller) { + _controller = controller; + }, + calendarBuilders: CalendarBuilders( + headerTitleBuilder: (context, dateTime) => CalendarHeader(dateFormat: DateFormat("MMMM, yyyy"), dateTime: dateTime), + dowBuilder: (context, dateTime) { + final day = DateFormat("EE").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); }, - calendarBuilders: CalendarBuilders( - headerTitleBuilder: (context, dateTime) => CalendarHeader(dateFormat: DateFormat("MMMM, yyyy"), dateTime: dateTime), - dowBuilder: (context, dateTime) { - final day = DateFormat("EE").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); - }, - ), - 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), - ), ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - 16.height, - Row( - children: [ - const CircleAvatar(backgroundColor: AppColor.primary40, radius: 8), - 8.width, - "My Requests".heading6(context), - ], - ), - 16.height, - Row( - children: [ - const CircleAvatar(backgroundColor: AppColor.green50, radius: 8), - 8.width, - "My Team Requests".heading6(context), - ], - ), - ], + daysOfWeekHeight: 35.toScreenHeight, + headerStyle: const HeaderStyle( + leftChevronVisible: false, + rightChevronVisible: false, + formatButtonVisible: false, + headerPadding: EdgeInsets.all(0), ), - ], - ).paddingOnly(start: 16, end: 16, top: 8, bottom: 8), - ), + calendarStyle: CalendarStyle( + isTodayHighlighted: false, + defaultTextStyle: AppTextStyles.bodyText, + defaultDecoration: const BoxDecoration(shape: BoxShape.circle, color: AppColor.neutral30), + ), + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + 16.height, + Row( + children: [ + const CircleAvatar(backgroundColor: AppColor.primary40, radius: 8), + 8.width, + "My Requests".heading6(context), + ], + ), + 16.height, + Row( + children: [ + const CircleAvatar(backgroundColor: AppColor.green50, radius: 8), + 8.width, + "My Team Requests".heading6(context), + ], + ), + ], + ), + ], + ).toShadowContainer, ); } } diff --git a/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart b/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart index 1cf153fa..1bb9ce2b 100644 --- a/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart +++ b/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.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/models/enums/translation_keys.dart'; import '../../app_style/app_color.dart'; @@ -12,7 +14,6 @@ class ContactUsBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - height: 300.toScreenHeight, clipBehavior: Clip.antiAlias, decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, @@ -23,75 +24,54 @@ class ContactUsBottomSheet extends StatelessWidget { ), padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight), child: Column( + mainAxisSize: MainAxisSize.min, children: [ Container( width: 40.toScreenWidth, height: 5.toScreenHeight, decoration: BoxDecoration(color: AppColor.neutral40, borderRadius: BorderRadius.circular(30)), ), + 16.height, Align( alignment: AlignmentDirectional.centerStart, - child: Padding( - padding: EdgeInsets.symmetric(vertical: 16.toScreenHeight), - child: Text( - context.translation.contactUs, - style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w600), - ), + child: Text( + context.translation.contactUs, + style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), ), ), + 16.height, Row( children: [ - Expanded(child: _ContactCard(iconName: "phone", title: context.translation.callUs, subtitle: "+966 546345567")), + contactItem(context.isDark, "phone", context.translation.callUs, "+966 546345567").onPress(() { }).expanded, 16.width, - Expanded( - child: _ContactCard( - iconName: "whatsapp", - title: context.translation.liveChat, - subtitle: context.translation.openWhatsapp, - ), - ), + contactItem(context.isDark, "whatsapp", context.translation.liveChat, context.translation.openWhatsapp).onPress(() {}).expanded, ], ), + 32.height, ], ), ); } -} - -class _ContactCard extends StatelessWidget { - final String iconName, title, subtitle; - const _ContactCard({ - Key key, - @required this.iconName, - @required this.title, - @required this.subtitle, - }) : super(key: key); - @override - Widget build(BuildContext context) { - return Card( - child: Padding( - padding: EdgeInsets.all(16.toScreenWidth), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset( - "assets/images/$iconName.svg", - width: 32.toScreenWidth, - color: context.isDark ? AppColor.primary40 : AppColor.primary70, - ), - 30.height, - Text( - title, - style: Theme.of(context).textTheme.titleLarge?.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), - ), - Text( - subtitle, - style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), - ), - ], + Widget contactItem(bool isDark, String iconName, String title, String subtitle) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SvgPicture.asset( + "assets/images/$iconName.svg", + width: 32.toScreenWidth, + color: isDark ? AppColor.primary40 : AppColor.primary70, ), - ), - ); + 30.height, + Text( + title, + style: AppTextStyles.heading6.copyWith(color: isDark ? AppColor.neutral30 : AppColor.neutral50), + ), + Text( + subtitle, + style: AppTextStyles.bodyText.copyWith(color: isDark ? AppColor.neutral10 : AppColor.neutral20), + ), + ], + ).toShadowContainer; } } From ff80897a3c34656515ccf4cb4676a146c3527935 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Wed, 8 Nov 2023 16:46:01 +0300 Subject: [PATCH 2/4] dashboard apis added. --- lib/controllers/api_routes/urls.dart | 2 + .../providers/api/all_requests_provider.dart | 250 +++++++++++++++--- lib/extensions/widget_extensions.dart | 15 ++ lib/models/all_requests_and_count_model.dart | 157 +++++++++++ .../progress_fragment.dart | 48 ++-- .../requests_fragment.dart | 112 ++++---- .../pages/land_page/dashboard_page.dart | 3 + .../equipment/equipment_status_buttons.dart | 1 + 8 files changed, 454 insertions(+), 134 deletions(-) create mode 100644 lib/models/all_requests_and_count_model.dart diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index ddc9dd25..09bdea74 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -32,6 +32,8 @@ class URLs { static get getAssets => "$_baseUrl/Asset/GetAssets"; // get static get getAssetById => "$_baseUrl/Asset/GetAssetById?assetId="; // get static get getModels => "$_baseUrl/ModelDefinition/GetModelDefinitionAsset"; // get ?client=2 + + static get getAllRequestsAndCount => "$_baseUrl/CallRequest/GetAllRequestsAndCount"; // get // 08051 static get getServiceRequests => "$_baseUrl/CallRequest/GetCallRequests"; // get static get getServiceRequestById => "$_baseUrl/CallRequest/GetCallRequestById"; // get diff --git a/lib/controllers/providers/api/all_requests_provider.dart b/lib/controllers/providers/api/all_requests_provider.dart index 20bf362e..1a08fc91 100644 --- a/lib/controllers/providers/api/all_requests_provider.dart +++ b/lib/controllers/providers/api/all_requests_provider.dart @@ -1,47 +1,213 @@ +import 'dart:convert'; + import 'package:flutter/widgets.dart'; import 'package:http/http.dart'; +import 'package:test_sa/controllers/api_routes/api_manager.dart'; +import 'package:test_sa/controllers/api_routes/urls.dart'; +import 'package:test_sa/models/all_requests_and_count_model.dart'; class AllRequestsProvider extends ChangeNotifier { - bool isLoading; - -// Future getAllRequests() async { -// if (isLoading == true) return -2; -// isLoading = true; -// if (serviceRequests?.isEmpty ?? false) notifyListeners(); -// Response response; -// try { -// Map body = {}; -// body.addAll(search.toMap()); -// body["pageNumber"] = (serviceRequests?.length ?? 0) ~/ pageItemNumber + 1; -// body["pageSize"] = pageItemNumber; -// -// response = await ApiManager.instance.post( -// URLs.getServiceRequests, -// body: body, -// ); -// -// stateCode = response.statusCode; -// if (response.statusCode >= 200 && response.statusCode < 300) { -// // client's request was successfully received -// List requestsListJson = json.decode(response.body)["data"]; -// List serviceRequestsPage = requestsListJson.map((request) => ServiceRequest.fromJson(request)).toList(); -// serviceRequests ??= []; -// serviceRequests.addAll(serviceRequestsPage); -// notifyListeners(); -// if (serviceRequestsPage.length == pageItemNumber) { -// nextPage = true; -// } else { -// nextPage = false; -// } -// } -// isLoading = false; -// notifyListeners(); -// return response.statusCode; -// } catch (error) { -// isLoading = false; -// stateCode = -1; -// notifyListeners(); -// return -1; -// } -// } + bool isAllLoading = false; + bool isOpenLoading = false; + bool isInProgressLoading = false; + bool isCloseLoading = false; + bool isOverdueLoading = false; + bool isHighPriorityLoading = false; + + int stateCode; + + AllRequestsAndCount allRequestsAndCount; + AllRequestsAndCount openRequests; + AllRequestsAndCount inProgressRequests; + AllRequestsAndCount closeRequests; + AllRequestsAndCount overdueRequests; + AllRequestsAndCount highPriorityRequests; + + void getRequests() { + getHighPriorityRequests(); + getOverdueRequests(); + getOpenRequests(); + getInProgressRequests(); + getCloseRequests(); + } + + Future getAllRequests() async { + if (isAllLoading == true) return -2; + isAllLoading = true; + if (allRequestsAndCount == null) notifyListeners(); + Response response; + try { + Map body = { + "typeTransaction": [1, 2, 3, 4], + "statusTransaction": [1, 2, 3], + "priority": [0, 1], + "displayData": [1] + }; + response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + allRequestsAndCount = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + notifyListeners(); + } + isAllLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isAllLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } + + Future getHighPriorityRequests() async { + if (isHighPriorityLoading == true) return -2; + isHighPriorityLoading = true; + if (highPriorityRequests == null) notifyListeners(); + Response response; + try { + Map body = { + "typeTransaction": [1, 2, 3, 4], + "statusTransaction": [1, 2, 3], + "priority": [0], + "displayData": [] + }; + response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + highPriorityRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + print("highPriorityRequests:${highPriorityRequests.total}"); + notifyListeners(); + } + isHighPriorityLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isHighPriorityLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } + + Future getOverdueRequests() async { + if (isOverdueLoading == true) return -2; + isOverdueLoading = true; + if (overdueRequests == null) notifyListeners(); + Response response; + try { + Map body = { + "typeTransaction": [1, 2, 3, 4], + "statusTransaction": [1, 2, 3], + "priority": [], + "displayData": [1] + }; + response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + notifyListeners(); + } + isOverdueLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isOverdueLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } + + Future getOpenRequests() async { + if (isOpenLoading == true) return -2; + isOpenLoading = true; + if (openRequests == null) notifyListeners(); + Response response; + try { + Map body = { + "typeTransaction": [1, 2, 3, 4], + "statusTransaction": [1], + "priority": [], + "displayData": [] + }; + response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + openRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + notifyListeners(); + } + isOpenLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isOpenLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } + + Future getInProgressRequests() async { + if (isInProgressLoading == true) return -2; + isInProgressLoading = true; + if (inProgressRequests == null) notifyListeners(); + Response response; + try { + Map body = { + "typeTransaction": [1, 2, 3, 4], + "statusTransaction": [2], + "priority": [], + "displayData": [] + }; + response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + inProgressRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + notifyListeners(); + } + isInProgressLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isInProgressLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } + + Future getCloseRequests() async { + if (isCloseLoading == true) return -2; + isCloseLoading = true; + if (closeRequests == null) notifyListeners(); + Response response; + try { + Map body = { + "typeTransaction": [1, 2, 3, 4], + "statusTransaction": [3], + "priority": [], + "displayData": [] + }; + response = await ApiManager.instance.post(URLs.getAllRequestsAndCount, body: body); + + stateCode = response.statusCode; + if (response.statusCode >= 200 && response.statusCode < 300) { + closeRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"]); + notifyListeners(); + } + isCloseLoading = false; + notifyListeners(); + return response.statusCode; + } catch (error) { + isCloseLoading = false; + stateCode = -1; + notifyListeners(); + return -1; + } + } } diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index a2f2a14b..444e7029 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; @@ -20,6 +21,20 @@ extension WidgetExtensions on Widget { Widget toExpanded({int flex = 1}) => Expanded(flex: flex, child: this); + Widget toShimmer({bool isShow = true, double radius = 20}) => isShow + ? Shimmer.fromColors( + baseColor: const Color(0xffe8eff0), + highlightColor: Colors.white, + child: ClipRRect( + borderRadius: BorderRadius.circular(radius), + child: Container( + color: Colors.white, + child: this, + ), + ), + ) + : this; + Widget get toShadowContainer => Container( padding: const EdgeInsets.all(16), decoration: ShapeDecoration( diff --git a/lib/models/all_requests_and_count_model.dart b/lib/models/all_requests_and_count_model.dart new file mode 100644 index 00000000..115f0c72 --- /dev/null +++ b/lib/models/all_requests_and_count_model.dart @@ -0,0 +1,157 @@ +class AllRequestsAndCount { + CountServiceRequest countServiceRequest; + CountServiceRequest countGasRefill; + CountServiceRequest countAssetTransfer; + CountServiceRequest countPPM; + DetailsStatusTotal detailsStatusTotal; + CountServiceRequest total; + List requestsDetails; + + AllRequestsAndCount({this.countServiceRequest, this.countGasRefill, this.countAssetTransfer, this.countPPM, this.detailsStatusTotal, this.total, this.requestsDetails}); + + AllRequestsAndCount.fromJson(Map json) { + countServiceRequest = json['countServiceRequest'] != null ? new CountServiceRequest.fromJson(json['countServiceRequest']) : null; + countGasRefill = json['countGasRefill'] != null ? new CountServiceRequest.fromJson(json['countGasRefill']) : null; + countAssetTransfer = json['countAssetTransfer'] != null ? new CountServiceRequest.fromJson(json['countAssetTransfer']) : null; + countPPM = json['countPPM'] != null ? new CountServiceRequest.fromJson(json['countPPM']) : null; + detailsStatusTotal = json['detailsStatusTotal'] != null ? new DetailsStatusTotal.fromJson(json['detailsStatusTotal']) : null; + total = json['total'] != null ? new CountServiceRequest.fromJson(json['total']) : null; + if (json['requestsDetails'] != null) { + requestsDetails = []; + json['requestsDetails'].forEach((v) { + requestsDetails.add(new RequestsDetails.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.countServiceRequest != null) { + data['countServiceRequest'] = this.countServiceRequest.toJson(); + } + + if (this.countGasRefill != null) { + data['countGasRefill'] = this.countGasRefill.toJson(); + } + if (this.countAssetTransfer != null) { + data['countAssetTransfer'] = this.countAssetTransfer.toJson(); + } + if (this.countPPM != null) { + data['countPPM'] = this.countPPM.toJson(); + } + + if (this.detailsStatusTotal != null) { + data['detailsStatusTotal'] = this.detailsStatusTotal.toJson(); + } + if (this.total != null) { + data['total'] = this.total.toJson(); + } + if (this.requestsDetails != null) { + data['requestsDetails'] = this.requestsDetails.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class CountServiceRequest { + int count; + + CountServiceRequest({this.count}); + + CountServiceRequest.fromJson(Map json) { + count = json['count']; + } + + Map toJson() { + final Map data = new Map(); + data['count'] = this.count; + return data; + } +} + +class DetailsStatusTotal { + int open; + int inProgress; + int closed; + + DetailsStatusTotal({this.open, this.inProgress, this.closed}); + + DetailsStatusTotal.fromJson(Map json) { + open = json['open']; + inProgress = json['inProgress']; + closed = json['closed']; + } + + Map toJson() { + final Map data = new Map(); + data['open'] = this.open; + data['inProgress'] = this.inProgress; + data['closed'] = this.closed; + return data; + } +} + +class RequestsDetails { + String nameOfType; + String status; + String statusReceiver; + String assetName; + String assetNo; + String requestType; + String requestNo; + String gasType; + String site; + String assetTransferFrom; + String assetTransferTo; + String assetSN; + String code; + + RequestsDetails( + {this.nameOfType, + this.status, + this.statusReceiver, + this.assetName, + this.assetNo, + this.requestType, + this.requestNo, + this.gasType, + this.site, + this.assetTransferFrom, + this.assetTransferTo, + this.assetSN, + this.code}); + + RequestsDetails.fromJson(Map json) { + nameOfType = json['nameOfType']; + status = json['status']; + statusReceiver = json['statusReceiver']; + assetName = json['assetName']; + assetNo = json['assetNo']; + requestType = json['requestType']; + requestNo = json['requestNo']; + gasType = json['gasType']; + site = json['site']; + assetTransferFrom = json['assetTransferFrom']; + assetTransferTo = json['assetTransferTo']; + assetSN = json['assetSN']; + code = json['code']; + } + + Map toJson() { + final Map data = new Map(); + data['nameOfType'] = this.nameOfType; + data['status'] = this.status; + data['statusReceiver'] = this.statusReceiver; + data['assetName'] = this.assetName; + data['assetNo'] = this.assetNo; + data['requestType'] = this.requestType; + data['requestNo'] = this.requestNo; + data['gasType'] = this.gasType; + data['site'] = this.site; + data['assetTransferFrom'] = this.assetTransferFrom; + data['assetTransferTo'] = this.assetTransferTo; + data['assetSN'] = this.assetSN; + data['code'] = this.code; + return data; + } +} diff --git a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart index 3b037be6..3414bb46 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:pie_chart/pie_chart.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'; @@ -18,36 +19,23 @@ class ProgressFragment extends StatelessWidget { }; return Column( children: [ - Card( - child: Stack( - alignment: Alignment.center, - children: [ - PieChart( - dataMap: statuses, - animationDuration: const Duration(milliseconds: 800), - chartRadius: 190.toScreenWidth, - colorList: [AColors.statusGreen, AColors.statusBlue, AColors.statusYellowLight], - initialAngleInDegree: 270, - chartType: ChartType.ring, - ringStrokeWidth: 40.toScreenWidth, - legendOptions: const LegendOptions(showLegends: false), - chartValuesOptions: ChartValuesOptions( - chartValueBackgroundColor: Colors.transparent, - chartValueStyle: AppTextStyles.heading6.copyWith(color: AppColor.neutral20), - showChartValuesOutside: true, - ), - ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - "Total".heading5(context), - "20".heading6(context).custom(color: AppColor.neutral20), - ], - ) - ], - ).paddingAll(23), - ), + PieChart( + dataMap: statuses, + animationDuration: const Duration(milliseconds: 500), + chartRadius: 190.toScreenWidth, + colorList: [AColors.statusGreen, AColors.statusBlue, AColors.statusYellowLight], + initialAngleInDegree: 270, + chartType: ChartType.ring, + ringStrokeWidth: 40.toScreenWidth, + centerText: "Total\n20", + centerTextStyle: AppTextStyles.heading5.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50), + legendOptions: const LegendOptions(showLegends: false), + chartValuesOptions: ChartValuesOptions( + chartValueBackgroundColor: Colors.transparent, + chartValueStyle: AppTextStyles.heading6.copyWith(color: AppColor.neutral20), + showChartValuesOutside: false, + ), + ).paddingAll(8).toShadowContainer, ], ).paddingOnly(start: 16, end: 16); } diff --git a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart index 91928b58..d886fb8b 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; +import 'package:test_sa/controllers/providers/api/all_requests_provider.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'; @@ -15,71 +17,57 @@ class RequestsFragment extends StatelessWidget { return Scaffold( // todo check here, nurse can add request not engineer floatingActionButton: const AppFloatingActionButton(), - body: GridView( - padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 191 / 237, crossAxisSpacing: 16, mainAxisSpacing: 16), - children: [ - gridItem("12", "high_priority",context.translation.highPriorityRequests,context), - gridItem("12", "overdue", context.translation.overdueRequests,context), - gridItem("12", "new_request", context.translation.newRequests,context), - gridItem("12", "complete_request", context.translation.completedRequests ,context), - ], + body: Consumer( + builder: (context, snapshot, _) => GridView( + padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 191 / 237, crossAxisSpacing: 16, mainAxisSpacing: 16), + children: [ + gridItem(snapshot.highPriorityRequests?.total?.count?.toString() ?? "-", "high_priority", context.translation.highPriorityRequests, context, snapshot.isHighPriorityLoading), + gridItem(snapshot.overdueRequests?.total?.count?.toString() ?? "-", "overdue", context.translation.overdueRequests, context, snapshot.isOverdueLoading), + gridItem(snapshot.openRequests?.total?.count?.toString() ?? "-", "new_request", context.translation.newRequests, context, snapshot.isOpenLoading), + gridItem(snapshot.closeRequests?.total?.count?.toString() ?? "-", "complete_request", context.translation.completedRequests, context, snapshot.isCloseLoading), + ], + ), ), ); } - Widget gridItem(String value, String icon, String title, BuildContext context) { - return Container( - padding: const EdgeInsets.all(16), - 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: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - value, - style: AppTextStyles.heading1.copyWith(color: AppColor.neutral70, height: 1), - ).expanded, - SvgPicture.asset('assets/images/$icon.svg', height: 35, width: 35), - ], - ).expanded, - Text( - title, - style: AppTextStyles.heading5.copyWith(color: AppColor.neutral50), - ), - 8.height, - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - context.translation.viewDetails, - style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), - ), - 4.width, - const Icon( - Icons.arrow_forward, - color: Color(0xFF4A8DB7), - size: 14, - ) - ], - ), - ], - ), - ); + Widget gridItem(String value, String icon, String title, BuildContext context, bool isLoading) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + value, + style: AppTextStyles.heading1.copyWith(color: AppColor.neutral70, height: 1), + ).toShimmer(isShow: isLoading).expanded, + 8.width, + SvgPicture.asset('assets/images/$icon.svg', height: 35, width: 35).toShimmer(isShow: isLoading), + ], + ).expanded, + Text( + title, + style: AppTextStyles.heading5.copyWith(color: AppColor.neutral50), + ).toShimmer(isShow: isLoading), + 8.height, + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + context.translation.viewDetails, + style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), + ), + 4.width, + const Icon( + Icons.arrow_forward, + color: Color(0xFF4A8DB7), + size: 14, + ) + ], + ).toShimmer(isShow: isLoading), + ], + ).toShadowContainer; } } diff --git a/lib/new_views/pages/land_page/dashboard_page.dart b/lib/new_views/pages/land_page/dashboard_page.dart index c952968a..4bf1a973 100644 --- a/lib/new_views/pages/land_page/dashboard_page.dart +++ b/lib/new_views/pages/land_page/dashboard_page.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:test_sa/controllers/providers/api/all_requests_provider.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'; @@ -24,6 +26,7 @@ class _DashboardPageState extends State { @override void initState() { super.initState(); + Provider.of(context, listen: false).getRequests(); } @override diff --git a/lib/views/widgets/equipment/equipment_status_buttons.dart b/lib/views/widgets/equipment/equipment_status_buttons.dart index b1bf737c..f1f5d32e 100644 --- a/lib/views/widgets/equipment/equipment_status_buttons.dart +++ b/lib/views/widgets/equipment/equipment_status_buttons.dart @@ -12,6 +12,7 @@ import '../../../providers/service_request_providers/equipment_status_provider.d class EquipmentStatusButtons extends StatefulWidget { final Function(Lookup) onSelect; + const EquipmentStatusButtons({Key key, this.onSelect}) : super(key: key); @override From eb8a9cc971ba752104ace8b026272e1f2358407a Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Thu, 9 Nov 2023 09:29:53 +0300 Subject: [PATCH 3/4] Improvements --- .../user/gas_refill/gas_refill_details.dart | 206 +++++++-------- .../user/gas_refill/request_gas_refill.dart | 154 ++++++------ .../work_order/create_service_report.dart | 2 +- .../work_order/work_order_details_page.dart | 3 +- .../pages/user/visits/visit_details.dart | 6 +- .../widgets/gas_refill/gas_refill_item.dart | 237 ++++++++---------- 6 files changed, 290 insertions(+), 318 deletions(-) diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index 3184bfa4..b768f7ed 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; -import 'package:test_sa/controllers/providers/api/gas_refill_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; -import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart'; @@ -31,7 +29,6 @@ class GasRefillDetailsPage extends StatefulWidget { class _GasRefillDetailsPageState extends State { GasRefillModel _model = GasRefillModel(gazRefillDetails: []); - bool _enableEdit = false; UserProvider _userProvider; bool _isLoading = false; @@ -46,7 +43,6 @@ class _GasRefillDetailsPageState extends State { @override Widget build(BuildContext context) { - _userProvider = Provider.of(context); return Scaffold( @@ -61,9 +57,7 @@ class _GasRefillDetailsPageState extends State { stateCode: 200, onRefresh: () async {}, child: Column( - children: [ - informationCard() - ], + children: [informationCard()], ), ), ), @@ -99,60 +93,15 @@ class _GasRefillDetailsPageState extends State { //textColor: AColors.getPriorityStatusTextColor(serviceRequest.priority.id), //backgroundColor: AColors.getPriorityStatusColor(serviceRequest.priority.id) //), - 8.width, + // 8.width, StatusLabel( - label: widget.model.status?.name??"", - textColor: AColors.getRequestStatusTextColor(widget.model.status?.value??0), - backgroundColor: AColors.getRequestStatusColor(widget.model.status?.value??0)), + label: widget.model.status?.name ?? "", + textColor: AColors.getRequestStatusTextColor(widget.model.status?.value ?? 0), + backgroundColor: AColors.getRequestStatusColor(widget.model.status?.value ?? 0)), 8.height, Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), - ], - ), - 1.width.expanded, - if (_userProvider.user.type == UsersTypes.engineer) - CircleAvatar( - radius: 25, - backgroundColor: AppColor.neutral30, - child: CircleAvatar( - radius: 24, - backgroundColor: Colors.white, - child: Padding( - padding: const EdgeInsets.only(left: 3.0), - child: SvgPicture.asset('assets/images/update.svg'), - ), - ), - ).onPress( - (widget.model.status?.value ?? 0) == 2 - ? null - : - () async { - _enableEdit = !_enableEdit; - _model?.fromGasRefillModel(widget.model); - // setState(() {}); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => RequestGasRefill( - gasRefillModel: widget.model, - ), - ), - ).then((value) { - if (value != null) { - _model = value; - } - }); - setState(() {}); - },), - ], - ), - 8.height, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + 8.height, + ///TBD Text( context.translation.gasRequest, @@ -168,7 +117,44 @@ class _GasRefillDetailsPageState extends State { ), ], ), - Text(widget.model.startDate?.toServiceRequestCardFormat??"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), + 1.width.expanded, + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + if (_userProvider.user.type == UsersTypes.engineer && (widget.model.status?.value ?? 0) != 2) + CircleAvatar( + radius: 25, + backgroundColor: AppColor.neutral30, + child: CircleAvatar( + radius: 24, + backgroundColor: Colors.white, + child: Padding( + padding: const EdgeInsets.only(left: 3.0), + child: SvgPicture.asset('assets/images/update.svg'), + ), + ), + ).onPress( + () async { + _model?.fromGasRefillModel(widget.model); + // setState(() {}); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => RequestGasRefill( + gasRefillModel: widget.model, + ), + ), + ).then((value) { + if (value != null) { + _model = value; + } + }); + setState(() {}); + }, + ), + Text(widget.model.startDate?.toServiceRequestCardFormat ?? "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), + ], + ) ], ), 8.height, @@ -185,59 +171,59 @@ class _GasRefillDetailsPageState extends State { 8.height, ], ).paddingAll(16), + /// TBD (_userProvider.user.type == UsersTypes.normal_user - ? Container( - height: 50, - padding: const EdgeInsets.only(left: 16, right: 16), - alignment: Alignment.center, - width: double.infinity, - decoration: const ShapeDecoration( - color: Color(0xFFEAF1F4), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(20), - bottomRight: Radius.circular(20), - ), - ), - ), - child: Row( - children: [ - Text( - '${context.translation.commentHere}...', - style: AppTextStyles.heading6.copyWith( - color: AppColor.neutral50.withOpacity(.6), - ), - ).expanded, - SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 24 * AppStyle.getScaleFactor(context), color: AppColor.primary70), - ], - ), - ) - : Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1), - 16.height, - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - '${context.translation.viewComments}', - style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), - ), - 4.width, - const Icon( - Icons.arrow_forward, - color: Color(0xFF4A8DB7), - size: 14, - ) - ], - ), - ], - ).paddingOnly(bottom: 16, start: 16, end: 16)) - .onPress(() { - }), + ? Container( + height: 50, + padding: const EdgeInsets.only(left: 16, right: 16), + alignment: Alignment.center, + width: double.infinity, + decoration: const ShapeDecoration( + color: Color(0xFFEAF1F4), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + ), + ), + ), + child: Row( + children: [ + Text( + '${context.translation.commentHere}...', + style: AppTextStyles.heading6.copyWith( + color: AppColor.neutral50.withOpacity(.6), + ), + ).expanded, + SvgPicture.asset("assets/images/comment_send.svg", width: 24 * AppStyle.getScaleFactor(context), height: 24 * AppStyle.getScaleFactor(context), color: AppColor.primary70), + ], + ), + ) + : Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1), + 16.height, + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + '${context.translation.viewComments}', + style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), + ), + 4.width, + const Icon( + Icons.arrow_forward, + color: Color(0xFF4A8DB7), + size: 14, + ) + ], + ), + ], + ).paddingOnly(bottom: 16, start: 16, end: 16)) + .onPress(() {}), ], ), ).paddingAll(16); diff --git a/lib/views/pages/user/gas_refill/request_gas_refill.dart b/lib/views/pages/user/gas_refill/request_gas_refill.dart index ec9062d4..cd280fea 100644 --- a/lib/views/pages/user/gas_refill/request_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/request_gas_refill.dart @@ -178,87 +178,89 @@ class _RequestGasRefillState extends State { stateCode: 200, onRefresh: () async {}, child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ SingleChildScrollView( - child: Column( - children: [ - Container( - width: MediaQuery.of(context).size.width, - decoration: ShapeDecoration( - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + width: MediaQuery.of(context).size.width, + 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)], ), - shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)], - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), - 8.height, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), + 8.height, - /// TBD - Text( - 'Gas Request:', - style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), - ), - Text( - 'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}', - style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), - ), - Text( - 'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}', - style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), - ), - Text( - 'Site: ${widget.gasRefillModel.site.name}', - style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), - ), - ], - ).paddingAll(16), - ), - 12.height, - AppTimer( - label: context.translation.workingHours, - timer: _formModel.timer, - enabled: _formModel.endDate == null, - onChange: (timer) async { - _formModel.timer = timer; - return true; - }, - ), - 12.height, - SingleItemDropDownMenu( - context: context, - title: context.translation.reportStatus, - initialValue: widget.gasRefillModel.status, - onSelect: (value) { - _formModel.status = value; - }, - ), - 12.height, - AppTextFormField( - labelText: context.translation.deliveredQuantity, - onSaved: (value) { - _currentDetails?.deliverdQty = double.tryParse(value); - }, - textInputType: TextInputType.number, - controller: _deliveredQuantityController, - validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only", - ), - 12.height, + /// TBD + Text( + 'Gas Request:', + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + ), + Text( + 'Cylinder Size: ${widget.gasRefillModel.gazRefillDetails[0].cylinderSize.value}', + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + ), + Text( + 'Request Quantity: ${widget.gasRefillModel.gazRefillDetails[0].requestedQty}', + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + ), + Text( + 'Site: ${widget.gasRefillModel.site.name}', + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + ), + ], + ).paddingAll(16), + ), + 12.height, + AppTimer( + label: context.translation.workingHours, + timer: _formModel.timer, + enabled: _formModel.endDate == null, + onChange: (timer) async { + _formModel.timer = timer; + return true; + }, + ), + 12.height, + SingleItemDropDownMenu( + context: context, + title: context.translation.reportStatus, + initialValue: widget.gasRefillModel.status, + onSelect: (value) { + _formModel.status = value; + }, + ), + 12.height, + AppTextFormField( + labelText: context.translation.deliveredQuantity, + onSaved: (value) { + _currentDetails?.deliverdQty = double.tryParse(value); + }, + textInputType: TextInputType.number, + controller: _deliveredQuantityController, + validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only", + ), + 12.height, - /// TBD - AppTextFormField( - labelText: context.translation.comments, - textInputType: TextInputType.multiline, - alignLabelWithHint: true, - controller: _commentController, - onSaved: (value) {}, - ), - ], - ).paddingAll(16)) - .expanded, + /// TBD + AppTextFormField( + labelText: context.translation.comments, + textInputType: TextInputType.multiline, + alignLabelWithHint: true, + controller: _commentController, + onSaved: (value) {}, + ), + ], + ).paddingAll(16), + ).expanded, AppFilledButton( label: widget.gasRefillModel == null ? context.translation.submit : context.translation.update, onPressed: () async { diff --git a/lib/views/pages/user/requests/work_order/create_service_report.dart b/lib/views/pages/user/requests/work_order/create_service_report.dart index 225f6b73..94698ec6 100644 --- a/lib/views/pages/user/requests/work_order/create_service_report.dart +++ b/lib/views/pages/user/requests/work_order/create_service_report.dart @@ -120,7 +120,7 @@ class _CreateServiceReportState extends State with TickerPr children: [ SingleChildScrollView( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Card( child: Column( diff --git a/lib/views/pages/user/requests/work_order/work_order_details_page.dart b/lib/views/pages/user/requests/work_order/work_order_details_page.dart index 6aa1db17..b8f29067 100644 --- a/lib/views/pages/user/requests/work_order/work_order_details_page.dart +++ b/lib/views/pages/user/requests/work_order/work_order_details_page.dart @@ -9,6 +9,7 @@ import 'package:test_sa/models/service_request/service_request.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; +import 'package:test_sa/views/pages/user/requests/work_order/update_service_report.dart'; import '../../../../../controllers/providers/api/user_provider.dart'; import '../../../../../models/enums/user_types.dart'; @@ -75,7 +76,7 @@ class WorkOrderDetailsPage extends StatelessWidget { if (userProvider.user.type == UsersTypes.engineer && serviceRequest.statusValue != 5 && serviceRequest.statusValue != 3) AppFilledButton( onPressed: () { - Navigator.of(context).push(MaterialPageRoute(builder: (_) => Container())); + Navigator.of(context).push(MaterialPageRoute(builder: (_) => UpdateServiceReport(workOrder: workOrder, request: serviceRequest))); }, label: context.translation.updateRequest, ).paddingAll(16), diff --git a/lib/views/pages/user/visits/visit_details.dart b/lib/views/pages/user/visits/visit_details.dart index 99ef76a5..5792cf00 100644 --- a/lib/views/pages/user/visits/visit_details.dart +++ b/lib/views/pages/user/visits/visit_details.dart @@ -7,7 +7,6 @@ import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/visits/visit.dart'; import 'package:test_sa/new_views/common_widgets/default_app_bar.dart'; -import 'package:test_sa/views/pages/user/visits/pantry/edit_pentry.dart'; import '../../../../controllers/providers/api/user_provider.dart'; import '../../../../models/enums/user_types.dart'; @@ -77,10 +76,11 @@ class VisitDetailsPage extends StatelessWidget { ).paddingAll(16), ), ).expanded, - if (userProvider.user.type == UsersTypes.engineer && visit.status.value != 5 && visit.status.value != 3) + if (userProvider.user.type == UsersTypes.engineer && visit.status.id != 270) AppFilledButton( onPressed: () { - Navigator.of(context).push(MaterialPageRoute(builder: (_) => EditPentry(visit: visit, pentry: visit.pentry))); + print(visit.status.id); + // Navigator.of(context).push(MaterialPageRoute(builder: (_) => EditPentry(visit: visit, pentry: visit.pentry))); }, label: context.translation.updateRequest, ).paddingAll(16), diff --git a/lib/views/widgets/gas_refill/gas_refill_item.dart b/lib/views/widgets/gas_refill/gas_refill_item.dart index 8f33c63a..126b7e44 100644 --- a/lib/views/widgets/gas_refill/gas_refill_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_item.dart @@ -3,7 +3,6 @@ import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; -import 'package:test_sa/views/app_style/sizing.dart'; import '../../../extensions/text_extensions.dart'; import '../../../models/new_models/gas_refill_model.dart'; @@ -19,137 +18,121 @@ class GasRefillItem extends StatelessWidget { @override Widget build(BuildContext context) { - - return Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), - backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), - ), - ), - onPressed: () { - onPressed(item); - }, - child: Column( + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - /// TBD - // StatusLabel( - // label: , - // id: , - // textColor: AColors.getPriorityStatusTextColor(), - // backgroundColor: AColors.getPriorityStatusColor()), - 8.width, - StatusLabel(label: item.status.name, textColor: AColors.getRequestStatusTextColor(item.status.value), backgroundColor: AColors.getRequestStatusColor(item.status.value)), - 1.width.expanded, - Text(item.startDate != null ?item.startDate.toServiceRequestCardFormat:"", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), - ], - ), - 8.height, - Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), - Text( - '${context.translation.gasType}: ${item.gazRefillDetails[0].gasType.name}', - style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), - ), + /// TBD + // StatusLabel( + // label: , + // id: , + // textColor: AColors.getPriorityStatusTextColor(), + // backgroundColor: AColors.getPriorityStatusColor()), + // 8.width, + StatusLabel(label: item.status.name, textColor: AColors.getRequestStatusTextColor(item.status.value), backgroundColor: AColors.getRequestStatusColor(item.status.value)), + 1.width.expanded, + Text(item.startDate != null ? item.startDate.toServiceRequestCardFormat : "", textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: const Color(0xFF3B3D4A))), + ], + ), + 8.height, + Text(context.translation.gasRefillRequest, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), + Text( + '${context.translation.gasType}: ${item.gazRefillDetails[0].gasType.name}', + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + ), + Text( + '${context.translation.site}: ${item.site.name}', + style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), + ), + 8.height, + Row( + mainAxisSize: MainAxisSize.min, + children: [ Text( - '${context.translation.site}: ${item.site.name}', - style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), - ), - 8.height, - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - context.translation.viewDetails, - style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), - ), - 4.width, - const Icon( - Icons.arrow_forward, - color: Color(0xFF4A8DB7), - size: 14, - ) - ], + context.translation.viewDetails, + style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)), ), - // Row( - // children: [ - // Expanded( - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Text( - // item.title ?? "-----", - // style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), - // ), - // Row( - // children: [ - // Expanded( - // child: Text( - // subtitle.hospital, - // style: Theme.of(context).textTheme.titleSmall.copyWith( - // color: onItemColor, - // ), - // ), - // ), - // if (item.clientName != null) - // Text( - // item.clientName, - // style: Theme.of(context).textTheme.titleSmall.copyWith( - // color: onItemColor, - // ), - // ), - // ], - // ), - // Divider(color: onItemColor), - // Row( - // children: [ - // Expanded( - // child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - // ), - // if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)), - // ], - // ), - // if (item?.expectedDate != null) Divider(color: onItemColor), - // if (item?.expectedDate != null) - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - // Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - // ], - // ), - // if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), - // Column( - // crossAxisAlignment: CrossAxisAlignment.end, - // children: item.details - // .map( - // (gas) => gas?.type?.name?.isNotEmpty ?? false - // ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)) - // : const SizedBox.shrink(), - // ) - // .toList(), - // ) - // ], - // ), - // ], - // ), - // ), - // ], - // ), + 4.width, + const Icon( + Icons.arrow_forward, + color: Color(0xFF4A8DB7), + size: 14, + ) ], ), - ), - ); + // Row( + // children: [ + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // item.title ?? "-----", + // style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), + // ), + // Row( + // children: [ + // Expanded( + // child: Text( + // subtitle.hospital, + // style: Theme.of(context).textTheme.titleSmall.copyWith( + // color: onItemColor, + // ), + // ), + // ), + // if (item.clientName != null) + // Text( + // item.clientName, + // style: Theme.of(context).textTheme.titleSmall.copyWith( + // color: onItemColor, + // ), + // ), + // ], + // ), + // Divider(color: onItemColor), + // Row( + // children: [ + // Expanded( + // child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // ), + // if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)), + // ], + // ), + // if (item?.expectedDate != null) Divider(color: onItemColor), + // if (item?.expectedDate != null) + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // ], + // ), + // if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)), + // Column( + // crossAxisAlignment: CrossAxisAlignment.end, + // children: item.details + // .map( + // (gas) => gas?.type?.name?.isNotEmpty ?? false + // ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)) + // : const SizedBox.shrink(), + // ) + // .toList(), + // ) + // ], + // ), + // ], + // ), + // ), + // ], + // ), + ], + ).toShadowContainer.paddingOnly(bottom: 8); } } From 7fcf49df5c38b688ebdc62b595886b5a46b8a472 Mon Sep 17 00:00:00 2001 From: zaid_daoud Date: Thu, 9 Nov 2023 09:32:44 +0300 Subject: [PATCH 4/4] Improvements --- lib/extensions/widget_extensions.dart | 4 ++-- lib/new_views/pages/land_page/calendar_page.dart | 2 +- .../land_page/calender_fragments/monthly_fragment.dart | 2 +- .../land_page/calender_fragments/weekly_fragment.dart | 2 +- .../pages/land_page/contact_us_bottom_sheet.dart | 9 ++++----- .../land_page/dashboard_fragments/progress_fragment.dart | 2 +- .../land_page/dashboard_fragments/requests_fragment.dart | 2 +- lib/views/widgets/gas_refill/gas_refill_item.dart | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 444e7029..941640d8 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -35,10 +35,10 @@ extension WidgetExtensions on Widget { ) : this; - Widget get toShadowContainer => Container( + Widget toShadowContainer(BuildContext context) => Container( padding: const EdgeInsets.all(16), decoration: ShapeDecoration( - color: Colors.white, + color: Theme.of(context).cardColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), diff --git a/lib/new_views/pages/land_page/calendar_page.dart b/lib/new_views/pages/land_page/calendar_page.dart index 677815b9..c067b5de 100644 --- a/lib/new_views/pages/land_page/calendar_page.dart +++ b/lib/new_views/pages/land_page/calendar_page.dart @@ -43,7 +43,7 @@ class _CalendarPageState extends State with SingleTickerProviderSt "Sunday to Thursday".bodyText(context), "09:00 to 18:00".bodyText(context).custom(color: AppColor.neutral50), ], - ).toShadowContainer, + ).toShadowContainer(context), ).paddingOnly(start: 16, end: 16), 16.height, Container( 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 3928e598..64323c4d 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 @@ -82,7 +82,7 @@ class _MonthlyFragmentState extends State { ], ), ], - ).toShadowContainer, + ).toShadowContainer(context), ); } } 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 12d55447..cceb4358 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 @@ -94,7 +94,7 @@ class _WeeklyFragmentState extends State { // availableGestures: AvailableGestures.none, // ), ], - ).toShadowContainer, + ).toShadowContainer(context), ); } diff --git a/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart b/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart index 1bb9ce2b..72b1d6a9 100644 --- a/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart +++ b/lib/new_views/pages/land_page/contact_us_bottom_sheet.dart @@ -4,7 +4,6 @@ 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/models/enums/translation_keys.dart'; import '../../app_style/app_color.dart'; @@ -42,9 +41,9 @@ class ContactUsBottomSheet extends StatelessWidget { 16.height, Row( children: [ - contactItem(context.isDark, "phone", context.translation.callUs, "+966 546345567").onPress(() { }).expanded, + contactItem(context, context.isDark, "phone", context.translation.callUs, "+966 546345567").onPress(() {}).expanded, 16.width, - contactItem(context.isDark, "whatsapp", context.translation.liveChat, context.translation.openWhatsapp).onPress(() {}).expanded, + contactItem(context, context.isDark, "whatsapp", context.translation.liveChat, context.translation.openWhatsapp).onPress(() {}).expanded, ], ), 32.height, @@ -53,7 +52,7 @@ class ContactUsBottomSheet extends StatelessWidget { ); } - Widget contactItem(bool isDark, String iconName, String title, String subtitle) { + Widget contactItem(BuildContext context, bool isDark, String iconName, String title, String subtitle) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -72,6 +71,6 @@ class ContactUsBottomSheet extends StatelessWidget { style: AppTextStyles.bodyText.copyWith(color: isDark ? AppColor.neutral10 : AppColor.neutral20), ), ], - ).toShadowContainer; + ).toShadowContainer(context); } } diff --git a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart index 3414bb46..d4f70e9e 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/progress_fragment.dart @@ -35,7 +35,7 @@ class ProgressFragment extends StatelessWidget { chartValueStyle: AppTextStyles.heading6.copyWith(color: AppColor.neutral20), showChartValuesOutside: false, ), - ).paddingAll(8).toShadowContainer, + ).paddingAll(8).toShadowContainer(context), ], ).paddingOnly(start: 16, end: 16); } diff --git a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart index d886fb8b..aea31335 100644 --- a/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart +++ b/lib/new_views/pages/land_page/dashboard_fragments/requests_fragment.dart @@ -68,6 +68,6 @@ class RequestsFragment extends StatelessWidget { ], ).toShimmer(isShow: isLoading), ], - ).toShadowContainer; + ).toShadowContainer(context); } } diff --git a/lib/views/widgets/gas_refill/gas_refill_item.dart b/lib/views/widgets/gas_refill/gas_refill_item.dart index 126b7e44..5ab6501e 100644 --- a/lib/views/widgets/gas_refill/gas_refill_item.dart +++ b/lib/views/widgets/gas_refill/gas_refill_item.dart @@ -133,6 +133,6 @@ class GasRefillItem extends StatelessWidget { // ], // ), ], - ).toShadowContainer.paddingOnly(bottom: 8); + ).toShadowContainer(context).paddingOnly(bottom: 8); } }