diff --git a/assets/svgs/jpg.svg b/assets/svgs/jpg.svg
new file mode 100644
index 0000000..f6e0591
--- /dev/null
+++ b/assets/svgs/jpg.svg
@@ -0,0 +1,33 @@
+
+
+
diff --git a/assets/svgs/pdf.svg b/assets/svgs/pdf.svg
new file mode 100644
index 0000000..5226e09
--- /dev/null
+++ b/assets/svgs/pdf.svg
@@ -0,0 +1,32 @@
+
+
+
diff --git a/assets/svgs/png.svg b/assets/svgs/png.svg
new file mode 100644
index 0000000..77671a4
--- /dev/null
+++ b/assets/svgs/png.svg
@@ -0,0 +1,28 @@
+
+
+
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index cdf552e..0bcedcc 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -11,8 +11,42 @@ PODS:
- SwiftProtobuf
- device_info (0.0.1):
- Flutter
+ - DKImagePickerController/Core (4.3.4):
+ - DKImagePickerController/ImageDataManager
+ - DKImagePickerController/Resource
+ - DKImagePickerController/ImageDataManager (4.3.4)
+ - DKImagePickerController/PhotoGallery (4.3.4):
+ - DKImagePickerController/Core
+ - DKPhotoGallery
+ - DKImagePickerController/Resource (4.3.4)
+ - DKPhotoGallery (0.0.17):
+ - DKPhotoGallery/Core (= 0.0.17)
+ - DKPhotoGallery/Model (= 0.0.17)
+ - DKPhotoGallery/Preview (= 0.0.17)
+ - DKPhotoGallery/Resource (= 0.0.17)
+ - SDWebImage
+ - SwiftyGif
+ - DKPhotoGallery/Core (0.0.17):
+ - DKPhotoGallery/Model
+ - DKPhotoGallery/Preview
+ - SDWebImage
+ - SwiftyGif
+ - DKPhotoGallery/Model (0.0.17):
+ - SDWebImage
+ - SwiftyGif
+ - DKPhotoGallery/Preview (0.0.17):
+ - DKPhotoGallery/Model
+ - DKPhotoGallery/Resource
+ - SDWebImage
+ - SwiftyGif
+ - DKPhotoGallery/Resource (0.0.17):
+ - SDWebImage
+ - SwiftyGif
- easy_app_installer (0.0.1):
- Flutter
+ - file_picker (0.0.1):
+ - DKImagePickerController/PhotoGallery
+ - Flutter
- Flutter (1.0.0)
- fluttertoast (0.0.2):
- Flutter
@@ -36,6 +70,9 @@ PODS:
- Flutter
- rive_common (0.0.1):
- Flutter
+ - SDWebImage (5.17.0):
+ - SDWebImage/Core (= 5.17.0)
+ - SDWebImage/Core (5.17.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
@@ -43,6 +80,7 @@ PODS:
- Flutter
- FMDB (>= 2.7.5)
- SwiftProtobuf (1.20.3)
+ - SwiftyGif (5.4.4)
- Toast (4.0.0)
DEPENDENCIES:
@@ -52,6 +90,7 @@ DEPENDENCIES:
- barcode_scan2 (from `.symlinks/plugins/barcode_scan2/ios`)
- device_info (from `.symlinks/plugins/device_info/ios`)
- easy_app_installer (from `.symlinks/plugins/easy_app_installer/ios`)
+ - file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- location (from `.symlinks/plugins/location/ios`)
@@ -66,9 +105,13 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
+ - DKImagePickerController
+ - DKPhotoGallery
- FMDB
- MTBBarcodeScanner
+ - SDWebImage
- SwiftProtobuf
+ - SwiftyGif
- Toast
EXTERNAL SOURCES:
@@ -84,6 +127,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/device_info/ios"
easy_app_installer:
:path: ".symlinks/plugins/easy_app_installer/ios"
+ file_picker:
+ :path: ".symlinks/plugins/file_picker/ios"
Flutter:
:path: Flutter
fluttertoast:
@@ -113,7 +158,10 @@ SPEC CHECKSUMS:
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
+ DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
+ DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
easy_app_installer: 29abe397da7d86721fee853281202f414373f45c
+ file_picker: ce3938a0df3cc1ef404671531facef740d03f920
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
@@ -125,9 +173,11 @@ SPEC CHECKSUMS:
permission_handler_apple: 8f116445eff3c0e7c65ad60f5fef5490aa94b4e4
platform_device_id: 81b3e2993881f87d0c82ef151dc274df4869aef5
rive_common: 60ae7896ab40f9513974f36f015de33f70d2c5c5
+ SDWebImage: 750adf017a315a280c60fde706ab1e552a3ae4e9
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1
+ SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
diff --git a/lib/bloc/profile/education/education_bloc.dart b/lib/bloc/profile/education/education_bloc.dart
index e965101..0117b6d 100644
--- a/lib/bloc/profile/education/education_bloc.dart
+++ b/lib/bloc/profile/education/education_bloc.dart
@@ -3,6 +3,9 @@ import 'package:equatable/equatable.dart';
import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/sevices/profile/education_services.dart';
+import '../../../model/profile/attachment.dart';
+import '../../../utils/attachment_services.dart';
+
part 'education_event.dart';
part 'education_state.dart';
@@ -11,20 +14,27 @@ class EducationBloc extends Bloc {
List schools = [];
List programs = [];
List honors = [];
+ List attachmentCategories = [];
EducationBloc() : super(EducationInitial()) {
on((event, emit) async {
emit(EducationalBackgroundLoadingState());
try {
+ if (attachmentCategories.isEmpty) {
+ attachmentCategories =
+ await AttachmentServices.instance.getCategories();
+ }
if (educationalBackgrounds.isEmpty) {
List educations = await EducationService
.instace
.getEducationalBackground(event.profileId, event.token);
educationalBackgrounds = educations;
- emit(EducationalBackgroundLoadedState(
- educationalBackground: educationalBackgrounds));
+ emit(EducationalBackgroundLoadedState(
+ educationalBackground: educationalBackgrounds,
+ attachmentCategory: attachmentCategories));
} else {
emit(EducationalBackgroundLoadedState(
- educationalBackground: educationalBackgrounds));
+ educationalBackground: educationalBackgrounds,
+ attachmentCategory: attachmentCategories));
}
} catch (e) {
emit(EducationalBackgroundErrorState(message: e.toString()));
@@ -77,7 +87,8 @@ class EducationBloc extends Bloc {
token: event.token,
profileId: event.profileId);
if (status['success']) {
- educationalBackgrounds.removeWhere((element) => event.educationalBackground.id == element.id);
+ educationalBackgrounds.removeWhere(
+ (element) => event.educationalBackground.id == element.id);
EducationalBackground educationalBackground =
EducationalBackground.fromJson(status['data']);
educationalBackgrounds.add(educationalBackground);
@@ -89,7 +100,8 @@ class EducationBloc extends Bloc {
////LOAD
on((event, emit) {
emit(EducationalBackgroundLoadedState(
- educationalBackground: educationalBackgrounds));
+ educationalBackground: educationalBackgrounds,
+ attachmentCategory: attachmentCategories));
});
//// SHOW EDIT FORM
on((event, emit) async {
@@ -134,5 +146,65 @@ class EducationBloc extends Bloc {
emit(EducationalBackgroundErrorState(message: e.toString()));
}
});
+ ////Add attachment
+ on((event, emit) async {
+ emit(EducationalBackgroundLoadingState());
+ EducationalBackground educationalBackground =
+ educationalBackgrounds.firstWhere(
+ (element) => element.id.toString() == event.attachmentModule);
+ List attachments = [];
+ try {
+ Map status = await AttachmentServices.instance
+ .attachment(
+ categoryId: event.categoryId,
+ module: event.attachmentModule,
+ paths: event.filePaths,
+ token: event.token,
+ profileId: event.profileId);
+
+ if (status['success']) {
+ status['data'].forEach((element) {
+ Attachment newAttachment = Attachment.fromJson(element);
+ attachments.add(newAttachment);
+ });
+ educationalBackground.attachments == null
+ ? educationalBackground.attachments = attachments
+ : educationalBackground.attachments = [
+ ...educationalBackground.attachments!,
+ ...attachments
+ ];
+ emit(EducationAddedState(response: status));
+ } else {
+ emit(EducationAddedState(response: status));
+ }
+ } catch (e) {
+ emit(EducationalBackgroundErrorState(message: e.toString()));
+ }
+ });
+ on((event, emit) async {
+ emit(EducationalBackgroundLoadingState());
+ try {
+ final bool success = await AttachmentServices.instance.deleteAttachment(
+ attachment: event.attachment,
+ moduleId: event.moduleId,
+ profileId: event.profileId.toString(),
+ token: event.token);
+ if (success) {
+ final EducationalBackground educationalBackground =
+ educationalBackgrounds
+ .firstWhere((element) => element.id == event.moduleId);
+ educationalBackground.attachments
+ ?.removeWhere((element) => element.id == event.attachment.id);
+ educationalBackgrounds
+ .removeWhere((element) => element.id == event.moduleId);
+ educationalBackgrounds.add(educationalBackground);
+ emit(EducationAttachmentDeletedState(success: success));
+ } else {
+ emit(EducationAttachmentDeletedState(success: success));
+ }
+ } catch (e) {
+ emit(EducationalBackgroundErrorState(message: e.toString()));
+ }
+ });
}
}
diff --git a/lib/bloc/profile/education/education_event.dart b/lib/bloc/profile/education/education_event.dart
index 59a431b..9b68a0f 100644
--- a/lib/bloc/profile/education/education_event.dart
+++ b/lib/bloc/profile/education/education_event.dart
@@ -63,3 +63,23 @@ class DeleteEducation extends EducationEvent{
@override
List