Merge branch 'zaid-development' into 'master'

Preventive Maintenance Screen

See merge request haroon6138/cloudsolutions-atoms!8
merge-requests/9/merge
Sikander Saleem 2 years ago
commit af5726fe38

@ -72,11 +72,9 @@ class RegularVisitsProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
// client's request was successfully received
try {
List requestsListJson =
json.decode(utf8.decode(response.bodyBytes).replaceAll("\\", ""));
List<Visit> visits =
requestsListJson.map((request) => Visit.fromJson(request)).toList();
visits.addAll(visits);
List requestsListJson = json.decode(utf8.decode(response.bodyBytes).replaceAll("\\", ""));
List<Visit> visitsList = requestsListJson.map((request) => Visit.fromJson(request)).toList();
visits.addAll(visitsList);
if (visits.length == pageItemNumber) {
nextPage = true;
} else {
@ -149,22 +147,22 @@ class RegularVisitsProvider extends ChangeNotifier {
}
Future<int> updatePentry({
required String host,
required User user,
required Pentry pentry,
required Visit visit,
required String? host,
required User? user,
required Pentry? pentry,
required Visit? visit,
}) async {
try {
Response response;
Map<String, String> body = pentry.toMap();
body["uid"] = user.id ?? "";
body["token"] = user.token ?? "";
Map<String, String>? body = pentry?.toMap();
body?["uid"] = user?.id ?? "";
body?["token"] = user?.token ?? "";
response = await post(
Uri.parse("$host${URLs.updatePentry}/${visit.id}"),
Uri.parse("$host${URLs.updatePentry}/${visit?.id}"),
body: body,
);
if (response.statusCode >= 200 && response.statusCode < 300) {
visit.status = pentry.ppmVisitStatus;
visit?.status = pentry?.ppmVisitStatus;
notifyListeners();
}
return response.statusCode;

@ -44,21 +44,15 @@ class Pentry {
Map<String, String> toMap() {
Map<String, String> map = {};
if (ppmVisitStatus != null)
map["visit_status"] = ppmVisitStatus!.id.toString();
if (ppmVisitStatus != null) map["visit_status"] = ppmVisitStatus!.id.toString();
if (status != null) map["pentry_status"] = status!.id.toString();
if (travelingHours != null) map["traveling_hours"] = travelingHours!;
if (imageFile != null)
map["file_attachement"] = base64Encode(imageFile!.readAsBytesSync());
map["actual_date"] = ((actualVisitDate?.millisecondsSinceEpoch ?? 0) / 1000)
.toStringAsFixed(0);
if (imageFile != null) map["file_attachement"] = base64Encode(imageFile!.readAsBytesSync());
map["actual_date"] = ((actualVisitDate?.millisecondsSinceEpoch ?? 0) / 1000).toStringAsFixed(0);
if (timer != null) {
map["start_date"] =
((timer!.startAt?.millisecondsSinceEpoch??0) / 1000).toStringAsFixed(0);
map["end_date"] =
(((timer!.endAt)?.millisecondsSinceEpoch??0) / 1000).toStringAsFixed(0);
map["working_hours"] =
((timer!.durationInSecond??0) / 60 / 60).toStringAsFixed(5);
map["start_date"] = ((timer!.startAt?.millisecondsSinceEpoch ?? 0) / 1000).toStringAsFixed(0);
map["end_date"] = (((timer!.endAt)?.millisecondsSinceEpoch ?? 0) / 1000).toStringAsFixed(0);
map["working_hours"] = ((timer!.durationInSecond ?? 0) / 60 / 60).toStringAsFixed(5);
}
// if(contacts?.isNotEmpty == true) {
// for(int i = 0;i<contacts.length;i++){
@ -67,10 +61,8 @@ class Pentry {
// });
// }
// }
map["ppmCheckLists"] =
jsonEncode(ppmCheckLists?.map((e) => e.toMap()).toList());
map["calibrationTools"] =
jsonEncode(calibrationTools?.map((e) => e.toMap()).toList());
map["ppmCheckLists"] = jsonEncode(ppmCheckLists?.map((e) => e.toMap()).toList());
map["calibrationTools"] = jsonEncode(calibrationTools?.map((e) => e.toMap()).toList());
map["pmKits"] = jsonEncode(pmKits?.map((e) => e.toMap()).toList());
return map;
}
@ -85,34 +77,24 @@ class Pentry {
List<PMKit> pmKits = [];
if (map['pmKits'] != null) {
pmKits = (map['pmKits'] as List<dynamic>)
.map((e) => PMKit.fromMap(e as Map<String, dynamic>))
.toList();
pmKits = (map['pmKits'] as List<dynamic>).map((e) => PMKit.fromMap(e as Map<String, dynamic>)).toList();
}
List<PPMCheckList> ppmCheckLists = [];
if (map['ppmCheckLists'] != null) {
ppmCheckLists = (map['ppmCheckLists'] as List<dynamic>)
.map((e) => PPMCheckList.fromMap(e as Map<String, dynamic>))
.toList();
ppmCheckLists = (map['ppmCheckLists'] as List<dynamic>).map((e) => PPMCheckList.fromMap(e as Map<String, dynamic>)).toList();
}
List<CalibrationTool> calibrationTools = [];
if (map['calibrationTools'] != null) {
calibrationTools = (map['calibrationTools'] as List<dynamic>)
.map((e) => CalibrationTool.fromMap(e as Map<String, dynamic>))
.toList();
calibrationTools = (map['calibrationTools'] as List<dynamic>).map((e) => CalibrationTool.fromMap(e as Map<String, dynamic>)).toList();
}
return Pentry(
status: Lookup.fromJson(map["pentry_status"]),
ppmVisitStatus: Lookup.fromJson(map["visit_status"]),
actualVisitDate: getDate(map["actual_date"]),
travelingHours: map["traveling_hours"],
timer: TimerModel(
startAt: getDate(map["start_date"]),
endAt: getDate(map["end_date"]),
durationInSecond:
(int.tryParse(map["working_hours"] ?? "") ?? 0) * 60 * 60),
timer: TimerModel(startAt: getDate(map["start_date"]), endAt: getDate(map["end_date"]), durationInSecond: (int.tryParse(map["working_hours"] ?? "") ?? 0) * 60 * 60),
// contacts: contacts,
ppmCheckLists: ppmCheckLists,
calibrationTools: calibrationTools,
@ -120,9 +102,7 @@ class Pentry {
);
}
static getDate(String date) {
return date.isEmpty
? null
: DateTime.fromMillisecondsSinceEpoch((int.tryParse(date) ?? 0) * 1000);
static getDate(String? date) {
return date == null || date.isEmpty ? null : DateTime.fromMillisecondsSinceEpoch((int.tryParse(date) ?? 0) * 1000);
}
}

@ -1,7 +1,6 @@
import '../lookup.dart';
class PMKit{
class PMKit {
Lookup? itemCode;
String? itemName;
String? preparationTimeFrame;
@ -10,37 +9,29 @@ class PMKit{
String? quantityNeeded;
String? quantityReserved;
PMKit({
this.itemCode,
this.itemName,
this.preparationTimeFrame,
this.kitFrequencyDemand,
this.availability,
this.quantityNeeded,
this.quantityReserved
});
PMKit({this.itemCode, this.itemName, this.preparationTimeFrame, this.kitFrequencyDemand, this.availability, this.quantityNeeded, this.quantityReserved});
Map<String, String> toMap() {
return {
if(itemCode != null) 'itemCode': (itemCode?.id).toString(),
if(itemName != null) 'itemName': itemName!,
if(preparationTimeFrame != null) 'preparationTimeFrame': preparationTimeFrame!,
if(kitFrequencyDemand != null) 'kitFrequencyDemand': kitFrequencyDemand!,
if(availability != null) 'availability': availability!,
if(quantityNeeded != null) 'quantityNeeded': quantityNeeded!,
if(quantityReserved != null) 'quantityReserved': quantityReserved!,
if (itemCode != null) 'itemCode': (itemCode?.id).toString(),
if (itemName != null) 'itemName': itemName!,
if (preparationTimeFrame != null) 'preparationTimeFrame': preparationTimeFrame!,
if (kitFrequencyDemand != null) 'kitFrequencyDemand': kitFrequencyDemand!,
if (availability != null) 'availability': availability!,
if (quantityNeeded != null) 'quantityNeeded': quantityNeeded!,
if (quantityReserved != null) 'quantityReserved': quantityReserved!,
};
}
factory PMKit.fromMap(Map<String, dynamic> map) {
return PMKit(
itemCode: Lookup.fromJson(map['itemCode']),
itemName: map['itemName'] as String,
preparationTimeFrame: map['preparationTimeFrame'] as String,
kitFrequencyDemand: map['kitFrequencyDemand'] as String,
availability: map['availability'] as String,
quantityNeeded: map['quantityNeeded'] as String,
quantityReserved: map['quantityReserved'] as String,
itemName: map['itemName'] as String?,
preparationTimeFrame: map['preparationTimeFrame'] as String?,
kitFrequencyDemand: map['kitFrequencyDemand'] as String?,
availability: map['availability'] as String?,
quantityNeeded: map['quantityNeeded'] as String?,
quantityReserved: map['quantityReserved'] as String?,
);
}
}
}

@ -1,7 +1,6 @@
import '../lookup.dart';
class PPMCheckList{
class PPMCheckList {
Lookup? status;
String? title;
String? comment;
@ -16,19 +15,19 @@ class PPMCheckList{
Map<String, String> toMap() {
return {
if(status != null) 'status': status!.id.toString(),
if(title != null) 'title': title!,
if(comment != null) 'comment': comment!,
if(measuredValue != null) 'measuredValue': measuredValue!,
if (status != null) 'status': status!.id.toString(),
if (title != null) 'title': title!,
if (comment != null) 'comment': comment!,
if (measuredValue != null) 'measuredValue': measuredValue!,
};
}
factory PPMCheckList.fromMap(Map<String, dynamic> map) {
return PPMCheckList(
status: Lookup.fromJson(map['status']),
title: map['title'] as String,
comment: map['comment'] as String,
measuredValue: map['measuredValue'] as String,
title: map['title'] as String?,
comment: map['comment'] as String?,
measuredValue: map['measuredValue'] as String?,
);
}
}
}

@ -1,7 +1,6 @@
import '../lookup.dart';
class Visit{
class Visit {
String? id;
String? serialNumber;
String? expectDate;
@ -42,7 +41,7 @@ class Visit{
this.deviceNumber,
});
factory Visit.fromJson(Map<String,dynamic> parsedJson){
factory Visit.fromJson(Map<String, dynamic> parsedJson) {
return Visit(
id: parsedJson["nid"],
serialNumber: parsedJson["title"],
@ -61,10 +60,10 @@ class Visit{
contactStatus: parsedJson["contactStatus"],
images: List<String>.from(parsedJson["images"] ?? []),
status: Lookup(
id: int.tryParse(parsedJson["status"] ?? "-1")??-1, // actual value (0,1,2)
label: parsedJson["status_value"] // text value
),
id: int.tryParse(parsedJson["status"] ?? "-1") ?? -1, // actual value (0,1,2)
label: parsedJson["status_value"] // text value
),
assignTo: parsedJson["assigned_to"],
);
}
}
}

@ -20,50 +20,48 @@ import '../../../../widgets/pentry/pentry_ppm_check_list_form.dart';
class EditPentry extends StatefulWidget {
final Pentry? pentry;
final Visit? visit;
const EditPentry({Key? key,this.pentry, this.visit}) : super(key: key);
const EditPentry({Key? key, this.pentry, this.visit}) : super(key: key);
@override
State<EditPentry> createState() => _EditPentryState();
}
class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateMixin{
class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateMixin {
bool _isLoading = false;
bool _validate = false;
late Subtitle _subtitle;
Subtitle? _subtitle;
late UserProvider _userProvider;
late SettingProvider _settingProvider;
late RegularVisitsProvider _regularVisitsProvider;
late Pentry _pentry;
Pentry? _pentry;
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
late TabController _tabController;
late final TabController _tabController;
_onSubmit() async {
_validate = true;
if(!_pentry.validate()) {
setState(() { });
if (!(_pentry?.validate() ?? false)) {
setState(() {});
return;
}
_isLoading = true;
setState(() {});
int status = await _regularVisitsProvider.updatePentry(
user: _userProvider.user!,
host: _settingProvider.host??"",
pentry: _pentry,
visit: widget.visit!
);
_isLoading =false;
int status = await _regularVisitsProvider.updatePentry(user: _userProvider.user, host: _settingProvider.host, pentry: _pentry, visit: widget.visit);
_isLoading = false;
setState(() {});
if(status >= 200 && status < 300){
Fluttertoast.showToast(
msg: _subtitle.requestCompleteSuccessfully,
);
if (status >= 200 && status < 300) {
if (_subtitle != null) {
Fluttertoast.showToast(
msg: _subtitle!.requestCompleteSuccessfully,
);
}
// Navigator.of(context).pop();
}else{
String errorMessage = HttpStatusManger.getStatusMessage(
status: status, subtitle: _subtitle);
} else {
String errorMessage = HttpStatusManger.getStatusMessage(status: status, subtitle: _subtitle);
Fluttertoast.showToast(
msg: errorMessage,
);
@ -72,7 +70,7 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
@override
void initState() {
_pentry = widget.pentry!;
_pentry = widget.pentry;
_tabController = TabController(length: 4, vsync: this);
super.initState();
}
@ -85,7 +83,7 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
@override
Widget build(BuildContext context) {
_subtitle = AppLocalization.of(context)!.subtitle!;
_subtitle = AppLocalization.of(context)?.subtitle;
_userProvider = Provider.of<UserProvider>(context);
_settingProvider = Provider.of<SettingProvider>(context);
_regularVisitsProvider = Provider.of<RegularVisitsProvider>(context);
@ -98,91 +96,101 @@ class _EditPentryState extends State<EditPentry> with SingleTickerProviderStateM
stateCode: 200,
onRefresh: () async {},
child: Column(
children: [
Material(
color: Theme.of(context).colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(2.0),
child: TabBar(
controller: _tabController,
isScrollable: true,
onTap: (index){
setState(() {});
},
tabs: const [
Tab(text: "PPM Check List",),
Tab(text: "Calibration Tools",),
Tab(text: "PK Kits",),
Tab(text: "Pentry",),
]),
children: [
Material(
color: Theme.of(context).colorScheme.primary,
child: Padding(
padding: const EdgeInsets.all(2.0),
child: TabBar(
controller: _tabController,
isScrollable: true,
onTap: (index) {
setState(() {});
},
tabs: const [
Tab(
text: "PPM Check List",
),
Tab(
text: "Calibration Tools",
),
Tab(
text: "PK Kits",
),
Tab(
text: "Pentry",
),
]),
),
),
Expanded(
child: Stack(
children: [
TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
PentryPPMCheckListForm(
models: _pentry?.ppmCheckLists,
enableValidate: _validate,
),
PentryCalibrationToolForm(
models: _pentry?.calibrationTools,
enableValidate: _validate,
),
PentryPMKitForm(
models: _pentry?.pmKits,
enableValidate: _validate,
),
PentryInfoForm(
model: _pentry,
enableValidate: _validate,
)
],
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
if (_tabController.index != 0)
ASmallButton(
text: _subtitle?.back,
onPressed: () {
_tabController.animateTo(
_tabController.index - 1,
);
setState(() {});
},
),
const Spacer(),
if (_tabController.index != _tabController.length - 1)
ASmallButton(
text: _subtitle?.next,
onPressed: () {
_tabController.animateTo(
_tabController.index + 1,
);
setState(() {});
},
),
if (_tabController.index == _tabController.length - 1)
ASmallButton(
text: _subtitle?.update,
onPressed: _onSubmit,
),
],
),
),
)
],
),
),
),
Expanded(
child: Stack(
children: [
TabBarView(
physics: const NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
PentryPPMCheckListForm(
models: _pentry.ppmCheckLists,
enableValidate: _validate,
),
PentryCalibrationToolForm(
models: _pentry.calibrationTools,
enableValidate: _validate,
),
PentryPMKitForm(
models: _pentry.pmKits,
enableValidate: _validate,
),
PentryInfoForm(
model: _pentry,
enableValidate: _validate,
)
],
),
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
if(_tabController.index != 0)
ASmallButton(
text: _subtitle.back,
onPressed: (){
_tabController.animateTo(_tabController.index - 1,);
setState(() {});
},
),
const Spacer(),
if(_tabController.index != _tabController.length -1)
ASmallButton(
text: _subtitle.next,
onPressed: (){
_tabController.animateTo(_tabController.index + 1,);
setState(() {});
},
),
if(_tabController.index == _tabController.length -1)
ASmallButton(
text: _subtitle.update,
onPressed: _onSubmit,
),
],
),
),
)
],
),
),
],
)
),
),
),
);
}
}

@ -4,20 +4,22 @@ import '../../../controllers/localization/localization.dart';
import '../../../models/subtitle.dart';
import '../../app_style/sizing.dart';
import 'date_picker.dart';
class FromToDateBar extends StatefulWidget {
final DateTime from;
final DateTime to;
final DateTime? from;
final DateTime? to;
final Function(DateTime)? onPickFrom;
final Function(DateTime)? onPickTo;
const FromToDateBar({Key? key, required this.from, required this.to, this.onPickFrom, this.onPickTo}) : super(key: key);
@override
_FromToDateBarState createState() => _FromToDateBarState();
}
class _FromToDateBarState extends State<FromToDateBar> {
late DateTime _from;
late DateTime _to;
late DateTime? _from;
late DateTime? _to;
@override
void initState() {
@ -32,22 +34,18 @@ class _FromToDateBarState extends State<FromToDateBar> {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_subtitle?.from??'',
style: Theme.of(context).textTheme.bodyText1?.copyWith(
fontSize: 12,
fontWeight: FontWeight.normal
),
_subtitle?.from ?? '',
style: Theme.of(context).textTheme.bodyText1?.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
textScaleFactor: AppStyle.getScaleFactor(context),
),
ADatePicker(
date: _from,
from: DateTime(1950),
onDatePicker: (date){
onDatePicker: (date) {
_from = date;
setState(() {});
widget.onPickFrom!(date);
@ -59,17 +57,14 @@ class _FromToDateBarState extends State<FromToDateBar> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_subtitle?.to??"",
style: Theme.of(context).textTheme.bodyText1?.copyWith(
fontSize: 12,
fontWeight: FontWeight.normal
),
_subtitle?.to ?? "",
style: Theme.of(context).textTheme.bodyText1?.copyWith(fontSize: 12, fontWeight: FontWeight.normal),
textScaleFactor: AppStyle.getScaleFactor(context),
),
ADatePicker(
date: _to,
from: DateTime(1950),
onDatePicker: (date){
onDatePicker: (date) {
_to = date;
setState(() {});
widget.onPickTo!(date);

@ -13,7 +13,9 @@ class PentryPPMCheckListForm extends StatefulWidget {
final List<PPMCheckList>? models;
final bool? enableValidate;
const PentryPPMCheckListForm({
Key? key, this.models, this.enableValidate,
Key? key,
this.models,
this.enableValidate,
}) : super(key: key);
@override
@ -21,99 +23,112 @@ class PentryPPMCheckListForm extends StatefulWidget {
}
class _PentryPPMCheckListFormState extends State<PentryPPMCheckListForm> {
@override
Widget build(BuildContext context) {
final subtitle = AppLocalization.of(context)?.subtitle;
return ListView.builder(
padding: EdgeInsets.only(
top: 12 * AppStyle.getScaleFactor(context),
left: 12 * AppStyle.getScaleFactor(context),
right: 12 * AppStyle.getScaleFactor(context),
bottom: 80 * AppStyle.getScaleFactor(context)
),
itemCount: (widget.models?.length??0) + 1,
itemBuilder: (context,index){
if(index == widget.models?.length){
return AButton(
text: subtitle?.add??"",
onPressed: (){
widget.models!.add(PPMCheckList());
setState(() {});
},
);
}
final model = widget.models![index];
return ListView(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ASubTitle("#${index+1}"),
if(index != 0)
ASmallButton(
color: Theme.of(context).colorScheme.error,
text: subtitle!.delete,
onPressed: (){
widget.models!.remove(model);
setState(() {});
},
),
],
),
const SizedBox(height: 8,),
const ASubTitle("Task"),
const SizedBox(height: 4,),
ATextFormField(
initialValue: (model.title ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.text,
onChange: (value){
model.title = value;
},
),
const SizedBox(height: 8,),
ASubTitle(subtitle?.status??""),
const SizedBox(height: 4,),
PentryTaskStatusMenu(
initialValue: model.status,
onSelect: (status){
model.status = status;
padding: EdgeInsets.only(
top: 12 * AppStyle.getScaleFactor(context), left: 12 * AppStyle.getScaleFactor(context), right: 12 * AppStyle.getScaleFactor(context), bottom: 80 * AppStyle.getScaleFactor(context)),
itemCount: (widget.models?.length ?? 0) + 1,
itemBuilder: (context, index) {
if (index == widget.models?.length) {
return AButton(
text: subtitle?.add ?? "",
onPressed: () {
widget.models?.add(PPMCheckList());
setState(() {});
},
),
const SizedBox(height: 8,),
const ASubTitle("Comment"),
const SizedBox(height: 4,),
ATextFormField(
initialValue: (model.comment ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.text,
onChange: (value){
model.comment = value;
},
),
const SizedBox(height: 8,),
const ASubTitle("Measured Value"),
const SizedBox(height: 4,),
ATextFormField(
initialValue: (model.measuredValue ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.text,
onChange: (value){
model.measuredValue = value;
},
),
const SizedBox(height: 8,),
Divider(color: Theme.of(context).textTheme.titleMedium?.color,),
],
);
}
);
);
}
final model = widget.models?[index];
return ListView(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ASubTitle("#${index + 1}"),
if (index != 0)
ASmallButton(
color: Theme.of(context).colorScheme.error,
text: subtitle?.delete,
onPressed: () {
widget.models?.remove(model);
setState(() {});
},
),
],
),
const SizedBox(
height: 8,
),
const ASubTitle("Task"),
const SizedBox(
height: 4,
),
ATextFormField(
initialValue: (model?.title ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.text,
onChange: (value) {
model?.title = value;
},
),
const SizedBox(
height: 8,
),
ASubTitle(subtitle?.status ?? ""),
const SizedBox(
height: 4,
),
PentryTaskStatusMenu(
initialValue: model?.status,
onSelect: (status) {
model?.status = status;
},
),
const SizedBox(
height: 8,
),
const ASubTitle("Comment"),
const SizedBox(
height: 4,
),
ATextFormField(
initialValue: (model?.comment ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.text,
onChange: (value) {
model?.comment = value;
},
),
const SizedBox(
height: 8,
),
const ASubTitle("Measured Value"),
const SizedBox(
height: 4,
),
ATextFormField(
initialValue: (model?.measuredValue ?? "").toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle1,
textInputType: TextInputType.text,
onChange: (value) {
model?.measuredValue = value;
},
),
const SizedBox(
height: 8,
),
Divider(
color: Theme.of(context).textTheme.titleMedium?.color,
),
],
);
});
}
}

@ -29,8 +29,7 @@ class VisitsSearchDialog extends StatefulWidget {
VisitsSearchDialogState createState() => VisitsSearchDialogState();
}
class VisitsSearchDialogState extends State<VisitsSearchDialog>
with TickerProviderStateMixin {
class VisitsSearchDialogState extends State<VisitsSearchDialog> with TickerProviderStateMixin {
VisitsSearch? _search;
List<Lookup> status = const [
Lookup(
@ -195,8 +194,7 @@ class VisitsSearchDialogState extends State<VisitsSearchDialog>
children: List.generate(
contactStatus.length,
(index) {
bool isSelected =
_search?.contactStatus == contactStatus[index].key;
bool isSelected = _search?.contactStatus == contactStatus[index].key;
return FilterItem(
isSelected: isSelected,
onSelected: () {
@ -220,8 +218,8 @@ class VisitsSearchDialogState extends State<VisitsSearchDialog>
height: 4.0 * AppStyle.getScaleFactor(context),
),
FromToDateBar(
from: _search!.actualDateFrom!,
to: _search!.actualDateTo!,
from: _search?.actualDateFrom,
to: _search?.actualDateTo,
onPickFrom: (date) {
_search?.actualDateFrom = date;
},
@ -237,11 +235,8 @@ class VisitsSearchDialogState extends State<VisitsSearchDialog>
height: 4.0 * AppStyle.getScaleFactor(context),
),
FromToDateBar(
from: _search?.expectedDateFrom ??
DateTime(today.year, today.month, 1),
to: _search?.expectedDateTo ??
DateTime(today.year, (today.month + 1).clamp(1, 12),
today.month == 12 ? 31 : 0),
from: _search?.expectedDateFrom ?? DateTime(today.year, today.month, 1),
to: _search?.expectedDateTo ?? DateTime(today.year, (today.month + 1).clamp(1, 12), today.month == 12 ? 31 : 0),
onPickFrom: (date) {
_search?.expectedDateFrom = date;
},
@ -252,8 +247,7 @@ class VisitsSearchDialogState extends State<VisitsSearchDialog>
Visibility(
visible: _search?.toSearchString().isNotEmpty ?? false,
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: AButton(
padding: EdgeInsets.zero,
text: subtitle?.clearSearch ?? '',

@ -26,11 +26,11 @@ class SingleStatusMenuState extends State<SingleStatusMenu> {
@override
void didUpdateWidget(covariant SingleStatusMenu oldWidget) {
if (widget.initialStatus != null) {
_selectedStatus = widget.statuses?.firstWhere((element) {
return element.id == widget.initialStatus?.id;
});
} else {
_selectedStatus = null;
_selectedStatus = widget.initialStatus?.id != null
? widget.statuses?.firstWhere((element) {
return element.id == widget.initialStatus?.id;
})
: null;
}
super.didUpdateWidget(oldWidget);
}
@ -38,9 +38,11 @@ class SingleStatusMenuState extends State<SingleStatusMenu> {
@override
void initState() {
if (widget.initialStatus != null) {
_selectedStatus = widget.statuses?.firstWhere((element) {
return element.id == widget.initialStatus?.id;
});
_selectedStatus = widget.initialStatus?.id != null
? widget.statuses?.firstWhere((element) {
return element.id == widget.initialStatus?.id;
})
: null;
}
super.initState();
@ -87,9 +89,7 @@ class SingleStatusMenuState extends State<SingleStatusMenu> {
value: value,
child: Text(
value.label ?? '',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.w600),
style: Theme.of(context).textTheme.titleMedium?.copyWith(color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600),
),
);
}).toList(),

Loading…
Cancel
Save