From 2962f248e0d3dcfa4841ea15c66fee5923705c90 Mon Sep 17 00:00:00 2001 From: waseemabbasi22 Date: Mon, 1 Dec 2025 11:51:48 +0300 Subject: [PATCH] timer fixes --- lib/controllers/api_routes/urls.dart | 8 +- lib/dashboard_latest/dashboard_view.dart | 7 +- .../internal_audit_attachment_model.dart | 1 - .../update_equipment_internal_audit_page.dart | 56 ++++++----- .../update_system_internal_audit_page.dart | 57 ++++++----- lib/views/widgets/timer/app_timer.dart | 95 ++++++++++--------- 6 files changed, 118 insertions(+), 106 deletions(-) diff --git a/lib/controllers/api_routes/urls.dart b/lib/controllers/api_routes/urls.dart index 9f074cce..05e7c274 100644 --- a/lib/controllers/api_routes/urls.dart +++ b/lib/controllers/api_routes/urls.dart @@ -4,13 +4,13 @@ class URLs { static const String appReleaseBuildNumber = "28"; // static const host1 = "https://atomsm.hmg.com"; // production url - static const host1 = "https://atomsmdev.hmg.com"; // local DEV url - // static const host1 = "https://atomsmuat.hmg.com"; // local UAT url + // static const host1 = "https://atomsmdev.hmg.com"; // local DEV url + static const host1 = "https://atomsmuat.hmg.com"; // local UAT url // static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url // static String _baseUrl = "$_host/mobile"; - // static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis - static final String _baseUrl = "$_host/mobile"; // host local UAT and for internal audit dev + static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis + // static final String _baseUrl = "$_host/mobile"; // host local UAT and for internal audit dev // static final String _baseUrl = "$_host/v3/mobile"; // v3 for production CM,PM,TM // static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation diff --git a/lib/dashboard_latest/dashboard_view.dart b/lib/dashboard_latest/dashboard_view.dart index 3e399e41..987e76cd 100644 --- a/lib/dashboard_latest/dashboard_view.dart +++ b/lib/dashboard_latest/dashboard_view.dart @@ -103,8 +103,11 @@ class _DashboardViewState extends State { @override Widget build(BuildContext context) { - bool isNurse = (Provider.of(context, listen: false).user?.type) == UsersTypes.normal_user; final user = Provider.of(context, listen: false).user; + bool isEngineer = (user?.type) == UsersTypes.engineer; + ///Need to check which info need to show on dashboard for quality user. + bool isQualityUser = (user?.type) == UsersTypes.qualityUser; + return Stack( children: [ Scaffold( @@ -126,7 +129,7 @@ class _DashboardViewState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, - children: [16.height, ProgressFragment(), 16.height, if (!isNurse) const RequestsFragment(), const RequestCategoryFragment()], + children: [16.height, ProgressFragment(), 16.height, if (isEngineer) const RequestsFragment(), const RequestCategoryFragment()], ), ), ), diff --git a/lib/modules/internal_audit_module/models/internal_audit_attachment_model.dart b/lib/modules/internal_audit_module/models/internal_audit_attachment_model.dart index 5e21d5ae..f2b14df1 100644 --- a/lib/modules/internal_audit_module/models/internal_audit_attachment_model.dart +++ b/lib/modules/internal_audit_module/models/internal_audit_attachment_model.dart @@ -9,7 +9,6 @@ class InternalAuditAttachments { String? createdBy; InternalAuditAttachments.fromJson(Map json) { - log('name is ${json['name']}'); id = json['id']; name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null; originalName = json['originalName']; diff --git a/lib/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart b/lib/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart index eff65653..8b6df199 100644 --- a/lib/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart +++ b/lib/modules/internal_audit_module/pages/equipment_internal_audit/update_equipment_internal_audit_page.dart @@ -61,6 +61,7 @@ class _UpdateEquipmentInternalAuditPageState extends State GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? []; calculateWorkingTime(); @@ -92,33 +93,36 @@ class _UpdateEquipmentInternalAuditPageState extends State(context, listen: false); - - showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); - formModel.auditTimers ??= []; - if (formModel.auditTimePicker != null) { - int durationInSecond = formModel.auditTimePicker!.endAt!.difference(formModel.auditTimePicker!.startAt!).inSeconds; - formModel.auditTimers?.add( - InternalAuditTimerModel( - id: 0, - startDate: formModel.auditTimePicker!.startAt!.toIso8601String(), // Handle potential null - endDate: formModel.auditTimePicker!.endAt?.toIso8601String(), // Handle potential null - totalWorkingHour: ((durationInSecond) / 60 / 60), - ), - ); + if ( formModel.startTime == null) { + Fluttertoast.showToast(msg: "Working Hours Required"); + return; } - formModel.timerModelList?.forEach((timer) { - int durationInSecond = timer.endAt!.difference(timer.startAt!).inSeconds; - formModel.auditTimers?.add( - InternalAuditTimerModel( - id: 0, - startDate: timer.startAt!.toIso8601String(), // Handle potential null - endDate: timer.endAt?.toIso8601String(), // Handle potential null - totalWorkingHour: ((durationInSecond) / 60 / 60), - ), - ); - }); - + showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); _formKey.currentState!.save(); formModel.attachments = []; for (var item in _attachments) { @@ -297,7 +301,7 @@ class _UpdateEquipmentInternalAuditPageState extends State GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? []; calculateWorkingTime(); @@ -91,34 +92,38 @@ class _UpdateSystemInternalAuditPageState extends State(context, listen: false); - showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); - - formModel.auditTimers ??= []; - if (formModel.auditTimePicker != null) { - int durationInSecond = formModel.auditTimePicker!.endAt!.difference(formModel.auditTimePicker!.startAt!).inSeconds; - formModel.auditTimers?.add( - InternalAuditTimerModel( - id: 0, - startDate: formModel.auditTimePicker!.startAt!.toIso8601String(), // Handle potential null - endDate: formModel.auditTimePicker!.endAt?.toIso8601String(), // Handle potential null - // endDate: formModel.auditTimePicker!.startAt?.add(const Duration(hours: 1)).toIso8601String(), // Handle potential null - totalWorkingHour: ((durationInSecond) / 60 / 60), - ), - ); + if ( formModel.startTime == null) { + Fluttertoast.showToast(msg: "Working Hours Required"); + return; } - formModel.timerModelList?.forEach((timer) { - int durationInSecond = timer.endAt!.difference(timer.startAt!).inSeconds; - formModel.auditTimers?.add( - InternalAuditTimerModel( - id: 0, - startDate: timer.startAt!.toIso8601String(), // Handle potential null - endDate: timer.endAt?.toIso8601String(), // Handle potential null - totalWorkingHour: ((durationInSecond) / 60 / 60), - ), - ); - }); + showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); _formKey.currentState!.save(); formModel.attachments = []; @@ -280,7 +285,7 @@ class _UpdateSystemInternalAuditPageState extends State { @override void initState() { - ///this is temp check for internal audit - canPickTime = widget.showPicker == false ? false : ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false; + ///this is temp check for internal audit to always show picker. + canPickTime = widget.showTimer == false ? true : ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false; _startAt = widget.timer?.startAt; _endAt = widget.timer?.endAt; _running = _startAt != null && _endAt == null; @@ -286,50 +286,51 @@ class _AppTimerState extends State { ], 8.height, ], - Container( - // width: widget.width ?? 100 * AppStyle.getScaleFactor(context), - height: 56.toScreenHeight, - padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), - decoration: widget.decoration ?? - BoxDecoration( - color: context.isDark && !widget.enabled - ? AppColor.neutral60 - : !widget.enabled - // backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, - ? AppColor.neutral40 - : AppColor.fieldBgColor(context), - borderRadius: BorderRadius.circular(10), - boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], - ), - child: _loading - ? const SizedBox.square(dimension: 18, child: CircularProgressIndicator(color: Colors.white)) - : Row( - children: [ - Expanded( - child: ValueListenableBuilder( - valueListenable: _period, - builder: (context, value, _) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - (widget.label ?? "Timer").tinyFont(context), - value.bodyText(context).custom( - color: widget.enabled - ? context.isDark - ? AppColor.neutral30 - : AppColor.neutral50 - : AppColor.neutral20, - ), - ], - ); - }, - ), - ), - if (widget.enabled) Icon(_running ? Icons.pause : Icons.play_arrow), - ], + if (widget.showTimer) + Container( + // width: widget.width ?? 100 * AppStyle.getScaleFactor(context), + height: 56.toScreenHeight, + padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), + decoration: widget.decoration ?? + BoxDecoration( + color: context.isDark && !widget.enabled + ? AppColor.neutral60 + : !widget.enabled + // backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, + ? AppColor.neutral40 + : AppColor.fieldBgColor(context), + borderRadius: BorderRadius.circular(10), + boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], ), - ).onPress(_loading || !widget.enabled ? null : _onPressed), + child: _loading + ? const SizedBox.square(dimension: 18, child: CircularProgressIndicator(color: Colors.white)) + : Row( + children: [ + Expanded( + child: ValueListenableBuilder( + valueListenable: _period, + builder: (context, value, _) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + (widget.label ?? "Timer").tinyFont(context), + value.bodyText(context).custom( + color: widget.enabled + ? context.isDark + ? AppColor.neutral30 + : AppColor.neutral50 + : AppColor.neutral20, + ), + ], + ); + }, + ), + ), + if (widget.enabled) Icon(_running ? Icons.pause : Icons.play_arrow), + ], + ), + ).onPress(_loading || !widget.enabled ? null : _onPressed), ], ); }