2023-08-07 06:33:38 +00:00
|
|
|
import 'package:auto_size_text/auto_size_text.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-08-07 06:33:38 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:fluttericon/entypo_icons.dart';
|
2023-08-07 06:33:38 +00:00
|
|
|
import 'package:unit2/bloc/profile/education/education_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart';
|
|
|
|
import 'package:unit2/bloc/profile/workHistory/workHistory_bloc.dart';
|
|
|
|
import 'package:unit2/utils/global_context.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
|
|
|
|
import '../../../model/profile/attachment.dart';
|
|
|
|
import '../../../theme-data.dart/box_shadow.dart';
|
|
|
|
import '../../../theme-data.dart/colors.dart';
|
2023-08-07 06:33:38 +00:00
|
|
|
import '../../../utils/alerts.dart';
|
2023-08-01 08:20:38 +00:00
|
|
|
import '../../../utils/global.dart';
|
|
|
|
|
|
|
|
class MultipleAttachments extends StatelessWidget {
|
2023-08-27 08:38:05 +00:00
|
|
|
final Function(String source, String fileName) viewAttachment;
|
2023-08-01 08:20:38 +00:00
|
|
|
final List<Attachment> attachments;
|
|
|
|
final String eligibilityName;
|
2023-08-07 06:33:38 +00:00
|
|
|
final EducationBloc? educationBloc;
|
|
|
|
final EligibilityBloc? eligibilityBloc;
|
|
|
|
final LearningDevelopmentBloc? learningDevelopmentBloc;
|
|
|
|
final WorkHistoryBloc? workHistoryBloc;
|
|
|
|
final int blocId;
|
|
|
|
final int moduleId;
|
|
|
|
final int profileId;
|
|
|
|
final String token;
|
|
|
|
const MultipleAttachments(
|
|
|
|
{super.key,
|
2023-08-27 08:38:05 +00:00
|
|
|
required this.viewAttachment,
|
2023-08-07 06:33:38 +00:00
|
|
|
required this.blocId,
|
|
|
|
required this.educationBloc,
|
|
|
|
required this.eligibilityBloc,
|
|
|
|
required this.learningDevelopmentBloc,
|
|
|
|
required this.workHistoryBloc,
|
|
|
|
required this.attachments,
|
|
|
|
required this.eligibilityName,
|
|
|
|
required this.moduleId,
|
|
|
|
required this.profileId,
|
|
|
|
required this.token});
|
2023-08-01 08:20:38 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Row(
|
2023-08-07 06:33:38 +00:00
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
flex: 3,
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.all(5),
|
|
|
|
decoration:
|
|
|
|
box1().copyWith(color: Colors.grey.shade300, boxShadow: []),
|
|
|
|
child: AutoSizeText(
|
|
|
|
|
|
|
|
attachments.first.filename!,
|
|
|
|
wrapWords: false,
|
|
|
|
maxLines: 1,
|
|
|
|
))),
|
|
|
|
const SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
child: FittedBox(
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.all(3),
|
|
|
|
decoration:
|
|
|
|
box1().copyWith(color: Colors.grey.shade300, boxShadow: []),
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertDialog(
|
|
|
|
title: Text(
|
|
|
|
"$eligibilityName Attachments",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
content: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: attachments.map((e) {
|
|
|
|
String ext = e.filename!
|
|
|
|
.substring(e.filename!.lastIndexOf("."));
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
2023-08-01 08:20:38 +00:00
|
|
|
children: [
|
2023-08-07 06:33:38 +00:00
|
|
|
Flexible(
|
|
|
|
child: SizedBox(
|
|
|
|
child: ext == '.pdf'
|
|
|
|
? SvgPicture.asset(
|
|
|
|
'assets/svgs/pdf.svg',
|
|
|
|
height: blockSizeVertical * 5,
|
|
|
|
allowDrawingOutsideViewBox:
|
|
|
|
true,
|
|
|
|
)
|
|
|
|
: ext == '.png'
|
|
|
|
? SvgPicture.asset(
|
|
|
|
'assets/svgs/png.svg',
|
|
|
|
height:
|
|
|
|
blockSizeVertical *
|
|
|
|
5.5,
|
|
|
|
allowDrawingOutsideViewBox:
|
|
|
|
true,
|
|
|
|
)
|
|
|
|
: ext == '.jpg'
|
|
|
|
? SvgPicture.asset(
|
|
|
|
'assets/svgs/jpg.svg',
|
|
|
|
height:
|
|
|
|
blockSizeVertical *
|
|
|
|
5,
|
|
|
|
allowDrawingOutsideViewBox:
|
|
|
|
true,
|
|
|
|
)
|
|
|
|
: SvgPicture.asset(
|
|
|
|
'assets/svgs/jpg.svg',
|
|
|
|
height:
|
|
|
|
blockSizeVertical *
|
|
|
|
5,
|
|
|
|
allowDrawingOutsideViewBox:
|
|
|
|
true,
|
|
|
|
),
|
2023-08-01 08:20:38 +00:00
|
|
|
),
|
2023-08-07 06:33:38 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
|
|
|
Flexible(
|
|
|
|
flex: 4,
|
|
|
|
child: Tooltip(
|
|
|
|
message: e.filename,
|
2023-08-27 08:38:05 +00:00
|
|
|
child: GestureDetector(
|
|
|
|
onTap: (){
|
|
|
|
viewAttachment(e.source!,e.filename!);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
e.filename!,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
2023-08-07 06:33:38 +00:00
|
|
|
)),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
2023-08-01 08:20:38 +00:00
|
|
|
Flexible(
|
2023-08-07 06:33:38 +00:00
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: IconButton(
|
|
|
|
icon: const Icon(
|
|
|
|
Icons.delete,
|
|
|
|
color: primary,
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
confirmAlert(context, () {
|
|
|
|
if (blocId == 1) {
|
|
|
|
Navigator.pop(
|
|
|
|
NavigationService
|
|
|
|
.navigatorKey
|
|
|
|
.currentContext!);
|
|
|
|
educationBloc!.add(
|
|
|
|
DeleteEducationAttachment(
|
|
|
|
attachment: e,
|
|
|
|
moduleId:
|
|
|
|
moduleId,
|
|
|
|
profileId:
|
|
|
|
profileId,
|
|
|
|
token: token));
|
|
|
|
} else if (blocId == 2) {
|
|
|
|
Navigator.pop(
|
|
|
|
NavigationService
|
|
|
|
.navigatorKey
|
|
|
|
.currentContext!);
|
|
|
|
eligibilityBloc!.add(
|
|
|
|
DeleteEligibyAttachment(
|
|
|
|
attachment: e,
|
|
|
|
moduleId: moduleId
|
|
|
|
.toString(),
|
|
|
|
profileId: profileId
|
|
|
|
.toString(),
|
|
|
|
token: token));
|
|
|
|
} else if (blocId == 3) {
|
|
|
|
Navigator.pop(
|
|
|
|
NavigationService
|
|
|
|
.navigatorKey
|
|
|
|
.currentContext!);
|
|
|
|
workHistoryBloc!.add(
|
|
|
|
DeleteWorkHistoryAttachment(
|
|
|
|
attachment: e,
|
|
|
|
moduleId:
|
|
|
|
moduleId,
|
|
|
|
profileId:
|
|
|
|
profileId,
|
|
|
|
token: token));
|
|
|
|
} else {
|
|
|
|
Navigator.pop(
|
|
|
|
NavigationService
|
|
|
|
.navigatorKey
|
|
|
|
.currentContext!);
|
|
|
|
learningDevelopmentBloc!.add(
|
|
|
|
DeleteLearningDevAttachment(
|
|
|
|
attachment: e,
|
|
|
|
moduleId:
|
|
|
|
moduleId,
|
|
|
|
profileId:
|
|
|
|
profileId,
|
|
|
|
token: token));
|
|
|
|
}
|
|
|
|
}, "Delete?",
|
|
|
|
"Confirm Delete?");
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
],
|
2023-08-01 08:20:38 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-08-07 06:33:38 +00:00
|
|
|
const Divider()
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
children: const [
|
|
|
|
Text(" See more.."),
|
|
|
|
Icon(
|
|
|
|
Icons.keyboard_arrow_right,
|
|
|
|
color: Colors.black54,
|
|
|
|
),
|
|
|
|
],
|
2023-08-01 08:20:38 +00:00
|
|
|
),
|
|
|
|
),
|
2023-08-07 06:33:38 +00:00
|
|
|
),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
);
|
2023-08-01 08:20:38 +00:00
|
|
|
}
|
|
|
|
}
|