Compare commits

..

No commits in common. 'de403c449e61176dc5eab44b2f490ab586cb2a32' and '0536d8b978dccf59056a4c78b5e8d23c45e182dd' have entirely different histories.

@ -15,19 +15,6 @@ import 'package:hmg_patient_app_new/services/error_handler_service.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
import 'package:permission_handler/permission_handler.dart';
/// Class to store feedback attachment data
class FeedbackAttachment {
final String base64String;
final File file;
final String fileName;
FeedbackAttachment({
required this.base64String,
required this.file,
required this.fileName,
});
}
class ContactUsViewModel extends ChangeNotifier {
ContactUsRepo contactUsRepo;
ErrorHandlerService errorHandlerService;
@ -48,7 +35,7 @@ class ContactUsViewModel extends ChangeNotifier {
String? chatRequestID;
List<FeedbackAttachment> feedbackAttachmentList = [];
List<String> feedbackAttachmentList = [];
List<COCItem> cocItemsList = [];
bool isCOCItemsListLoading = false;
@ -181,20 +168,13 @@ class ContactUsViewModel extends ChangeNotifier {
notifyListeners();
}
addFeedbackAttachment(String base64String, File file) {
// Extract filename from file path
final fileName = file.path.split('/').last;
feedbackAttachmentList.add(FeedbackAttachment(
base64String: base64String,
file: file,
fileName: fileName,
));
addFeedbackAttachment(String attachmentPath) {
feedbackAttachmentList.add(attachmentPath);
notifyListeners();
}
removeFeedbackAttachment(FeedbackAttachment attachment) {
feedbackAttachmentList.remove(attachment);
removeFeedbackAttachment(String attachmentPath) {
feedbackAttachmentList.remove(attachmentPath);
notifyListeners();
}
@ -302,7 +282,7 @@ class ContactUsViewModel extends ChangeNotifier {
Future<void> insertCOCItem({required String subject, required String message, Function(dynamic)? onSuccess, Function(String)? onError}) async {
RequestInsertCOCItem requestInsertCOCItem = RequestInsertCOCItem();
requestInsertCOCItem.attachment = feedbackAttachmentList.isNotEmpty ? feedbackAttachmentList.first.base64String : "";
requestInsertCOCItem.attachment = feedbackAttachmentList.isNotEmpty ? feedbackAttachmentList.first : "";
requestInsertCOCItem.title = subject;
requestInsertCOCItem.details = message;
requestInsertCOCItem.cOCTypeName = selectedFeedbackType.id.toString();
@ -311,7 +291,7 @@ class ContactUsViewModel extends ChangeNotifier {
requestInsertCOCItem.isUserLoggedIn = true;
requestInsertCOCItem.projectID = 0;
requestInsertCOCItem.patientName = "${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}";
requestInsertCOCItem.fileName = feedbackAttachmentList.isNotEmpty ? feedbackAttachmentList.first.fileName : "";
requestInsertCOCItem.fileName = "Image 1";
requestInsertCOCItem.appVersion = ApiConsts.appVersionID;
requestInsertCOCItem.uILanguage = appState.isArabic() ? "ar" : "en";
requestInsertCOCItem.browserInfo = Platform.localHostname;

@ -354,10 +354,11 @@ class FeedbackPage extends StatelessWidget {
ImageOptions.showImageOptionsNew(
context,
true,
(String base64Image, file) {
// base64Image: The base64-encoded image string
// file: The File object
contactUsViewModel.addFeedbackAttachment(base64Image, file);
(String image, file) {
print(image);
print(file);
// Navigator.pop(context);
contactUsViewModel.addFeedbackAttachment(image);
},
);
},
@ -384,31 +385,25 @@ class FeedbackPage extends StatelessWidget {
child: ListView.builder(
padding: EdgeInsets.all(16.h),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: contactUsViewModel.feedbackAttachmentList.length,
itemBuilder: (BuildContext context, int index) {
final attachment = contactUsViewModel.feedbackAttachmentList[index];
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
Icons.attach_file,
color: Color(0xff2B353E),
),
SizedBox(width: 8.w),
Expanded(
child: attachment.fileName.toText14().paddingOnly(bottom: 8.h),
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
Icons.attach_file,
color: Color(0xff2B353E),
),
SizedBox(width: 8.w),
"Image ${index + 1}".toText14().paddingOnly(bottom: 8.h),
],
),
Utils.buildSvgWithAssets(icon: AppAssets.cancel_circle_icon).onPress(() {
contactUsViewModel.removeFeedbackAttachment(attachment);
contactUsViewModel.removeFeedbackAttachment(contactUsViewModel.feedbackAttachmentList[index]);
}),
],
);

@ -48,8 +48,7 @@ class AttachmentOptions extends StatelessWidget {
).onPress(() async {
await onGalleryTap();
}),
// if (!showFilesOption) commented because the ui issue.
SizedBox(height: 16.h),
if (!showFilesOption) SizedBox(height: 16.h),
if (showFilesOption)
checkInOptionCard(
appState,

Loading…
Cancel
Save