You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
8.4 KiB
Dart
189 lines
8.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
import 'package:test_sa/modules/demo_module/demo_extension_bottom_sheet.dart';
|
|
import 'package:test_sa/modules/demo_module/demo_provider.dart';
|
|
import 'package:test_sa/modules/loan_module/models/loan_attachment_model.dart';
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
|
|
import '../../controllers/api_routes/urls.dart';
|
|
import '../../extensions/text_extensions.dart';
|
|
import '../../new_views/common_widgets/default_app_bar.dart';
|
|
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';
|
|
|
|
class DemoDetailViewPage extends StatefulWidget {
|
|
static const String id = "/demo-detail-page";
|
|
final int demoId;
|
|
|
|
DemoDetailViewPage({Key? key, required this.demoId}) : super(key: key);
|
|
|
|
@override
|
|
_DemoDetailViewPageState createState() {
|
|
return _DemoDetailViewPageState();
|
|
}
|
|
}
|
|
|
|
class _DemoDetailViewPageState extends State<DemoDetailViewPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
List<LoanAttachmentModel> allAttachments = [];
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const DefaultAppBar(title: "Request Details"),
|
|
body: Column(
|
|
children: [
|
|
// FutureBuilder<LoanRequestModel?>(
|
|
// future: Provider.of<DemoProvider>(context, listen: false).getLoanById(widget.demoId),
|
|
// builder: (BuildContext context, AsyncSnapshot<LoanRequestModel?> snapshot) {
|
|
// if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
|
// if (snapshot.data == null) return const NoDataFound().center;
|
|
//
|
|
// List<LoanAttachmentModel> allAttachments = snapshot.data!.loanAttachments!;
|
|
//
|
|
// return
|
|
|
|
SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Row(
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
// children: [
|
|
// StatusLabel(
|
|
// label: snapshot.data!.loanStatusName!,
|
|
// textColor: AppColor.getRequestStatusTextColorByName(context, snapshot.data!.loanStatusName!),
|
|
// backgroundColor: AppColor.getRequestStatusColorByName(context, snapshot.data!.loanStatusName!),
|
|
// ),
|
|
// 1.width.expanded,
|
|
// Text(
|
|
// snapshot.data!.createdDate?.toServiceRequestCardFormat ?? "-",
|
|
// textAlign: TextAlign.end,
|
|
// style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// 12.height,
|
|
...requesterDetails(context, LoanRequestModel()),
|
|
12.height,
|
|
...requestDetails(context, LoanRequestModel()),
|
|
12.height,
|
|
...doctorDetails(context, LoanRequestModel()),
|
|
12.height,
|
|
...assetDetails(context, LoanRequestModel()),
|
|
12.height,
|
|
...vendorDetails(context, LoanRequestModel()),
|
|
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.attachmentName ?? '') ?? '').toList() ?? []),
|
|
],
|
|
],
|
|
).toShadowContainer(context, padding: 12),
|
|
)
|
|
// ;
|
|
// }
|
|
//
|
|
// )
|
|
|
|
.expanded,
|
|
FooterActionButton.footerContainer(
|
|
context: context,
|
|
child: AppFilledButton(
|
|
buttonColor: AppColor.primary10,
|
|
label: "Activities",
|
|
onPressed: () {
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => DemoActivitiesPage()));
|
|
},
|
|
),
|
|
),
|
|
FooterActionButton.footerContainer(
|
|
context: context,
|
|
child: AppFilledButton(
|
|
buttonColor: AppColor.primary10,
|
|
label: context.translation.update,
|
|
onPressed: _update,
|
|
),
|
|
),
|
|
],
|
|
));
|
|
}
|
|
|
|
List<Widget> requestDetails(BuildContext context, LoanRequestModel loanData) {
|
|
return [
|
|
Text("Request Details", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
// 'Loan Type: ${loanData.loanTypeName ?? "-"}'.bodyText(context),
|
|
'Demo No: ${loanData.reqCode ?? "-"}'.bodyText(context),
|
|
'Demo Period: ${loanData.loanPeriodName ?? "-"}'.bodyText(context),
|
|
'${context.translation.site}: ${loanData.siteName ?? "-"}'.bodyText(context),
|
|
'${context.translation.department}: ${loanData.departmentName ?? "-"}'.bodyText(context),
|
|
'Item Description: ${loanData.itemDescription ?? "-"}'.bodyText(context),
|
|
'Request Description: ${loanData.requestDescription ?? "-"}'.bodyText(context),
|
|
];
|
|
}
|
|
|
|
List<Widget> vendorDetails(BuildContext context, LoanRequestModel loanData) {
|
|
return [
|
|
Text("Vendor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
'Name: ${loanData.vendorName ?? "-"}'.bodyText(context),
|
|
'Representative Name: ${loanData.vendorRepName ?? "-"}'.bodyText(context),
|
|
'Contact: ${loanData.vendorContact ?? "-"}'.bodyText(context),
|
|
'Email: ${loanData.vendorEmail ?? "-"}'.bodyText(context),
|
|
];
|
|
}
|
|
|
|
List<Widget> assetDetails(BuildContext context, LoanRequestModel loanData) {
|
|
return [
|
|
Text("Asset Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
// '${context.translation.assetName}: ${loanData.assetName ?? "-"}'.bodyText(context),
|
|
// '${context.translation.assetNo}: ${loanData.assetNumber ?? "-"}'.bodyText(context),
|
|
// '${context.translation.serialNumber}: ${loanData.assetSerialNumber ?? "-"}'.bodyText(context),
|
|
'${context.translation.manufacture}: ${loanData.manufacturer ?? "-"}'.bodyText(context),
|
|
'${context.translation.model}: ${loanData.model ?? "-"}'.bodyText(context),
|
|
'Estimated Delivery Date: 29 October, 2025'.bodyText(context),
|
|
];
|
|
}
|
|
|
|
List<Widget> doctorDetails(BuildContext context, LoanRequestModel loanData) {
|
|
return [
|
|
Text("Doctor Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
'Name: ${loanData.doctorName ?? "-"}'.bodyText(context),
|
|
'Contact: ${loanData.doctorContact ?? "-"}'.bodyText(context),
|
|
'Email: ${loanData.doctorEmail ?? "-"}'.bodyText(context),
|
|
];
|
|
}
|
|
|
|
List<Widget> requesterDetails(BuildContext context, LoanRequestModel loanData) {
|
|
return [
|
|
Text("Requester Information", style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50)),
|
|
'Name: ${loanData.requestorUserIdForDisplay ?? "-"}'.bodyText(context),
|
|
'Email: ${loanData.requestorUserEmail ?? "-"}'.bodyText(context),
|
|
'Contact: ${loanData.requestorUserMobileNumber ?? "-"}'.bodyText(context),
|
|
// 'Extension: ${loanData.requesterExtensionNo ?? "-"}'.bodyText(context),
|
|
];
|
|
}
|
|
|
|
void _update() {}
|
|
}
|