|
|
|
|
@ -5,6 +5,7 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
|
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/service_request_latest/request_detail_provider.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
@ -28,6 +29,7 @@ class HistoryLogView extends StatelessWidget {
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return Consumer<RequestDetailProvider>(builder: (context, requestProvider, _) {
|
|
|
|
|
String status = "";
|
|
|
|
|
return requestProvider.isLoading
|
|
|
|
|
? const CircularProgressIndicator(color: AppColor.primary10).center
|
|
|
|
|
: (requestProvider.currentWorkOrder == null || (requestProvider.currentWorkOrder?.data?.workOrderHistory.isEmpty ?? true)
|
|
|
|
|
@ -44,58 +46,81 @@ class HistoryLogView extends StatelessWidget {
|
|
|
|
|
endIndent: 10,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
ListView.builder(
|
|
|
|
|
itemCount: dummyList.length,
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return historyLogCard(context: context, historyLogModel: dummyList[index]);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Builder(builder: (cxt) {
|
|
|
|
|
List<Widget> items = [];
|
|
|
|
|
String lastStatus = "";
|
|
|
|
|
for (var object in requestProvider.currentWorkOrder!.data!.workOrderHistory) {
|
|
|
|
|
String currentStatus = object.workorderStatus!.name!;
|
|
|
|
|
if (lastStatus.isEmpty) {
|
|
|
|
|
lastStatus = currentStatus;
|
|
|
|
|
}
|
|
|
|
|
if (lastStatus == currentStatus) {
|
|
|
|
|
items.add(historyLogCard(cxt, object));
|
|
|
|
|
} else {
|
|
|
|
|
items.add(statusCard(cxt, lastStatus));
|
|
|
|
|
lastStatus = currentStatus;
|
|
|
|
|
items.add(historyLogCard(cxt, object));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
items.add(statusCard(cxt, lastStatus));
|
|
|
|
|
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(children: items),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget historyLogCard({required BuildContext context, required HistoryLogModel historyLogModel}) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
Widget historyLogCard(BuildContext context, WorkOrderHistory object) {
|
|
|
|
|
return Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
historyLogModel.status != null
|
|
|
|
|
? Padding(
|
|
|
|
|
padding: EdgeInsets.only(top: 16.toScreenHeight, bottom: 16.toScreenHeight, right: 89.toScreenWidth),
|
|
|
|
|
child: StatusLabel(
|
|
|
|
|
radius: 4,
|
|
|
|
|
label: historyLogModel.status,
|
|
|
|
|
textColor: AppColor.getRequestStatusTextColorByName(context, historyLogModel.status!),
|
|
|
|
|
backgroundColor: AppColor.getRequestStatusColorByName(context, historyLogModel.status!),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: 12.height,
|
|
|
|
|
Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
padding: EdgeInsets.only(left: 12.toScreenWidth, bottom: 16.toScreenHeight, top: 12.toScreenHeight),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
historyLogModel.date.toString().toServiceRequestCardFormat,
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
50.width,
|
|
|
|
|
Expanded(
|
|
|
|
|
child: historyLogModel.message.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
child: Text(
|
|
|
|
|
object.date.toString().toServiceRequestCardFormat,
|
|
|
|
|
textAlign: TextAlign.end,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral120),
|
|
|
|
|
),
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
).expanded,
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 2,
|
|
|
|
|
child: object.step!.name!.bodyText(context).custom(color: AppColor.black10),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
).toShadowContainer(context, padding: 16).paddingOnly(bottom: 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget statusCard(BuildContext context, String status) {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: 153.toScreenWidth,
|
|
|
|
|
child: StatusLabel(
|
|
|
|
|
radius: 4,
|
|
|
|
|
label: statusText(status.toLowerCase()),
|
|
|
|
|
labelInCenter: true,
|
|
|
|
|
textColor: AppColor.getHistoryLogStatusTextColorByName(status),
|
|
|
|
|
backgroundColor: AppColor.getHistoryLogStatusColorByName(status),
|
|
|
|
|
),
|
|
|
|
|
).paddingOnly(bottom: 16, start: 40);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String statusText(String status) {
|
|
|
|
|
if (status == "new") {
|
|
|
|
|
return "Open Request".addTranslation;
|
|
|
|
|
} else if (status == "in progress") {
|
|
|
|
|
return "Status update to In Progress".addTranslation;
|
|
|
|
|
} else if (status == "closed") {
|
|
|
|
|
return "Status update to Closed".addTranslation;
|
|
|
|
|
} else if (status == "completed") {
|
|
|
|
|
return "Status update to Completed".addTranslation;
|
|
|
|
|
} else if (status == "fixed") {
|
|
|
|
|
return "Status update to Fixed".addTranslation;
|
|
|
|
|
} else
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|