add asset id to spare parts API

add attachments and signature to the sender & receiver info
main_design2.0
zaid_daoud 2 years ago
parent 5c14375d6f
commit 9dca070121

@ -140,6 +140,9 @@ class DeviceTransferProvider extends ChangeNotifier {
"senderFloorId": model.device.destFloorId,
"senderDepartmentId": model.device.destDepartmentId,
"senderRoom": model.device.destRoom,
if (model?.sender?.attachments?.isNotEmpty ?? false)
"senderAttachments":
model?.sender?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
// "senderAssignedEmployeeId": "string",
// "senderMachineStatusId": 0,
// "senderComment": "string",
@ -202,7 +205,10 @@ class DeviceTransferProvider extends ChangeNotifier {
"senderStartDate": newModel.timer?.startAt?.toIso8601String(),
"senderEndDate": newModel.timer?.endAt?.toIso8601String(),
"senderTravelingHours": newModel.travelingHours,
"senderAttachmentName": newModel?.signature ?? "",
"senderEngSignature": newModel.engSignature,
if (newModel?.attachments?.isNotEmpty ?? false)
"senderAttachments":
newModel?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
"destSiteId": oldModel.receiver.client?.id,
"destDepartmentId": oldModel.receiver.department?.id,
"destBuildingId": oldModel.device?.destBuildingId,
@ -214,8 +220,12 @@ class DeviceTransferProvider extends ChangeNotifier {
"receiverWorkingHours": oldModel.receiver.workingHours,
"receiverStartDate": oldModel.receiver.timer?.startAt?.toIso8601String(),
"receiverEndDate": oldModel.receiver.timer?.endAt?.toIso8601String(),
"receiverTravelingHours": oldModel.receiver.travelingHours,
"receiverAttachmentName": oldModel.receiver?.signature ?? "",
"receiverTravelingHours": oldModel.receiver?.travelingHours,
"receiverEngSignature": oldModel.receiver?.engSignature,
if (oldModel.receiver?.attachments?.isNotEmpty ?? false)
"receiverAttachments": oldModel.receiver?.attachments
?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})
?.toList(),
});
} else {
body.addAll({
@ -227,8 +237,11 @@ class DeviceTransferProvider extends ChangeNotifier {
"senderWorkingHours": oldModel.sender.workingHours,
"senderStartDate": oldModel.sender.timer?.startAt?.toIso8601String(),
"senderEndDate": oldModel.sender.timer?.endAt?.toIso8601String(),
"senderTravelingHours": oldModel.sender.travelingHours,
"senderAttachmentName": oldModel.sender?.signature ?? "",
"senderTravelingHours": oldModel.sender?.travelingHours,
"senderEngSignature": oldModel.sender?.engSignature,
if (oldModel.sender?.attachments?.isNotEmpty ?? false)
"senderAttachments":
oldModel.sender?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
"destSiteId": newModel.client?.id,
"destDepartmentId": newModel.department?.id,
"destBuildingId": oldModel.device?.destBuildingId,
@ -241,10 +254,12 @@ class DeviceTransferProvider extends ChangeNotifier {
"receiverStartDate": newModel.timer?.startAt?.toIso8601String(),
"receiverEndDate": newModel.timer?.endAt?.toIso8601String(),
"receiverTravelingHours": newModel.travelingHours,
"receiverAttachmentName": newModel?.signature ?? "",
"receiverEngSignature": newModel.engSignature,
if (newModel?.attachments?.isNotEmpty ?? false)
"receiverAttachments":
newModel?.attachments?.map((file) => {"attachmentName": _isLocalUrl(file.path) ? ("${file.path.split("/").last}|${base64Encode(file.readAsBytesSync())}") : file.path})?.toList(),
});
}
if (true) {}
//body.addAll(newModel.toJson(isSender));
log(body?.toString());
Response response;
@ -252,7 +267,7 @@ class DeviceTransferProvider extends ChangeNotifier {
response = await ApiManager.instance.put(URLs.updateDeviceTransfer, body: body);
print(response.body);
print("${newModel.signature}.png");
print("${newModel.engSignature}.png");
// response = await post(
// Uri.parse("$host${URLs.updateDeviceTransfer}/$requestId"),
// body: body,
@ -273,4 +288,9 @@ class DeviceTransferProvider extends ChangeNotifier {
return -1;
}
}
bool _isLocalUrl(String url) {
if (url?.isEmpty != false) return false;
return url.startsWith("/") || url.startsWith("file://") || url.substring(1).startsWith(':\\');
}
}

@ -90,13 +90,13 @@ class PartsProvider extends ChangeNotifier {
/// return state code if request complete may be 200, 404 or 403
/// for more details check http state manager
/// lib\controllers\http_status_manger\http_status_manger.dart
Future<List<Part>> getPartsList({String host, User user, String title}) async {
Future<List<Part>> getPartsList({String host, User user, num assetId, String title}) async {
Response response;
try {
if (int.tryParse(title) != null) {
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partNo": title});
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partNo": title, "assetId": assetId});
} else {
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partName": title});
response = await ApiManager.instance.post(URLs.getPartNumber, body: {if (title != null && title.isNotEmpty) "partName": title, "assetId": assetId});
}
List<Part> page = [];
if (response.statusCode >= 200 && response.statusCode < 300) {

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/models/department.dart';
import 'package:test_sa/models/device/device.dart';
@ -46,6 +48,16 @@ class DeviceTransfer {
}
factory DeviceTransfer.fromJson(Map<String, dynamic> parsedJson) {
List<String> senderFiles = [];
if (parsedJson["senderAttachments"] != null && parsedJson["senderAttachments"] is List) {
List list = parsedJson["senderAttachments"];
senderFiles = list.map((e) => (URLs.getFileUrl(e["attachmentName"]))).toList();
}
List<String> receiverFiles = [];
if (parsedJson["receiverAttachments"] != null && parsedJson["receiverAttachments"] is List) {
List list = parsedJson["receiverAttachments"];
receiverFiles = list.map((e) => (URLs.getFileUrl(e["attachmentName"]))).toList();
}
return DeviceTransfer(
id: parsedJson["id"],
title: parsedJson["transferCode"],
@ -69,6 +81,7 @@ class DeviceTransfer {
travelingHours: parsedJson["senderTravelingHours"],
comment: parsedJson["senderComment"],
workingHours: parsedJson["senderWorkingHours"],
attachments: senderFiles?.map((e) => File(e))?.toList(),
timer: TimerModel(
startAt: DateTime.tryParse(parsedJson["senderStartDate"] ?? ""),
endAt: DateTime.tryParse(parsedJson["senderEndDate"] ?? ""),
@ -84,8 +97,7 @@ class DeviceTransfer {
id: parsedJson["senderDepartmentId"],
name: parsedJson["senderDepartmentName"],
),
// todo add segnature
signature: URLs.getFileUrl(parsedJson["senderAttachmentName"]),
engSignature: URLs.getFileUrl(parsedJson["senderEngSignature"]),
status: Lookup(
id: parsedJson["senderMachineStatusId"],
name: parsedJson["senderMachineStatusName"],
@ -95,6 +107,7 @@ class DeviceTransfer {
travelingHours: parsedJson["receiverTravelingHours"],
comment: parsedJson["receiverComment"],
workingHours: parsedJson["receiverWorkingHours"],
attachments: receiverFiles?.map((e) => File(e))?.toList(),
timer: parsedJson["receiverStartDate"] != null || parsedJson["receiverEndDate"] != null
? TimerModel(startAt: DateTime.tryParse(parsedJson["receiverStartDate"] ?? ""), endAt: DateTime.tryParse(parsedJson["receiverEndDate"] ?? ""))
: null,
@ -108,8 +121,7 @@ class DeviceTransfer {
id: parsedJson["destDepartmentId"],
name: parsedJson["destDepartmentName"],
),
// todo add segnature
signature: URLs.getFileUrl(parsedJson["receiverAttachmentName"]),
engSignature: URLs.getFileUrl(parsedJson["receiverEngSignature"]),
status: Lookup(
id: parsedJson["receiverMachineStatusId"],
name: parsedJson["receiverMachineStatusName"],

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:test_sa/models/department.dart';
import 'package:test_sa/models/hospital.dart';
import 'package:test_sa/models/lookup.dart';
@ -15,7 +17,8 @@ class DeviceTransferInfo {
// DateTime endDate;
String travelingHours;
String userName;
String signature;
String engSignature;
List<File> attachments;
String assignedEmployeeName;
Lookup status;
TimerModel timer;
@ -30,10 +33,11 @@ class DeviceTransferInfo {
// this.startDate,
// this.endDate,
this.workingHours,
this.signature,
this.engSignature,
this.status,
this.assignedEmployeeName,
this.timer,
this.attachments,
});
Map<String, String> toJson(bool isSender) {
@ -48,7 +52,7 @@ class DeviceTransferInfo {
if (timer?.endAt != null) body["${baseKey}end_date"] = timer?.endAt?.toIso8601String();
if (travelingHours != null && travelingHours.isNotEmpty) body["${baseKey}travel_hours"] = travelingHours;
if (status != null) body["${baseKey}status"] = status.id.toString();
if (signature != null && signature.isNotEmpty) body["${baseKey}image"] = signature;
if (engSignature != null && engSignature.isNotEmpty) body["${baseKey}image"] = engSignature;
return body;
}
@ -64,36 +68,37 @@ class DeviceTransferInfo {
client = Hospital.fromHospital(old.client);
department = Department.fromDepartment(old.department);
workingHours = old.workingHours;
attachments = old.attachments ?? [];
// startDate = old.startDate;
// endDate = old.endDate;
timer = old.timer;
travelingHours = old.travelingHours;
comment = old.comment;
if (withSignature) signature = old.signature;
if (withSignature) engSignature = old.engSignature;
status = old.status;
}
factory DeviceTransferInfo.fromJson(Map<String, dynamic> parsedJson, String key) {
return DeviceTransferInfo(
workingHours: parsedJson["${key}working_hours"],
// startDate: parsedJson["${key}start_date"],
// endDate: parsedJson["${key}end_date"],
timer: TimerModel(
startAt: DateTime.tryParse(parsedJson["${key}start_date"] ?? ""),
endAt: DateTime.tryParse(parsedJson["${key}end_date"] ?? ""),
durationInSecond: ((parsedJson["${key}working_hours"] ?? 0) * 60 * 60).toInt(),
),
travelingHours: parsedJson["${key}travel_hours"],
userName: parsedJson["${key}name"],
signature: parsedJson["${key}image"],
userId: parsedJson["${key}id"],
comment: parsedJson["${key}comment"],
assignedEmployeeName: parsedJson["${key}AssignedEmployeeName"],
client: Hospital(id: parsedJson["${key}SiteId"], name: parsedJson["${key}SiteName"]),
department: Department(
id: parsedJson["${key}DepartmentId"],
name: parsedJson["${key}DepartmentName"],
),
);
}
// factory DeviceTransferInfo.fromJson(Map<String, dynamic> parsedJson, String key) {
// return DeviceTransferInfo(
// workingHours: parsedJson["${key}working_hours"],
// // startDate: parsedJson["${key}start_date"],
// // endDate: parsedJson["${key}end_date"],
// timer: TimerModel(
// startAt: DateTime.tryParse(parsedJson["${key}start_date"] ?? ""),
// endAt: DateTime.tryParse(parsedJson["${key}end_date"] ?? ""),
// durationInSecond: ((parsedJson["${key}working_hours"] ?? 0) * 60 * 60).toInt(),
// ),
// travelingHours: parsedJson["${key}travel_hours"],
// userName: parsedJson["${key}name"],
// signature: parsedJson["${key}image"],
// userId: parsedJson["${key}id"],
// comment: parsedJson["${key}comment"],
// assignedEmployeeName: parsedJson["${key}AssignedEmployeeName"],
// client: Hospital(id: parsedJson["${key}SiteId"], name: parsedJson["${key}SiteName"]),
// department: Department(
// id: parsedJson["${key}DepartmentId"],
// name: parsedJson["${key}DepartmentName"],
// ),
// );
// }
}

@ -14,9 +14,9 @@ import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/app_text_form_field.dart';
import 'package:test_sa/views/widgets/buttons/app_button.dart';
import 'package:test_sa/views/widgets/e_signature/e_signature.dart';
import 'package:test_sa/views/widgets/images/multi_image_picker.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/status/asset_status.dart';
import 'package:test_sa/views/widgets/status/gas_refill/gas_status.dart';
import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
import '../../../../controllers/localization/localization.dart';
@ -41,7 +41,7 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
Uint8List _signature;
DeviceTransferProvider _deviceTransferProvider;
final TextEditingController _requestedQuantityController = TextEditingController();
final DeviceTransferInfo _formModel = DeviceTransferInfo();
final DeviceTransferInfo _formModel = DeviceTransferInfo(attachments: []);
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@ -189,7 +189,14 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
},
),
const SizedBox(
height: 8,
height: 16,
),
MultiFilesPicker(
label: "Attachments",
files: _formModel.attachments,
),
const SizedBox(
height: 16,
),
const ASubTitle("Signature"),
// if(_validate && _formModel.signature == null)
@ -198,12 +205,12 @@ class _UpdateDeviceTransferState extends State<UpdateDeviceTransfer> {
height: 4,
),
ESignature(
oldSignature: widget.isSender ? widget.model.sender.signature : widget.model.receiver.signature,
oldSignature: widget.isSender ? widget.model.sender.engSignature : widget.model.receiver.engSignature,
newSignature: _signature,
onSaved: (signature) {
_signature = signature;
if (signature == null || signature.isEmpty) return;
_formModel.signature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
_formModel.engSignature = "${DateTime.now().toIso8601String()}.png|${base64Encode(signature)}";
// base64Encode(signature);
},
),

@ -55,7 +55,7 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
void initState() {
_subWorkOrders = SearchWorkOrder(
assignedEmployee: widget?.workOrder?.callRequest?.assignedEmployee,
callRequest: CallRequest(id: widget?.workOrder?.callRequest?.id),
callRequest: CallRequest(id: widget?.workOrder?.callRequest?.id, asset: widget.workOrder?.callRequest?.asset),
currentSituation: null,
supplier: null,
parentWOId: widget.workOrder.id,
@ -328,7 +328,7 @@ class _CreateSubWorkOrderPageState extends State<CreateSubWorkOrderPage> {
_validate = true;
setState(() {});
if (validate()) {
if(_subWorkOrders.calllastSituation.value == 12 && (_subWorkOrders.sparePartsWorkOrders == null || _subWorkOrders.sparePartsWorkOrders.isEmpty)){
if (_subWorkOrders.calllastSituation.value == 12 && (_subWorkOrders.sparePartsWorkOrders == null || _subWorkOrders.sparePartsWorkOrders.isEmpty)) {
await Fluttertoast.showToast(msg: "You have to add parts");
return;
}

@ -97,6 +97,7 @@ class _SparePartsBottomSheetState extends State<SparePartsBottomSheet> {
: const SizedBox.shrink(),
const SizedBox(height: 4),
AutoCompletePartsField(
assetId: widget.subWorkOrder?.callRequest?.asset?.id,
onPick: (part) {
_workOrder.sparePartsWorkOrders ??= [];
_workOrder.sparePartsWorkOrders.add(SparePartsWorkOrders(

@ -873,6 +873,7 @@ class _CreateServiceReportState extends State<CreateServiceReport> with TickerPr
height: 4,
),
AutoCompletePartsField(
assetId: _serviceReport?.device?.id,
onPick: (part) {
_serviceReport.parts.add(part);
},

@ -1013,6 +1013,7 @@ class _EditServiceReportState extends State<EditServiceReport> with TickerProvid
height: 4,
),
AutoCompletePartsField(
assetId: _serviceReport?.device?.id,
onPick: (part) {
_serviceReport.parts.add(part);
setState(() {});

@ -146,6 +146,7 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
PentryPMKitForm(
models: _pentry.pmKits,
enableValidate: _validate,
assetId: widget.visit?.deviceId,
),
PentryInfoForm(
model: _pentry,

@ -8,6 +8,7 @@ import 'package:test_sa/views/widgets/requests/info_row.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import '../../../controllers/providers/api/user_provider.dart';
import '../images/multi_image_picker.dart';
class DeviceTransferInfoSection extends StatelessWidget {
final DeviceTransferInfo info;
@ -19,7 +20,8 @@ class DeviceTransferInfoSection extends StatelessWidget {
Widget build(BuildContext context) {
info.userName = Provider.of<UserProvider>(context).user.username;
final subtitle = AppLocalization.of(context).subtitle;
print("url:${info.signature}");
print("url:${info.engSignature}");
info.attachments ??= [];
return Column(
children: [
RequestInfoRow(
@ -52,12 +54,16 @@ class DeviceTransferInfoSection extends StatelessWidget {
),
RequestInfoRow(
title: "Signature",
info: info.signature?.isEmpty != false ? subtitle.noDateFound : null,
contentWidget: info.signature?.isEmpty != false
? null
: ImageLoader(
url: info.signature,
),
info: info.engSignature?.isEmpty != false ? subtitle.noDateFound : null,
contentWidget: info.engSignature?.isEmpty != false ? null : ImageLoader(url: info.engSignature),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: MultiFilesPicker(
label: "Attachments",
files: info.attachments,
enabled: false,
),
),
RequestInfoRow(
title: subtitle.status,

@ -33,117 +33,121 @@ class _MultiFilesPickerState extends State<MultiFilesPicker> with TickerProvider
Widget build(BuildContext context) {
_size = MediaQuery.of(context).size;
Subtitle subtitle = AppLocalization.of(context).subtitle;
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xfff5f5f5),
border: Border.all(
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
Row(
children: [
Expanded(
child: Text(
widget.label ?? subtitle.images,
style: Theme.of(context).textTheme.headline6.copyWith(
fontSize: 14,
),
textScaleFactor: AppStyle.getScaleFactor(context),
),
return (widget.enabled == false && (widget.files?.isEmpty ?? false))
? const SizedBox()
: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: const Color(0xfff5f5f5),
border: Border.all(
color: const Color(0xffefefef),
),
AFlatButton(
text: subtitle.add,
onPressed: widget.enabled
? () {
// onImagePick(_subtitle);
onFilePicker(subtitle);
}
: null,
),
],
),
12.height,
AnimatedSize(
duration: const Duration(milliseconds: 400),
child: !widget.error
? const SizedBox.shrink()
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
subtitle.imagesRequired,
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// SizedBox(height: 8 * AppStyle.getScaleFactor(context),),
Row(
children: [
Expanded(
child: Text(
widget.label ?? subtitle.images,
style: Theme.of(context).textTheme.headline6.copyWith(
fontSize: 14,
color: AColors.red,
),
textScaleFactor: AppStyle.getScaleFactor(context),
),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
if (widget.enabled)
AFlatButton(
text: subtitle.add,
onPressed: widget.enabled
? () {
// onImagePick(_subtitle);
onFilePicker(subtitle);
}
: null,
),
],
),
),
AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: Container(
key: ValueKey(widget.files.length),
width: _size.width,
height: 200 * AppStyle.getScaleFactor(context),
padding: EdgeInsets.all(
8 * AppStyle.getScaleFactor(context),
),
alignment: Alignment.topLeft,
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
),
child: widget.files.isEmpty
? MaterialButton(
onPressed: widget.enabled
? () {
// onImagePick(_subtitle);
onFilePicker(subtitle);
}
: null,
child: Center(
child: Icon(
Icons.file_upload,
size: 48 * AppStyle.getScaleFactor(context),
color: Theme.of(context).primaryColor,
)),
)
: GridView.count(
crossAxisCount: 2,
//_size.width ~/ 80,
scrollDirection: Axis.horizontal,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
children: List.generate(widget.files.length, (index) {
File _image = widget.files[index];
return MultiFilesPickerItem(
file: _image,
onRemoveTap: (image) {
if (!widget.enabled) {
return;
}
widget.files.remove(image);
setState(() {});
},
);
}),
],
),
12.height,
AnimatedSize(
duration: const Duration(milliseconds: 400),
child: !widget.error
? const SizedBox.shrink()
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
subtitle.imagesRequired,
style: Theme.of(context).textTheme.headline6.copyWith(
fontSize: 14,
color: AColors.red,
),
textScaleFactor: AppStyle.getScaleFactor(context),
),
SizedBox(
height: 8 * AppStyle.getScaleFactor(context),
),
],
),
),
AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: Container(
key: ValueKey(widget.files.length),
width: _size.width,
height: 200 * AppStyle.getScaleFactor(context),
padding: EdgeInsets.all(
8 * AppStyle.getScaleFactor(context),
),
alignment: Alignment.topLeft,
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
borderRadius: BorderRadius.circular(8 * AppStyle.getScaleFactor(context)),
),
child: widget.files.isEmpty && widget.enabled
? MaterialButton(
onPressed: widget.enabled
? () {
// onImagePick(_subtitle);
onFilePicker(subtitle);
}
: null,
child: Center(
child: Icon(
Icons.file_upload,
size: 48 * AppStyle.getScaleFactor(context),
color: Theme.of(context).primaryColor,
)),
)
: GridView.count(
crossAxisCount: 2,
//_size.width ~/ 80,
scrollDirection: Axis.horizontal,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
children: List.generate(widget.files.length, (index) {
File _image = widget.files[index];
return MultiFilesPickerItem(
file: _image,
enabled: widget.enabled,
onRemoveTap: (image) {
if (!widget.enabled) {
return;
}
widget.files.remove(image);
setState(() {});
},
);
}),
),
),
),
],
),
),
],
),
);
);
}
fromFilePicker(Subtitle subtitle) async {

@ -12,9 +12,10 @@ import 'package:url_launcher/url_launcher.dart';
class MultiFilesPickerItem extends StatelessWidget {
final File file;
final bool enabled;
final Function(File) onRemoveTap;
const MultiFilesPickerItem({Key key, this.file, this.onRemoveTap}) : super(key: key);
const MultiFilesPickerItem({Key key, this.file, this.enabled, this.onRemoveTap}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -68,23 +69,25 @@ class MultiFilesPickerItem extends StatelessWidget {
}
}
},
child: Align(
alignment: Alignment.topRight,
child: IconButton(
padding: const EdgeInsets.all(2.0),
icon: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(color: Theme.of(context).scaffoldBackgroundColor.withOpacity(.3), borderRadius: BorderRadius.circular(8)),
child: const Icon(
Icons.remove_circle,
color: AColors.red,
),
),
onPressed: () {
onRemoveTap(file);
},
),
),
child: enabled
? Align(
alignment: Alignment.topRight,
child: IconButton(
padding: const EdgeInsets.all(2.0),
icon: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(color: Theme.of(context).scaffoldBackgroundColor.withOpacity(.3), borderRadius: BorderRadius.circular(8)),
child: const Icon(
Icons.remove_circle,
color: AColors.red,
),
),
onPressed: () {
onRemoveTap(file);
},
),
)
: const SizedBox(),
),
);
}

@ -10,10 +10,11 @@ import 'package:test_sa/views/app_style/sizing.dart';
class AutoCompletePartsField extends StatefulWidget {
final String initialValue;
final num assetId;
final bool clearAfterPick;
final Function(Part) onPick;
const AutoCompletePartsField({Key key, this.initialValue, this.onPick, this.clearAfterPick = true}) : super(key: key);
const AutoCompletePartsField({Key key, this.initialValue, this.assetId, this.onPick, this.clearAfterPick = true}) : super(key: key);
@override
_AutoCompletePartsFieldState createState() => _AutoCompletePartsFieldState();
@ -64,7 +65,7 @@ class _AutoCompletePartsFieldState extends State<AutoCompletePartsField> {
textInputAction: TextInputAction.search,
),
suggestionsCallback: (vale) async {
return await _partsProvider.getPartsList(host: _settingProvider.host, title: vale);
return await _partsProvider.getPartsList(host: _settingProvider.host, title: vale, assetId: widget.assetId);
},
itemBuilder: (context, part) {
return ListTile(

@ -11,9 +11,11 @@ import 'package:test_sa/views/widgets/titles/app_sub_title.dart';
class PentryPMKitForm extends StatefulWidget {
final List<PMKit> models;
final bool enableValidate;
final num assetId;
const PentryPMKitForm({
Key key,
this.models,
this.assetId,
this.enableValidate,
}) : super(key: key);
@ -71,6 +73,7 @@ class _PentryPMKitFormState extends State<PentryPMKitForm> {
height: 4,
),
AutoCompletePartsField(
assetId: widget.assetId,
clearAfterPick: false,
initialValue: (model.itemCode?.name ?? "").toString(),
onPick: (part) {

Loading…
Cancel
Save