Implemented crud operation API for NonAcademic Recognition screen
parent
58e1167613
commit
36bec39fb6
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:unit2/sevices/profile/non_academic_services.dart';
|
import 'package:unit2/sevices/profile/non_academic_services.dart';
|
||||||
|
@ -7,46 +9,162 @@ import '../../../../model/utils/agency.dart';
|
||||||
import '../../../../model/utils/category.dart';
|
import '../../../../model/utils/category.dart';
|
||||||
import '../../../../utils/profile_utilities.dart';
|
import '../../../../utils/profile_utilities.dart';
|
||||||
|
|
||||||
|
|
||||||
part 'non_academic_recognition_event.dart';
|
part 'non_academic_recognition_event.dart';
|
||||||
part 'non_academic_recognition_state.dart';
|
part 'non_academic_recognition_state.dart';
|
||||||
|
|
||||||
class NonAcademicRecognitionBloc extends Bloc<NonAcademicRecognitionEvent, NonAcademicRecognitionState> {
|
class NonAcademicRecognitionBloc
|
||||||
|
extends Bloc<NonAcademicRecognitionEvent, NonAcademicRecognitionState> {
|
||||||
NonAcademicRecognitionBloc() : super(NonAcademicRecognitionInitial()) {
|
NonAcademicRecognitionBloc() : super(NonAcademicRecognitionInitial()) {
|
||||||
List<NonAcademicRecognition> nonAcademicRecognitions = [];
|
List<NonAcademicRecognition> nonAcademicRecognitions = [];
|
||||||
List<Agency> agencies = [];
|
List<Agency> agencies = [];
|
||||||
List<Category> agencyCategory = [];
|
List<Category> agencyCategory = [];
|
||||||
////GET
|
////GET
|
||||||
on<GetNonAcademicRecognition>((event, emit)async {
|
on<GetNonAcademicRecognition>((event, emit) async {
|
||||||
emit(NonAcademicRecognitionLoadingState());
|
emit(NonAcademicRecognitionLoadingState());
|
||||||
try{
|
try {
|
||||||
List<NonAcademicRecognition> recognitions = await NonAcademicRecognitionServices.instance.getNonAcademicRecognition(event.profileId, event.token);
|
if (nonAcademicRecognitions.isEmpty) {
|
||||||
nonAcademicRecognitions = recognitions;
|
List<NonAcademicRecognition> recognitions =
|
||||||
emit(NonAcademicRecognitionLoadedState(nonAcademicRecognition: nonAcademicRecognitions));
|
await NonAcademicRecognitionServices.instance
|
||||||
}catch(e){
|
.getNonAcademicRecognition(event.profileId!, event.token!);
|
||||||
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
nonAcademicRecognitions = recognitions;
|
||||||
}
|
emit(NonAcademicRecognitionLoadedState(
|
||||||
|
nonAcademicRecognition: nonAcademicRecognitions));
|
||||||
|
} else {
|
||||||
|
emit(NonAcademicRecognitionLoadedState(
|
||||||
|
nonAcademicRecognition: nonAcademicRecognitions));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
////LOAD
|
||||||
|
on<LoadNonAcademeRecognition>((event,emit){
|
||||||
|
nonAcademicRecognitions = event.nonAcademicRecognitions;
|
||||||
|
emit(NonAcademicRecognitionLoadedState(nonAcademicRecognition: nonAcademicRecognitions));
|
||||||
});
|
});
|
||||||
////SHOW ADD FORM
|
////SHOW ADD FORM
|
||||||
on<ShowAddNonAcademeRecognitionForm>((event, emit)async{
|
on<ShowAddNonAcademeRecognitionForm>(
|
||||||
|
(event, emit) async {
|
||||||
emit(NonAcademicRecognitionLoadingState());
|
emit(NonAcademicRecognitionLoadingState());
|
||||||
try{
|
try {
|
||||||
if(agencies.isEmpty){
|
if (agencies.isEmpty) {
|
||||||
List<Agency> newAgencies = await ProfileUtilities.instance.getAgecies();
|
List<Agency> newAgencies =
|
||||||
agencies = newAgencies;
|
await ProfileUtilities.instance.getAgecies();
|
||||||
|
agencies = newAgencies;
|
||||||
}
|
}
|
||||||
if(agencyCategory.isEmpty){
|
if (agencyCategory.isEmpty) {
|
||||||
List<Category>newAgencyCategories = await ProfileUtilities.instance.agencyCategory();
|
List<Category> newAgencyCategories =
|
||||||
agencyCategory = newAgencyCategories;
|
await ProfileUtilities.instance.agencyCategory();
|
||||||
}
|
agencyCategory = newAgencyCategories;
|
||||||
emit(AddNonAcademeRecognitionState(agencies: agencies, agencyCategories: agencyCategory));
|
}
|
||||||
}catch(e){
|
emit(AddNonAcademeRecognitionState(
|
||||||
|
agencies: agencies, agencyCategories: agencyCategory));
|
||||||
|
} catch (e) {
|
||||||
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||||
}
|
}
|
||||||
},);
|
},
|
||||||
////ADD
|
);
|
||||||
on<AddNonAcademeRecognition>((event,emit){
|
////SHOW EDIT FORM
|
||||||
emit(NonAcademicRecognitionLoadingState());
|
on<ShowEditNonAcademicRecognitionForm>((event, emit) async {
|
||||||
});
|
emit(NonAcademicRecognitionLoadingState());
|
||||||
|
try {
|
||||||
|
if (agencies.isEmpty) {
|
||||||
|
List<Agency> newAgencies =
|
||||||
|
await ProfileUtilities.instance.getAgecies();
|
||||||
|
agencies = newAgencies;
|
||||||
|
}
|
||||||
|
if (agencyCategory.isEmpty) {
|
||||||
|
List<Category> newAgencyCategories =
|
||||||
|
await ProfileUtilities.instance.agencyCategory();
|
||||||
|
agencyCategory = newAgencyCategories;
|
||||||
|
}
|
||||||
|
emit(EditNonAcademeRecognitionState(
|
||||||
|
agencies: agencies,
|
||||||
|
agencyCategories: agencyCategory,
|
||||||
|
nonAcademicRecognition: event.nonAcademicRecognition));
|
||||||
|
} catch (e) {
|
||||||
|
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
////ADD
|
||||||
|
on<AddNonAcademeRecognition>((event, emit) async {
|
||||||
|
emit(NonAcademicRecognitionLoadingState());
|
||||||
|
try {
|
||||||
|
Map<dynamic, dynamic> status =
|
||||||
|
await NonAcademicRecognitionServices.instance.add(
|
||||||
|
token: event.token,
|
||||||
|
profileId: event.profileId,
|
||||||
|
nonAcademicRecognition: event.nonAcademicRecognition);
|
||||||
|
if (status['success']) {
|
||||||
|
NonAcademicRecognition nonAcademicRecognition =
|
||||||
|
NonAcademicRecognition.fromJson(status['data']);
|
||||||
|
nonAcademicRecognitions.add(nonAcademicRecognition);
|
||||||
|
emit(NonAcademeRecognitionAddedState(
|
||||||
|
response: status,
|
||||||
|
nonAcademicRecognition: nonAcademicRecognitions));
|
||||||
|
} else {
|
||||||
|
emit(NonAcademeRecognitionAddedState(
|
||||||
|
response: status,
|
||||||
|
nonAcademicRecognition: nonAcademicRecognitions));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
////EDIT
|
||||||
|
on<EditNonAcademeRecognition>((event, emit) async {
|
||||||
|
emit(NonAcademicRecognitionLoadingState());
|
||||||
|
try {
|
||||||
|
Map<dynamic, dynamic> status =
|
||||||
|
await NonAcademicRecognitionServices.instance.update(
|
||||||
|
nonAcademicRecognition: event.nonAcademicRecognition,
|
||||||
|
profileId: event.profileId,
|
||||||
|
token: event.token);
|
||||||
|
if (status['success']) {
|
||||||
|
NonAcademicRecognition newNonAcademeRecognition =
|
||||||
|
NonAcademicRecognition.fromJson(status['data']);
|
||||||
|
nonAcademicRecognitions.removeWhere(
|
||||||
|
(element) => element.id == event.nonAcademicRecognition.id);
|
||||||
|
nonAcademicRecognitions.add(newNonAcademeRecognition);
|
||||||
|
emit(NonAcademeRecognitionEditedState(
|
||||||
|
nonAcademicRecognitions: nonAcademicRecognitions,
|
||||||
|
response: status));
|
||||||
|
}else{
|
||||||
|
emit(NonAcademeRecognitionEditedState(
|
||||||
|
nonAcademicRecognitions: nonAcademicRecognitions,
|
||||||
|
response: status));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
////DELETE
|
||||||
|
on<DeleteNonAcademeRecognition>((event, emit) async {
|
||||||
|
emit(NonAcademicRecognitionLoadingState());
|
||||||
|
try {
|
||||||
|
final bool success = await NonAcademicRecognitionServices.instance
|
||||||
|
.delete(
|
||||||
|
title: event.nonAcademicRecognition.title!,
|
||||||
|
id: event.nonAcademicRecognition.id!,
|
||||||
|
token: event.token,
|
||||||
|
profileId: event.profileId);
|
||||||
|
if (success) {
|
||||||
|
event.nonAcademicRecognitions.removeWhere(
|
||||||
|
(element) => element.id == event.nonAcademicRecognition.id);
|
||||||
|
nonAcademicRecognitions = event.nonAcademicRecognitions;
|
||||||
|
emit(NonAcademeRecognitionDeletedState(
|
||||||
|
nonAcademicRecognitions: nonAcademicRecognitions,
|
||||||
|
success: success));
|
||||||
|
} else {
|
||||||
|
emit(NonAcademeRecognitionDeletedState(
|
||||||
|
nonAcademicRecognitions: nonAcademicRecognitions,
|
||||||
|
success: success));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(NonAcademicRecognitionErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,9 @@ abstract class NonAcademicRecognitionEvent extends Equatable {
|
||||||
}
|
}
|
||||||
//// GET EVENT
|
//// GET EVENT
|
||||||
class GetNonAcademicRecognition extends NonAcademicRecognitionEvent{
|
class GetNonAcademicRecognition extends NonAcademicRecognitionEvent{
|
||||||
final int profileId;
|
final int? profileId;
|
||||||
final String token;
|
final String? token;
|
||||||
const GetNonAcademicRecognition({required this.profileId, required this.token});
|
const GetNonAcademicRecognition({ this.profileId, this.token});
|
||||||
@override
|
|
||||||
List<Object> get props => [profileId,token];
|
|
||||||
}
|
}
|
||||||
////LOAD EVENT
|
////LOAD EVENT
|
||||||
class LoadNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
class LoadNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
||||||
|
@ -27,6 +25,14 @@ class ShowAddNonAcademeRecognitionForm extends NonAcademicRecognitionEvent{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//// SHOW EDIT FORM
|
||||||
|
class ShowEditNonAcademicRecognitionForm extends NonAcademicRecognitionEvent{
|
||||||
|
final NonAcademicRecognition nonAcademicRecognition;
|
||||||
|
const ShowEditNonAcademicRecognitionForm({required this.nonAcademicRecognition});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [nonAcademicRecognition];
|
||||||
|
}
|
||||||
|
|
||||||
//// ADD EVENT
|
//// ADD EVENT
|
||||||
class AddNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
class AddNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
||||||
final int profileId;
|
final int profileId;
|
||||||
|
@ -35,18 +41,27 @@ class AddNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
||||||
const AddNonAcademeRecognition({required this.nonAcademicRecognition, required this.profileId, required this.token});
|
const AddNonAcademeRecognition({required this.nonAcademicRecognition, required this.profileId, required this.token});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [nonAcademicRecognition,profileId,token];
|
List<Object> get props => [nonAcademicRecognition,profileId,token];
|
||||||
|
}
|
||||||
|
|
||||||
|
//// EDIT EVENT
|
||||||
|
class EditNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
||||||
|
final NonAcademicRecognition nonAcademicRecognition;
|
||||||
|
final String token;
|
||||||
|
final int profileId;
|
||||||
|
const EditNonAcademeRecognition({required this.nonAcademicRecognition, required this.profileId, required this.token});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [nonAcademicRecognition,profileId,token];
|
||||||
}
|
}
|
||||||
|
|
||||||
//// DELETE EVENT
|
//// DELETE EVENT
|
||||||
class DeleteNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
class DeleteNonAcademeRecognition extends NonAcademicRecognitionEvent{
|
||||||
final int profileId;
|
final int profileId;
|
||||||
final String token;
|
final String token;
|
||||||
final int id;
|
final List<NonAcademicRecognition> nonAcademicRecognitions;
|
||||||
final String title;
|
final NonAcademicRecognition nonAcademicRecognition;
|
||||||
const DeleteNonAcademeRecognition({required this.id,required this.profileId, required this.title,required this.token});
|
const DeleteNonAcademeRecognition({required this.nonAcademicRecognitions, required this.nonAcademicRecognition,required this.profileId,required this.token});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [profileId,token,id,title];
|
List<Object> get props => [profileId,token,nonAcademicRecognition,nonAcademicRecognitions];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,60 +2,78 @@ part of 'non_academic_recognition_bloc.dart';
|
||||||
|
|
||||||
abstract class NonAcademicRecognitionState extends Equatable {
|
abstract class NonAcademicRecognitionState extends Equatable {
|
||||||
const NonAcademicRecognitionState();
|
const NonAcademicRecognitionState();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class NonAcademicRecognitionInitial extends NonAcademicRecognitionState {}
|
class NonAcademicRecognitionInitial extends NonAcademicRecognitionState {}
|
||||||
|
|
||||||
|
|
||||||
////LOADING STATE
|
////LOADING STATE
|
||||||
class NonAcademicRecognitionLoadingState extends NonAcademicRecognitionState{
|
class NonAcademicRecognitionLoadingState extends NonAcademicRecognitionState {}
|
||||||
|
|
||||||
}
|
|
||||||
////LOADED STATE
|
////LOADED STATE
|
||||||
class NonAcademicRecognitionLoadedState extends NonAcademicRecognitionState{
|
class NonAcademicRecognitionLoadedState extends NonAcademicRecognitionState {
|
||||||
final List<NonAcademicRecognition> nonAcademicRecognition;
|
final List<NonAcademicRecognition> nonAcademicRecognition;
|
||||||
const NonAcademicRecognitionLoadedState({required this.nonAcademicRecognition});
|
const NonAcademicRecognitionLoadedState(
|
||||||
@override
|
{required this.nonAcademicRecognition});
|
||||||
List<Object> get props => [];
|
@override
|
||||||
}
|
List<Object> get props => [];
|
||||||
////DELETED STATE
|
}
|
||||||
class NonAcademeRecognitionDeletedState extends NonAcademicRecognitionState{
|
|
||||||
final List<NonAcademicRecognition> nonAcademicRecognition;
|
////DELETED STATE
|
||||||
final bool success;
|
class NonAcademeRecognitionDeletedState extends NonAcademicRecognitionState {
|
||||||
const NonAcademeRecognitionDeletedState({required this.nonAcademicRecognition, required this.success});
|
final List<NonAcademicRecognition> nonAcademicRecognitions;
|
||||||
@override
|
final bool success;
|
||||||
List<Object> get props => [nonAcademicRecognition,success];
|
const NonAcademeRecognitionDeletedState(
|
||||||
}
|
{required this.nonAcademicRecognitions, required this.success});
|
||||||
|
@override
|
||||||
////ADDED STATE
|
List<Object> get props => [nonAcademicRecognitions, success];
|
||||||
class NonAcademeRecognitionAddedState extends NonAcademicRecognitionState{
|
}
|
||||||
final List<NonAcademicRecognition> nonAcademicRecognition;
|
|
||||||
final Map<dynamic,dynamic> response;
|
class NonAcademeRecognitionEditedState extends NonAcademicRecognitionState{
|
||||||
const NonAcademeRecognitionAddedState({required this.nonAcademicRecognition, required this.response});
|
final List<NonAcademicRecognition> nonAcademicRecognitions;
|
||||||
@override
|
final Map<dynamic,dynamic> response;
|
||||||
List<Object> get props => [nonAcademicRecognition,response];
|
const NonAcademeRecognitionEditedState(
|
||||||
}
|
{required this.nonAcademicRecognitions, required this.response});
|
||||||
|
@override
|
||||||
////ADDING STATE
|
List<Object> get props => [nonAcademicRecognitions, response];
|
||||||
class AddNonAcademeRecognitionState extends NonAcademicRecognitionState{
|
}
|
||||||
final List<Agency> agencies;
|
|
||||||
final List<Category> agencyCategories;
|
////ADDED STATE
|
||||||
const AddNonAcademeRecognitionState({required this.agencies, required this.agencyCategories});
|
class NonAcademeRecognitionAddedState extends NonAcademicRecognitionState {
|
||||||
@override
|
final List<NonAcademicRecognition> nonAcademicRecognition;
|
||||||
List<Object> get props => [agencies,agencyCategories];
|
final Map<dynamic, dynamic> response;
|
||||||
|
const NonAcademeRecognitionAddedState(
|
||||||
}
|
{required this.nonAcademicRecognition, required this.response});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [nonAcademicRecognition, response];
|
||||||
|
}
|
||||||
////ERROR STATE
|
|
||||||
class NonAcademicRecognitionErrorState extends NonAcademicRecognitionState{
|
////ADDING STATE
|
||||||
final String message;
|
class AddNonAcademeRecognitionState extends NonAcademicRecognitionState {
|
||||||
const NonAcademicRecognitionErrorState({required this.message});
|
final List<Agency> agencies;
|
||||||
|
final List<Category> agencyCategories;
|
||||||
|
const AddNonAcademeRecognitionState(
|
||||||
|
{required this.agencies, required this.agencyCategories});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [agencies, agencyCategories];
|
||||||
|
}
|
||||||
|
|
||||||
|
class EditNonAcademeRecognitionState extends NonAcademicRecognitionState {
|
||||||
|
final List<Agency> agencies;
|
||||||
|
final List<Category> agencyCategories;
|
||||||
|
final NonAcademicRecognition nonAcademicRecognition;
|
||||||
|
const EditNonAcademeRecognitionState({required this.agencies, required this.agencyCategories,required this.nonAcademicRecognition});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [agencies, agencyCategories,nonAcademicRecognition];
|
||||||
|
}
|
||||||
|
|
||||||
|
////ERROR STATE
|
||||||
|
class NonAcademicRecognitionErrorState extends NonAcademicRecognitionState {
|
||||||
|
final String message;
|
||||||
|
const NonAcademicRecognitionErrorState({required this.message});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
|
||||||
on<CallErrorState>((event, emit) async {
|
on<CallErrorState>((event, emit) async {
|
||||||
emit(const ReferencesErrorState(
|
emit(const ReferencesErrorState(
|
||||||
message: "Something went wrong. Please try again"));
|
message: "Something went wrong. Please try again"));
|
||||||
//// ADD REFERENCES EVENT
|
//// EDIT REFERENCES EVENT
|
||||||
});on<EditReference>((event,emit)async{
|
});on<EditReference>((event,emit)async{
|
||||||
emit(ReferencesLoadingState());
|
emit(ReferencesLoadingState());
|
||||||
Map<dynamic,dynamic> status =await ReferencesServices.instace.update(ref: event.reference, token: event.token, profileId: event.profileId);
|
Map<dynamic,dynamic> status =await ReferencesServices.instace.update(ref: event.reference, token: event.token, profileId: event.profileId);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/src/widgets/framework.dart';
|
|
||||||
import 'package:flutter/src/widgets/placeholder.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:fluttericon/font_awesome_icons.dart';
|
import 'package:fluttericon/font_awesome_icons.dart';
|
||||||
|
@ -18,6 +16,7 @@ import '../../../../../model/utils/category.dart';
|
||||||
import '../../../../../theme-data.dart/box_shadow.dart';
|
import '../../../../../theme-data.dart/box_shadow.dart';
|
||||||
import '../../../../../theme-data.dart/btn-style.dart';
|
import '../../../../../theme-data.dart/btn-style.dart';
|
||||||
import '../../../../../theme-data.dart/colors.dart';
|
import '../../../../../theme-data.dart/colors.dart';
|
||||||
|
import '../../../../../utils/text_container.dart';
|
||||||
|
|
||||||
class AddNonAcademicRecognitionScreen extends StatefulWidget {
|
class AddNonAcademicRecognitionScreen extends StatefulWidget {
|
||||||
const AddNonAcademicRecognitionScreen({super.key});
|
const AddNonAcademicRecognitionScreen({super.key});
|
||||||
|
@ -48,9 +47,12 @@ class _AddNonAcademicRecognitionScreenState
|
||||||
return BlocBuilder<UserBloc, UserState>(
|
return BlocBuilder<UserBloc, UserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
|
token = state.userData!.user!.login!.token;
|
||||||
|
profileId = state.userData!.user!.login!.user!.profileId!;
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is ProfileLoaded) {
|
if (state is ProfileLoaded) {
|
||||||
|
|
||||||
return BlocBuilder<NonAcademicRecognitionBloc,
|
return BlocBuilder<NonAcademicRecognitionBloc,
|
||||||
NonAcademicRecognitionState>(
|
NonAcademicRecognitionState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
@ -58,7 +60,9 @@ class _AddNonAcademicRecognitionScreenState
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: blockSizeVertical * 90,
|
height: blockSizeVertical * 90,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: FormBuilder(child: Padding(
|
child: FormBuilder(
|
||||||
|
key: _formKey,
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 25,horizontal: 18),
|
padding: const EdgeInsets.symmetric(vertical: 25,horizontal: 18),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -321,7 +325,38 @@ class _AddNonAcademicRecognitionScreenState
|
||||||
: const SizedBox()),
|
: const SizedBox()),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
})
|
}),
|
||||||
|
const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 60,
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: mainBtnStyle(primary,
|
||||||
|
Colors.transparent, second),
|
||||||
|
onPressed: () {
|
||||||
|
|
||||||
|
if (_formKey.currentState!
|
||||||
|
.saveAndValidate()) {
|
||||||
|
String title = _formKey.currentState!.value['title'];
|
||||||
|
|
||||||
|
if(selectedAgency?.privateEntity != null){
|
||||||
|
newAgency = selectedAgency;
|
||||||
|
}else{
|
||||||
|
newAgency = Agency(
|
||||||
|
id: selectedAgency?.id,
|
||||||
|
name: selectedAgency!.name,
|
||||||
|
category:
|
||||||
|
selectedCategory,
|
||||||
|
privateEntity: isPrivate);
|
||||||
|
}
|
||||||
|
nonAcademicRecognition = NonAcademicRecognition(id: null, title:title,presenter: newAgency );
|
||||||
|
context.read<NonAcademicRecognitionBloc>().add(AddNonAcademeRecognition(nonAcademicRecognition: nonAcademicRecognition!, profileId: profileId!, token: token!));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text(submit)),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -0,0 +1,410 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
|
import 'package:fluttericon/font_awesome_icons.dart';
|
||||||
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||||
|
import 'package:searchfield/searchfield.dart';
|
||||||
|
import 'package:unit2/bloc/profile/other_information/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/model/profile/other_information/non_acedimic_recognition.dart';
|
||||||
|
import 'package:unit2/theme-data.dart/form-style.dart';
|
||||||
|
import 'package:unit2/utils/global.dart';
|
||||||
|
|
||||||
|
import '../../../../../model/utils/agency.dart';
|
||||||
|
import '../../../../../model/utils/category.dart';
|
||||||
|
import '../../../../../theme-data.dart/box_shadow.dart';
|
||||||
|
import '../../../../../theme-data.dart/btn-style.dart';
|
||||||
|
import '../../../../../theme-data.dart/colors.dart';
|
||||||
|
import '../../../../../utils/text_container.dart';
|
||||||
|
|
||||||
|
class EditNonAcademicRecognitionScreen extends StatefulWidget {
|
||||||
|
const EditNonAcademicRecognitionScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<EditNonAcademicRecognitionScreen> createState() =>
|
||||||
|
_EditNonAcademicRecognitionScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _EditNonAcademicRecognitionScreenState
|
||||||
|
extends State<EditNonAcademicRecognitionScreen> {
|
||||||
|
bool showAgencyCategory = false;
|
||||||
|
final agencyFocusNode = FocusNode();
|
||||||
|
|
||||||
|
final agencyCategoryFocusNode = FocusNode();
|
||||||
|
final addAgencyController = TextEditingController();
|
||||||
|
Agency? selectedAgency;
|
||||||
|
Category? selectedCategory;
|
||||||
|
Agency? newAgency;
|
||||||
|
bool showIsPrivateRadio = false;
|
||||||
|
bool? isPrivate = false;
|
||||||
|
NonAcademicRecognition? nonAcademicRecognition;
|
||||||
|
final oldAgencyController = TextEditingController();
|
||||||
|
final _formKey = GlobalKey<FormBuilderState>();
|
||||||
|
int? profileId;
|
||||||
|
String? token;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BlocBuilder<UserBloc, UserState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state is UserLoggedIn) {
|
||||||
|
token = state.userData!.user!.login!.token;
|
||||||
|
profileId = state.userData!.user!.login!.user!.profileId!;
|
||||||
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state is ProfileLoaded) {
|
||||||
|
return BlocBuilder<NonAcademicRecognitionBloc,
|
||||||
|
NonAcademicRecognitionState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state is EditNonAcademeRecognitionState) {
|
||||||
|
oldAgencyController.text =
|
||||||
|
state.nonAcademicRecognition.presenter!.name!;
|
||||||
|
selectedAgency = state.nonAcademicRecognition.presenter;
|
||||||
|
selectedCategory =
|
||||||
|
state.nonAcademicRecognition.presenter!.category;
|
||||||
|
return SizedBox(
|
||||||
|
height: blockSizeVertical * 90,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: FormBuilder(
|
||||||
|
key: _formKey,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 25, horizontal: 18),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
FormBuilderTextField(
|
||||||
|
name: 'title',
|
||||||
|
initialValue:
|
||||||
|
state.nonAcademicRecognition.title,
|
||||||
|
decoration: normalTextFieldStyle(
|
||||||
|
"Recognition / Award Title *",
|
||||||
|
"Recognition / Award Title"),
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators.required(
|
||||||
|
errorText:
|
||||||
|
"this field is required"),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
StatefulBuilder(
|
||||||
|
builder: (context, setState) {
|
||||||
|
//// AGENCY SEARCHFIELD
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
SearchField(
|
||||||
|
controller: oldAgencyController,
|
||||||
|
itemHeight: 70,
|
||||||
|
suggestions: state.agencies
|
||||||
|
.map((Agency agency) =>
|
||||||
|
SearchFieldListItem(
|
||||||
|
agency.name!,
|
||||||
|
item: agency,
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
agency.name!
|
||||||
|
.toUpperCase(),
|
||||||
|
overflow:
|
||||||
|
TextOverflow
|
||||||
|
.ellipsis,
|
||||||
|
),
|
||||||
|
subtitle: Text(agency
|
||||||
|
.privateEntity ==
|
||||||
|
true
|
||||||
|
? "Private"
|
||||||
|
: agency.privateEntity ==
|
||||||
|
false
|
||||||
|
? "Government"
|
||||||
|
: ""),
|
||||||
|
)))
|
||||||
|
.toList(),
|
||||||
|
|
||||||
|
validator: FormBuilderValidators
|
||||||
|
.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
focusNode: agencyFocusNode,
|
||||||
|
searchInputDecoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
|
"Agency *", "")
|
||||||
|
.copyWith(
|
||||||
|
suffixIcon:
|
||||||
|
const Icon(Icons
|
||||||
|
.arrow_drop_down)),
|
||||||
|
////agency suggestion tap
|
||||||
|
onSuggestionTap: (agency) {
|
||||||
|
setState(() {
|
||||||
|
selectedAgency = agency.item;
|
||||||
|
agencyFocusNode.unfocus();
|
||||||
|
if (selectedAgency
|
||||||
|
?.category ==
|
||||||
|
null) {
|
||||||
|
showAgencyCategory = true;
|
||||||
|
showIsPrivateRadio = true;
|
||||||
|
} else {
|
||||||
|
showAgencyCategory = false;
|
||||||
|
showIsPrivateRadio = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
emptyWidget: Container(
|
||||||
|
decoration: box1(),
|
||||||
|
height: 100,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment
|
||||||
|
.center,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment
|
||||||
|
.center,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"No result found..."),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
//// Add agency onpressed
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context:
|
||||||
|
context,
|
||||||
|
builder:
|
||||||
|
(BuildContext
|
||||||
|
context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text(
|
||||||
|
"Add Agency?"),
|
||||||
|
content:
|
||||||
|
SizedBox(
|
||||||
|
height:
|
||||||
|
130,
|
||||||
|
child:
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller:
|
||||||
|
addAgencyController,
|
||||||
|
decoration:
|
||||||
|
normalTextFieldStyle("", ""),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height:
|
||||||
|
12,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 50,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: mainBtnStyle(primary, Colors.transparent, second),
|
||||||
|
//// onpressed
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
newAgency = Agency(id: null, name: addAgencyController.text.toUpperCase(), category: null, privateEntity: null);
|
||||||
|
state.agencies.insert(0, newAgency!);
|
||||||
|
addAgencyController.clear();
|
||||||
|
Navigator.pop(context);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: const Text("Add"))),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
"Add position"))
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
child: showAgencyCategory
|
||||||
|
? SearchField(
|
||||||
|
focusNode:
|
||||||
|
agencyCategoryFocusNode,
|
||||||
|
itemHeight: 70,
|
||||||
|
suggestions: state
|
||||||
|
.agencyCategories
|
||||||
|
.map((Category
|
||||||
|
category) =>
|
||||||
|
SearchFieldListItem(
|
||||||
|
category
|
||||||
|
.name!,
|
||||||
|
item:
|
||||||
|
category,
|
||||||
|
child:
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
category
|
||||||
|
.name!),
|
||||||
|
subtitle: Text(category
|
||||||
|
.industryClass!
|
||||||
|
.name!),
|
||||||
|
)))
|
||||||
|
.toList(),
|
||||||
|
emptyWidget: Container(
|
||||||
|
height: 100,
|
||||||
|
decoration: box1(),
|
||||||
|
child: const Center(
|
||||||
|
child: Text(
|
||||||
|
"No result found ...")),
|
||||||
|
),
|
||||||
|
////agency controller suggestion tap
|
||||||
|
onSuggestionTap:
|
||||||
|
(agencyCategory) {
|
||||||
|
setState(() {
|
||||||
|
selectedCategory =
|
||||||
|
agencyCategory
|
||||||
|
.item;
|
||||||
|
|
||||||
|
agencyCategoryFocusNode
|
||||||
|
.unfocus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
searchInputDecoration:
|
||||||
|
normalTextFieldStyle(
|
||||||
|
"Category *",
|
||||||
|
"")
|
||||||
|
.copyWith(
|
||||||
|
suffixIcon:
|
||||||
|
const Icon(
|
||||||
|
Icons
|
||||||
|
.arrow_drop_down)),
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators
|
||||||
|
.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
),
|
||||||
|
|
||||||
|
////PRVIATE SECTOR
|
||||||
|
SizedBox(
|
||||||
|
child: showIsPrivateRadio
|
||||||
|
? FormBuilderRadioGroup(
|
||||||
|
decoration:
|
||||||
|
InputDecoration(
|
||||||
|
border:
|
||||||
|
InputBorder.none,
|
||||||
|
label: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Is this private sector? ",
|
||||||
|
style: Theme.of(
|
||||||
|
context)
|
||||||
|
.textTheme
|
||||||
|
.headlineSmall!
|
||||||
|
.copyWith(
|
||||||
|
fontSize:
|
||||||
|
24),
|
||||||
|
),
|
||||||
|
const Icon(FontAwesome
|
||||||
|
.help_circled)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
////onvhange private sector
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
if (value
|
||||||
|
.toString() ==
|
||||||
|
"YES") {
|
||||||
|
isPrivate = true;
|
||||||
|
} else {
|
||||||
|
isPrivate = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
name: 'isPrivate',
|
||||||
|
validator:
|
||||||
|
FormBuilderValidators
|
||||||
|
.required(
|
||||||
|
errorText:
|
||||||
|
"This field is required"),
|
||||||
|
options: ["YES", "NO"]
|
||||||
|
.map((lang) =>
|
||||||
|
FormBuilderFieldOption(
|
||||||
|
value:
|
||||||
|
lang))
|
||||||
|
.toList(
|
||||||
|
growable:
|
||||||
|
false),
|
||||||
|
)
|
||||||
|
: const SizedBox()),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 60,
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: mainBtnStyle(primary,
|
||||||
|
Colors.transparent, second),
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!
|
||||||
|
.saveAndValidate()) {
|
||||||
|
String title = _formKey
|
||||||
|
.currentState!
|
||||||
|
.value['title'];
|
||||||
|
|
||||||
|
if (selectedAgency
|
||||||
|
?.privateEntity !=
|
||||||
|
null) {
|
||||||
|
newAgency = selectedAgency;
|
||||||
|
} else {
|
||||||
|
newAgency = Agency(
|
||||||
|
id: selectedAgency?.id,
|
||||||
|
name:
|
||||||
|
selectedAgency!.name,
|
||||||
|
category:
|
||||||
|
selectedCategory,
|
||||||
|
privateEntity: isPrivate);
|
||||||
|
}
|
||||||
|
nonAcademicRecognition =
|
||||||
|
NonAcademicRecognition(
|
||||||
|
id: state.nonAcademicRecognition.id,
|
||||||
|
title: title,
|
||||||
|
presenter: newAgency);
|
||||||
|
context
|
||||||
|
.read<
|
||||||
|
NonAcademicRecognitionBloc>()
|
||||||
|
.add(EditNonAcademeRecognition(
|
||||||
|
nonAcademicRecognition:
|
||||||
|
nonAcademicRecognition!,
|
||||||
|
profileId: profileId!,
|
||||||
|
token: token!));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text(submit)),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:app_popup_menu/app_popup_menu.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
|
@ -5,6 +6,7 @@ import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
import 'package:unit2/screens/profile/components/other_information/non_academic/add_modal.dart';
|
import 'package:unit2/screens/profile/components/other_information/non_academic/add_modal.dart';
|
||||||
|
import 'package:unit2/screens/profile/components/other_information/non_academic/edit_modal.dart';
|
||||||
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
import 'package:unit2/theme-data.dart/box_shadow.dart';
|
||||||
import 'package:unit2/theme-data.dart/colors.dart';
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
import 'package:unit2/utils/global.dart';
|
import 'package:unit2/utils/global.dart';
|
||||||
|
@ -13,6 +15,7 @@ import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||||
import 'package:unit2/widgets/empty_data.dart';
|
import 'package:unit2/widgets/empty_data.dart';
|
||||||
|
|
||||||
import '../../../../bloc/profile/other_information/non_academic_recognition.dart/non_academic_recognition_bloc.dart';
|
import '../../../../bloc/profile/other_information/non_academic_recognition.dart/non_academic_recognition_bloc.dart';
|
||||||
|
import '../../../../utils/alerts.dart';
|
||||||
|
|
||||||
class NonAcademicRecognitionScreen extends StatelessWidget {
|
class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
const NonAcademicRecognitionScreen({
|
const NonAcademicRecognitionScreen({
|
||||||
|
@ -28,9 +31,13 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
title: const Text(nonAcademicRecTitle),
|
title: const Text(nonAcademicRecTitle),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
backgroundColor: primary,
|
backgroundColor: primary,
|
||||||
actions: [AddLeading(onPressed: () {
|
actions: [
|
||||||
context.read<NonAcademicRecognitionBloc>().add(ShowAddNonAcademeRecognitionForm());
|
AddLeading(onPressed: () {
|
||||||
})],
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add(ShowAddNonAcademeRecognitionForm());
|
||||||
|
})
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: ProgressHUD(
|
body: ProgressHUD(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
|
@ -39,7 +46,7 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
child: BlocBuilder<UserBloc, UserState>(
|
child: BlocBuilder<UserBloc, UserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
token = state.userData!.user!.login!.token;
|
token = state.userData!.user!.login!.token;
|
||||||
profileId = state.userData!.user!.login!.user!.profileId!;
|
profileId = state.userData!.user!.login!.user!.profileId!;
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
@ -52,10 +59,72 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
progress!.showWithText("Please wait...");
|
progress!.showWithText("Please wait...");
|
||||||
}
|
}
|
||||||
if (state is NonAcademicRecognitionLoadedState ||
|
if (state is NonAcademicRecognitionLoadedState ||
|
||||||
state is NonAcademicRecognitionErrorState || state is AddNonAcademeRecognitionState) {
|
state is NonAcademicRecognitionErrorState ||
|
||||||
|
state is AddNonAcademeRecognitionState || state is EditNonAcademeRecognitionState || state is NonAcademeRecognitionEditedState) {
|
||||||
final progress = ProgressHUD.of(context);
|
final progress = ProgressHUD.of(context);
|
||||||
progress!.dismiss();
|
progress!.dismiss();
|
||||||
}
|
}
|
||||||
|
////ADDED STATE
|
||||||
|
if (state is NonAcademeRecognitionAddedState) {
|
||||||
|
if (state.response['success']) {
|
||||||
|
successAlert(context, "Adding Successfull!",
|
||||||
|
state.response['message'], () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add(const GetNonAcademicRecognition());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
errorAlert(context, "Adding Failed",
|
||||||
|
"Something went wrong. Please try again.",
|
||||||
|
() {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add(const GetNonAcademicRecognition());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
////DELETED STATE
|
||||||
|
if (state is NonAcademeRecognitionDeletedState) {
|
||||||
|
if (state.success) {
|
||||||
|
successAlert(context, "Deletion Successfull",
|
||||||
|
"Work has been deleted successfully", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add(const GetNonAcademicRecognition());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
errorAlert(context, "Deletion Failed",
|
||||||
|
"Error deleting Work History", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add(const GetNonAcademicRecognition());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
////EDITED STATE
|
||||||
|
if (state is NonAcademeRecognitionEditedState) {
|
||||||
|
if (state.response['success']) {
|
||||||
|
successAlert(context, "Update Successfull",
|
||||||
|
state.response['message'], () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add( LoadNonAcademeRecognition(nonAcademicRecognitions: state.nonAcademicRecognitions));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
errorAlert(context, "Update Failed",
|
||||||
|
state.response['message'], () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<NonAcademicRecognitionBloc>()
|
||||||
|
.add(LoadNonAcademeRecognition(nonAcademicRecognitions: state.nonAcademicRecognitions));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is NonAcademicRecognitionLoadedState) {
|
if (state is NonAcademicRecognitionLoadedState) {
|
||||||
|
@ -103,12 +172,57 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
Text(presenter),
|
Text(presenter),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
IconButton(
|
AppPopupMenu<int>(
|
||||||
onPressed: () {},
|
offset: const Offset(-10, -10),
|
||||||
icon: const Icon(
|
elevation: 3,
|
||||||
Icons.more_vert,
|
onSelected: (value) {
|
||||||
color: Colors.grey,
|
|
||||||
))
|
////delete non academic recognition-= = = = = = = = =>>
|
||||||
|
if (value == 1) {
|
||||||
|
confirmAlert(context, () {
|
||||||
|
context
|
||||||
|
.read<
|
||||||
|
NonAcademicRecognitionBloc>()
|
||||||
|
.add(DeleteNonAcademeRecognition(
|
||||||
|
nonAcademicRecognition:
|
||||||
|
state
|
||||||
|
.nonAcademicRecognition[
|
||||||
|
index],
|
||||||
|
profileId:
|
||||||
|
profileId!,
|
||||||
|
nonAcademicRecognitions:
|
||||||
|
state
|
||||||
|
.nonAcademicRecognition,
|
||||||
|
token: token!));
|
||||||
|
}, "Delete?",
|
||||||
|
"Confirm Delete?");
|
||||||
|
}
|
||||||
|
if (value == 2) {
|
||||||
|
context
|
||||||
|
.read<
|
||||||
|
NonAcademicRecognitionBloc>()
|
||||||
|
.add(ShowEditNonAcademicRecognitionForm(
|
||||||
|
nonAcademicRecognition:
|
||||||
|
state.nonAcademicRecognition[
|
||||||
|
index]));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
menuItems: [
|
||||||
|
popMenuItem(
|
||||||
|
text: "Delete",
|
||||||
|
value: 1,
|
||||||
|
icon: Icons.delete),
|
||||||
|
popMenuItem(
|
||||||
|
text: "Edit",
|
||||||
|
value: 2,
|
||||||
|
icon: Icons.delete),
|
||||||
|
],
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.more_vert,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
tooltip: "Options",
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -123,8 +237,11 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
message:
|
message:
|
||||||
"You don't have any Non Academic Recognition added. Please click + to add");
|
"You don't have any Non Academic Recognition added. Please click + to add");
|
||||||
}
|
}
|
||||||
}if(state is AddNonAcademeRecognitionState){
|
}
|
||||||
|
if (state is AddNonAcademeRecognitionState) {
|
||||||
return const AddNonAcademicRecognitionScreen();
|
return const AddNonAcademicRecognitionScreen();
|
||||||
|
}if(state is EditNonAcademeRecognitionState){
|
||||||
|
return const EditNonAcademicRecognitionScreen();
|
||||||
}
|
}
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
|
@ -140,3 +257,22 @@ class NonAcademicRecognitionScreen extends StatelessWidget {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PopupMenuItem<int> popMenuItem({String? text, int? value, IconData? icon}) {
|
||||||
|
return PopupMenuItem(
|
||||||
|
value: value,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
icon,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
text!,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -212,10 +212,7 @@ class ReferencesScreen extends StatelessWidget {
|
||||||
offset: const Offset(-10, -10),
|
offset: const Offset(-10, -10),
|
||||||
elevation: 3,
|
elevation: 3,
|
||||||
onSelected: (value) {
|
onSelected: (value) {
|
||||||
final progress =
|
|
||||||
ProgressHUD.of(context);
|
|
||||||
progress!.showWithText(
|
|
||||||
"Loading...");
|
|
||||||
////delete eligibilty-= = = = = = = = =>>
|
////delete eligibilty-= = = = = = = = =>>
|
||||||
if (value == 2) {
|
if (value == 2) {
|
||||||
confirmAlert(context, () {
|
confirmAlert(context, () {
|
||||||
|
|
|
@ -36,7 +36,7 @@ class NonAcademicRecognitionServices {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw e.toString();
|
throw e.toString();
|
||||||
}
|
}
|
||||||
return nonAcademicRecognitions;
|
return nonAcademicRecognitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,8 +75,42 @@ class NonAcademicRecognitionServices {
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
////DELETE
|
////UPDATE
|
||||||
|
Future<Map<dynamic, dynamic>> update(
|
||||||
|
{required NonAcademicRecognition nonAcademicRecognition,
|
||||||
|
required int profileId,
|
||||||
|
required String token}) async {
|
||||||
|
String authToken = "Token $token";
|
||||||
|
String path = "${Url.instance.getNonAcademicRecognition()}$profileId/";
|
||||||
|
Map<String, String> headers = {
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
'Authorization': authToken
|
||||||
|
};
|
||||||
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
|
Map body = {
|
||||||
|
"id": nonAcademicRecognition.id,
|
||||||
|
"title": nonAcademicRecognition.title,
|
||||||
|
"presenter_id": nonAcademicRecognition.presenter?.id,
|
||||||
|
"_presenterName": nonAcademicRecognition.presenter!.name,
|
||||||
|
"_presenterCatId": nonAcademicRecognition.presenter!.category!.id,
|
||||||
|
"_privateEntity": nonAcademicRecognition.presenter!.privateEntity
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.putRequest(path: path, headers: headers, body: body, param: {});
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
statusResponse = data;
|
||||||
|
} else {
|
||||||
|
statusResponse.addAll({'success': false});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw e.toString();
|
||||||
|
}
|
||||||
|
return statusResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
////DELETE
|
||||||
Future<bool> delete(
|
Future<bool> delete(
|
||||||
{required String title,
|
{required String title,
|
||||||
required int id,
|
required int id,
|
||||||
|
|
|
@ -257,6 +257,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
|
filter_list:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: filter_list
|
||||||
|
sha256: "2d80d6d19beb7847c1176e8bf6fe06d302b23eb7d1bf48c231dd730409ff9b4d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.2"
|
||||||
fixnum:
|
fixnum:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -71,6 +71,7 @@ dependencies:
|
||||||
app_popup_menu: ^1.0.0
|
app_popup_menu: ^1.0.0
|
||||||
modal_progress_hud_nsn: ^0.3.0
|
modal_progress_hud_nsn: ^0.3.0
|
||||||
searchfield: ^0.7.5
|
searchfield: ^0.7.5
|
||||||
|
filter_list: ^1.0.2
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
Loading…
Reference in New Issue