timer fixes

design_3.0_internal_audit_module
waseemabbasi22 3 months ago
parent de48ca97bd
commit 2962f248e0

@ -4,13 +4,13 @@ class URLs {
static const String appReleaseBuildNumber = "28"; static const String appReleaseBuildNumber = "28";
// static const host1 = "https://atomsm.hmg.com"; // production url // static const host1 = "https://atomsm.hmg.com"; // production url
static const host1 = "https://atomsmdev.hmg.com"; // local DEV 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://atomsmuat.hmg.com"; // local UAT url
// static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url // static const host1 = "http://10.201.111.125:9495"; // temporary Server UAT url
// static String _baseUrl = "$_host/mobile"; // static String _baseUrl = "$_host/mobile";
// static final String _baseUrl = "$_host/v2/mobile"; // new V2 apis 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/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/v3/mobile"; // v3 for production CM,PM,TM
// static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation // static final String _baseUrl = "$_host/v5/mobile"; // v5 for data segregation

@ -103,8 +103,11 @@ class _DashboardViewState extends State<DashboardView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isNurse = (Provider.of<UserProvider>(context, listen: false).user?.type) == UsersTypes.normal_user;
final user = Provider.of<UserProvider>(context, listen: false).user; final user = Provider.of<UserProvider>(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( return Stack(
children: [ children: [
Scaffold( Scaffold(
@ -126,7 +129,7 @@ class _DashboardViewState extends State<DashboardView> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, 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()],
), ),
), ),
), ),

@ -9,7 +9,6 @@ class InternalAuditAttachments {
String? createdBy; String? createdBy;
InternalAuditAttachments.fromJson(Map<String, dynamic> json) { InternalAuditAttachments.fromJson(Map<String, dynamic> json) {
log('name is ${json['name']}');
id = json['id']; id = json['id'];
name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null; name = (json['name'] != null && !json['name'].toString().startsWith('data:image/jpeg')) ? json['name'] : null;
originalName = json['originalName']; originalName = json['originalName'];

@ -61,6 +61,7 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
void populateForm() { void populateForm() {
formModel.requestId = widget.model?.id; formModel.requestId = widget.model?.id;
formModel.id = widget.model?.id; formModel.id = widget.model?.id;
formModel.debrief = widget.model?.engineerData?.debrief;
_attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? []; _attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? [];
calculateWorkingTime(); calculateWorkingTime();
@ -92,33 +93,36 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
_onSubmit(BuildContext context) async { _onSubmit(BuildContext context) async {
bool isTimerPickerEnable = ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false; bool isTimerPickerEnable = ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
/// Need to refactor this code when timer requirements clear keep picker or both.
// 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),
// ),
// );
// }
// 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),
// ),
// );
// });
InternalAuditProvider provider = Provider.of<InternalAuditProvider>(context, listen: false); InternalAuditProvider provider = Provider.of<InternalAuditProvider>(context, listen: false);
if ( formModel.startTime == null) {
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); Fluttertoast.showToast(msg: "Working Hours Required");
formModel.auditTimers ??= []; return;
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),
),
);
} }
formModel.timerModelList?.forEach((timer) { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
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),
),
);
});
_formKey.currentState!.save(); _formKey.currentState!.save();
formModel.attachments = []; formModel.attachments = [];
for (var item in _attachments) { for (var item in _attachments) {
@ -297,7 +301,7 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
timer: formModel.auditTimerModel, timer: formModel.auditTimerModel,
pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''), pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''),
pickerTimer: formModel.auditTimePicker, pickerTimer: formModel.auditTimePicker,
showPicker: false, showTimer: false,
onPick: (timer) { onPick: (timer) {
updateTimer(timer: timer); updateTimer(timer: timer);
}, },

@ -61,6 +61,7 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
void populateForm() { void populateForm() {
formModel.requestId = widget.model?.id; formModel.requestId = widget.model?.id;
formModel.id = widget.model?.id; formModel.id = widget.model?.id;
formModel.debrief = widget.model?.engineerData?.debrief;
_attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? []; _attachments = widget.model?.engineerData?.attachments?.map((e) => GenericAttachmentModel(id: e.id?.toInt() ?? 0, name: e.name!)).toList() ?? [];
calculateWorkingTime(); calculateWorkingTime();
@ -91,34 +92,38 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
} }
_onSubmit(BuildContext context) async { _onSubmit(BuildContext context) async {
/// Need to refactor this code when timer requirements clear keep picker or both.
// // 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),
// // ),
// // );
// // }
// // 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),
// // ),
// // );
// // });
bool isTimerPickerEnable = ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false; bool isTimerPickerEnable = ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
InternalAuditProvider provider = Provider.of<InternalAuditProvider>(context, listen: false); InternalAuditProvider provider = Provider.of<InternalAuditProvider>(context, listen: false);
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading()); if ( formModel.startTime == null) {
Fluttertoast.showToast(msg: "Working Hours Required");
formModel.auditTimers ??= []; return;
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),
),
);
} }
formModel.timerModelList?.forEach((timer) { showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
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),
),
);
});
_formKey.currentState!.save(); _formKey.currentState!.save();
formModel.attachments = []; formModel.attachments = [];
@ -280,7 +285,7 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
// ), // ),
AppTimer( AppTimer(
label: context.translation.workingHours, label: context.translation.workingHours,
showPicker: false, showTimer: false,
timer: formModel.auditTimerModel, timer: formModel.auditTimerModel,
// enabled:formModel.endTime==null, // enabled:formModel.endTime==null,
pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''), pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''),

@ -22,7 +22,7 @@ class AppTimer extends StatefulWidget {
final TextStyle? style; final TextStyle? style;
final BoxDecoration? decoration; final BoxDecoration? decoration;
final bool enabled; final bool enabled;
final bool showPicker; final bool showTimer;
final String? label; final String? label;
final double? width; final double? width;
@ -41,7 +41,7 @@ class AppTimer extends StatefulWidget {
this.onPick, this.onPick,
this.timerProgress, this.timerProgress,
this.enabled = true, this.enabled = true,
this.showPicker = true, this.showTimer = true,
}) : super(key: key); }) : super(key: key);
@override @override
@ -128,8 +128,8 @@ class _AppTimerState extends State<AppTimer> {
@override @override
void initState() { void initState() {
///this is temp check for internal audit ///this is temp check for internal audit to always show picker.
canPickTime = widget.showPicker == false ? false : ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false; canPickTime = widget.showTimer == false ? true : ApiManager.instance.assetGroup?.enabledEngineerTimer ?? false;
_startAt = widget.timer?.startAt; _startAt = widget.timer?.startAt;
_endAt = widget.timer?.endAt; _endAt = widget.timer?.endAt;
_running = _startAt != null && _endAt == null; _running = _startAt != null && _endAt == null;
@ -286,50 +286,51 @@ class _AppTimerState extends State<AppTimer> {
], ],
8.height, 8.height,
], ],
Container( if (widget.showTimer)
// width: widget.width ?? 100 * AppStyle.getScaleFactor(context), Container(
height: 56.toScreenHeight, // width: widget.width ?? 100 * AppStyle.getScaleFactor(context),
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth), height: 56.toScreenHeight,
decoration: widget.decoration ?? padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
BoxDecoration( decoration: widget.decoration ??
color: context.isDark && !widget.enabled BoxDecoration(
? AppColor.neutral60 color: context.isDark && !widget.enabled
: !widget.enabled ? AppColor.neutral60
// backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90, : !widget.enabled
? AppColor.neutral40 // backgroundColor: context.isDark ? AppColor.neutral20 : AppColor.neutral90,
: AppColor.fieldBgColor(context), ? AppColor.neutral40
borderRadius: BorderRadius.circular(10), : AppColor.fieldBgColor(context),
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)], 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<String>(
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), child: _loading
? const SizedBox.square(dimension: 18, child: CircularProgressIndicator(color: Colors.white))
: Row(
children: [
Expanded(
child: ValueListenableBuilder<String>(
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),
], ],
); );
} }

Loading…
Cancel
Save