non academic recognition refactor created its own bloc
parent
acc74653d1
commit
2a57e7453b
|
@ -0,0 +1,24 @@
|
|||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:unit2/sevices/profile/non_academic_services.dart';
|
||||
|
||||
import '../../model/profile/other_information/non_acedimic_recognition.dart';
|
||||
|
||||
part 'non_academic_recognition_event.dart';
|
||||
part 'non_academic_recognition_state.dart';
|
||||
|
||||
class NonAcademicRecognitionBloc extends Bloc<NonAcademicRecognitionEvent, NonAcademicRecognitionState> {
|
||||
NonAcademicRecognitionBloc() : super(NonAcademicRecognitionInitial()) {
|
||||
List<NonAcademicRecognition> nonAcademicRecognitions = [];
|
||||
on<GetNonAcademicRecognition>((event, emit)async {
|
||||
emit(NonAcademicRecognitionLoadingState());
|
||||
try{
|
||||
List<NonAcademicRecognition> recognitions = await NonAcademicRecognitionServices.instance.getNonAcademicRecognition(event.profileId, event.token);
|
||||
nonAcademicRecognitions = recognitions;
|
||||
emit(NonAcademicRecognitionLoadedState(nonAcademicRecognition: nonAcademicRecognitions));
|
||||
}catch(e){
|
||||
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
part of 'non_academic_recognition_bloc.dart';
|
||||
|
||||
abstract class NonAcademicRecognitionEvent extends Equatable {
|
||||
const NonAcademicRecognitionEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class GetNonAcademicRecognition extends NonAcademicRecognitionEvent{
|
||||
final int profileId;
|
||||
final String token;
|
||||
const GetNonAcademicRecognition({required this.profileId, required this.token});
|
||||
@override
|
||||
List<Object> get props => [profileId,token];
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
part of 'non_academic_recognition_bloc.dart';
|
||||
|
||||
abstract class NonAcademicRecognitionState extends Equatable {
|
||||
const NonAcademicRecognitionState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class NonAcademicRecognitionInitial extends NonAcademicRecognitionState {}
|
||||
|
||||
class NonAcademicRecognitionLoadingState extends NonAcademicRecognitionState{
|
||||
|
||||
}
|
||||
class NonAcademicRecognitionLoadedState extends NonAcademicRecognitionState{
|
||||
final List<NonAcademicRecognition> nonAcademicRecognition;
|
||||
const NonAcademicRecognitionLoadedState({required this.nonAcademicRecognition});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class NonAcademicRecognitionErrorState extends NonAcademicRecognitionState{
|
||||
final String message;
|
||||
const NonAcademicRecognitionErrorState({required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:unit2/model/profile/other_information/non_acedimic_recognition.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:unit2/bloc/non_academic_recognition.dart/non_academic_recognition_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
||||
import 'package:unit2/theme-data.dart/colors.dart';
|
||||
import 'package:unit2/utils/global.dart';
|
||||
|
@ -8,44 +13,120 @@ import 'package:unit2/widgets/Leadings/add_leading.dart';
|
|||
import 'package:unit2/widgets/empty_data.dart';
|
||||
|
||||
class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||
final List<NonAcademicRecognition> nonAcademicRecognitions;
|
||||
const NonAcademicRecognitionScreen({super.key, required this.nonAcademicRecognitions});
|
||||
const NonAcademicRecognitionScreen({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text(nonAcademicRecTitle), centerTitle: true, backgroundColor: primary,actions: [AddLeading(onPressed: (){})],),
|
||||
body: nonAcademicRecognitions.isNotEmpty?ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8,horizontal: 10),
|
||||
itemCount: nonAcademicRecognitions.length,
|
||||
itemBuilder: (BuildContext context, int index){
|
||||
String award = nonAcademicRecognitions[index].title!;
|
||||
String presenter = nonAcademicRecognitions[index].presenter!.name!;
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: screenWidth,
|
||||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12,vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(award,style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w500),),
|
||||
const Divider(),
|
||||
Text(presenter),
|
||||
],)),
|
||||
|
||||
IconButton(onPressed: (){}, icon: const Icon(Icons.more_vert,color: Colors.grey,))
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5,),
|
||||
],
|
||||
);
|
||||
}): const EmptyData(message: "You don't have any Non Academic Recognition added. Please click + to add"),
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text(nonAcademicRecTitle),
|
||||
centerTitle: true,
|
||||
backgroundColor: primary,
|
||||
actions: [AddLeading(onPressed: () {})],
|
||||
),
|
||||
body: ProgressHUD(
|
||||
padding: const EdgeInsets.all(24),
|
||||
backgroundColor: Colors.black87,
|
||||
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||
child: BlocBuilder<UserBloc, UserState>(
|
||||
builder: (context, state) {
|
||||
if (state is UserLoggedIn) {
|
||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||
builder: (context, state) {
|
||||
if (state is ProfileLoaded) {
|
||||
return BlocConsumer<NonAcademicRecognitionBloc,
|
||||
NonAcademicRecognitionState>(
|
||||
listener: (context, state) {
|
||||
if (state is NonAcademicRecognitionLoadingState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.showWithText("Please wait...");
|
||||
}
|
||||
if (state is NonAcademicRecognitionLoadedState ||
|
||||
state is NonAcademicRecognitionErrorState) {
|
||||
final progress = ProgressHUD.of(context);
|
||||
progress!.dismiss();
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is NonAcademicRecognitionLoadedState) {
|
||||
if (state.nonAcademicRecognition.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 10),
|
||||
itemCount:
|
||||
state.nonAcademicRecognition.length,
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
String award = state
|
||||
.nonAcademicRecognition[index].title!;
|
||||
String presenter = state
|
||||
.nonAcademicRecognition[index]
|
||||
.presenter!
|
||||
.name!;
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: screenWidth,
|
||||
decoration: box1(),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
award,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium!
|
||||
.copyWith(
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w500),
|
||||
),
|
||||
const Divider(),
|
||||
Text(presenter),
|
||||
],
|
||||
)),
|
||||
IconButton(
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
color: Colors.grey,
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
} else {
|
||||
const EmptyData(
|
||||
message:
|
||||
"You don't have any Non Academic Recognition added. Please click + to add");
|
||||
}
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:unit2/bloc/bloc/organization_membership_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||
import 'package:unit2/model/profile/other_information/organization_memberships.dart';
|
||||
|
@ -12,6 +11,7 @@ import 'package:unit2/utils/text_container.dart';
|
|||
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||
import 'package:unit2/widgets/empty_data.dart';
|
||||
|
||||
import '../../../../bloc/org_membership/organization_membership_bloc.dart';
|
||||
import '../../../../utils/global.dart';
|
||||
|
||||
class OrgMembershipsScreen extends StatelessWidget {
|
||||
|
|
|
@ -8,11 +8,11 @@ import 'package:fluttericon/elusive_icons.dart';
|
|||
import 'package:fluttericon/entypo_icons.dart';
|
||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||
import 'package:fluttericon/modern_pictograms_icons.dart';
|
||||
import 'package:unit2/bloc/bloc/organization_membership_bloc.dart';
|
||||
import 'package:unit2/bloc/education/education_bloc.dart';
|
||||
import 'package:unit2/bloc/eligibility/eligibility_bloc.dart';
|
||||
import 'package:unit2/bloc/hobbies/hoobies_bloc.dart';
|
||||
import 'package:unit2/bloc/learningDevelopment/learning_development_bloc.dart';
|
||||
import 'package:unit2/bloc/non_academic_recognition.dart/non_academic_recognition_bloc.dart';
|
||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||
import 'package:unit2/bloc/references/references_bloc.dart';
|
||||
import 'package:unit2/bloc/voluntary_works/voluntary_work_bloc.dart';
|
||||
|
@ -35,6 +35,7 @@ import 'package:unit2/screens/profile/components/references_screen.dart';
|
|||
import 'package:unit2/screens/profile/components/work_history_screen.dart';
|
||||
import 'package:unit2/screens/profile/components/voluntary_works_screen.dart';
|
||||
import 'package:unit2/theme-data.dart/colors.dart';
|
||||
import '../../bloc/org_membership/organization_membership_bloc.dart';
|
||||
import '../../bloc/user/user_bloc.dart';
|
||||
import 'components/main_menu.dart';
|
||||
import 'components/submenu.dart';
|
||||
|
@ -298,14 +299,16 @@ class _ProfileInfoState extends State<ProfileInfo> {
|
|||
subMenu(Entypo.doc_text,
|
||||
"Non-Academic Recognitions", () {
|
||||
|
||||
// Navigator.push(context, MaterialPageRoute(
|
||||
// builder: (BuildContext context) {
|
||||
// return NonAcademicRecognitionScreen(
|
||||
// nonAcademicRecognitions: state
|
||||
// .profileInformation
|
||||
// .otherInformation
|
||||
// .nonAcademicRecognition);
|
||||
// }));
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => NonAcademicRecognitionBloc()
|
||||
..add(GetNonAcademicRecognition(
|
||||
profileId: profileId!,
|
||||
token: token!)),
|
||||
child: const NonAcademicRecognitionScreen(),
|
||||
);
|
||||
}));
|
||||
}),
|
||||
]),
|
||||
ExpandableGroup(
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:unit2/utils/request.dart';
|
||||
|
||||
import '../../model/profile/other_information/non_acedimic_recognition.dart';
|
||||
import '../../utils/urls.dart';
|
||||
|
||||
class NonAcademicRecognitionServices {
|
||||
static final NonAcademicRecognitionServices _instance =
|
||||
NonAcademicRecognitionServices();
|
||||
static NonAcademicRecognitionServices get instance => _instance;
|
||||
|
||||
Future<List<NonAcademicRecognition>> getNonAcademicRecognition(
|
||||
int profileId, String token) async {
|
||||
List<NonAcademicRecognition> nonAcademicRecognitions = [];
|
||||
String authToken = "Token $token";
|
||||
String path = "${Url.instance.getNonAcademicRecognition()}$profileId/";
|
||||
Map<String, String> headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': authToken
|
||||
};
|
||||
try {
|
||||
http.Response response = await Request.instance
|
||||
.getRequest(path: path, param: {}, headers: headers);
|
||||
if (response.statusCode == 200) {
|
||||
Map data = jsonDecode(response.body);
|
||||
if (data['data'] != null) {
|
||||
data['data'].forEach((var recognition) {
|
||||
NonAcademicRecognition nonAcademicRecognition =
|
||||
NonAcademicRecognition.fromJson(recognition);
|
||||
nonAcademicRecognitions.add(nonAcademicRecognition);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw e.toString();
|
||||
}
|
||||
return nonAcademicRecognitions;
|
||||
}
|
||||
}
|
|
@ -77,6 +77,11 @@ String getOrgMemberShips(){
|
|||
return "/api/jobnet_app/profile/pds/other/org_membership/";
|
||||
}
|
||||
|
||||
////non academic recognition
|
||||
String getNonAcademicRecognition(){
|
||||
return "/api/jobnet_app/profile/pds/other/non_acad_recognition/";
|
||||
}
|
||||
|
||||
// location utils path
|
||||
String getCounties(){
|
||||
return "/api/jobnet_app/countries/";
|
||||
|
|
Loading…
Reference in New Issue