Merge remote-tracking branch 'origin/main_design2.0' into main_design2.0

design_3.0_demo_module
Sikander Saleem 2 years ago
commit b03f350a2c

@ -1,5 +1,4 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
@ -149,11 +148,12 @@ class AssetTransferProvider extends ChangeNotifier {
} }
} }
Future<int> updateRequest({ Future<int> updateRequest({@required AssetTransfer assetTransfer}) async {
@required AssetTransfer assetTransfer,
}) async {
Response response; Response response;
try { try {
assetTransfer.receiverStartDate = assetTransfer.timer?.startAt?.toIso8601String();
assetTransfer.receiverEndDate = assetTransfer.timer?.endAt?.toIso8601String();
assetTransfer.receiverWorkingHours = (((assetTransfer.timer?.durationInSecond ?? 0) / 60) / 60).toStringAsFixed(2);
response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: assetTransfer.toJson()); response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: assetTransfer.toJson());
print(response.body); print(response.body);

@ -2,6 +2,7 @@ import 'package:flutter/src/widgets/framework.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/device/asset.dart'; import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/timer_model.dart';
import 'asset_transfer_attachment.dart'; import 'asset_transfer_attachment.dart';
@ -64,7 +65,8 @@ class AssetTransfer {
this.senderMachineStatusName, this.senderMachineStatusName,
this.senderSiteName, this.senderSiteName,
this.supplierId, this.supplierId,
this.supplierName this.supplierName,
this.timer,
}); });
AssetTransfer.fromJson(dynamic json) { AssetTransfer.fromJson(dynamic json) {
@ -104,6 +106,15 @@ class AssetTransfer {
receiverWorkingHours = json['receiverWorkingHours']; receiverWorkingHours = json['receiverWorkingHours'];
receiverTravelingHours = json['receiverTravelingHours']; receiverTravelingHours = json['receiverTravelingHours'];
receiverEngSignature = json['receiverEngSignature']; receiverEngSignature = json['receiverEngSignature'];
try {
timer = TimerModel(startAt: DateTime.tryParse(receiverStartDate ?? ""), endAt: DateTime.tryParse(receiverEndDate));
if (timer.endAt != null && timer.startAt != null) {
timer.durationInSecond = (timer.endAt.difference(timer.startAt))?.inSeconds;
receiverWorkingHours = (((timer.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2);
}
} catch (e) {
print(e);
}
if (json['receiverAttachments'] != null) { if (json['receiverAttachments'] != null) {
receiverAttachments = []; receiverAttachments = [];
json['receiverAttachments'].forEach((v) { json['receiverAttachments'].forEach((v) {
@ -195,6 +206,7 @@ class AssetTransfer {
bool applied; bool applied;
String createdOn; String createdOn;
String modifiedOn; String modifiedOn;
TimerModel timer = TimerModel();
AssetTransfer copyWith({ AssetTransfer copyWith({
num id, num id,
@ -255,7 +267,8 @@ class AssetTransfer {
String modelName, String modelName,
int manufacturerId, int manufacturerId,
String manufacturerName, String manufacturerName,
String destDepartmentName String destDepartmentName,
TimerModel timer,
}) => }) =>
AssetTransfer( AssetTransfer(
id: id ?? this.id, id: id ?? this.id,
@ -315,8 +328,8 @@ class AssetTransfer {
modelId: modelId ?? this.modelId, modelId: modelId ?? this.modelId,
modelName: modelName ?? this.modelName, modelName: modelName ?? this.modelName,
manufacturerId: manufacturerId ?? this.manufacturerId, manufacturerId: manufacturerId ?? this.manufacturerId,
manufacturerName:manufacturerName??this.manufacturerName timer: timer ?? this.timer,
); manufacturerName: manufacturerName ?? this.manufacturerName);
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['id'] = id; map['id'] = id;
@ -425,10 +438,7 @@ class AssetTransfer {
return map; return map;
} }
fromDetails(AssetTransfer assetTransfer) { fromDetails(AssetTransfer assetTransfer) {
id = assetTransfer.id; id = assetTransfer.id;
transferNo = assetTransfer.transferNo; transferNo = assetTransfer.transferNo;
transferCode = assetTransfer.transferCode; transferCode = assetTransfer.transferCode;
@ -489,7 +499,6 @@ class AssetTransfer {
manufacturerName = assetTransfer.manufacturerName; manufacturerName = assetTransfer.manufacturerName;
} }
Future<bool> validate(BuildContext context) async { Future<bool> validate(BuildContext context) async {
if (assetId == null) { if (assetId == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.device}"); await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.device}");

@ -1,4 +1,3 @@
import 'dart:developer';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -10,6 +9,7 @@ import 'package:test_sa/models/new_models/building.dart';
import 'package:test_sa/models/new_models/department.dart'; import 'package:test_sa/models/new_models/department.dart';
import 'package:test_sa/models/new_models/floor.dart'; import 'package:test_sa/models/new_models/floor.dart';
import 'package:test_sa/models/new_models/site.dart'; import 'package:test_sa/models/new_models/site.dart';
import 'package:test_sa/models/timer_model.dart';
class GasRefillModel { class GasRefillModel {
GasRefillModel({ GasRefillModel({
@ -32,7 +32,8 @@ class GasRefillModel {
this.status, this.status,
this.gazRefillDetails, this.gazRefillDetails,
this.localEngineerSignature, this.localEngineerSignature,
this.localNurseSignature this.localNurseSignature,
this.timer,
}); });
GasRefillModel.fromJson(dynamic json) { GasRefillModel.fromJson(dynamic json) {
@ -44,6 +45,22 @@ class GasRefillModel {
startTime = json['startTime']; startTime = json['startTime'];
endDate = json['endDate']; endDate = json['endDate'];
endTime = json['endTime']; endTime = json['endTime'];
try {
final sd = DateTime.tryParse(startDate ?? "");
final st = DateTime.tryParse(startTime ?? "");
final ed = DateTime.tryParse(endDate ?? "");
final et = DateTime.tryParse(endTime ?? "");
timer = TimerModel(
startAt: st == null ? sd : sd.add(Duration(hours: st.hour, minutes: st.minute, seconds: st.second)),
endAt: et == null ? ed : ed.add(Duration(hours: et.hour, minutes: et.minute, seconds: et.second)),
);
if (timer.endAt != null && timer.startAt != null) {
timer.durationInSecond = (timer.endAt.difference(timer.startAt))?.inSeconds;
workingHours = (((timer.durationInSecond ?? 0) / 60) / 60);
}
} catch (e) {
print(e);
}
engSignature = json['engSignature']; engSignature = json['engSignature'];
nurseSignature = json['nurseSignature']; nurseSignature = json['nurseSignature'];
workingHours = json['workingHours']; workingHours = json['workingHours'];
@ -81,6 +98,7 @@ class GasRefillModel {
List<GasRefillDetails> gazRefillDetails; List<GasRefillDetails> gazRefillDetails;
Uint8List localNurseSignature; Uint8List localNurseSignature;
Uint8List localEngineerSignature; Uint8List localEngineerSignature;
TimerModel timer = TimerModel();
GasRefillModel copyWith({ GasRefillModel copyWith({
num id, num id,
@ -101,6 +119,7 @@ class GasRefillModel {
AssignedEmployee assignedEmployee, AssignedEmployee assignedEmployee,
Lookup status, Lookup status,
List<GasRefillDetails> gazRefillDetails, List<GasRefillDetails> gazRefillDetails,
TimerModel timer,
}) => }) =>
GasRefillModel( GasRefillModel(
id: id ?? this.id, id: id ?? this.id,
@ -121,6 +140,7 @@ class GasRefillModel {
assignedEmployee: assignedEmployee ?? this.assignedEmployee, assignedEmployee: assignedEmployee ?? this.assignedEmployee,
status: status ?? this.status, status: status ?? this.status,
gazRefillDetails: gazRefillDetails ?? this.gazRefillDetails, gazRefillDetails: gazRefillDetails ?? this.gazRefillDetails,
timer: timer ?? this.timer,
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -200,15 +220,7 @@ class GasRefillModel {
} }
class GasRefillDetails { class GasRefillDetails {
GasRefillDetails({ GasRefillDetails({this.id, this.gasType, this.cylinderType, this.cylinderSize, this.requestedQty, this.deliverdQty, this.selectedForEditing});
this.id,
this.gasType,
this.cylinderType,
this.cylinderSize,
this.requestedQty,
this.deliverdQty,
this.selectedForEditing
});
GasRefillDetails.fromJson(dynamic json) { GasRefillDetails.fromJson(dynamic json) {
id = json['id']; id = json['id'];

@ -9,6 +9,7 @@ import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart'; import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/models/service_request/wo_call_request.dart'; import 'package:test_sa/models/service_request/wo_call_request.dart';
import 'package:test_sa/models/service_request/wo_parent.dart'; import 'package:test_sa/models/service_request/wo_parent.dart';
import 'package:test_sa/models/timer_model.dart';
import '../../attachment.dart'; import '../../attachment.dart';
import '../device/asset.dart'; import '../device/asset.dart';
@ -54,6 +55,7 @@ class ServiceReport {
this.woParentDto, this.woParentDto,
this.loanAvailablity, this.loanAvailablity,
this.assetLoan, this.assetLoan,
this.timer,
}); });
ServiceReport.fromJson(dynamic json) { ServiceReport.fromJson(dynamic json) {
@ -88,6 +90,15 @@ class ServiceReport {
startofWorkTime = json['startofWorkTime']; startofWorkTime = json['startofWorkTime'];
endofWorkTime = json['endofWorkTime']; endofWorkTime = json['endofWorkTime'];
workingHours = json['workingHours']; workingHours = json['workingHours'];
try {
timer = TimerModel(startAt: DateTime.tryParse(startofWorkTime ?? ""), endAt: DateTime.tryParse(endofWorkTime));
if (timer.endAt != null && timer.startAt != null) {
timer.durationInSecond = (timer.endAt.difference(timer.startAt))?.inSeconds;
workingHours = (((timer.durationInSecond ?? 0) / 60) / 60);
}
} catch (e) {
print(e);
}
travelingHours = json['travelingHours']; travelingHours = json['travelingHours'];
travelingExpenses = json['travelingExpenses']; travelingExpenses = json['travelingExpenses'];
faultDescription = json['faultDescription'] != null ? FaultDescription.fromJson(json['faultDescription']) : null; faultDescription = json['faultDescription'] != null ? FaultDescription.fromJson(json['faultDescription']) : null;
@ -155,6 +166,7 @@ class ServiceReport {
WoParent woParentDto; WoParent woParentDto;
Lookup loanAvailablity; Lookup loanAvailablity;
AssetInfo assetLoan; AssetInfo assetLoan;
TimerModel timer = TimerModel();
ServiceReport copyWith({ ServiceReport copyWith({
num id, num id,
num parentWOId, num parentWOId,
@ -191,6 +203,7 @@ class ServiceReport {
WoParent woParentDto, WoParent woParentDto,
Lookup loanAvailablity, Lookup loanAvailablity,
AssetInfo assetLoan, AssetInfo assetLoan,
TimerModel timer,
}) => }) =>
ServiceReport( ServiceReport(
id: id ?? this.id, id: id ?? this.id,
@ -228,6 +241,7 @@ class ServiceReport {
woParentDto: woParentDto ?? this.woParentDto, woParentDto: woParentDto ?? this.woParentDto,
loanAvailablity: loanAvailablity ?? this.loanAvailablity, loanAvailablity: loanAvailablity ?? this.loanAvailablity,
assetLoan: assetLoan ?? this.assetLoan, assetLoan: assetLoan ?? this.assetLoan,
timer: timer ?? this.timer,
); );
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
@ -306,6 +320,14 @@ class ServiceReport {
} }
Future<bool> validate(BuildContext context) async { Future<bool> validate(BuildContext context) async {
if (timer?.startAt == null) {
await Fluttertoast.showToast(msg: "Working Hours Required");
return false;
}
if (timer?.endAt == null) {
await Fluttertoast.showToast(msg: "Please Stop The Timer");
return false;
}
if (calllastSituation == null) { if (calllastSituation == null) {
await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.callLastSituation}"); await Fluttertoast.showToast(msg: "${context.translation.youHaveToSelect} ${context.translation.callLastSituation}");
return false; return false;

@ -11,14 +11,10 @@ import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/models/device/asset_transfer.dart'; import 'package:test_sa/models/device/asset_transfer.dart';
import 'package:test_sa/models/subtitle.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/views/app_style/sizing.dart'; import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
import '../../../controllers/validator/validator.dart'; import '../../../controllers/validator/validator.dart';
import '../../../extensions/text_extensions.dart'; import '../../../extensions/text_extensions.dart';
import '../../../models/lookup.dart'; import '../../../models/lookup.dart';
@ -27,6 +23,7 @@ import '../../../new_views/common_widgets/default_app_bar.dart';
import '../../../new_views/common_widgets/single_item_drop_down_menu.dart'; import '../../../new_views/common_widgets/single_item_drop_down_menu.dart';
import '../../../providers/gas_request_providers/gas_status_provider.dart'; import '../../../providers/gas_request_providers/gas_status_provider.dart';
import '../../widgets/e_signature/e_signature.dart'; import '../../widgets/e_signature/e_signature.dart';
import '../../widgets/timer/app_timer.dart';
class UpdateDeviceTransfer extends StatefulWidget { class UpdateDeviceTransfer extends StatefulWidget {
final AssetTransfer model; final AssetTransfer model;
@ -51,14 +48,14 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
_update() async { _update() async {
// if (_formModel?.timer?.startAt == null) { if (_formModel?.timer?.startAt == null) {
// await Fluttertoast.showToast(msg: "Working Hours Required"); await Fluttertoast.showToast(msg: "Working Hours Required");
// return false; return false;
// } }
// if (_formModel?.timer?.endAt == null) { if (_formModel?.timer?.endAt == null) {
// await Fluttertoast.showToast(msg: "Please Stop The Timer"); await Fluttertoast.showToast(msg: "Please Stop The Timer");
// return false; return false;
// } }
_validate = true; _validate = true;
if (!(_formKey.currentState.validate())) { if (!(_formKey.currentState.validate())) {
setState(() {}); setState(() {});
@ -68,8 +65,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
_isLoading = true; _isLoading = true;
setState(() {}); setState(() {});
int status = await _deviceTransferProvider.updateRequest( int status = await _deviceTransferProvider.updateRequest(assetTransfer: _formModel);
assetTransfer: _formModel);
_isLoading = false; _isLoading = false;
setState(() {}); setState(() {});
if (status >= 200 && status < 300) { if (status >= 200 && status < 300) {
@ -119,7 +115,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
SingleChildScrollView( SingleChildScrollView(
padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)), padding: EdgeInsets.all(12 * AppStyle.getScaleFactor(context)),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
_buildCard(), _buildCard(),
8.height, 8.height,
@ -127,8 +123,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
initialValue: widget.isSender ? _formModel.senderTravelingHours : _formModel.receiverTravelingHours, initialValue: widget.isSender ? _formModel.senderTravelingHours : _formModel.receiverTravelingHours,
labelText: context.translation.travelingHours, labelText: context.translation.travelingHours,
onSaved: (value) { onSaved: (value) {
widget.isSender? _formModel.senderTravelingHours widget.isSender ? _formModel.senderTravelingHours : _formModel.receiverTravelingHours = value;
: _formModel.receiverTravelingHours= value;
//_formModel?.workingHours = double.tryParse(value); //_formModel?.workingHours = double.tryParse(value);
// _formModel.travelingHours = value; // _formModel.travelingHours = value;
}, },
@ -136,25 +131,24 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only", validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
), ),
8.height, 8.height,
AppTextFormField( AppTimer(
labelText: context.translation.workingHours, label: context.translation.workingHours,
initialValue: widget.isSender?_formModel.senderWorkingHours:_formModel.receiverWorkingHours, timer: _formModel.timer,
onSaved:(value){ enabled: _formModel.receiverEndDate == null,
widget.isSender? onChange: (timer) async {
_formModel?.senderWorkingHours = value:_formModel?.receiverWorkingHours = value; _formModel.timer = timer;
// _formModel.timer = timer; return true;
// _formModel.workingHours = (((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0";
}, },
textInputType: TextInputType.number,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
), ),
8.height, 8.height,
///TBD ///TBD
Consumer<GasStatusProvider>(builder: (context, snapshot, _) { Consumer<GasStatusProvider>(builder: (context, snapshot, _) {
return SingleItemDropDownMenu<Lookup, GasStatusProvider>( return SingleItemDropDownMenu<Lookup, GasStatusProvider>(
context: context, context: context,
title: context.translation.reportStatus, title: context.translation.reportStatus,
initialValue: snapshot.items?.firstWhere((element) => element.name == (widget.isSender?_formModel.senderMachineStatusName:_formModel.receiverMachineStatusName), orElse: () => null), initialValue: snapshot.items
?.firstWhere((element) => element.name == (widget.isSender ? _formModel.senderMachineStatusName : _formModel.receiverMachineStatusName), orElse: () => null),
onSelect: (value) { onSelect: (value) {
if (widget.isSender) { if (widget.isSender) {
_formModel.senderMachineStatusName = value.name; _formModel.senderMachineStatusName = value.name;
@ -175,8 +169,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
textInputType: TextInputType.multiline, textInputType: TextInputType.multiline,
alignLabelWithHint: true, alignLabelWithHint: true,
onSaved: (value) { onSaved: (value) {
widget.isSender? widget.isSender ? _formModel.senderComment = value : _formModel.receiverComment = value;
_formModel.senderComment = value:_formModel.receiverComment=value;
}, },
), ),
8.height, 8.height,
@ -187,8 +180,9 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
onSaved: (signature) { onSaved: (signature) {
_signature = signature; _signature = signature;
if (signature == null || signature.isEmpty) return; if (signature == null || signature.isEmpty) return;
widget.isSender? _formModel.senderEngSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}": widget.isSender
_formModel.receiverEngSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"; ? _formModel.senderEngSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}"
: _formModel.receiverEngSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
base64Encode(signature); base64Encode(signature);
}, },
@ -230,6 +224,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
'${context.translation.assetName}: ${_formModel.assetName}', '${context.translation.assetName}: ${_formModel.assetName}',
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)), style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
), ),
///TBD ///TBD
Text( Text(
'${context.translation.requesterName}: ', '${context.translation.requesterName}: ',

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -15,7 +14,6 @@ import 'package:test_sa/models/timer_model.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import '../../../../controllers/providers/api/hospitals_provider.dart'; import '../../../../controllers/providers/api/hospitals_provider.dart';
import '../../../../extensions/text_extensions.dart'; import '../../../../extensions/text_extensions.dart';
import '../../../../models/new_models/gas_refill_model.dart'; import '../../../../models/new_models/gas_refill_model.dart';
@ -23,7 +21,7 @@ import '../../../../new_views/common_widgets/app_text_form_field.dart';
import '../../../../new_views/common_widgets/default_app_bar.dart'; import '../../../../new_views/common_widgets/default_app_bar.dart';
import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart'; import '../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
import '../../../../providers/gas_request_providers/gas_status_provider.dart'; import '../../../../providers/gas_request_providers/gas_status_provider.dart';
import '../../../widgets/timer/app_timer.dart';
class RequestGasRefill extends StatefulWidget { class RequestGasRefill extends StatefulWidget {
static const String id = "/request-gas-refill"; static const String id = "/request-gas-refill";
@ -67,6 +65,14 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
} }
_onSubmit(BuildContext context) async { _onSubmit(BuildContext context) async {
if (_formModel.timer?.startAt == null) {
await Fluttertoast.showToast(msg: "Working Hours Required");
return false;
}
if (_formModel.timer?.endAt == null) {
await Fluttertoast.showToast(msg: "Please Stop The Timer");
return false;
}
if (_formModel.gazRefillDetails.isEmpty) { if (_formModel.gazRefillDetails.isEmpty) {
if (!(await _addNewModel(context))) return; if (!(await _addNewModel(context))) return;
} }
@ -133,7 +139,6 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_userProvider = Provider.of<UserProvider>(context); _userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context); _settingProvider = Provider.of<SettingProvider>(context);
if (_gasRefillProvider == null) { if (_gasRefillProvider == null) {
@ -191,6 +196,7 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
children: [ children: [
Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))), Text(context.translation.gasRefill, style: AppTextStyles.heading5.copyWith(color: const Color(0xFF3B3D4A))),
8.height, 8.height,
/// TBD /// TBD
Text( Text(
'Gas Request:', 'Gas Request:',
@ -212,14 +218,14 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
).paddingAll(16), ).paddingAll(16),
), ),
12.height, 12.height,
AppTextFormField( AppTimer(
labelText: context.translation.workingHours, label: context.translation.workingHours,
onSaved:(value){ timer: _formModel.timer,
_formModel?.workingHours = double.tryParse(value); enabled: _formModel.endDate == null,
onChange: (timer) async {
_formModel.timer = timer;
return true;
}, },
textInputType: TextInputType.number,
controller: _workingHoursController,
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
), ),
12.height, 12.height,
SingleItemDropDownMenu<Lookup, GasStatusProvider>( SingleItemDropDownMenu<Lookup, GasStatusProvider>(
@ -241,25 +247,26 @@ class _RequestGasRefillState extends State<RequestGasRefill> {
validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only", validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
), ),
12.height, 12.height,
/// TBD /// TBD
AppTextFormField( AppTextFormField(
labelText: context.translation.comments, labelText: context.translation.comments,
textInputType: TextInputType.multiline, textInputType: TextInputType.multiline,
alignLabelWithHint: true, alignLabelWithHint: true,
controller: _commentController, controller: _commentController,
onSaved: (value){ onSaved: (value) {},
},
), ),
], ],
).paddingAll(16) ).paddingAll(16))
).expanded, .expanded,
AppFilledButton( AppFilledButton(
label: widget.gasRefillModel == null ? context.translation.submit : context.translation.update, label: widget.gasRefillModel == null ? context.translation.submit : context.translation.update,
onPressed:()async{_onSubmit.call(context);}, onPressed: () async {
_onSubmit.call(context);
},
).paddingAll(16), ).paddingAll(16),
], ],
) )),
),
), ),
), ),
); );

@ -31,6 +31,7 @@ import '../../../../../new_views/common_widgets/default_app_bar.dart';
import '../../../../../new_views/common_widgets/single_item_drop_down_menu.dart'; import '../../../../../new_views/common_widgets/single_item_drop_down_menu.dart';
import '../../../../widgets/date_and_time/date_picker.dart'; import '../../../../widgets/date_and_time/date_picker.dart';
import '../../../../widgets/images/multi_image_picker.dart'; import '../../../../widgets/images/multi_image_picker.dart';
import '../../../../widgets/timer/app_timer.dart';
/// todo : TBD (compare with the design) /// todo : TBD (compare with the design)
class CreateServiceReport extends StatefulWidget { class CreateServiceReport extends StatefulWidget {
@ -142,11 +143,13 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
}, },
), ),
8.height, 8.height,
AppTextFormField( AppTimer(
labelText: context.translation.workingHours, label: context.translation.workingHours,
textInputType: TextInputType.number, timer: _serviceReport.timer,
onSaved: (text) { enabled: _serviceReport.endofWorkTime == null,
_serviceReport.workingHours = num.tryParse(text ?? ""); onChange: (timer) async {
_serviceReport.timer = timer;
return true;
}, },
), ),
8.height, 8.height,

@ -31,6 +31,7 @@ import '../../../../widgets/date_and_time/date_picker.dart';
import '../../../../widgets/e_signature/e_signature.dart'; import '../../../../widgets/e_signature/e_signature.dart';
import '../../../../widgets/images/multi_image_picker.dart'; import '../../../../widgets/images/multi_image_picker.dart';
import '../../../../widgets/status/report/service_report_assistant_employee_menu.dart'; import '../../../../widgets/status/report/service_report_assistant_employee_menu.dart';
import '../../../../widgets/timer/app_timer.dart';
class EditServiceReport extends StatefulWidget { class EditServiceReport extends StatefulWidget {
static final String id = "/edit-service-report"; static final String id = "/edit-service-report";
@ -108,7 +109,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
children: [ children: [
SingleChildScrollView( SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Card( Card(
child: Column( child: Column(
@ -131,12 +132,13 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
}, },
), ),
8.height, 8.height,
AppTextFormField( AppTimer(
labelText: context.translation.workingHours, label: context.translation.workingHours,
textInputType: TextInputType.number, timer: _serviceReport.timer,
initialValue: _serviceReport.workingHours?.toString(), enabled: _serviceReport.endofWorkTime == null,
onSaved: (text) { onChange: (timer) async {
_serviceReport.workingHours = num.tryParse(text ?? ""); _serviceReport.timer = timer;
return true;
}, },
), ),
8.height, 8.height,

@ -14,9 +14,11 @@ class AppTimer extends StatefulWidget {
final Future<bool> Function(TimerModel) onChange; final Future<bool> Function(TimerModel) onChange;
final TextStyle style; final TextStyle style;
final bool enabled; final bool enabled;
final String label;
const AppTimer({ const AppTimer({
Key key, Key key,
this.label,
this.timer, this.timer,
this.onChange, this.onChange,
this.style, this.style,
@ -121,7 +123,7 @@ class _AppTimerState extends State<AppTimer> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
"Timer".tinyFont(context), (widget.label ?? "Timer").tinyFont(context),
value.bodyText(context).custom(color: AppColor.neutral50), value.bodyText(context).custom(color: AppColor.neutral50),
], ],
); );

Loading…
Cancel
Save