2023-08-01 08:20:38 +00:00
|
|
|
import 'dart:io';
|
2023-02-15 05:23:06 +00:00
|
|
|
import 'package:app_popup_menu/app_popup_menu.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:file_picker/file_picker.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-15 05:23:06 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
2023-02-16 07:10:54 +00:00
|
|
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
2023-03-02 00:40:47 +00:00
|
|
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
2023-08-07 06:33:38 +00:00
|
|
|
import 'package:unit2/bloc/profile/education/education_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
|
2023-02-15 05:23:06 +00:00
|
|
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
2023-08-07 06:33:38 +00:00
|
|
|
import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart';
|
2023-02-15 05:23:06 +00:00
|
|
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:unit2/model/profile/attachment.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:unit2/model/profile/eligibility.dart';
|
2023-02-23 00:53:14 +00:00
|
|
|
import 'package:unit2/screens/profile/components/eligibility/add_modal.dart';
|
2023-02-15 05:23:06 +00:00
|
|
|
import 'package:unit2/screens/profile/components/eligibility/edit_modal.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:unit2/theme-data.dart/btn-style.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:unit2/theme-data.dart/colors.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:unit2/theme-data.dart/form-style.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
import 'package:unit2/utils/global.dart';
|
|
|
|
import 'package:unit2/utils/text_container.dart';
|
2023-03-02 00:40:47 +00:00
|
|
|
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
|
|
|
import 'package:unit2/widgets/Leadings/close_leading.dart';
|
2023-02-27 06:26:27 +00:00
|
|
|
import 'package:unit2/widgets/empty_data.dart';
|
2023-04-11 01:27:53 +00:00
|
|
|
import 'package:unit2/widgets/error_state.dart';
|
2023-03-07 02:31:28 +00:00
|
|
|
import '../../../bloc/profile/eligibility/eligibility_bloc.dart';
|
2023-02-15 05:23:06 +00:00
|
|
|
import '../../../utils/alerts.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import '../shared/multiple_attachment.dart';
|
|
|
|
import '../shared/single_attachment.dart';
|
2023-02-09 08:48:19 +00:00
|
|
|
|
2023-02-15 05:23:06 +00:00
|
|
|
class EligibiltyScreen extends StatelessWidget {
|
2023-02-15 08:48:34 +00:00
|
|
|
const EligibiltyScreen({super.key});
|
|
|
|
|
2023-02-09 08:48:19 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-08-01 08:20:38 +00:00
|
|
|
BuildContext parent = context;
|
2023-02-23 00:53:14 +00:00
|
|
|
String? token;
|
2023-04-11 01:27:53 +00:00
|
|
|
int? profileId;
|
2023-08-07 06:33:38 +00:00
|
|
|
List<PlatformFile>? results = [];
|
2023-08-01 08:20:38 +00:00
|
|
|
AttachmentCategory? selectedAttachmentCategory;
|
|
|
|
List<AttachmentCategory> attachmentCategories = [];
|
2023-03-02 05:28:33 +00:00
|
|
|
|
2023-03-02 00:40:47 +00:00
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: () async {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
2023-08-01 08:20:38 +00:00
|
|
|
resizeToAvoidBottomInset: true,
|
2023-03-02 00:40:47 +00:00
|
|
|
appBar: AppBar(
|
2023-03-02 05:28:33 +00:00
|
|
|
title: context.watch<EligibilityBloc>().state is AddEligibilityState
|
2023-03-02 00:40:47 +00:00
|
|
|
? const Text("Add Eligiblity")
|
2023-03-02 05:28:33 +00:00
|
|
|
: context.watch<EligibilityBloc>().state is EditEligibilityState
|
2023-03-02 00:40:47 +00:00
|
|
|
? const Text("Edit Eligibilty")
|
|
|
|
: const Text(elibilityScreenTitle),
|
|
|
|
centerTitle: true,
|
|
|
|
backgroundColor: primary,
|
2023-08-01 08:20:38 +00:00
|
|
|
actions:
|
|
|
|
(context.watch<EligibilityBloc>().state is EligibilityLoaded)
|
|
|
|
? [
|
|
|
|
AddLeading(onPressed: () {
|
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(ShowAddEligibilityForm());
|
|
|
|
})
|
|
|
|
]
|
|
|
|
: (context.watch<EligibilityBloc>().state
|
|
|
|
is AddEligibilityState ||
|
|
|
|
context.watch<EligibilityBloc>().state
|
|
|
|
is EditEligibilityState)
|
|
|
|
? [
|
|
|
|
CloseLeading(onPressed: () {
|
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
|
|
|
})
|
|
|
|
]
|
|
|
|
: [],
|
2023-03-02 00:40:47 +00:00
|
|
|
),
|
|
|
|
body: BlocBuilder<UserBloc, UserState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
if (state is UserLoggedIn) {
|
|
|
|
token = state.userData!.user!.login!.token;
|
2023-08-01 08:20:38 +00:00
|
|
|
profileId = state.userData!.user!.login!.user!.profileId;
|
2023-03-02 05:28:33 +00:00
|
|
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
2023-08-01 08:20:38 +00:00
|
|
|
builder: (context, state) {
|
|
|
|
if (state is ProfileLoaded) {
|
|
|
|
return ProgressHUD(
|
2023-03-02 05:28:33 +00:00
|
|
|
padding: const EdgeInsets.all(24),
|
|
|
|
indicatorWidget: const SpinKitFadingCircle(
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
backgroundColor: Colors.black87,
|
|
|
|
child: BlocConsumer<EligibilityBloc, EligibilityState>(
|
|
|
|
listener: (context, state) {
|
|
|
|
if (state is EligibilityLoadingState) {
|
|
|
|
final progress = ProgressHUD.of(context);
|
2023-03-02 06:59:40 +00:00
|
|
|
progress!.showWithText("Please wait...");
|
2023-03-02 05:28:33 +00:00
|
|
|
}
|
|
|
|
if (state is EligibilityLoaded ||
|
|
|
|
state is AddEligibilityState ||
|
|
|
|
state is EditEligibilityState ||
|
2023-08-07 06:33:38 +00:00
|
|
|
state is EligibilityDeletedState ||
|
2023-03-02 05:28:33 +00:00
|
|
|
state is EligibilityAddedState ||
|
2023-04-11 01:27:53 +00:00
|
|
|
state is EligibilityEditedState ||
|
2023-08-01 08:20:38 +00:00
|
|
|
state is EligibilityErrorState) {
|
2023-03-02 05:28:33 +00:00
|
|
|
final progress = ProgressHUD.of(context);
|
|
|
|
progress!.dismiss();
|
|
|
|
}
|
2023-03-24 06:46:17 +00:00
|
|
|
////DELETED STATE
|
2023-08-07 06:33:38 +00:00
|
|
|
if (state is EligibilityDeletedState) {
|
2023-03-02 05:28:33 +00:00
|
|
|
if (state.success) {
|
|
|
|
successAlert(context, "Deletion Successfull",
|
|
|
|
"Eligibility has been deleted successfully",
|
|
|
|
() {
|
|
|
|
Navigator.of(context).pop();
|
2023-08-01 08:20:38 +00:00
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
2023-03-02 05:28:33 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
errorAlert(context, "Deletion Failed",
|
|
|
|
"Error deleting eligibility", () {
|
|
|
|
Navigator.of(context).pop();
|
2023-08-01 08:20:38 +00:00
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
2023-03-02 05:28:33 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-08-07 06:33:38 +00:00
|
|
|
////ATTACHMENT ADDED STATE
|
|
|
|
|
|
|
|
if (state is EligibilityAttachmentAddedState) {
|
|
|
|
if (state.response['success']) {
|
|
|
|
successAlert(context, "Adding Successfull!",
|
|
|
|
state.response['message'], () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
errorAlert(context, "Adding Failed",
|
|
|
|
"Something went wrong. Please try again.",
|
|
|
|
() {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-03-24 06:46:17 +00:00
|
|
|
////ADDED STATE
|
2023-03-02 05:28:33 +00:00
|
|
|
if (state is EligibilityAddedState) {
|
|
|
|
if (state.response['success']) {
|
|
|
|
successAlert(context, "Adding Successfull!",
|
|
|
|
state.response['message'], () {
|
|
|
|
Navigator.of(context).pop();
|
2023-08-01 08:20:38 +00:00
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
2023-03-02 05:28:33 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
errorAlert(context, "Adding Failed",
|
|
|
|
"Something went wrong. Please try again.",
|
|
|
|
() {
|
|
|
|
Navigator.of(context).pop();
|
2023-08-01 08:20:38 +00:00
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
2023-03-02 05:28:33 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-03-24 06:46:17 +00:00
|
|
|
////UPDATED STATE
|
2023-03-02 05:28:33 +00:00
|
|
|
if (state is EligibilityEditedState) {
|
|
|
|
if (state.response['success']) {
|
|
|
|
successAlert(context, "Update Successfull!",
|
|
|
|
state.response['message'], () {
|
|
|
|
Navigator.of(context).pop();
|
2023-08-01 08:20:38 +00:00
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
2023-03-02 05:28:33 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
errorAlert(context, "Update Failed",
|
|
|
|
"Something went wrong. Please try again.",
|
|
|
|
() {
|
|
|
|
Navigator.of(context).pop();
|
2023-08-01 08:20:38 +00:00
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
2023-03-02 05:28:33 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-08-07 06:33:38 +00:00
|
|
|
////ATTACHMENT DELETED STATE
|
|
|
|
if (state is EligibilitytAttachmentDeletedState) {
|
|
|
|
if (state.success) {
|
|
|
|
successAlert(context, "Deletion Successfull",
|
|
|
|
"Attachment has been deleted successfully",
|
|
|
|
() {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
errorAlert(context, "Deletion Failed",
|
|
|
|
"Error deleting Attachment", () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
context
|
|
|
|
.read<EligibilityBloc>()
|
|
|
|
.add(const LoadEligibility());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-03-02 05:28:33 +00:00
|
|
|
},
|
2023-03-02 00:40:47 +00:00
|
|
|
builder: (context, state) {
|
2023-03-02 05:28:33 +00:00
|
|
|
return BlocBuilder<EligibilityBloc, EligibilityState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
if (state is EligibilityLoaded) {
|
2023-08-01 08:20:38 +00:00
|
|
|
for (var cat in state.attachmentCategory) {
|
2023-08-07 06:33:38 +00:00
|
|
|
if (cat.subclass!.id == 3) {
|
2023-08-01 08:20:38 +00:00
|
|
|
attachmentCategories.add(cat);
|
|
|
|
}
|
|
|
|
}
|
2023-03-02 05:28:33 +00:00
|
|
|
if (state.eligibilities.isNotEmpty) {
|
|
|
|
return ListView.builder(
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 8, horizontal: 10),
|
|
|
|
itemCount: state.eligibilities.length,
|
|
|
|
itemBuilder:
|
|
|
|
(BuildContext context, int index) {
|
|
|
|
String title = state
|
|
|
|
.eligibilities[index]
|
|
|
|
.eligibility!
|
|
|
|
.title;
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.symmetric(
|
|
|
|
horizontal: 12,
|
|
|
|
vertical: 8),
|
|
|
|
decoration: box1(),
|
2023-08-07 06:33:38 +00:00
|
|
|
child: Column(
|
2023-03-02 05:28:33 +00:00
|
|
|
children: [
|
2023-08-07 06:33:38 +00:00
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment
|
|
|
|
.start,
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment
|
|
|
|
.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: Theme.of(
|
|
|
|
context)
|
|
|
|
.textTheme
|
|
|
|
.titleMedium!
|
|
|
|
.copyWith(
|
|
|
|
fontWeight:
|
|
|
|
FontWeight
|
|
|
|
.w500,
|
|
|
|
color:
|
|
|
|
primary),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}",
|
|
|
|
style: Theme.of(
|
|
|
|
context)
|
|
|
|
.textTheme
|
|
|
|
.titleSmall),
|
|
|
|
const SizedBox(
|
|
|
|
height: 3,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Rating : ${state.eligibilities[index].rating ?? 'N/A'}",
|
|
|
|
style: Theme.of(
|
|
|
|
context)
|
|
|
|
.textTheme
|
|
|
|
.titleSmall),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
AppPopupMenu<int>(
|
|
|
|
offset: const Offset(
|
|
|
|
-10, -10),
|
|
|
|
elevation: 3,
|
|
|
|
onSelected: (value) {
|
|
|
|
////delete eligibilty-= = = = = = = = =>>
|
|
|
|
if (value == 2) {
|
|
|
|
confirmAlert(
|
|
|
|
context, () {
|
|
|
|
final progress =
|
|
|
|
ProgressHUD.of(
|
|
|
|
context);
|
|
|
|
progress!
|
|
|
|
.showWithText(
|
|
|
|
"Loading...");
|
|
|
|
BlocProvider
|
|
|
|
.of<EligibilityBloc>(
|
|
|
|
context)
|
|
|
|
.add(DeleteEligibility(
|
|
|
|
eligibilityId: state
|
2023-08-01 08:20:38 +00:00
|
|
|
.eligibilities[
|
|
|
|
index]
|
2023-08-07 06:33:38 +00:00
|
|
|
.id!,
|
|
|
|
profileId:
|
|
|
|
profileId
|
|
|
|
.toString(),
|
|
|
|
token:
|
|
|
|
token!));
|
|
|
|
}, "Delete?",
|
|
|
|
"Confirm Delete?");
|
|
|
|
}
|
|
|
|
if (value == 1) {
|
|
|
|
////edit eligibilty-= = = = = = = = =>>
|
|
|
|
final progress =
|
|
|
|
ProgressHUD.of(
|
|
|
|
context);
|
|
|
|
progress!
|
|
|
|
.showWithText(
|
|
|
|
"Loading...");
|
|
|
|
EligibityCert
|
|
|
|
eligibityCert =
|
|
|
|
state.eligibilities[
|
|
|
|
index];
|
|
|
|
bool overseas = eligibityCert
|
|
|
|
.examAddress!
|
|
|
|
.country!
|
|
|
|
.id
|
|
|
|
.toString() ==
|
|
|
|
'175'
|
|
|
|
? false
|
|
|
|
: true;
|
|
|
|
eligibityCert
|
|
|
|
.overseas =
|
|
|
|
overseas;
|
2023-03-02 00:40:47 +00:00
|
|
|
|
2023-08-07 06:33:38 +00:00
|
|
|
eligibityCert
|
|
|
|
.overseas =
|
|
|
|
overseas;
|
2023-03-02 00:40:47 +00:00
|
|
|
|
2023-08-07 06:33:38 +00:00
|
|
|
context
|
|
|
|
.read<
|
|
|
|
EligibilityBloc>()
|
|
|
|
.add(ShowEditEligibilityForm(
|
|
|
|
eligibityCert:
|
|
|
|
eligibityCert));
|
|
|
|
}
|
|
|
|
////Attachment
|
|
|
|
if (value == 3) {
|
|
|
|
results.clear();
|
|
|
|
showDialog(
|
|
|
|
context:
|
|
|
|
context,
|
|
|
|
builder:
|
|
|
|
(BuildContext
|
|
|
|
context) {
|
|
|
|
return AlertDialog(
|
|
|
|
contentPadding:
|
|
|
|
const EdgeInsets
|
|
|
|
.all(0),
|
|
|
|
backgroundColor:
|
|
|
|
Colors
|
|
|
|
.grey
|
|
|
|
.shade100,
|
|
|
|
icon:
|
|
|
|
const Icon(
|
|
|
|
Icons
|
|
|
|
.file_copy,
|
|
|
|
size: 32,
|
|
|
|
color:
|
|
|
|
primary,
|
|
|
|
),
|
|
|
|
title: const Text(
|
|
|
|
"File Attachment:"),
|
|
|
|
content: StatefulBuilder(builder:
|
2023-08-01 08:20:38 +00:00
|
|
|
(context,
|
|
|
|
setState) {
|
2023-08-07 06:33:38 +00:00
|
|
|
return Padding(
|
|
|
|
padding:
|
|
|
|
const EdgeInsets.all(16.0),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize:
|
|
|
|
MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
const Divider(),
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500, color: primary),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Text("$licenseNumber: ${state.eligibilities[index].licenseNumber == null ? 'N/A' : state.eligibilities[index].licenseNumber.toString()}", style: Theme.of(context).textTheme.titleSmall),
|
|
|
|
const SizedBox(
|
|
|
|
height: 3,
|
2023-08-01 08:20:38 +00:00
|
|
|
),
|
2023-08-07 06:33:38 +00:00
|
|
|
Text("Rating : ${state.eligibilities[index].rating ?? 'N/A'}", style: Theme.of(context).textTheme.titleSmall),
|
|
|
|
const Divider(),
|
|
|
|
FormBuilderDropdown(
|
|
|
|
autovalidateMode: AutovalidateMode.always,
|
|
|
|
decoration: normalTextFieldStyle("attachment category", "attachment category"),
|
|
|
|
name: 'attachments_categorues',
|
|
|
|
validator: FormBuilderValidators.required(errorText: "This field is required"),
|
|
|
|
onChanged: (value) {
|
|
|
|
selectedAttachmentCategory = value;
|
|
|
|
},
|
|
|
|
items: attachmentCategories.map((e) {
|
|
|
|
return DropdownMenuItem(value: e, child: Text(e.description!));
|
|
|
|
}).toList()),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"You may attach necessary documents such as Transcript of Records (TOR), diploma, and the likes.",
|
|
|
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.black),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Acceptable Files: PDF, JPEG, PNG",
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Max File Size (per attachment): 1MB",
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
ElevatedButton(
|
|
|
|
style: ButtonStyle(
|
|
|
|
elevation: MaterialStateProperty.all(0),
|
|
|
|
backgroundColor: MaterialStateProperty.all<Color>(Colors.white),
|
|
|
|
),
|
|
|
|
onPressed: () async {
|
|
|
|
FilePickerResult? newResult = await FilePicker.platform.pickFiles(allowMultiple: true, type: FileType.custom, allowedExtensions: [
|
|
|
|
'jpg',
|
|
|
|
'png',
|
|
|
|
'jpeg',
|
|
|
|
'pdf'
|
|
|
|
]);
|
|
|
|
setState(() {
|
|
|
|
FilePickerResult? x;
|
|
|
|
if (newResult != null) {
|
|
|
|
newResult.files.forEach((element) {
|
|
|
|
results.add(element);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: const Center(
|
|
|
|
child: Text(
|
|
|
|
"Select Files",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(color: Colors.black),
|
|
|
|
))),
|
|
|
|
const Divider(),
|
|
|
|
SingleChildScrollView(
|
|
|
|
child: SizedBox(
|
|
|
|
height: 100,
|
|
|
|
width: double.maxFinite,
|
|
|
|
child: results.isEmpty
|
|
|
|
? const SizedBox()
|
|
|
|
: Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: results.length,
|
|
|
|
itemBuilder: (BuildContext context, index) {
|
|
|
|
final kb = results[index].size / 1024;
|
|
|
|
final mb = kb / 1024;
|
|
|
|
final size = mb >= 1 ? '${mb.toStringAsFixed(2)}MB' : '${kb.toStringAsFixed(2)}KB';
|
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: SizedBox(
|
|
|
|
child: results[index].extension!.toLowerCase() == 'pdf'
|
2023-08-01 08:20:38 +00:00
|
|
|
? SvgPicture.asset(
|
2023-08-07 06:33:38 +00:00
|
|
|
'assets/svgs/pdf.svg',
|
2023-08-01 08:20:38 +00:00
|
|
|
height: blockSizeVertical * 3,
|
|
|
|
allowDrawingOutsideViewBox: true,
|
|
|
|
)
|
2023-08-07 06:33:38 +00:00
|
|
|
: results[index].extension!.toLowerCase() == 'png'
|
2023-08-01 08:20:38 +00:00
|
|
|
? SvgPicture.asset(
|
2023-08-07 06:33:38 +00:00
|
|
|
'assets/svgs/png.svg',
|
2023-08-01 08:20:38 +00:00
|
|
|
height: blockSizeVertical * 3,
|
|
|
|
allowDrawingOutsideViewBox: true,
|
|
|
|
)
|
2023-08-07 06:33:38 +00:00
|
|
|
: results[index].extension!.toLowerCase() == 'jpg' || results[index].extension!.toLowerCase() == 'jpeg'
|
|
|
|
? SvgPicture.asset(
|
|
|
|
'assets/svgs/jpg.svg',
|
|
|
|
height: blockSizeVertical * 3,
|
|
|
|
allowDrawingOutsideViewBox: true,
|
|
|
|
)
|
|
|
|
: const SizedBox())),
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
flex: 6,
|
|
|
|
child: Text(
|
|
|
|
results[index].name,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: Theme.of(context).textTheme.headlineLarge!.copyWith(fontSize: blockSizeVertical * 2),
|
2023-08-01 08:20:38 +00:00
|
|
|
),
|
2023-08-07 06:33:38 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
|
|
|
Flexible(
|
2023-08-01 08:20:38 +00:00
|
|
|
flex: 2,
|
2023-08-07 06:33:38 +00:00
|
|
|
child: Text(
|
|
|
|
size,
|
|
|
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.grey),
|
|
|
|
)),
|
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: IconButton(
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.close,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
results.removeAt(index);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
const Divider()
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: double.maxFinite,
|
|
|
|
height: 50,
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: mainBtnStyle(primary, Colors.transparent, second),
|
|
|
|
onPressed: () {
|
|
|
|
List<String> paths = [];
|
2023-08-01 08:20:38 +00:00
|
|
|
|
2023-08-07 06:33:38 +00:00
|
|
|
if (selectedAttachmentCategory != null && results.isNotEmpty) {
|
|
|
|
for (var res in results) {
|
|
|
|
paths.add(res.path!);
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
results.clear();
|
|
|
|
});
|
|
|
|
Navigator.pop(context);
|
|
|
|
parent.read<EligibilityBloc>().add(AddEligibiltyAttachment(attachmentModule: state.eligibilities[index].id.toString(), filePaths: paths, categoryId: selectedAttachmentCategory!.id.toString(), token: token!, profileId: profileId.toString()));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child: const Text("Submit")),
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
}),
|
2023-08-01 08:20:38 +00:00
|
|
|
);
|
2023-08-07 06:33:38 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
menuItems: [
|
|
|
|
popMenuItem(
|
|
|
|
text: "Update",
|
|
|
|
value: 1,
|
|
|
|
icon: Icons.edit),
|
|
|
|
popMenuItem(
|
|
|
|
text: "Remove",
|
|
|
|
value: 2,
|
|
|
|
icon:
|
|
|
|
Icons.delete),
|
|
|
|
popMenuItem(
|
|
|
|
text: "Attach",
|
|
|
|
value: 3,
|
|
|
|
icon: Icons
|
|
|
|
.attach_file),
|
|
|
|
],
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.more_vert,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
tooltip: "Options",
|
|
|
|
)
|
2023-08-01 08:20:38 +00:00
|
|
|
],
|
2023-08-07 06:33:38 +00:00
|
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
////Show Attachments
|
|
|
|
SizedBox(
|
|
|
|
width: screenWidth,
|
|
|
|
child: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.attachments ==
|
|
|
|
null ||
|
|
|
|
state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.attachments!
|
|
|
|
.isEmpty
|
|
|
|
? const SizedBox()
|
|
|
|
: state.eligibilities[index].attachments !=
|
|
|
|
null &&
|
|
|
|
state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.attachments!
|
|
|
|
.length ==
|
|
|
|
1
|
|
|
|
?
|
|
|
|
////Single Attachment view
|
|
|
|
SingleAttachment(
|
|
|
|
onpressed:
|
|
|
|
() {
|
|
|
|
confirmAlert(
|
|
|
|
context,
|
|
|
|
() {
|
|
|
|
parent.read<EligibilityBloc>().add(DeleteEligibyAttachment(
|
|
|
|
attachment: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.attachments!
|
|
|
|
.first,
|
|
|
|
moduleId: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.id
|
|
|
|
.toString(),
|
|
|
|
profileId: profileId
|
|
|
|
.toString(),
|
|
|
|
token:
|
|
|
|
token!));
|
|
|
|
}, "Delete?",
|
|
|
|
"Confirm Delete?");
|
|
|
|
},
|
|
|
|
attachment: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.attachments!
|
|
|
|
.first,
|
|
|
|
)
|
|
|
|
////Multiple Attachments View
|
|
|
|
: MultipleAttachments(
|
|
|
|
profileId:
|
|
|
|
profileId!,
|
|
|
|
token: token!,
|
|
|
|
moduleId: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.eligibility!
|
|
|
|
.id,
|
|
|
|
educationBloc:
|
|
|
|
null,
|
|
|
|
learningDevelopmentBloc:
|
|
|
|
null,
|
|
|
|
workHistoryBloc:
|
|
|
|
null,
|
|
|
|
eligibilityBloc:
|
|
|
|
BlocProvider.of<
|
|
|
|
EligibilityBloc>(
|
|
|
|
context),
|
|
|
|
blocId: 2,
|
|
|
|
eligibilityName: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.eligibility!
|
|
|
|
.title,
|
|
|
|
attachments: state
|
|
|
|
.eligibilities[
|
|
|
|
index]
|
|
|
|
.attachments!,
|
|
|
|
))
|
2023-03-02 00:40:47 +00:00
|
|
|
],
|
2023-03-02 05:28:33 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
2023-08-01 08:20:38 +00:00
|
|
|
),
|
2023-03-02 05:28:33 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
return const EmptyData(
|
|
|
|
message:
|
|
|
|
"You don't have any eligibilities added. Please click + to add");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (state is EditEligibilityState) {
|
|
|
|
return EditEligibilityScreen(
|
2023-08-01 08:20:38 +00:00
|
|
|
profileId: profileId!,
|
|
|
|
token: token!,
|
2023-03-02 05:28:33 +00:00
|
|
|
eligibityCert: state.eligibityCert);
|
|
|
|
}
|
|
|
|
if (state is AddEligibilityState) {
|
2023-08-01 08:20:38 +00:00
|
|
|
return AddEligibilityScreen(
|
|
|
|
token: token!,
|
|
|
|
profileId: profileId!,
|
|
|
|
);
|
2023-03-02 05:28:33 +00:00
|
|
|
}
|
|
|
|
if (state is EligibilityErrorState) {
|
2023-08-01 08:20:38 +00:00
|
|
|
return SomethingWentWrong(
|
|
|
|
message: state.message,
|
|
|
|
onpressed: () {
|
|
|
|
context.read<EligibilityBloc>().add(
|
|
|
|
GetEligibilities(
|
|
|
|
token: token!,
|
|
|
|
profileId: profileId!));
|
|
|
|
});
|
2023-03-02 05:28:33 +00:00
|
|
|
}
|
|
|
|
return Container(
|
|
|
|
color: Colors.grey.shade200,
|
|
|
|
);
|
|
|
|
},
|
2023-02-23 00:53:14 +00:00
|
|
|
);
|
2023-03-02 00:40:47 +00:00
|
|
|
},
|
2023-03-02 05:28:33 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2023-08-01 08:20:38 +00:00
|
|
|
return Container();
|
|
|
|
});
|
2023-03-02 00:40:47 +00:00
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
);
|
2023-02-15 05:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PopupMenuItem<int> popMenuItem({String? text, int? value, IconData? icon}) {
|
|
|
|
return PopupMenuItem(
|
|
|
|
value: value,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
icon,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 10,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
text!,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-02-09 08:48:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|