recurrent task ui complete
parent
81d4fa6a89
commit
ed1337e16d
@ -0,0 +1,184 @@
|
|||||||
|
class DummyData {
|
||||||
|
static List<Map<String, dynamic>> roomData = [
|
||||||
|
{
|
||||||
|
"name": "Room 1",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "General Inspection",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Alarm Check",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Overall Result",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Manifold",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Alarm Check",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Room 2",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "General Inspection",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Alarm Check",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Overall Result",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Room 3",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "General Inspection",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Alarm Check",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Overall Result",
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Room 4",
|
||||||
|
"cards": [
|
||||||
|
{
|
||||||
|
"title": "General Inspection",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Alarm Check",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Overall Result",
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "General Inspection",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Alarm Check",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "General Inspection",
|
||||||
|
"info": [
|
||||||
|
{
|
||||||
|
"label": "Room Temperature (15-35 C)",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Room Humidity <35%",
|
||||||
|
"value": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Valve value",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:test_sa/dashboard_latest/dashboard_view.dart';
|
||||||
|
import 'package:test_sa/extensions/text_extensions.dart';
|
||||||
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||||
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||||
|
|
||||||
|
class RoomInspectionCard extends StatefulWidget {
|
||||||
|
final Map<String, dynamic>? inspectionModel;
|
||||||
|
|
||||||
|
RoomInspectionCard({super.key, required this.inspectionModel});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RoomInspectionCard> createState() => _RoomInspectionCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RoomInspectionCardState extends State<RoomInspectionCard> {
|
||||||
|
late List<bool> inspectionValues; // Add a list to store the state of switches
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
inspectionValues = widget.inspectionModel?['info']
|
||||||
|
?.map<bool>((inspectionType) => inspectionType['value'] as bool)
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: widget.inspectionModel?['info']
|
||||||
|
?.asMap()
|
||||||
|
.entries
|
||||||
|
.map<Widget>((entry) => inspectionStatusRadioWidget(
|
||||||
|
index: entry.key,
|
||||||
|
label: entry.value['label'],
|
||||||
|
context: context,
|
||||||
|
))
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
).toShadowContainer(context).paddingOnly(top: 12);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget inspectionStatusRadioWidget({
|
||||||
|
required int index,
|
||||||
|
required String label,
|
||||||
|
required BuildContext context,
|
||||||
|
}) {
|
||||||
|
String status = inspectionValues[index] ? 'Pass' : 'Fail';
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
label
|
||||||
|
.bodyText2(context)
|
||||||
|
.custom(color: AppColor.white936, fontWeight: FontWeight.w500),
|
||||||
|
status
|
||||||
|
.bodyText2(context)
|
||||||
|
.custom(color: AppColor.neutral120, fontWeight: FontWeight.w500),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
CupertinoSwitch(
|
||||||
|
thumbColor:
|
||||||
|
inspectionValues[index] ? AppColor.green50 : AppColor.red30,
|
||||||
|
activeColor: inspectionValues[index]
|
||||||
|
? AppColor.green50.withOpacity(0.25)
|
||||||
|
: AppColor.red30.withOpacity(0.25),
|
||||||
|
value: inspectionValues[index],
|
||||||
|
onChanged: (state) {
|
||||||
|
setState(() {
|
||||||
|
inspectionValues[index] = state;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingOnly(bottom: 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
import 'package:flutter/material.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/new_views/app_style/app_color.dart';
|
||||||
|
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/dummy_data.dart';
|
||||||
|
import 'package:test_sa/views/pages/user/ppm/ppm_work_order/recurrent_wo/components/room_inspection_card.dart';
|
||||||
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
||||||
|
|
||||||
|
class RoomTabsWidget extends StatefulWidget {
|
||||||
|
const RoomTabsWidget({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RoomTabsWidget> createState() => _RoomTabsWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RoomTabsWidgetState extends State<RoomTabsWidget> {
|
||||||
|
int selectedIndex = 0;
|
||||||
|
bool isLoading = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(12.toScreenHeight),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: context.isDark ? AppColor.neutral50 : AppColor.white10,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
|
children: DummyData.roomData.asMap().entries.map((entry) {
|
||||||
|
final int index = entry.key;
|
||||||
|
final String label = entry.value['name'];
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
selectedIndex = index;
|
||||||
|
//TODO replace with api response delay...
|
||||||
|
Future.delayed(const Duration(seconds: 1)).whenComplete(() {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.only(right: 8.toScreenWidth),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: 20.toScreenHeight,
|
||||||
|
horizontal: 30.toScreenWidth,
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: selectedIndex == index ? (context.isDark ? AppColor.neutral60 : AppColor.neutral110) : Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(7),
|
||||||
|
),
|
||||||
|
child: label.bodyText(context).custom(
|
||||||
|
color: selectedIndex == index ? (context.isDark ? AppColor.white10 : AppColor.black20) : (context.isDark ? AppColor.neutral30 : AppColor.black20),
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.height,
|
||||||
|
// Display the Selected Tab Content
|
||||||
|
isLoading
|
||||||
|
? SizedBox(height: 120.toScreenHeight, child: const ALoading().center)
|
||||||
|
: ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
children: DummyData.roomData[selectedIndex]['cards'].map<Widget>((card) {
|
||||||
|
return RoomInspectionCard(inspectionModel: card);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue