|
|
|
|
@ -1,15 +1,10 @@
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:test_sa/dashboard_latest/dashboard_view.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/enums/recurrent_task_inspection_data_type.dart';
|
|
|
|
|
import 'package:test_sa/models/ppm/recurrent_wo.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
|
|
|
import 'package:toggle_switch/toggle_switch.dart';
|
|
|
|
|
|
|
|
|
|
class RoomInspectionCard extends StatefulWidget {
|
|
|
|
|
final PlanRecurrentMedicalTaskRoomTabs? inspectionModel;
|
|
|
|
|
@ -21,7 +16,8 @@ class RoomInspectionCard extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
int selectedIndex =0;
|
|
|
|
|
int selectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -34,33 +30,28 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
children: [
|
|
|
|
|
widget.inspectionModel!.tabName!.bodyText(context).custom(color: AppColor.neutral50, fontWeight: FontWeight.w600),
|
|
|
|
|
8.height,
|
|
|
|
|
Column(
|
|
|
|
|
children: widget.inspectionModel!.planRecurrentMedicalTaskRoomTabAttributes?.asMap().entries.map<Widget>((entry) {
|
|
|
|
|
final model = entry.value;
|
|
|
|
|
final attribute = model.attribute;
|
|
|
|
|
|
|
|
|
|
switch (attribute?.dataTypeEnum) {
|
|
|
|
|
case RecurrentTaskInspectionDataTypeEnum.bool:
|
|
|
|
|
return inspectionStatusRadioWidget(
|
|
|
|
|
index: entry.key,
|
|
|
|
|
model: model,
|
|
|
|
|
context: context,
|
|
|
|
|
);
|
|
|
|
|
case RecurrentTaskInspectionDataTypeEnum.number:
|
|
|
|
|
return inspectionStatusNumberWidget(
|
|
|
|
|
index: entry.key,
|
|
|
|
|
model: model,
|
|
|
|
|
context: context,
|
|
|
|
|
);
|
|
|
|
|
default:
|
|
|
|
|
return const SizedBox.shrink(); // Handles any unexpected cases gracefully
|
|
|
|
|
}
|
|
|
|
|
}).toList() ??
|
|
|
|
|
[],
|
|
|
|
|
Container(
|
|
|
|
|
color: Colors.white10,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: widget.inspectionModel!.planRecurrentMedicalTaskRoomTabAttributes?.asMap().entries.map<Widget>((entry) {
|
|
|
|
|
final model = entry.value;
|
|
|
|
|
final attribute = model.attribute;
|
|
|
|
|
switch (attribute?.dataTypeEnum) {
|
|
|
|
|
case RecurrentTaskInspectionDataTypeEnum.bool:
|
|
|
|
|
return inspectionStatusRadioWidget(index: entry.key, model: model, context: context);
|
|
|
|
|
case RecurrentTaskInspectionDataTypeEnum.number:
|
|
|
|
|
return inspectionStatusNumberWidget(index: entry.key, model: model, context: context);
|
|
|
|
|
default:
|
|
|
|
|
return const SizedBox.shrink(); // Handles any unexpected cases gracefully
|
|
|
|
|
}
|
|
|
|
|
}).toList() ??
|
|
|
|
|
[],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context).paddingOnly(top: 12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget inspectionStatusRadioWidget({
|
|
|
|
|
required int index,
|
|
|
|
|
required PlanRecurrentMedicalTaskRoomTabAttributes model,
|
|
|
|
|
@ -68,8 +59,8 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
}) {
|
|
|
|
|
bool status = model.attribute != null
|
|
|
|
|
? model.attributeValue == 'true'
|
|
|
|
|
? true
|
|
|
|
|
: false
|
|
|
|
|
? true
|
|
|
|
|
: false
|
|
|
|
|
: false;
|
|
|
|
|
|
|
|
|
|
return Row(
|
|
|
|
|
@ -79,17 +70,15 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 220.toScreenWidth,
|
|
|
|
|
child: Text(
|
|
|
|
|
model.attribute!.name!,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
maxLines: 1, // Ensures text is limited to one line before ellipsis
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
model.attribute!.name!,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: AppColor.white936),
|
|
|
|
|
),
|
|
|
|
|
(status ? 'Pass' : 'Fail').bodyText2(context).custom(color: AppColor.neutral120, fontWeight: FontWeight.w500),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
@ -102,7 +91,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
height: 30.toScreenHeight,
|
|
|
|
|
padding: EdgeInsetsDirectional.all(4.toScreenHeight),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color:AppColor.white80,
|
|
|
|
|
color: AppColor.white80,
|
|
|
|
|
borderRadius: BorderRadius.circular(5),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
@ -113,7 +102,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
isActive: status,
|
|
|
|
|
activeColor: AppColor.green20,
|
|
|
|
|
inactiveColor: Colors.transparent,
|
|
|
|
|
textColor: status ? AppColor.green50 :AppColor.black20,
|
|
|
|
|
textColor: status ? AppColor.green50 : AppColor.black20,
|
|
|
|
|
),
|
|
|
|
|
buildToggleOption(
|
|
|
|
|
label: "FAIL",
|
|
|
|
|
@ -127,8 +116,9 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(bottom: 12);
|
|
|
|
|
).paddingOnly(top: 6, bottom: 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget buildToggleOption({
|
|
|
|
|
required String label,
|
|
|
|
|
required bool isActive,
|
|
|
|
|
@ -148,7 +138,6 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Widget inspectionStatusRadioWidget({
|
|
|
|
|
// required int index,
|
|
|
|
|
// required PlanRecurrentMedicalTaskRoomTabAttributes model,
|
|
|
|
|
@ -195,11 +184,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
// ).paddingOnly(bottom: 12);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Widget inspectionStatusNumberWidget({
|
|
|
|
|
required int index,
|
|
|
|
|
required PlanRecurrentMedicalTaskRoomTabAttributes model,
|
|
|
|
|
required BuildContext context,
|
|
|
|
|
}) {
|
|
|
|
|
Widget inspectionStatusNumberWidget({required int index, required PlanRecurrentMedicalTaskRoomTabAttributes model, required BuildContext context}) {
|
|
|
|
|
final border = OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(4), // Optional: Slight rounding
|
|
|
|
|
borderSide: const BorderSide(
|
|
|
|
|
@ -219,7 +204,7 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 5.toScreenWidth),
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: AppColor.neutral100,
|
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
|
maxWidth: 99.toScreenWidth,
|
|
|
|
|
maxHeight: 30.toScreenHeight,
|
|
|
|
|
),
|
|
|
|
|
@ -232,14 +217,10 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(bottom: 12);
|
|
|
|
|
).paddingOnly(bottom: 6, top: 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // I need it here ....
|
|
|
|
|
// Container(
|
|
|
|
|
// padding: EdgeInsets.all(6.toScreenHeight),
|
|
|
|
|
@ -297,4 +278,4 @@ class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
|
|
|
|
// // onToggle: (index) {
|
|
|
|
|
// // print('switched to: $index');
|
|
|
|
|
// // },
|
|
|
|
|
// // ),
|
|
|
|
|
// // ),
|
|
|
|
|
|