|
|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/controllers/notification/firebase_notification_manger.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/modules/cx_module/chat/chat_provider.dart';
|
|
|
|
|
import 'package:test_sa/modules/cx_module/chat/model/unread_message_model.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../widgets/loaders/no_data_found.dart';
|
|
|
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
|
|
|
|
|
class UnReadChatList extends StatelessWidget {
|
|
|
|
|
UnReadChatList({Key? key}) : super(key: key);
|
|
|
|
|
@ -15,139 +19,62 @@ class UnReadChatList extends StatelessWidget {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: const DefaultAppBar(title: "Unread Messages"),
|
|
|
|
|
body: FutureBuilder<List>(
|
|
|
|
|
body: FutureBuilder<List<UnReadMessage>>(
|
|
|
|
|
future: Provider.of<ChatProvider>(context, listen: false).getUnReadMessages(context.userProvider.user!.employeeId ?? context.userProvider.user!.username!),
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<List> snapshot) {
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<List<UnReadMessage>> snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) return const CircularProgressIndicator(color: AppColor.primary10).center;
|
|
|
|
|
if (snapshot.data == null) return const NoDataFound().center;
|
|
|
|
|
if (snapshot.data?.isEmpty ?? true) return const NoDataFound().center;
|
|
|
|
|
|
|
|
|
|
return SizedBox();
|
|
|
|
|
List<UnReadMessage> messages = snapshot.data!;
|
|
|
|
|
|
|
|
|
|
// List<LoanAttachmentModel> allAttachments = snapshot.data!.loanAttachments!;
|
|
|
|
|
//
|
|
|
|
|
// return Column(
|
|
|
|
|
// children: [
|
|
|
|
|
// ListView(
|
|
|
|
|
// padding: const EdgeInsets.all(16),
|
|
|
|
|
// children: [
|
|
|
|
|
// 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, snapshot.data!),
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// ...requestDetails(context, snapshot.data!),
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// ...assetDetails(context, snapshot.data!),
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// ...installationDetails(context, snapshot.data!),
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// ...doctorDetails(context, snapshot.data!),
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// ...vendorDetails(context, snapshot.data!),
|
|
|
|
|
// if (allAttachments.isNotEmpty) ...[
|
|
|
|
|
// const Divider().defaultStyle(context),
|
|
|
|
|
// Text(
|
|
|
|
|
// "Attachments".addTranslation,
|
|
|
|
|
// style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
|
|
|
// ),
|
|
|
|
|
// FilesList(images: allAttachments.map((e) => URLs.getFileUrl(e.attachmentName ?? '') ?? '').toList() ?? []),
|
|
|
|
|
// ],
|
|
|
|
|
// ],
|
|
|
|
|
// ).toShadowContainer(context, padding: 12),
|
|
|
|
|
// ],
|
|
|
|
|
// ).expanded,
|
|
|
|
|
// // @todo ask backend to add loanTypeValue, so we can show or hide the buttons
|
|
|
|
|
// if (snapshot.data?.loanTypeName == "Standard" &&
|
|
|
|
|
// context.userProvider.isEngineer &&
|
|
|
|
|
// (snapshot.data?.loanStatusValue == 4 || snapshot.data?.loanStatusValue == 5 || snapshot.data?.loanStatusValue == 8))
|
|
|
|
|
// FooterActionButton.footerContainer(
|
|
|
|
|
// context: context,
|
|
|
|
|
// child: AppFilledButton(
|
|
|
|
|
// onPressed: () async {
|
|
|
|
|
// if (snapshot.data?.loanStatusValue == 4) {
|
|
|
|
|
// String comment = "";
|
|
|
|
|
// context.showBottomSheet(
|
|
|
|
|
// Column(
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
|
// children: [
|
|
|
|
|
// 'Estimated Date: ${snapshot.data?.installationEDD?.toAssetDetailsFormat ?? "-"}'.bodyText(context),
|
|
|
|
|
// 16.height,
|
|
|
|
|
// AppTextFormField(
|
|
|
|
|
// labelText: context.translation.comments,
|
|
|
|
|
// showSpeechToText: true,
|
|
|
|
|
// textInputType: TextInputType.multiline,
|
|
|
|
|
// labelStyle: AppTextStyles.textFieldLabelStyle,
|
|
|
|
|
// showWithoutDecoration: true,
|
|
|
|
|
// backgroundColor: context.isDarkNotListen ? AppColor.neutral20 : AppColor.neutral100,
|
|
|
|
|
// alignLabelWithHint: true,
|
|
|
|
|
// onChange: (text) {
|
|
|
|
|
// comment = text;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 16.height,
|
|
|
|
|
// AppFilledButton(
|
|
|
|
|
// onPressed: () async {
|
|
|
|
|
// Utils.showLoading(context);
|
|
|
|
|
// LoanProvider loanProvider = Provider.of<LoanProvider>(context, listen: false);
|
|
|
|
|
// bool isSuccess = await loanProvider.loanWorkflowAction({
|
|
|
|
|
// "userId": context.userProvider.user!.userID,
|
|
|
|
|
// "isFromMobile": true,
|
|
|
|
|
// "commentsFromMobile": comment,
|
|
|
|
|
// 'loanId': snapshot.data?.id,
|
|
|
|
|
// 'loanStatusId': snapshot.data?.loanStatusValue,
|
|
|
|
|
// });
|
|
|
|
|
// Utils.hideLoading(context);
|
|
|
|
|
// if (isSuccess) {
|
|
|
|
|
// Navigator.pop(context, true);
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// label: "Delivered"),
|
|
|
|
|
// ],
|
|
|
|
|
// ),
|
|
|
|
|
// title: "EDD & Comments",
|
|
|
|
|
// showCancelButton: true);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// if (snapshot.data?.loanStatusValue == 5) {
|
|
|
|
|
// bool isSuccess = await Navigator.push(context, MaterialPageRoute(builder: (context) => InstallationFormView(loanData: snapshot.data))) ?? false;
|
|
|
|
|
// if (isSuccess) {
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// bool isSuccess = await Navigator.push(context, MaterialPageRoute(builder: (context) => PullOutDetailsPage(loanData: snapshot.data))) ?? false;
|
|
|
|
|
// if (isSuccess) {
|
|
|
|
|
// setState(() {});
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// label: snapshot.data?.loanStatusValue == 4
|
|
|
|
|
// ? "Delivered"
|
|
|
|
|
// : snapshot.data?.loanStatusValue == 5
|
|
|
|
|
// ? 'Installation Report'
|
|
|
|
|
// : 'PullOut Report',
|
|
|
|
|
// ),
|
|
|
|
|
// )
|
|
|
|
|
// ],
|
|
|
|
|
// );
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
|
itemCount: messages.length,
|
|
|
|
|
separatorBuilder: (context, itemIndex) => const Divider().defaultStyle(context),
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
messages[index].senderUserName ?? "",
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(
|
|
|
|
|
color: context.isDark ? AppColor.neutral30 : AppColor.neutral50,
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
messages[index].createdAt?.toServiceRequestCardFormat ?? "",
|
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(
|
|
|
|
|
color: context.isDark ? AppColor.neutral20 : AppColor.neutral50,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
messages[index].content ?? "",
|
|
|
|
|
style: AppTextStyles.bodyText2.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF757575)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
FirebaseNotificationManger.handleMessage(context, {
|
|
|
|
|
"transactionType": "17",
|
|
|
|
|
"requestType": "chat",
|
|
|
|
|
"moduleId": messages[index].moduleCode,
|
|
|
|
|
"requestNumber": messages[index].conversationId,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
).toShadowContainer(context),
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|