diff --git a/assets/subtitles/ar_subtitle.json b/assets/subtitles/ar_subtitle.json index 16cad068..b9a51fd7 100644 --- a/assets/subtitles/ar_subtitle.json +++ b/assets/subtitles/ar_subtitle.json @@ -167,7 +167,7 @@ "newServiceReport": "تقرير خدمة جديد", "number": "رقم", "operatingHours": "ساعات العمل", - "partNumber": "رقم القطعة", + "partNumberName": "رقم/اسم القطعة", "quantity": "كمية", "reasons": "الاسباب", "reportStatus": "حالة التقرير", diff --git a/assets/subtitles/en_subtitle.json b/assets/subtitles/en_subtitle.json index 4b5352f9..fc57c444 100644 --- a/assets/subtitles/en_subtitle.json +++ b/assets/subtitles/en_subtitle.json @@ -167,7 +167,7 @@ "newServiceReport": "New Work Order", "number": "Number", "operatingHours": "Operating Hours", - "partNumber": "Part Number", + "partNumberName": "Part Number/Name", "quantity": "Quantity", "reasons": "Reasons", "reportStatus": "Report Status", diff --git a/lib/controllers/providers/api/device_transfer_provider.dart b/lib/controllers/providers/api/device_transfer_provider.dart index c5677c75..cdd685bd 100644 --- a/lib/controllers/providers/api/device_transfer_provider.dart +++ b/lib/controllers/providers/api/device_transfer_provider.dart @@ -6,6 +6,7 @@ import 'package:test_sa/controllers/api_routes/api_manager.dart'; import 'package:test_sa/controllers/api_routes/urls.dart'; import 'package:test_sa/models/device/device_transfer.dart'; import 'package:test_sa/models/device/device_transfer_info.dart'; +import 'package:test_sa/models/device/device_transfer_search.dart'; import 'package:test_sa/models/user.dart'; import '../../../models/hospital.dart'; @@ -14,6 +15,8 @@ class DeviceTransferProvider extends ChangeNotifier { // number of items call in each request final pageItemNumber = 12; + DeviceTransferSearch deviceTransferSearch = DeviceTransferSearch(); + //reset provider data void reset() { items = null; @@ -60,7 +63,6 @@ class DeviceTransferProvider extends ChangeNotifier { Future getRequests({ @required String host, @required User user, - bool mostRecent, }) async { if (isLoading == true) return -2; isLoading = true; @@ -70,6 +72,7 @@ class DeviceTransferProvider extends ChangeNotifier { Map body = {}; body["pageNumber"] = (items?.length ?? 0) ~/ pageItemNumber + 1; body["pageSize"] = pageItemNumber; + body.addAll(deviceTransferSearch.toMap()); response = await ApiManager.instance.post( URLs.getDeviceTransfer, @@ -83,7 +86,7 @@ class DeviceTransferProvider extends ChangeNotifier { List itemsPage = listJson.map((request) => DeviceTransfer.fromJson(request)).toList(); items ??= []; items.addAll(itemsPage.toSet().toList()); - sortMostRecent(items, mostRecent); + sortMostRecent(items, deviceTransferSearch.mostRecent); print(listJson); if (itemsPage.length == pageItemNumber) { diff --git a/lib/controllers/providers/api/gas_refill_provider.dart b/lib/controllers/providers/api/gas_refill_provider.dart index 1c567e31..40a96203 100644 --- a/lib/controllers/providers/api/gas_refill_provider.dart +++ b/lib/controllers/providers/api/gas_refill_provider.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:developer'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart'; @@ -113,10 +114,10 @@ class GasRefillProvider extends ChangeNotifier { "floor": {"id": floor?.id, "name": floor?.name, "value": floor?.value}, if (expectedDateTime != null) "expectedDate": expectedDateTime?.toIso8601String(), if (expectedDateTime != null) "expectedTime": expectedDateTime?.toIso8601String(), - if (startDate != null) "startDate": startDate?.toIso8601String(), - if (startDate != null) "startTime": startDate?.toIso8601String(), - if (endDate != null) "endDate": endDate?.toIso8601String(), - if (endDate != null) "endTime": endDate?.toIso8601String(), + if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(), + if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(), + if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(), + if (timer?.endAt != null) "endTime": timer.endAt.toIso8601String(), "department": {"id": department?.id, "departmentName": department?.name, "departmentCode": "", "ntCode": ""}, "GazRefillNo": "GR-${DateTime.now().toString().split(" ").first}", "status": model.status.toMap(), @@ -159,12 +160,12 @@ class GasRefillProvider extends ChangeNotifier { "status": newModel.status.toMap(), "expectedDate": newModel.expectedDate?.toIso8601String(), "expectedTime": newModel.expectedDate?.toIso8601String(), - "startDate": newModel.startDate?.toIso8601String(), - "startTime": newModel.startDate?.toIso8601String(), - "endDate": newModel.endDate?.toIso8601String(), - "endTime": newModel.endDate?.toIso8601String(), + if (timer?.startAt != null) "startDate": timer.startAt.toIso8601String(), + if (timer?.startAt != null) "startTime": timer.startAt.toIso8601String(), + if (timer?.endAt != null) "endDate": timer.endAt.toIso8601String(), + if (timer?.endAt != null) "endTime": timer.endAt.toIso8601String(), // "workingHours": ((endDate?.difference(startDate)?.inMinutes ?? 0) / 60), - 'workingHours': newModel.workingHours, + 'workingHours': timer.durationInSecond != null ? timer.durationInSecond / 60 / 60 : newModel.workingHours, "assignedEmployee": oldModel?.assignedEmployee?.id == null ? null : oldModel?.assignedEmployee?.toJson(), "site": hospital?.toMap(), "building": building?.toJson(includeFloors: false), @@ -183,24 +184,25 @@ class GasRefillProvider extends ChangeNotifier { "deliverdQty": model.deliveredQuantity, }) .toList(); - - Response response; - try { - response = await ApiManager.instance.put(URLs.updateGasRefill, body: body); - // response = await post( - // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"), - // body: body, - // ); - - stateCode = response.statusCode; - if (response.statusCode >= 200 && response.statusCode < 300) { - oldModel.fromGasRefillModel(newModel); - notifyListeners(); - } - return response.statusCode; - } catch (error) { - return -1; - } + log(body.toString()); + return -1; + // Response response; + // try { + // response = await ApiManager.instance.put(URLs.updateGasRefill, body: body); + // // response = await post( + // // Uri.parse("$host${URLs.updateGasRefill}/${newModel.id}"), + // // body: body, + // // ); + // + // stateCode = response.statusCode; + // if (response.statusCode >= 200 && response.statusCode < 300) { + // oldModel.fromGasRefillModel(newModel); + // notifyListeners(); + // } + // return response.statusCode; + // } catch (error) { + // return -1; + // } } Hospital hospital; @@ -208,7 +210,5 @@ class GasRefillProvider extends ChangeNotifier { Floors floor; Departments department; DateTime expectedDateTime; - DateTime startDate; - DateTime endDate; TimerModel timer; } diff --git a/lib/controllers/providers/api/service_requests_provider.dart b/lib/controllers/providers/api/service_requests_provider.dart index d255f7bc..ea03c7ee 100644 --- a/lib/controllers/providers/api/service_requests_provider.dart +++ b/lib/controllers/providers/api/service_requests_provider.dart @@ -312,7 +312,7 @@ class ServiceRequestsProvider extends ChangeNotifier { }, "assetType": report.assetType?.toMap(), "assignedEmployee": {"id": report.engineer?.id, "name": report.engineer?.name ?? ""}, - "visitDate": report.visitDate?.toIso8601String() ?? "", + "visitDate": report.returnToService?.toIso8601String() ?? "", // "assistantEmployees": [ // {"id": report.engineer.id, "name": report.engineer.name}, // ], diff --git a/lib/models/device/device_transfer_search.dart b/lib/models/device/device_transfer_search.dart new file mode 100644 index 00000000..14cf6956 --- /dev/null +++ b/lib/models/device/device_transfer_search.dart @@ -0,0 +1,49 @@ +import '../lookup.dart'; + +class DeviceTransferSearch { + String assetName, assetNumber, site; + bool mostRecent; + Lookup dateOperator; + String from, to; + + DeviceTransferSearch({ + this.assetName, + this.assetNumber, + this.site, + this.mostRecent, + this.dateOperator, + this.from, + this.to, + }); + + Map toMap() { + Map search = {}; + if (assetName != null && assetName.isNotEmpty) { + search["assetName"] = assetName; + } + if (assetNumber != null && assetNumber.isNotEmpty) { + search["assetNumber"] = assetNumber; + } + if (site != null && site.isNotEmpty) { + search["site"] = site; + } + if (dateOperator != null && from != null) { + search["requestedDateSymbol"] = dateOperator.toMap(); + search["requestedDateFrom"] = from; + } + if (dateOperator != null && to != null) { + search["requestedDateTo"] = to; + } + return search; + } + + void fromSearch(DeviceTransferSearch newSearch) { + assetName = newSearch.assetName; + assetNumber = newSearch.assetNumber; + site = newSearch.site; + mostRecent = newSearch.mostRecent; + from = newSearch.from; + to = newSearch.to; + dateOperator = newSearch.dateOperator; + } +} diff --git a/lib/models/service_report.dart b/lib/models/service_report.dart index bf2f53d4..a5fed419 100644 --- a/lib/models/service_report.dart +++ b/lib/models/service_report.dart @@ -160,7 +160,7 @@ class ServiceReport { return false; } if (returnToService == null) { - await Fluttertoast.showToast(msg: "return To Service Date Required"); + await Fluttertoast.showToast(msg: "Return To Service Date Required"); return false; } if (timer?.startAt == null) { diff --git a/lib/models/subtitle.dart b/lib/models/subtitle.dart index 4007a7cb..6786ddd1 100644 --- a/lib/models/subtitle.dart +++ b/lib/models/subtitle.dart @@ -205,7 +205,7 @@ class Subtitle { String reasons; String attachImage; String operatingHours; - String partNumber; + String partNumberName; String number; String quantity; String orderWorkNumber; @@ -417,7 +417,7 @@ class Subtitle { @required this.newServiceReport, @required this.number, @required this.operatingHours, - @required this.partNumber, + @required this.partNumberName, @required this.reasons, @required this.reportStatus, @required this.reportType, @@ -618,7 +618,7 @@ class Subtitle { newServiceReport: parsedJson["newServiceReport"], number: parsedJson["number"], operatingHours: parsedJson["operatingHours"], - partNumber: parsedJson["partNumber"], + partNumberName: parsedJson["partNumberName"], quantity: parsedJson["quantity"], reasons: parsedJson["reasons"], reportStatus: parsedJson["reportStatus"], diff --git a/lib/views/pages/device_transfer/device_transfer_details.dart b/lib/views/pages/device_transfer/device_transfer_details.dart index c4ebb783..2e807ec9 100644 --- a/lib/views/pages/device_transfer/device_transfer_details.dart +++ b/lib/views/pages/device_transfer/device_transfer_details.dart @@ -143,7 +143,7 @@ class _DeviceTransferDetailsState extends State { if (_userProvider.user?.type == UsersTypes.engineer) ASmallButton( text: _subtitle.edit, - onPressed: (_isSender || _isReceiver || false) + onPressed: (_isSender) ? () { Navigator.of(context).push(MaterialPageRoute( builder: (_) => UpdateDeviceTransfer( @@ -169,7 +169,7 @@ class _DeviceTransferDetailsState extends State { if (_userProvider.user?.type == UsersTypes.engineer) ASmallButton( text: _subtitle.edit, - onPressed: (_isReceiver || false) + onPressed: (_isReceiver) ? () { Navigator.of(context).push(MaterialPageRoute( builder: (_) => UpdateDeviceTransfer( diff --git a/lib/views/pages/device_transfer/track_device_transfer.dart b/lib/views/pages/device_transfer/track_device_transfer.dart index 1ce0e2fa..1610640c 100644 --- a/lib/views/pages/device_transfer/track_device_transfer.dart +++ b/lib/views/pages/device_transfer/track_device_transfer.dart @@ -1,15 +1,16 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:test_sa/controllers/localization/localization.dart'; import 'package:test_sa/controllers/providers/api/device_transfer_provider.dart'; import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/controllers/providers/settings/setting_provider.dart'; -import 'package:test_sa/models/subtitle.dart'; +import 'package:test_sa/models/device/device_transfer_search.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/widgets/buttons/app_back_button.dart'; import 'package:test_sa/views/widgets/device_trancfer/device_transfer_list.dart'; import 'package:test_sa/views/widgets/loaders/loading_manager.dart'; -import 'package:test_sa/views/widgets/switch_button.dart'; +import 'package:test_sa/views/widgets/search/asset_transfer_search_dialog.dart'; + +import '../../widgets/buttons/app_icon_button.dart'; class TrackDeviceTransferPage extends StatefulWidget { static const String id = "/track-device-transfer"; @@ -24,13 +25,12 @@ class _TrackDeviceTransferPageState extends State with DeviceTransferProvider _deviceTransferProvider; UserProvider _userProvider; SettingProvider _settingProvider; - bool mostRecent = false; + @override Widget build(BuildContext context) { _deviceTransferProvider = Provider.of(context); _userProvider = Provider.of(context); _settingProvider = Provider.of(context); - Subtitle _subtitle = AppLocalization.of(context).subtitle; return Scaffold( body: SafeArea( @@ -56,7 +56,7 @@ class _TrackDeviceTransferPageState extends State with children: [ Row( children: [ - ABackButton(), + const ABackButton(), Expanded( child: Center( child: Text( @@ -65,29 +65,35 @@ class _TrackDeviceTransferPageState extends State with ), ), ), - const SizedBox( - width: 48, - ) + AIconButton( + iconData: Icons.search, + color: AColors.secondaryColor, + buttonSize: 42, + backgroundColor: AColors.white, + onPressed: () async { + DeviceTransferSearch temp = await showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (context) { + return AssetTransferSearchDialog(initialSearchValue: _deviceTransferProvider.deviceTransferSearch); + }); + if (temp != null) { + _deviceTransferProvider.deviceTransferSearch = temp; + _deviceTransferProvider.reset(); + setState(() {}); + await _deviceTransferProvider.getRequests( + user: _userProvider.user, + host: _settingProvider.host, + ); + } + }, + ), + const SizedBox(width: 16), ], ), ], ), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: ASwitchButton( - title: "Most Recent", - value: mostRecent, - onChange: (value) async { - mostRecent = value; - await _deviceTransferProvider.getRequests( - user: _userProvider.user, - host: _settingProvider.host, - mostRecent: mostRecent, - ); - }, - ), - ), Expanded( child: DeviceTransferList( nextPage: _deviceTransferProvider.nextPage, diff --git a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart index feac7419..9cb43482 100644 --- a/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart +++ b/lib/views/pages/sub_workorder/spare_parts_details_bottom_sheet.dart @@ -87,7 +87,7 @@ class _SparePartsBottomSheetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(subtitle.partNumber), + ASubTitle(subtitle.partNumberName), _validate && _workOrder.sparePartsWorkOrders == null ? ASubTitle( subtitle.requiredWord, diff --git a/lib/views/pages/user/gas_refill/gas_refill_details.dart b/lib/views/pages/user/gas_refill/gas_refill_details.dart index 943776ea..bc6f49a0 100644 --- a/lib/views/pages/user/gas_refill/gas_refill_details.dart +++ b/lib/views/pages/user/gas_refill/gas_refill_details.dart @@ -106,7 +106,7 @@ class _GasRefillDetailsState extends State { Expanded( child: Center( child: Text( - _subtitle.details, + "Gas Refill Request", style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic), ), ), diff --git a/lib/views/pages/user/gas_refill/request_gas_refill.dart b/lib/views/pages/user/gas_refill/request_gas_refill.dart index 5300a3ee..b638120a 100644 --- a/lib/views/pages/user/gas_refill/request_gas_refill.dart +++ b/lib/views/pages/user/gas_refill/request_gas_refill.dart @@ -12,6 +12,7 @@ import 'package:test_sa/models/gas_refill/gas_refill_details.dart'; import 'package:test_sa/models/gas_refill/gas_refill_model.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/models/subtitle.dart'; +import 'package:test_sa/models/timer_model.dart'; 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'; @@ -156,14 +157,15 @@ class _RequestGasRefillState extends State { if (widget.gasRefillModel != null) { _formModel.status = widget.gasRefillModel?.status ?? const Lookup(value: 0); _gasRefillProvider.expectedDateTime = _formModel.expectedDate; + _gasRefillProvider.timer = TimerModel(startAt: widget.gasRefillModel?.startDate, endAt: widget.gasRefillModel?.endDate); + } else { + _gasRefillProvider.timer = null; } HospitalsProvider().getHospitalsListByVal(searchVal: _userProvider.user?.clientName).then((value) { _gasRefillProvider.hospital = value?.firstWhere((element) => element.name == _userProvider.user?.clientName, orElse: () => null); _gasRefillProvider.building = _gasRefillProvider.hospital?.buildings?.firstWhere((element) => element.name == widget.gasRefillModel?.building?.name, orElse: () => null); _gasRefillProvider.floor = _gasRefillProvider.building?.floors?.firstWhere((element) => element.name == widget.gasRefillModel?.floor?.name, orElse: () => null); _gasRefillProvider.department = _gasRefillProvider.floor?.departments?.firstWhere((element) => element.name == widget.gasRefillModel?.department?.departmentName, orElse: () => null); - _gasRefillProvider.startDate = widget.gasRefillModel?.startDate; - _gasRefillProvider.endDate = widget.gasRefillModel?.endDate; _firstTime = false; setState(() {}); }); @@ -252,6 +254,7 @@ class _RequestGasRefillState extends State { BuildingTypeMenu( initialValue: _gasRefillProvider?.building, building: _gasRefillProvider?.hospital?.buildings, + enabled: widget.gasRefillModel == null, onSelect: (status) { _gasRefillProvider.building = status; setState(() {}); @@ -261,6 +264,7 @@ class _RequestGasRefillState extends State { FloorTypeMenu( initialValue: _gasRefillProvider?.floor, floors: _gasRefillProvider?.building?.floors, + enabled: widget.gasRefillModel == null, onSelect: (status) { _gasRefillProvider.floor = status; setState(() {}); @@ -270,6 +274,7 @@ class _RequestGasRefillState extends State { DepartmentTypeMenu( initialValue: _gasRefillProvider?.department, departments: _gasRefillProvider?.floor?.departments, + enabled: widget.gasRefillModel == null, onSelect: (status) { _gasRefillProvider.department = status; setState(() {}); @@ -286,8 +291,6 @@ class _RequestGasRefillState extends State { timer: _gasRefillProvider.timer, onChange: (timer) async { _gasRefillProvider.timer = timer; - _formModel.startDate ??= timer.startAt; - _gasRefillProvider.endDate = timer.endAt; _formModel.workingHours = num.tryParse((((timer?.durationInSecond ?? 0) / 60) / 60)?.toStringAsFixed(2) ?? "0"); return true; }, diff --git a/lib/views/pages/user/requests/report/create_service_report.dart b/lib/views/pages/user/requests/report/create_service_report.dart index 6187418a..89fdf8da 100644 --- a/lib/views/pages/user/requests/report/create_service_report.dart +++ b/lib/views/pages/user/requests/report/create_service_report.dart @@ -22,7 +22,6 @@ 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_back_button.dart'; import 'package:test_sa/views/widgets/buttons/app_button.dart'; -import 'package:test_sa/views/widgets/date_and_time/date_picker.dart'; import 'package:test_sa/views/widgets/e_signature/e_signature.dart'; import 'package:test_sa/views/widgets/equipment/auto_complete_devices_field.dart'; import 'package:test_sa/views/widgets/images/mini_one_image_picker.dart'; @@ -35,6 +34,7 @@ import 'package:test_sa/views/widgets/status/report/service_report_reasons.dart' import 'package:test_sa/views/widgets/titles/app_sub_title.dart'; import '../../../../../controllers/providers/api/status_drop_down/report/service_types_provider.dart'; +import '../../../../widgets/date_and_time/date_picker.dart'; import '../../../../widgets/status/report/service_report_fault_description.dart'; import '../../../../widgets/status/report/service_report_repair_location.dart'; import '../../../../widgets/timer/app_timer.dart'; @@ -69,7 +69,7 @@ class _CreateServiceReportState extends State with TickerPr @override void initState() { _serviceReport = ServiceReport( - visitDate: DateTime.now(), + returnToService: DateTime.now(), //type: const Lookup(value: 2), device: widget.request.device, parts: [], @@ -200,63 +200,6 @@ class _CreateServiceReportState extends State with TickerPr crossAxisAlignment: CrossAxisAlignment.start, children: [ // Report type and Reasons - Row( - children: [ - // Report Status - // Expanded( - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // ASubTitle(_subtitle.reportType), - // _validate && _serviceReport.type == null ? - // ASubTitle(_subtitle.requiredWord,color: Colors.red,): - // const SizedBox.shrink(), - // const SizedBox(height: 4,), - // ServiceReportTypeMenu( - // initialValue: _serviceReport.type, - // onSelect: (status){ - // _serviceReport.type = status; - // }, - // ), - // ], - // ), - // ), - // const SizedBox(width: 8,), - // visit date - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ASubTitle(_subtitle.visitDate), - _validate && _serviceReport.visitDate == null - ? ASubTitle( - _subtitle.requiredWord, - color: Colors.red, - ) - : const SizedBox.shrink(), - Row( - children: [ - Expanded( - child: ADatePicker( - date: _serviceReport.visitDate, - from: DateTime.now().subtract(const Duration(days: 365)), - to: DateTime.now().add(const Duration(days: 365)), - onDatePicker: (date) { - _serviceReport.visitDate = date; - setState(() {}); - }, - ), - ), - ], - ), - ], - ), - ), - ], - ), - const SizedBox( - height: 8, - ), // device sn Visibility( visible: widget.request.deviceSerialNumber == null, @@ -420,6 +363,63 @@ class _CreateServiceReportState extends State with TickerPr SizedBox( height: 8 * AppStyle.getScaleFactor(context), ), + Row( + children: [ + // Report Status + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // ASubTitle(_subtitle.reportType), + // _validate && _serviceReport.type == null ? + // ASubTitle(_subtitle.requiredWord,color: Colors.red,): + // const SizedBox.shrink(), + // const SizedBox(height: 4,), + // ServiceReportTypeMenu( + // initialValue: _serviceReport.type, + // onSelect: (status){ + // _serviceReport.type = status; + // }, + // ), + // ], + // ), + // ), + // const SizedBox(width: 8,), + // visit date + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const ASubTitle("Return to Service"), + _validate && _serviceReport.returnToService == null + ? ASubTitle( + _subtitle.requiredWord, + color: Colors.red, + ) + : const SizedBox.shrink(), + Row( + children: [ + Expanded( + child: ADatePicker( + date: _serviceReport.returnToService, + from: DateTime.now().subtract(const Duration(days: 365)), + to: DateTime.now().add(const Duration(days: 365)), + onDatePicker: (date) { + _serviceReport.returnToService = date; + setState(() {}); + }, + ), + ), + ], + ), + ], + ), + ), + ], + ), + const SizedBox( + height: 8, + ), ASubTitle(_subtitle.workingHours), const SizedBox(height: 8), Row( @@ -569,7 +569,7 @@ class _CreateServiceReportState extends State with TickerPr ), Row( children: [ - ASubTitle(_subtitle.workPreformed), + const ASubTitle("Solutions"), // Expanded( // child: SizedBox( // height: 32 * AppStyle.getScaleFactor(context), @@ -609,7 +609,7 @@ class _CreateServiceReportState extends State with TickerPr child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(_subtitle.reasons), + const ASubTitle("Failure Reason"), _validate && _serviceReport.reason?.id == null ? ASubTitle( _subtitle.requiredWord, @@ -655,7 +655,7 @@ class _CreateServiceReportState extends State with TickerPr }, ), const SizedBox(height: 16), - ASubTitle(_subtitle.travelingExpense), + const ASubTitle("Travel Expenses"), const SizedBox( height: 4, ), @@ -791,7 +791,7 @@ class _CreateServiceReportState extends State with TickerPr // ), const SizedBox(height: 8), - ASubTitle(_subtitle.comment), + const ASubTitle("Technical comment"), const SizedBox(height: 4), ATextFormField( initialValue: _serviceReport?.comment, @@ -858,7 +858,7 @@ class _CreateServiceReportState extends State with TickerPr child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(_subtitle.partNumber), + ASubTitle(_subtitle.partNumberName), _validate && _serviceReport.parts == null ? ASubTitle( _subtitle.requiredWord, diff --git a/lib/views/pages/user/requests/report/edit_service_report.dart b/lib/views/pages/user/requests/report/edit_service_report.dart index 8191fc4d..b783e5a6 100644 --- a/lib/views/pages/user/requests/report/edit_service_report.dart +++ b/lib/views/pages/user/requests/report/edit_service_report.dart @@ -1000,7 +1000,7 @@ class _EditServiceReportState extends State with TickerProvid child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ASubTitle(_subtitle.partNumber), + ASubTitle(_subtitle.partNumberName), _validate && _serviceReport.parts == null ? ASubTitle( _subtitle.requiredWord, diff --git a/lib/views/pages/user/visits/visit_details.dart b/lib/views/pages/user/visits/visit_details.dart index 72143a2d..7fb05200 100644 --- a/lib/views/pages/user/visits/visit_details.dart +++ b/lib/views/pages/user/visits/visit_details.dart @@ -13,20 +13,18 @@ import 'package:test_sa/views/widgets/loaders/image_loader.dart'; import 'package:test_sa/views/widgets/requests/info_row.dart'; import 'package:test_sa/views/widgets/visits/visit_status.dart'; -import '../../../../controllers/providers/api/regular_visits_provider.dart'; import '../../../../controllers/providers/api/user_provider.dart'; import '../../../../models/enums/user_types.dart'; class VisitDetailsPage extends StatelessWidget { - static final String id = "/visit-details"; + static const String id = "/visit-details"; final Visit visit; const VisitDetailsPage({Key key, this.visit}) : super(key: key); @override Widget build(BuildContext context) { - Subtitle _subtitle = AppLocalization.of(context).subtitle; - final regularVisitsProvider = Provider.of(context); - UserProvider _userProvider = Provider.of(context); + Subtitle subtitle = AppLocalization.of(context).subtitle; + UserProvider userProvider = Provider.of(context); return Scaffold( body: SafeArea( @@ -37,16 +35,16 @@ class VisitDetailsPage extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4), child: Row( children: [ - ABackButton(), + const ABackButton(), Expanded( child: Center( child: Text( - _subtitle.visitInformation, - style: Theme.of(context).textTheme.headline6.copyWith(color: AColors.white, fontStyle: FontStyle.italic), + subtitle.visitInformation, + style: Theme.of(context).textTheme.titleLarge.copyWith(color: AColors.white, fontStyle: FontStyle.italic), ), ), ), - if (_userProvider?.user?.type == UsersTypes.engineer) + if (userProvider?.user?.type == UsersTypes.engineer) AIconButton( iconData: Icons.edit, color: AColors.white, @@ -60,15 +58,15 @@ class VisitDetailsPage extends StatelessWidget { ))); }, ), - SizedBox(width: 42) + const SizedBox(width: 42) ], ), ), Expanded( child: ListView( - padding: EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 16), children: [ - SizedBox( + const SizedBox( height: 8, ), MaterialButton( @@ -97,7 +95,7 @@ class VisitDetailsPage extends StatelessWidget { ), ), ), - SizedBox( + const SizedBox( height: 8, ), SizedBox( @@ -106,11 +104,11 @@ class VisitDetailsPage extends StatelessWidget { images: visit.images, ), ), - SizedBox( + const SizedBox( height: 8, ), RequestInfoRow( - title: _subtitle.code, + title: subtitle.code, info: visit.serialNumber, ), RequestInfoRow( @@ -118,27 +116,27 @@ class VisitDetailsPage extends StatelessWidget { info: visit.deviceNumber, ), RequestInfoRow( - title: _subtitle.deviceName, + title: subtitle.deviceName, content: visit.deviceEnglishName, ), RequestInfoRow( - title: _subtitle.deviceSN, + title: subtitle.deviceSN, info: visit.deviceSerialNumber, ), RequestInfoRow( - title: _subtitle.expectDate, + title: subtitle.expectDate, info: visit.expectDate, ), RequestInfoRow( - title: _subtitle.actualDate, + title: subtitle.actualDate, info: visit.actualDate, ), Row( children: [ Expanded( child: Text( - "${_subtitle.status} : ", - style: Theme.of(context).textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold), + "${subtitle.status} : ", + style: Theme.of(context).textTheme.titleMedium.copyWith(fontWeight: FontWeight.bold), textScaleFactor: AppStyle.getScaleFactor(context), ), ), @@ -151,15 +149,15 @@ class VisitDetailsPage extends StatelessWidget { color: Theme.of(context).primaryColor, ), RequestInfoRow( - title: _subtitle.contactStatus, + title: subtitle.contactStatus, info: visit.assignTo, ), RequestInfoRow( - title: _subtitle.engineerName, + title: subtitle.engineerName, info: visit.employName, ), RequestInfoRow( - title: _subtitle.hospital, + title: subtitle.hospital, content: visit.hospitalName, ), ], diff --git a/lib/views/widgets/gas_refill/building_type_menu.dart b/lib/views/widgets/gas_refill/building_type_menu.dart index afccd900..7509fe4d 100644 --- a/lib/views/widgets/gas_refill/building_type_menu.dart +++ b/lib/views/widgets/gas_refill/building_type_menu.dart @@ -3,12 +3,15 @@ import 'package:test_sa/models/hospital.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; +import '../loaders/app_loading.dart'; + class BuildingTypeMenu extends StatefulWidget { final Function(Buildings) onSelect; Buildings initialValue; List building; + bool enabled; - BuildingTypeMenu({Key key, this.onSelect, this.initialValue, this.building = const []}) : super(key: key); + BuildingTypeMenu({Key key, this.onSelect, this.initialValue, this.building = const [], this.enabled = true}) : super(key: key); @override _BuildingTypeMenuState createState() { @@ -51,46 +54,55 @@ class _BuildingTypeMenuState extends State { decoration: BoxDecoration( color: AColors.inputFieldBackgroundColor, border: Border.all( - color: Color(0xffefefef), + color: const Color(0xffefefef), ), borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)), // boxShadow: const [ // AppStyle.boxShadow // ] ), - child: DropdownButton( - value: _selectedBuilding, - iconSize: 24, - icon: const Icon(Icons.keyboard_arrow_down_rounded), - elevation: 0, - isExpanded: true, - hint: Text( - "Select Building", - style: Theme.of(context).textTheme.subtitle1, - ), - style: TextStyle(color: Theme.of(context).primaryColor), - underline: SizedBox.shrink(), - onChanged: (Buildings newValue) { - setState(() { - _selectedBuilding = newValue; - }); - widget.onSelect(newValue); - }, - items: _building?.map>((Buildings value) { - return DropdownMenuItem( - value: value, - child: Text( - value.name ?? "", - style: Theme.of(context).textTheme.subtitle1.copyWith( - color: Theme.of(context).primaryColor, - fontSize: 11, - //fontWeight: FontWeight.bold + child: widget.enabled + ? DropdownButton( + value: _selectedBuilding, + iconSize: 24, + icon: const Icon(Icons.keyboard_arrow_down_rounded), + elevation: 0, + isExpanded: true, + hint: Text( + "Select Building", + style: Theme.of(context).textTheme.subtitle1, + ), + style: TextStyle(color: Theme.of(context).primaryColor), + underline: const SizedBox.shrink(), + onChanged: (Buildings newValue) { + setState(() { + _selectedBuilding = newValue; + }); + widget.onSelect(newValue); + }, + items: _building?.map>((Buildings value) { + return DropdownMenuItem( + value: value, + child: Text( + value.name ?? "", + style: Theme.of(context).textTheme.subtitle1.copyWith( + color: Theme.of(context).primaryColor, + fontSize: 11, + //fontWeight: FontWeight.bold + ), ), + ); + })?.toList() ?? + [], + ) + : widget.initialValue == null + ? const Padding( + padding: EdgeInsets.all(8.0), + child: ALoading(), + ) + : ListTile( + title: Center(child: Text(widget.initialValue.name)), ), - ); - })?.toList() ?? - [], - ), ); } } diff --git a/lib/views/widgets/gas_refill/department_type_menu.dart b/lib/views/widgets/gas_refill/department_type_menu.dart index 1b58c200..bd887c74 100644 --- a/lib/views/widgets/gas_refill/department_type_menu.dart +++ b/lib/views/widgets/gas_refill/department_type_menu.dart @@ -3,12 +3,21 @@ import 'package:test_sa/models/hospital.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; +import '../loaders/app_loading.dart'; + class DepartmentTypeMenu extends StatefulWidget { final Function(Departments) onSelect; Departments initialValue; List departments; + bool enabled; - DepartmentTypeMenu({Key key, this.onSelect, this.initialValue, this.departments = const []}) : super(key: key); + DepartmentTypeMenu({ + Key key, + this.onSelect, + this.initialValue, + this.departments = const [], + this.enabled = true, + }) : super(key: key); @override _DepartmentTypeMenuState createState() { @@ -58,39 +67,43 @@ class _DepartmentTypeMenuState extends State { // AppStyle.boxShadow // ] ), - child: DropdownButton( - value: _selected, - iconSize: 24, - icon: const Icon(Icons.keyboard_arrow_down_rounded), - elevation: 0, - isExpanded: true, - hint: Text( - "Select Department", - style: Theme.of(context).textTheme.subtitle1, - ), - style: TextStyle(color: Theme.of(context).primaryColor), - underline: SizedBox.shrink(), - onChanged: (Departments newValue) { - setState(() { - _selected = newValue; - }); - widget.onSelect(newValue); - }, - items: widget?.departments?.map>((Departments value) { - return DropdownMenuItem( - value: value, - child: Text( - value.name, - style: Theme.of(context).textTheme.subtitle1.copyWith( - color: Theme.of(context).primaryColor, - fontSize: 11, - //fontWeight: FontWeight.bold + child: widget.enabled + ? DropdownButton( + value: _selected, + iconSize: 24, + icon: const Icon(Icons.keyboard_arrow_down_rounded), + elevation: 0, + isExpanded: true, + hint: Text( + "Select Department", + style: Theme.of(context).textTheme.subtitle1, + ), + style: TextStyle(color: Theme.of(context).primaryColor), + underline: SizedBox.shrink(), + onChanged: (Departments newValue) { + setState(() { + _selected = newValue; + }); + widget.onSelect(newValue); + }, + items: widget?.departments?.map>((Departments value) { + return DropdownMenuItem( + value: value, + child: Text( + value.name, + style: Theme.of(context).textTheme.subtitle1.copyWith( + color: Theme.of(context).primaryColor, + fontSize: 11, + //fontWeight: FontWeight.bold + ), ), - ), - ); - })?.toList() ?? - [], - ), + ); + })?.toList() ?? + [], + ) + : widget.initialValue == null + ? const Padding(padding: EdgeInsets.all(8.0), child: ALoading()) + : ListTile(title: Center(child: Text(widget.initialValue.name))), ); } } diff --git a/lib/views/widgets/gas_refill/floor_type_menu.dart b/lib/views/widgets/gas_refill/floor_type_menu.dart index df5d3325..5c29fac1 100644 --- a/lib/views/widgets/gas_refill/floor_type_menu.dart +++ b/lib/views/widgets/gas_refill/floor_type_menu.dart @@ -3,12 +3,21 @@ import 'package:test_sa/models/hospital.dart'; import 'package:test_sa/views/app_style/colors.dart'; import 'package:test_sa/views/app_style/sizing.dart'; +import '../loaders/app_loading.dart'; + class FloorTypeMenu extends StatefulWidget { final Function(Floors) onSelect; Floors initialValue; List floors; + bool enabled; - FloorTypeMenu({Key key, this.onSelect, this.initialValue, this.floors = const []}) : super(key: key); + FloorTypeMenu({ + Key key, + this.onSelect, + this.initialValue, + this.floors = const [], + this.enabled = true, + }) : super(key: key); @override _FloorTypeMenuState createState() { @@ -51,46 +60,55 @@ class _FloorTypeMenuState extends State { decoration: BoxDecoration( color: AColors.inputFieldBackgroundColor, border: Border.all( - color: Color(0xffefefef), + color: const Color(0xffefefef), ), borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)), // boxShadow: const [ // AppStyle.boxShadow // ] ), - child: DropdownButton( - value: _selected, - iconSize: 24, - icon: const Icon(Icons.keyboard_arrow_down_rounded), - elevation: 0, - isExpanded: true, - hint: Text( - "Select Floor", - style: Theme.of(context).textTheme.subtitle1, - ), - style: TextStyle(color: Theme.of(context).primaryColor), - underline: SizedBox.shrink(), - onChanged: (Floors newValue) { - setState(() { - _selected = newValue; - }); - widget.onSelect(newValue); - }, - items: _floors?.map>((Floors value) { - return DropdownMenuItem( - value: value, - child: Text( - value.name ?? "", - style: Theme.of(context).textTheme.subtitle1.copyWith( - color: Theme.of(context).primaryColor, - fontSize: 11, - //fontWeight: FontWeight.bold + child: widget.enabled + ? DropdownButton( + value: _selected, + iconSize: 24, + icon: const Icon(Icons.keyboard_arrow_down_rounded), + elevation: 0, + isExpanded: true, + hint: Text( + "Select Floor", + style: Theme.of(context).textTheme.subtitle1, + ), + style: TextStyle(color: Theme.of(context).primaryColor), + underline: const SizedBox.shrink(), + onChanged: (Floors newValue) { + setState(() { + _selected = newValue; + }); + widget.onSelect(newValue); + }, + items: _floors?.map>((Floors value) { + return DropdownMenuItem( + value: value, + child: Text( + value.name ?? "", + style: Theme.of(context).textTheme.subtitle1.copyWith( + color: Theme.of(context).primaryColor, + fontSize: 11, + //fontWeight: FontWeight.bold + ), ), + ); + })?.toList() ?? + [], + ) + : widget.initialValue == null + ? const Padding( + padding: EdgeInsets.all(8.0), + child: ALoading(), + ) + : ListTile( + title: Center(child: Text(widget.initialValue.name)), ), - ); - })?.toList() ?? - [], - ), ); } } diff --git a/lib/views/widgets/search/asset_transfer_search_dialog.dart b/lib/views/widgets/search/asset_transfer_search_dialog.dart new file mode 100644 index 00000000..59539238 --- /dev/null +++ b/lib/views/widgets/search/asset_transfer_search_dialog.dart @@ -0,0 +1,202 @@ +import 'package:flutter/material.dart'; +import 'package:test_sa/controllers/localization/localization.dart'; +import 'package:test_sa/models/device/device_transfer_search.dart'; +import 'package:test_sa/models/subtitle.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/buttons/app_small_button.dart'; + +import '../app_text_form_field.dart'; +import '../date_and_time/date_picker.dart'; +import '../status/report/service_report_visit_date_operator.dart'; +import '../switch_button.dart'; +import '../titles/app_sub_title.dart'; + +class AssetTransferSearchDialog extends StatefulWidget { + final DeviceTransferSearch initialSearchValue; + final bool expandedSearch; + final Function(DeviceTransferSearch) onSearch; + + const AssetTransferSearchDialog({Key key, this.initialSearchValue, this.expandedSearch, this.onSearch}) : super(key: key); + @override + AssetTransferSearchDialogState createState() => AssetTransferSearchDialogState(); +} + +class AssetTransferSearchDialogState extends State with TickerProviderStateMixin { + DeviceTransferSearch _search; + final GlobalKey _formKey = GlobalKey(); + + @override + void initState() { + super.initState(); + _search = DeviceTransferSearch(); + _search.fromSearch(widget.initialSearchValue); + } + + @override + Widget build(BuildContext context) { + Subtitle subtitle = AppLocalization.of(context).subtitle; + return SizedBox( + height: MediaQuery.of(context).size.height / 1.3, + child: Form( + key: _formKey, + child: ListView( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ASmallButton( + text: subtitle.cancel, + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ASmallButton( + text: subtitle.search, + onPressed: () { + if (!_formKey.currentState.validate()) { + return; + } + _formKey.currentState.save(); + Navigator.of(context).pop(_search); + }, + ) + ], + ), + ASwitchButton( + title: "Most Recent", + value: _search.mostRecent ?? false, + onChange: (value) { + _search.mostRecent = value; + setState(() {}); + }, + ), + SizedBox( + height: 8.0 * AppStyle.getScaleFactor(context), + ), + ATextFormField( + initialValue: _search.assetNumber, + hintText: subtitle.assetNumber, + style: Theme.of(context).textTheme.headline6, + textInputAction: TextInputAction.search, + onAction: () { + if (!_formKey.currentState.validate()) { + return; + } + _formKey.currentState.save(); + Navigator.of(context).pop(_search); + }, + onSaved: (value) { + _search.assetNumber = value; + }, + ), + SizedBox( + height: 8.0 * AppStyle.getScaleFactor(context), + ), + ATextFormField( + initialValue: _search.assetName, + hintText: subtitle.assetName, + style: Theme.of(context).textTheme.headline6, + textInputAction: TextInputAction.search, + onAction: () { + if (!_formKey.currentState.validate()) { + return; + } + _formKey.currentState.save(); + Navigator.of(context).pop(_search); + }, + onSaved: (value) { + _search.site = value; + }, + ), + SizedBox( + height: 8.0 * AppStyle.getScaleFactor(context), + ), + ATextFormField( + initialValue: _search.site, + hintText: subtitle.site, + style: Theme.of(context).textTheme.headline6, + textInputAction: TextInputAction.search, + onAction: () { + if (!_formKey.currentState.validate()) { + return; + } + _formKey.currentState.save(); + Navigator.of(context).pop(_search); + }, + onSaved: (value) { + _search.assetName = value; + }, + ), + SizedBox( + height: 8.0 * AppStyle.getScaleFactor(context), + ), + const ASubTitle("Request Date"), + const SizedBox(height: 4), + ServiceReportVisitDateOperator( + initialValue: _search.dateOperator, + onSelect: (status) { + _search.dateOperator = status; + setState(() {}); + }, + ), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const ASubTitle("From"), + ADatePicker( + date: DateTime.tryParse(_search.from ?? ""), + from: DateTime(1950), + onDatePicker: (date) { + _search.from = date?.toIso8601String(); + setState(() {}); + }, + ), + ], + ), + ), + if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) const SizedBox(width: 16), + if (_search?.dateOperator?.name?.toLowerCase()?.contains("between") ?? false) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const ASubTitle("To"), + ADatePicker( + date: DateTime.tryParse(_search.to ?? ""), + from: DateTime(1950), + onDatePicker: (date) { + _search.to = date?.toIso8601String(); + setState(() {}); + }, + ), + ], + ), + ), + ], + ), + const SizedBox(width: 16), + Visibility( + visible: _search.toMap().isNotEmpty, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + child: AButton( + padding: EdgeInsets.zero, + text: subtitle.clearSearch, + onPressed: () { + _search = DeviceTransferSearch(); + Navigator.of(context).pop(_search); + }, + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/views/widgets/search/service_request_search_bar.dart b/lib/views/widgets/search/service_request_search_bar.dart index adabc6d8..682b4177 100644 --- a/lib/views/widgets/search/service_request_search_bar.dart +++ b/lib/views/widgets/search/service_request_search_bar.dart @@ -244,7 +244,7 @@ class _ServiceRequestsSearchDialogState extends State(context); + UserProvider userProvider = Provider.of(context); Color itemColor = index % 2 == 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; Color onItemColor = index % 2 != 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onPrimary; - Subtitle _subtitle = AppLocalization.of(context).subtitle; + Subtitle subtitle = AppLocalization.of(context).subtitle; return Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: ElevatedButton( style: ElevatedButton.styleFrom( - padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8), - primary: itemColor, + padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8), + backgroundColor: itemColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppStyle.getBorderRadius(context)), ), ), onPressed: () { - if (activeSelectMod && _userProvider.user.type == UsersTypes.engineer) + if (activeSelectMod && userProvider.user.type == UsersTypes.engineer) { onSelect(visit); - else + } else { onPressed(visit); + } }, - onLongPress: _userProvider.user.type == UsersTypes.engineer + onLongPress: userProvider.user.type == UsersTypes.engineer ? () { onLongPress(visit); } @@ -53,12 +54,12 @@ class VisitItem extends StatelessWidget { children: [ Expanded( child: Text( - "S.N: " + visit.deviceSerialNumber ?? "No serial number", - style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), + "S.N: ${visit.deviceSerialNumber}" ?? "No serial number", + style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold), ), ), AnimatedSwitcher( - duration: Duration(milliseconds: 400), + duration: const Duration(milliseconds: 400), child: Visibility( key: ValueKey(activeSelectMod), visible: activeSelectMod, @@ -83,10 +84,7 @@ class VisitItem extends StatelessWidget { ), Text( visit.deviceNumber ?? "", - style: Theme.of(context).textTheme.subtitle1.copyWith( - color: onItemColor, - fontSize: 14, - ), + style: Theme.of(context).textTheme.titleMedium.copyWith(color: onItemColor, fontSize: 14), ), Divider( color: onItemColor, @@ -96,7 +94,7 @@ class VisitItem extends StatelessWidget { Expanded( child: Text( visit.hospitalName ?? "No client found", - style: Theme.of(context).textTheme.subtitle1.copyWith( + style: Theme.of(context).textTheme.titleMedium.copyWith( color: onItemColor, fontSize: 14, ), @@ -106,29 +104,30 @@ class VisitItem extends StatelessWidget { ), Text( visit.modelAndBrand ?? "", - style: Theme.of(context).textTheme.subtitle1.copyWith( + style: Theme.of(context).textTheme.titleMedium.copyWith( color: onItemColor, fontSize: 14, ), ), - Divider(color: onItemColor), - Row( - children: [ - Expanded( - child: Text( - visit.employName ?? "No employ found", - style: Theme.of(context).textTheme.headline6.copyWith(color: onItemColor, fontSize: 14, fontWeight: FontWeight.bold), + if (visit.employName != null && visit.employName.isNotEmpty) Divider(color: onItemColor), + if (visit.employName != null && visit.employName.isNotEmpty) + Row( + children: [ + Expanded( + child: Text( + visit.employName ?? "No employ found", + style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14, fontWeight: FontWeight.bold), + ), ), - ), - // Text( - // visit.contactStatus ?? "", - // style: Theme.of(context).textTheme.subtitle1.copyWith( - // color: onItemColor, - // fontSize: 14, - // ), - // ), - ], - ), + // Text( + // visit.contactStatus ?? "", + // style: Theme.of(context).textTheme.subtitle1.copyWith( + // color: onItemColor, + // fontSize: 14, + // ), + // ), + ], + ), Divider( color: onItemColor, ), @@ -139,18 +138,12 @@ class VisitItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - _subtitle.expectDate, - style: Theme.of(context).textTheme.headline6.copyWith( - color: onItemColor, - fontSize: 14, - ), + subtitle.expectDate, + style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14), ), Text( - visit.expectDate ?? _subtitle.noDateFound, - style: Theme.of(context).textTheme.headline6.copyWith( - color: onItemColor, - fontSize: 14, - ), + visit.expectDate ?? subtitle.noDateFound, + style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14), ), ], ), @@ -159,25 +152,12 @@ class VisitItem extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - _subtitle.actualDate, - style: Theme.of(context).textTheme.headline6.copyWith( - color: onItemColor, - fontSize: 14, - ), + subtitle.actualDate, + style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14), ), Text( - visit.actualDate ?? _subtitle.noDateFound, - style: Theme.of(context).textTheme.headline6.copyWith( - color: onItemColor, - fontSize: 14, - ), - // Text( - // visit.contactStatus ?? "", - // style: Theme.of(context).textTheme.subtitle1.copyWith( - // color: onItemColor, - // fontSize: 14, - // ), - // ), + visit.actualDate ?? subtitle.noDateFound, + style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 14), ), ], ), diff --git a/lib/views/widgets/visits/visits_list.dart b/lib/views/widgets/visits/visits_list.dart index d4a867c8..bb327679 100644 --- a/lib/views/widgets/visits/visits_list.dart +++ b/lib/views/widgets/visits/visits_list.dart @@ -21,7 +21,7 @@ class VisitsList extends StatefulWidget { } class _VisitsListState extends State { - List _selectedVisits = []; + final List _selectedVisits = []; @override void initState() { @@ -31,10 +31,10 @@ class _VisitsListState extends State { @override Widget build(BuildContext context) { - Subtitle _subtitle = AppLocalization.of(context).subtitle; - if (widget.visits.length == 0) { + Subtitle subtitle = AppLocalization.of(context).subtitle; + if (widget.visits.isEmpty) { return NoItemFound( - message: _subtitle.noVisitsFound, + message: subtitle.noVisitsFound, ); } return Stack( @@ -45,13 +45,13 @@ class _VisitsListState extends State { child: ListView.builder( //physics: BouncingScrollPhysics(), itemCount: widget.visits.length, - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), itemBuilder: (context, itemIndex) { - Visit _visit = widget.visits[itemIndex]; - bool _isSelected = _selectedVisits.contains(_visit); + Visit visit = widget.visits[itemIndex]; + bool isSelected = _selectedVisits.contains(visit); return VisitItem( - visit: _visit, - isSelected: _isSelected, + visit: visit, + isSelected: isSelected, index: itemIndex, activeSelectMod: _selectedVisits.isNotEmpty, onPressed: (visit) { @@ -61,7 +61,7 @@ class _VisitsListState extends State { ))); }, onSelect: (visit) { - if (_isSelected) { + if (isSelected) { _selectedVisits.remove(visit); } else { _selectedVisits.add(visit); @@ -69,7 +69,7 @@ class _VisitsListState extends State { setState(() {}); }, onLongPress: (visit) { - if (_isSelected) { + if (isSelected) { _selectedVisits.remove(visit); } else { _selectedVisits.add(visit); @@ -84,7 +84,7 @@ class _VisitsListState extends State { child: Padding( padding: EdgeInsets.all(8.0 * AppStyle.getScaleFactor(context)), child: AnimatedSwitcher( - duration: Duration(milliseconds: 400), + duration: const Duration(milliseconds: 400), child: Visibility( key: ValueKey(_selectedVisits.isNotEmpty), visible: _selectedVisits.isNotEmpty, @@ -93,7 +93,7 @@ class _VisitsListState extends State { children: [ FloatingActionButton( heroTag: "cancel", - child: Icon(Icons.cancel), + child: const Icon(Icons.cancel), onPressed: () { _selectedVisits.clear(); setState(() {}); @@ -101,7 +101,7 @@ class _VisitsListState extends State { ), FloatingActionButton( heroTag: "edit", - child: Icon(Icons.edit), + child: const Icon(Icons.edit), onPressed: () { if (!widget.visits.contains(_selectedVisits.first)) { _selectedVisits.clear();