timer fixes

design_3.0_internal_audit_module
waseemabbasi22 11 hours ago
parent de48ca97bd
commit 2962f248e0

@ -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

@ -103,8 +103,11 @@ class _DashboardViewState extends State<DashboardView> {
@override
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;
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<DashboardView> {
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()],
),
),
),

@ -9,7 +9,6 @@ class InternalAuditAttachments {
String? createdBy;
InternalAuditAttachments.fromJson(Map<String, dynamic> 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'];

@ -61,6 +61,7 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
void populateForm() {
formModel.requestId = 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() ?? [];
calculateWorkingTime();
@ -92,33 +93,36 @@ class _UpdateEquipmentInternalAuditPageState extends State<UpdateEquipmentIntern
_onSubmit(BuildContext context) async {
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);
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<UpdateEquipmentIntern
timer: formModel.auditTimerModel,
pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''),
pickerTimer: formModel.auditTimePicker,
showPicker: false,
showTimer: false,
onPick: (timer) {
updateTimer(timer: timer);
},

@ -61,6 +61,7 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
void populateForm() {
formModel.requestId = 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() ?? [];
calculateWorkingTime();
@ -91,34 +92,38 @@ class _UpdateSystemInternalAuditPageState extends State<UpdateSystemInternalAudi
}
_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;
InternalAuditProvider provider = Provider.of<InternalAuditProvider>(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<UpdateSystemInternalAudi
// ),
AppTimer(
label: context.translation.workingHours,
showPicker: false,
showTimer: false,
timer: formModel.auditTimerModel,
// enabled:formModel.endTime==null,
pickerFromDate: DateTime.tryParse(widget.model?.createdDate ?? ''),

@ -22,7 +22,7 @@ class AppTimer extends StatefulWidget {
final TextStyle? style;
final BoxDecoration? decoration;
final bool enabled;
final bool showPicker;
final bool showTimer;
final String? label;
final double? width;
@ -41,7 +41,7 @@ class AppTimer extends StatefulWidget {
this.onPick,
this.timerProgress,
this.enabled = true,
this.showPicker = true,
this.showTimer = true,
}) : super(key: key);
@override
@ -128,8 +128,8 @@ class _AppTimerState extends State<AppTimer> {
@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<AppTimer> {
],
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<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),
],
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<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