|
|
|
|
@ -22,6 +22,7 @@ import '../../views/widgets/images/files_list.dart';
|
|
|
|
|
import '../../views/widgets/requests/request_status.dart';
|
|
|
|
|
import '../loan_module/models/loan_request_model.dart';
|
|
|
|
|
import 'demo_activities_page.dart';
|
|
|
|
|
import 'models/demo_attachment_model.dart';
|
|
|
|
|
|
|
|
|
|
class DemoDetailViewPage extends StatefulWidget {
|
|
|
|
|
static const String id = "/demo-detail-page";
|
|
|
|
|
@ -36,36 +37,37 @@ class DemoDetailViewPage extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
bool isLoading = false;
|
|
|
|
|
// bool isLoading = false;
|
|
|
|
|
|
|
|
|
|
DemoRequestModel? dataModel;
|
|
|
|
|
// DemoRequestModel? dataModel;
|
|
|
|
|
DemoProvider? demoProvider;
|
|
|
|
|
List<WorkOrderAttachments> allAttachments = [];
|
|
|
|
|
|
|
|
|
|
// List<DemoAttachments> allAttachments = [];
|
|
|
|
|
|
|
|
|
|
//Todo need to check about attachments.
|
|
|
|
|
|
|
|
|
|
bool loading = false;
|
|
|
|
|
// bool loading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
demoProvider = Provider.of<DemoProvider>(context, listen: false);
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
getDetailsById();
|
|
|
|
|
});
|
|
|
|
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
// getDetailsById();
|
|
|
|
|
// });
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getDetailsById() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
loading = true;
|
|
|
|
|
});
|
|
|
|
|
dataModel = await demoProvider?.getDemoById(widget.demoId) ?? DemoRequestModel();
|
|
|
|
|
|
|
|
|
|
// _attachments = dataModel.demoAttachments.toList() ?? [];
|
|
|
|
|
setState(() {
|
|
|
|
|
loading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// Future<void> getDetailsById() async {
|
|
|
|
|
// setState(() {
|
|
|
|
|
// loading = true;
|
|
|
|
|
// });
|
|
|
|
|
// dataModel = await demoProvider?.getDemoById(widget.demoId);// ?? DemoRequestModel();
|
|
|
|
|
//
|
|
|
|
|
// allAttachments = dataModel?.demoAttachments ?? [];
|
|
|
|
|
// setState(() {
|
|
|
|
|
// loading = false;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
@ -76,69 +78,78 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: const DefaultAppBar(title: "Request Details"),
|
|
|
|
|
body: loading
|
|
|
|
|
? const CircularProgressIndicator(color: AppColor.primary10).center
|
|
|
|
|
: dataModel == null
|
|
|
|
|
? const NoDataFound().center
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (dataModel?.status != null) ...[
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: dataModel?.status?.name,
|
|
|
|
|
id: dataModel?.status?.value,
|
|
|
|
|
radius: 4,
|
|
|
|
|
textColor: AppColor.demoRequestStatusTextColor(context, dataModel!.status!.value!),
|
|
|
|
|
backgroundColor: AppColor.demoRequestStatus(context, dataModel!.status!.value!),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
...requesterDetails(context, dataModel),
|
|
|
|
|
12.height,
|
|
|
|
|
...requestDetails(context, dataModel),
|
|
|
|
|
12.height,
|
|
|
|
|
...doctorDetails(context, dataModel),
|
|
|
|
|
12.height,
|
|
|
|
|
...assetDetails(context, dataModel),
|
|
|
|
|
12.height,
|
|
|
|
|
...vendorDetails(context, dataModel),
|
|
|
|
|
if (allAttachments.isNotEmpty) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
Text(
|
|
|
|
|
"Attachments".addTranslation,
|
|
|
|
|
style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.name ?? '') ?? '').toList() ?? []),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, padding: 12),
|
|
|
|
|
).expanded,
|
|
|
|
|
FooterActionButton.demoRequestDetailsFooterWidget(
|
|
|
|
|
demoRequestStage: dataModel!.status!.demoRequestStepEnum!,
|
|
|
|
|
// demoRequestStage: DemoRequestStepEnum.updateRequest,
|
|
|
|
|
dataModel: dataModel!,
|
|
|
|
|
status: dataModel!.status!,
|
|
|
|
|
context: context,
|
|
|
|
|
refreshData: (status) {
|
|
|
|
|
if (status) {
|
|
|
|
|
getDetailsById();
|
|
|
|
|
}
|
|
|
|
|
}).toShadowContainer(context, padding: 0, showShadow: false, borderRadius: 0),
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
body: FutureBuilder<DemoRequestModel?>(
|
|
|
|
|
future: Provider.of<DemoProvider>(context, listen: false).getDemoById(widget.demoId),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<DemoRequestModel?> snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
|
|
|
|
if (snapshot.data == null) return const NoDataFound().center;
|
|
|
|
|
|
|
|
|
|
List<DemoAttachments> allAttachments = snapshot.data!.demoAttachments! ?? [];
|
|
|
|
|
|
|
|
|
|
DemoRequestModel demoData = snapshot.data!;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (demoData.status != null) ...[
|
|
|
|
|
StatusLabel(
|
|
|
|
|
label: demoData.status?.name,
|
|
|
|
|
id: demoData.status?.value,
|
|
|
|
|
radius: 4,
|
|
|
|
|
textColor: AppColor.demoRequestStatusTextColor(context, demoData.status!.value!),
|
|
|
|
|
backgroundColor: AppColor.demoRequestStatus(context, demoData.status!.value!),
|
|
|
|
|
),
|
|
|
|
|
8.height,
|
|
|
|
|
],
|
|
|
|
|
12.height,
|
|
|
|
|
...requesterDetails(context, demoData),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
...requestDetails(context, demoData),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
...doctorDetails(context, demoData),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
...assetDetails(context, demoData),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
...vendorDetails(context, demoData),
|
|
|
|
|
if (allAttachments.isNotEmpty) ...[
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
Text(
|
|
|
|
|
"Attachments".addTranslation,
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
),
|
|
|
|
|
FilesList(
|
|
|
|
|
showAsListView: true,
|
|
|
|
|
images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList(),
|
|
|
|
|
types: allAttachments.map((e) => e.documentType?.name ?? '').toList()),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
).toShadowContainer(context, padding: 12),
|
|
|
|
|
).expanded,
|
|
|
|
|
FooterActionButton.demoRequestDetailsFooterWidget(
|
|
|
|
|
demoRequestStage: demoData.status!.demoRequestStepEnum!,
|
|
|
|
|
// demoRequestStage: DemoRequestStepEnum.updateRequest,
|
|
|
|
|
dataModel: demoData,
|
|
|
|
|
status: demoData.status!,
|
|
|
|
|
context: context,
|
|
|
|
|
refreshData: () => setState(() {})).toShadowContainer(context, padding: 0, showShadow: false, borderRadius: 0),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> requestDetails(BuildContext context, DemoRequestModel? model) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
Text("Request Details", style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
// 'Demo No: ${model. ?? "-"}'.bodyText(context),
|
|
|
|
|
'Demo Period: ${model?.demoPeriod?.name ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.site}: ${model?.site?.custName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.department}: ${model?.department?.name ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.building}: ${model?.building?.name ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.floor}: ${model?.floor?.name ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.department}: ${model?.department?.departmentName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Item Description: ${model?.itemDescription ?? "-"}'.bodyText(context),
|
|
|
|
|
'Request Description: ${model?.requestDescription ?? "-"}'.bodyText(context),
|
|
|
|
|
];
|
|
|
|
|
@ -146,17 +157,17 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
|
|
|
|
|
List<Widget> vendorDetails(BuildContext context, DemoRequestModel? model) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Vendor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${model?.supplier?.name ?? "-"}'.bodyText(context),
|
|
|
|
|
'Representative Name: ${model?.suppPerson?.name ?? "-"}'.bodyText(context),
|
|
|
|
|
'Contact: ${model?.supplier?.contact ?? "-"}'.bodyText(context),
|
|
|
|
|
'Email: ${model?.supplier?.email ?? "-"}'.bodyText(context),
|
|
|
|
|
Text("Vendor Information", style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${model?.supplier?.name ?? model?.vendorName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Representative Name: ${model?.suppPerson?.name ?? model?.vendorRepresentativeName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Contact: ${model?.supplier?.contact ?? model?.vendorContactNumber ?? "-"}'.bodyText(context),
|
|
|
|
|
'Email: ${model?.supplier?.email ?? model?.vendorEmail ?? "-"}'.bodyText(context),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Widget> assetDetails(BuildContext context, DemoRequestModel? model) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Asset Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
Text("Asset Information", style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'${context.translation.assetName}: ${model?.assetName ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.manufacture}: ${model?.manufacturer ?? "-"}'.bodyText(context),
|
|
|
|
|
'${context.translation.model}: ${model?.model ?? "-"}'.bodyText(context),
|
|
|
|
|
@ -165,7 +176,7 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
|
|
|
|
|
List<Widget> doctorDetails(BuildContext context, DemoRequestModel? model) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Doctor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
Text("Doctor Information", style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${model?.doctorName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Contact: ${model?.doctorContactNumber ?? "-"}'.bodyText(context),
|
|
|
|
|
'Email: ${model?.doctorContactEmail ?? "-"}'.bodyText(context),
|
|
|
|
|
@ -174,7 +185,7 @@ class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
|
|
|
|
|
|
|
|
List<Widget> requesterDetails(BuildContext context, DemoRequestModel? model) {
|
|
|
|
|
return [
|
|
|
|
|
Text("Requester Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
Text("Requester Information", style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
|
|
|
'Name: ${model?.requesterUser?.requesterName ?? "-"}'.bodyText(context),
|
|
|
|
|
'Email: ${model?.requesterUser?.requesterEmail ?? "-"}'.bodyText(context),
|
|
|
|
|
'Contact: ${model?.requesterUser?.requesterMobile ?? "-"}'.bodyText(context),
|
|
|
|
|
|