improvements

main_design2.0
Sikander Saleem 3 years ago
parent dc983f0db4
commit 300bc0a1a6

@ -87,7 +87,7 @@ class Pentry {
map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5); map["workingHours"] = (timer.durationInSecond / 60 / 60).toStringAsFixed(5);
} }
if (files?.isNotEmpty ?? false) { if (files?.isNotEmpty ?? false) {
map["vAttachments"] = files.map((file) => {"attachmentName": (file.path.split("/").last + base64Encode(file.readAsBytesSync()))}).toList(); map["vAttachments"] = files.map((file) => {"attachmentName": _isLocalUrl(file.path) ? (file.path.split("/").last + "|" + base64Encode(file.readAsBytesSync())): file.path}).toList();
} }
map["travelingHours"] = travelingHours; map["travelingHours"] = travelingHours;
// if(contacts?.isNotEmpty == true) { // if(contacts?.isNotEmpty == true) {
@ -104,7 +104,10 @@ class Pentry {
map["engSignature"] = signatureEngineer; //"${DateTime.now().toIso8601String()}.png|$signatureEngineer"; map["engSignature"] = signatureEngineer; //"${DateTime.now().toIso8601String()}.png|$signatureEngineer";
return map; return map;
} }
bool _isLocalUrl(String url) {
if (url?.isEmpty != false) return false;
return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
}
factory Pentry.fromMap(Map<String, dynamic> map) { factory Pentry.fromMap(Map<String, dynamic> map) {
// List<Contact> contacts = []; // List<Contact> contacts = [];
// if(map['contacts'] != null){ // if(map['contacts'] != null){
@ -120,6 +123,7 @@ class Pentry {
List<String> files = []; List<String> files = [];
if (map["vAttachments"] != null) if (map["vAttachments"] is List) { if (map["vAttachments"] != null) if (map["vAttachments"] is List) {
List list = map["vAttachments"]; List list = map["vAttachments"];
list.removeWhere((element) => (element["attachmentURL"]?.toString() ?? "").isEmpty);
files = list.map((e) => URLs.getFileUrl(e["attachmentName"])).toList(); files = list.map((e) => URLs.getFileUrl(e["attachmentName"])).toList();
} }
List<PPMCheckList> ppmCheckLists = []; List<PPMCheckList> ppmCheckLists = [];
@ -146,7 +150,11 @@ class Pentry {
ppmCheckLists: ppmCheckLists, ppmCheckLists: ppmCheckLists,
calibrationTools: calibrationTools, calibrationTools: calibrationTools,
pmKits: pmKits, pmKits: pmKits,
files: files.map((e) => File(e)).toList(), files: files?.map((e) {
print("${map["id"]}:${files?.length}:e:$e");
return File(e);
})?.toList() ??
[],
signatureNurse: URLs.getFileUrl(map["nurseSignature"]), signatureNurse: URLs.getFileUrl(map["nurseSignature"]),
signatureEngineer: URLs.getFileUrl(map["engSignature"]), signatureEngineer: URLs.getFileUrl(map["engSignature"]),
); );

@ -144,13 +144,13 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
ASmallButton( ASmallButton(
text: _subtitle.edit, text: _subtitle.edit,
onPressed: (_isSender) onPressed: (_isSender)
? () { ? ( _model.sender.status?.name=="Closed" ? null: () {
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer( builder: (_) => UpdateDeviceTransfer(
model: _model, model: _model,
isSender: true, isSender: true,
))); )));
} })
: null, : null,
), ),
], ],
@ -170,13 +170,13 @@ class _DeviceTransferDetailsState extends State<DeviceTransferDetails> {
ASmallButton( ASmallButton(
text: _subtitle.edit, text: _subtitle.edit,
onPressed: (_isReceiver) onPressed: (_isReceiver)
? () { ? ( _model.receiver.status?.name=="Closed" ? null: () {
Navigator.of(context).push(MaterialPageRoute( Navigator.of(context).push(MaterialPageRoute(
builder: (_) => UpdateDeviceTransfer( builder: (_) => UpdateDeviceTransfer(
model: _model, model: _model,
isSender: false, isSender: false,
))); )));
} })
: null, : null,
), ),
], ],

@ -121,26 +121,28 @@ class _GasRefillDetailsState extends State<GasRefillDetails> {
color: Theme.of(context).colorScheme.onPrimary, color: Theme.of(context).colorScheme.onPrimary,
buttonSize: 42, buttonSize: 42,
backgroundColor: AColors.green, backgroundColor: AColors.green,
onPressed: () async { onPressed: (widget.model.status?.value ?? 0) == 2
// _enableEdit = !_enableEdit; ? null
print(widget.model.startDate); : () async {
_model?.fromGasRefillModel(widget.model); // _enableEdit = !_enableEdit;
print(widget.model.startDate); print(widget.model.startDate);
// setState(() {}); _model?.fromGasRefillModel(widget.model);
Navigator.push( print(widget.model.startDate);
context, // setState(() {});
MaterialPageRoute( Navigator.push(
builder: (context) => RequestGasRefill( context,
gasRefillModel: widget.model, MaterialPageRoute(
), builder: (context) => RequestGasRefill(
), gasRefillModel: widget.model,
).then((value) { ),
if (value != null) { ),
_model = value; ).then((value) {
} if (value != null) {
}); _model = value;
setState(() {}); }
}, });
setState(() {});
},
), ),
const SizedBox( const SizedBox(
width: 16, width: 16,

Loading…
Cancel
Save