Merge pull request 'release/v1/beta/v1.0.1-beta' (#40) from release/v1/beta/v1.0.1-beta into master

Reviewed-on: http://git.agusandelnorte.gov.ph:3000/SoftwareDevelopmentSection/unit2-null-safety-repository/pulls/40
dev
rodolfobacuinjr 2023-09-06 09:44:39 +08:00
commit 4f48b9cba1
34 changed files with 417 additions and 288 deletions

View File

@ -219,8 +219,7 @@ class EducationBloc extends Bloc<EducationEvent, EducationState> {
}
});
on<EducationViewAttachment>((event, emit) {
String fileUrl =
'${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}';
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}/media/${event.source}';
emit(EducationAttachmentViewState(
fileUrl: fileUrl, fileName: event.fileName));
});

View File

@ -290,7 +290,7 @@ class EligibilityBloc extends Bloc<EligibilityEvent, EligibilityState> {
}
});
on<EligibiltyViewAttachmentEvent>((event,emit){
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}';
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}/media/${event.source}';
emit(EligibilityAttachmentViewState(fileUrl: fileUrl,fileName: event.filename));
});
on<ShareAttachment>((event, emit) async {

View File

@ -334,7 +334,7 @@ class LearningDevelopmentBloc
}
});
on<LearningDevelopmentViewAttachmentEvent>((event,emit){
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}';
String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}/media/${event.source}';
emit(LearningAndDevelopmentAttachmentViewState(fileUrl: fileUrl, filename: event.filename));
});
on<ShareAttachment>((event, emit) async {

View File

@ -29,7 +29,7 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
references = refs;
emit(ReferencesLoadedState(references: references));
}
emit(ReferencesLoadedState(references: references));
} catch (e) {
emit( ReferencesErrorState(message: e.toString()));
}

View File

@ -5,6 +5,7 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:unit2/model/roles/pass_check/passer_info.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart';
import 'package:unit2/sevices/roles/pass_check_services.dart';
import '../../../utils/scanner.dart';
part 'pass_check_event.dart';
@ -12,7 +13,7 @@ part 'pass_check_state.dart';
class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
PassCheckBloc() : super(PassCheckInitial()) {
int? roleId;
RoleIdRoleName? roleIdRoleName;
String? uuid;
bool? otherInputs;
String? io;
@ -25,9 +26,8 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
try {
emit(PassCheckLoadingState());
List<dynamic> response = await PassCheckServices.instance
.getPassCheckArea(roleId: event.roleId, userId: event.userId);
roleId = event.roleId;
emit(AssignAreaLoaded(assignedArea: response, roleId: roleId!));
.getPassCheckArea(roleIdRoleName:RoleIdRoleName(roleId: event.roleIdRoleName.roleId, roleName: event.roleIdRoleName.roleName), userId: event.userId);
emit(AssignAreaLoaded(assignedArea: response, roleIdRoleName: RoleIdRoleName(roleId: event.roleIdRoleName.roleId, roleName: event.roleIdRoleName.roleName)));
} catch (e) {
emit(PassCheckErrorState(message: e.toString()));
}
@ -37,14 +37,14 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
checkerId = event.checkerId;
io = event.entranceExit;
token = event.token;
roleId = event.roleId;
roleIdRoleName = event.roleIdRoleName;
assignedArea = event.assignedArea;
emit(SettingSaved(
assignedArea: assignedArea,
checker: checkerId!,
io: io!,
otherInputs: otherInputs!,
roleId: roleId!,
roleIdRoleName: roleIdRoleName!,
token: token!));
});
on<ScanError>((event, emit) {
@ -53,7 +53,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
checker: checkerId!,
io: io!,
otherInputs: otherInputs!,
roleId: roleId!,
roleIdRoleName: roleIdRoleName!,
token: token!));
});
on<PerformIncomingPostLog>((event, emit) {
@ -64,7 +64,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
io: io!.toLowerCase() == "incoming" ? "i" : "o",
otherInputs: otherInputs!,
passerId: uuid!,
roleId: roleId!,
roleId: roleIdRoleName!.roleId,
stationId: stationId,
temp: event.temp));
});
@ -77,7 +77,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
io: io!.toLowerCase() == "incoming" ? "i" : "o",
otherInputs: otherInputs!,
passerId: uuid!,
roleId: roleId!,
roleId: roleIdRoleName!.roleId,
stationId: stationId,
temp: null));
});
@ -89,13 +89,13 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
try {
PasserInfo? passerInfo = await PassCheckServices.instance
.getPasserInfo(uuid: uuid!, token: event.token);
if (roleId == 41 || roleId == 13 || roleId == 17 || roleId == 22) {
if (roleIdRoleName!.roleName.toLowerCase() == "41" || roleIdRoleName!.roleName.toLowerCase() == 'qr code scanner' || roleIdRoleName!.roleName.toLowerCase() == 'office/branch chief' || roleIdRoleName!.roleName.toLowerCase() == 'registration in-charge') {
stationId = assignedArea.id;
} else if (roleId == 7) {
} else if (roleIdRoleName!.roleName.toLowerCase() == 'barangay chairperson') {
cpId = assignedArea.brgycode;
} else if (roleId == 10) {
} else if (roleIdRoleName!.roleName.toLowerCase() == 'purok pres') {
cpId = assignedArea.purokdesc;
} else if (roleId == 16) {
} else if (roleIdRoleName!.roleName.toLowerCase() == 'establishment point-person') {
cpId = assignedArea.id;
}
if (passerInfo == null) {
@ -122,7 +122,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
io: io!.toLowerCase() == "incoming" ? "i" : "o",
otherInputs: otherInputs!,
passerId: uuid!,
roleId: roleId!,
roleId: roleIdRoleName!.roleId,
stationId: stationId,
temp: null));
}
@ -136,7 +136,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
checker: checkerId!,
io: io!,
otherInputs: otherInputs!,
roleId: roleId!,
roleIdRoleName: roleIdRoleName!,
token: token!));
}
});

View File

@ -8,13 +8,13 @@ abstract class PassCheckEvent extends Equatable {
}
class GetPassCheckAreas extends PassCheckEvent {
final int roleId;
final RoleIdRoleName roleIdRoleName;
final int userId;
const GetPassCheckAreas({required this.roleId, required this.userId});
const GetPassCheckAreas({required this.roleIdRoleName, required this.userId});
}
class SetScannerSettings extends PassCheckEvent {
final int roleId;
final RoleIdRoleName roleIdRoleName;
final String token;
final dynamic assignedArea;
final bool includeOtherInputs;
@ -25,7 +25,7 @@ class SetScannerSettings extends PassCheckEvent {
required this.checkerId,
required this.entranceExit,
required this.includeOtherInputs,
required this.roleId,
required this.roleIdRoleName,
required this.token});
}

View File

@ -23,8 +23,8 @@ class PassCheckLoadingState extends PassCheckState {}
class AssignAreaLoaded extends PassCheckState {
final List<dynamic> assignedArea;
final int roleId;
const AssignAreaLoaded({required this.assignedArea, required this.roleId});
final RoleIdRoleName roleIdRoleName;
const AssignAreaLoaded({required this.assignedArea, required this.roleIdRoleName});
}
class SettingSaved extends PassCheckState {
@ -33,13 +33,13 @@ class SettingSaved extends PassCheckState {
final String io;
final int checker;
final bool otherInputs;
final int roleId;
final RoleIdRoleName roleIdRoleName;
const SettingSaved(
{required this.assignedArea,
required this.checker,
required this.io,
required this.otherInputs,
required this.roleId,
required this.roleIdRoleName,
required this.token});
}

View File

@ -107,6 +107,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
emit(InternetTimeout(message: timeoutError));
} on Error catch (e) {
emit(LoginErrorState(message: e.toString()));
}catch(e){
emit(LoginErrorState(message: e.toString()));
}
});
on<UuidLogin>((event, emit) async {

View File

@ -10,6 +10,8 @@ import 'package:unit2/model/passo/additional_items.dart';
import 'package:unit2/model/passo/class_components.dart';
import 'package:unit2/model/passo/unit_construct.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
class AddExtraItems extends StatefulWidget {
final List<UnitConstruct> unit;
@ -573,6 +575,14 @@ class _AddExtraItems extends State<AddExtraItems> {
),
)));
}
if (state is AdditionalItemsErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<AdditionalItemBloc>().add(LoadAdditionalItems());
},
);
}
return Container();
});
}

View File

@ -52,13 +52,6 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
if (state is LocationErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
},
builder: (context, state) {
@ -77,13 +70,6 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
if (state is LandrefErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
},
builder: (context, state) {
@ -102,13 +88,6 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
if (state is MunicipalityErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
}, builder: (context, state) {
if (state is MunicipalityLoaded) {
@ -132,13 +111,6 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
if (state is BarangayErrorState) {
final progress = ProgressHUD.of(context);
progress?.dismiss();
// Fluttertoast.showToast(
// msg: onError,
// fontSize: 24,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.CENTER,
// backgroundColor: Colors.black,
// textColor: Colors.white);
}
}, builder: (context, state) {
if (state is BarangayLoaded) {
@ -150,17 +122,15 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
return FormBuilder(
key: keys,
initialValue: {
'street': bldgloc.street,
// 'brgy': bldgloc.barangay,
// 'municipality': bldgloc.municipality,
'province': bldgloc.province,
'street': bldgloc.street ?? "",
'province': bldgloc.province ?? "",
'l_owner': landRef.owner,
'oct_tct_cloa': landRef.cloaNo,
'survey_no': landRef.surveyNo,
'lot_no': landRef.lotNo,
'blk_no': landRef.blkNo,
'l_td_arp': landRef.tdn,
'area': landRef.area
'oct_tct_cloa': landRef.cloaNo ?? "",
'survey_no': landRef.surveyNo ?? "",
'lot_no': landRef.lotNo ?? "",
'blk_no': landRef.blkNo ?? "",
'l_td_arp': landRef.tdn ?? "",
'area': landRef.area ?? ""
},
enabled: true,
onChanged: () {
@ -250,8 +220,8 @@ class _BldgLocLandRefEdit extends State<BldgLocLandRefEdit> {
// optional flex property if flex is 1 because the default flex is 1
flex: 1,
child: customDropDownField(
bldgloc.barangay,
"",
bldgloc.barangay ?? "",
"Barangay",
'brgy',
brgyNAmes))
]),

View File

@ -43,13 +43,13 @@ class _StructuralMaterialsPageEdit extends State<StructuralMaterialsPageEdit> {
listener: (context, state) {
if (state is StructuralMaterialsLoaded) {
setState(() {
foundation = state.structure.foundation!.split(',');
column = state.structure.columns!.split(',');
beam = state.structure.beams!.split(',');
truss_framing = state.structure.trussFraming!.split(',');
roof = state.structure.roof!.split(',');
flooring = state.structure.flooring!.split(',');
walls = state.structure.walls!.split(',');
foundation = state.structure.foundation!.split(',') ?? [];
column = state.structure.columns!.split(',') ?? [];
beam = state.structure.beams!.split(',') ?? [];
truss_framing = state.structure.trussFraming!.split(',') ?? [];
roof = state.structure.roof!.split(',') ?? [];
flooring = state.structure.flooring!.split(',') ?? [];
walls = state.structure.walls!.split(',') ?? [];
// Update other local state variables here if needed
});
}

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
class PropertyOwnerPage extends StatefulWidget {
@override
_PropertyOwnerPage createState() => _PropertyOwnerPage();
}
class _PropertyOwnerPage extends State<PropertyOwnerPage> {
@override
Widget build(BuildContext context) {
return Scaffold(body: Container());
}
}

View File

@ -19,6 +19,8 @@ import 'package:unit2/model/passo/land_subclassification.dart';
import 'package:unit2/model/passo/unit_construct.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';
class AddLandAppraisalModal extends StatefulWidget {
@ -392,22 +394,54 @@ class _AddLandAppraisalModal extends State<AddLandAppraisalModal> {
)));
}
if (state is MunicipalityErrorState) {
return Text(state.error);
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<MunicipalityBloc>()
.add(LoadMunicipality());
},
);
}
return Container();
},
);
}
if (state is LandSubClassificationErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandSubClassificationBloc>().add(
const LoadLandSubClassification(
cityCode: '1', classCode: 1));
},
);
}
return Container();
},
);
}
if (state is LandClassificationErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandClassificationBloc>()
.add(LoadLandClassification());
},
);
}
return Container();
},
);
}
if (state is LandAppraisalErrorState) {
return Text(state.error);
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<LandAppraisalBloc>().add(LoadLandAppraisal());
},
);
}
return Container();
});

View File

@ -9,6 +9,8 @@ import 'package:unit2/bloc/passo/land/other_improvements/other_improvements_bloc
import 'package:unit2/model/passo/other_improvements.dart';
import 'package:unit2/model/passo/trees_improvements.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
class AddOtherImprovementModal extends StatefulWidget {
// final List<UnitConstruct> unit;
@ -329,16 +331,28 @@ class _AddOtherImprovementModal extends State<AddOtherImprovementModal> {
),
));
}
if (state is LandTreesImprovementsErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandTreesImprovementsBloc>()
.add(LoadLandTreesImprovements());
},
);
}
return Container();
});
}
if (state is OtherImprovementErrorState) {
return Text(state.error);
}
return Container(
child: Text("Other Improvement"),
return SomethingWentWrong(
message: onError,
onpressed: () {
context.read<OtherImprovementsBloc>().add(LoadOtherImprovement());
},
);
}
return Container();
});
}
}

View File

@ -8,6 +8,8 @@ import 'package:unit2/bloc/passo/land/land_value_adjustments/land_value_adjustme
import 'package:unit2/model/passo/land_property_assessment.dart';
import 'package:unit2/model/passo/land_value_adjustment.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/text_container.dart';
import 'package:unit2/widgets/error_state.dart';
class AddPropertyAssessmentModal extends StatefulWidget {
// final List<UnitConstruct> unit;
@ -327,16 +329,30 @@ class _AddPropertyAssessmentModal extends State<AddPropertyAssessmentModal> {
),
));
}
if (state is LandValueAdjustmentsErrorState) {
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandValueAdjustmentsBloc>()
.add(LoadLandValueAdjustments());
},
);
}
return Container();
});
}
if (state is LandPropertyAssessmentErrorState) {
return Text(state.error);
}
return Container(
child: Text("Property Assessment"),
return SomethingWentWrong(
message: onError,
onpressed: () {
context
.read<LandPropertyAssessmentBloc>()
.add(LoadLandPropertyAssessment());
},
);
}
return Container();
});
}
}

View File

@ -68,7 +68,6 @@ class BuildingHome extends StatelessWidget {
Profile profile;
return Scaffold(
body: ProgressHUD(
padding: const EdgeInsets.only(left: 24, right: 24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
@ -96,7 +95,9 @@ class BuildingHome extends StatelessWidget {
List<PropertyInfo> propertyList = state.property_info;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Expanded(
child: Column(
children: [
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: propertyList.length,
@ -106,6 +107,8 @@ class BuildingHome extends StatelessWidget {
},
),
),
],
),
);
}
if (state is PropertyInfoErrorState) {

View File

@ -96,7 +96,9 @@ class LandHome extends StatelessWidget {
List<LandPropertyOwner> propertyList = state.land;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Expanded(
child: Column(
children: [
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: propertyList.length,
@ -106,6 +108,8 @@ class LandHome extends StatelessWidget {
},
),
),
],
),
);
}
if (state is LandErrorState) {
@ -114,7 +118,7 @@ class LandHome extends StatelessWidget {
onpressed: () {
context
.read<LandPropertyOwnerInfoBloc>()
.add(LoadLand());
.add(const LoadLand());
},
);
}

View File

@ -81,8 +81,8 @@ class _LearningDevelopmentViewAttachmentState
),
imageUrl: state.fileUrl,
width: double.infinity,
height: 220,
fit: BoxFit.cover,
fit: BoxFit.fitHeight,
),
),
);

View File

@ -1,11 +1,9 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../model/profile/attachment.dart';
import '../../../theme-data.dart/box_shadow.dart';
import '../../../theme-data.dart/colors.dart';
import '../../../utils/alerts.dart';
class SingleAttachment extends StatelessWidget {
final Function()? onpressed;
@ -36,9 +34,9 @@ class SingleAttachment extends StatelessWidget {
child:
GestureDetector(
onTap: view,
child: AutoSizeText(
child: Text(
attachment.filename!,
wrapWords: false,
maxLines: 1,
),
),

View File

@ -264,13 +264,13 @@ class RbacModuleObjectsScreen extends StatelessWidget {
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: second,
tileColor: Colors.white,
title: Text(
moduleObjects.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: Colors.white),
.copyWith(color: primary,fontWeight: FontWeight.bold),
),
);
},

View File

@ -5,10 +5,12 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/error_state.dart';
import '../../../model/rbac/rbac.dart';
import '../../../theme-data.dart/box_shadow.dart';
import '../../../theme-data.dart/btn-style.dart';
import '../../../theme-data.dart/colors.dart';
@ -24,12 +26,38 @@ class RbacRoleScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>();
List<RBAC> roles = [];
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Role Screen"),
actions: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: primary),
builder: (RBAC rbac) {
return ListTile(
title: Text(rbac.name!),
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Role found :("),
),
items: roles,
searchLabel: "Search Role",
suggestion: const Center(
child: Text("Search role by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () {
BuildContext parent = context;
showDialog(
@ -174,6 +202,7 @@ class RbacRoleScreen extends StatelessWidget {
final parent = context;
if (state is RoleLoadedState) {
if (state.roles.isNotEmpty) {
roles = state.roles;
return ListView.builder(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -191,8 +220,12 @@ class RbacRoleScreen extends StatelessWidget {
Expanded(
child: Row(
children: [
CircleAvatar(child: Text('${index+1}'),),
const SizedBox(width: 12,),
CircleAvatar(
child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Flexible(
child: Text(state.roles[index].name!,
style: Theme.of(context)
@ -360,7 +393,8 @@ class RbacRoleScreen extends StatelessWidget {
}
if (state is RoleErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
message: state.message,
onpressed: () {
context.read<RoleBloc>().add(GetRoles());
});
}

View File

@ -35,7 +35,7 @@ class RbacRoleAssignment extends StatelessWidget {
elevation: 0,
centerTitle: true,
backgroundColor: primary,
title: const Text("User Roles Screenss"),
title: const Text("User Roles Screens"),
actions: [
AddLeading(onPressed: () {
BuildContext parent = context;

View File

@ -262,13 +262,13 @@ class RbacRoleExtendScreen extends StatelessWidget {
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: second,
tileColor: Colors.white,
title: Text(
rolesExtend.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: Colors.white),
.copyWith(color: primary,fontWeight: FontWeight.bold),
),
);
},

View File

@ -252,13 +252,13 @@ class RbacRoleModuleScreen extends StatelessWidget {
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: second,
tileColor: Colors.white,
title: Text(
roleModules.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: Colors.white),
.copyWith(color: primary,fontWeight: FontWeight.bold),
),
);
},

View File

@ -1,3 +1,4 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
@ -13,6 +14,7 @@ import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart';
import '../../../bloc/user/user_bloc.dart';
import '../../../theme-data.dart/colors.dart';
import '../../../utils/urls.dart';
import '../../../widgets/splash_screen.dart';
import '../signature/signature_pad.dart';
import './components/cover-image.dart';
@ -30,6 +32,8 @@ class BasicInfo extends StatelessWidget {
child: BlocBuilder<UserBloc, UserState>(
builder: (context, state) {
if (state is UserLoggedIn) {
String fileUrl =
'${Url.instance.prefixHost()}://${Url.instance.host()}/media/${state.userData?.employeeInfo?.profile?.photoPath}';
state.userData!.employeeInfo!.profile!.sex!.toUpperCase();
return SafeArea(
child: Scaffold(
@ -47,17 +51,38 @@ class BasicInfo extends StatelessWidget {
child: Stack(
alignment: Alignment.center,
children: [
const CircleAvatar(
radius: 72,
backgroundColor: Colors.white,
CachedNetworkImage(
imageUrl: fileUrl,
imageBuilder: (context, imageProvider) =>
Container(
width: 160,
height: 160,
decoration: BoxDecoration(
border:
Border.all(color: Colors.black26, width: 3),
shape: BoxShape.circle,
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover),
),
),
placeholder: (context, url) =>
const CircularProgressIndicator(),
errorWidget: (context, url, error) =>
Container(
width: 160,
height: 160,
decoration: BoxDecoration(
border:
Border.all(color: Colors.white, width: 3),
shape: BoxShape.circle,
),
CircleAvatar(
radius: 69,
backgroundColor: Colors.grey.shade800,
child: SvgPicture.asset(
'assets/svgs/male.svg',
),
),
),
],
),
),

View File

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard_icon_generator.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/superadmin_expanded_menu.dart';
import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart';
@ -68,10 +69,6 @@ class _DashBoardState extends State<DashBoard> {
docSmsCards.add(e);
}
});
unit2Cards.forEach((element) {
print(
"${element.moduleName} - ${element.object.name!} - ${element.roleName} ");
});
if (superadminCards.length > 3) {
tempSuperAdminCards = superadminCards.sublist(0, 4);
}
@ -79,6 +76,10 @@ class _DashBoardState extends State<DashBoard> {
tempUnit2Cards = unit2Cards.sublist(0, 4);
}
superadminCards.forEach((el) {
print(el.object.name);
});
return Container(
padding:
const EdgeInsetsDirectional.symmetric(vertical: 24, horizontal: 24),
@ -196,7 +197,7 @@ class _DashBoardState extends State<DashBoard> {
: e.object.name!,
ontap: () {
if (e.object.name!.toLowerCase() == 'pass check') {
PassCheckArguments passCheckArguments = PassCheckArguments(roleId: e.roleId, userId: widget.userId);
PassCheckArguments passCheckArguments = PassCheckArguments(roleIdRoleName: RoleIdRoleName(roleId: e.roleId, roleName: e.roleName), userId: widget.userId);
Navigator.pushNamed(context, '/pass-check', arguments: passCheckArguments);
}
if (e.object.name!.toLowerCase() == 'role based access control') {
@ -312,7 +313,7 @@ class _DashBoardState extends State<DashBoard> {
PassCheckArguments
passCheckArguments =
PassCheckArguments(
roleId: 10,
roleIdRoleName: RoleIdRoleName(roleId: e.roleId, roleName: e.roleName),
userId:
widget.userId);
Navigator.pushNamed(
@ -386,7 +387,7 @@ class _DashBoardState extends State<DashBoard> {
PassCheckArguments
passCheckArguments =
PassCheckArguments(
roleId: 10,
roleIdRoleName: RoleIdRoleName(roleId: e.roleId,roleName: e.roleName),
userId: widget.userId);
Navigator.pushNamed(
context, '/pass-check',
@ -647,7 +648,8 @@ class _DashBoardState extends State<DashBoard> {
? "Field Surveyor"
: e.object.name!,
ontap: () {
Navigator.pushNamed(context, '/passo-home');
Navigator.pushNamed(
context, '/passo-home');
})
: Container(
color: Colors.black,
@ -706,7 +708,13 @@ class _DashBoardState extends State<DashBoard> {
}
class PassCheckArguments {
final int roleId;
final RoleIdRoleName roleIdRoleName;
final int userId;
const PassCheckArguments({required this.roleId, required this.userId});
const PassCheckArguments({required this.roleIdRoleName, required this.userId});
}
class RoleIdRoleName{
final int roleId;
final String roleName;
const RoleIdRoleName({required this.roleId, required this.roleName});
}

View File

@ -271,6 +271,7 @@ class SuperAdminMenu extends StatelessWidget {
roleAssignmentKey
.currentState!
.value['lastname'];
Navigator.of(context).pop();
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext

View File

@ -47,7 +47,7 @@ class _UniT2LoginState extends State<UniT2Login> {
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
print(state);
if (state is UserLoggedIn || state is UuidLoaded) {
if (state is UserLoggedIn || state is UuidLoaded || state is LoginErrorState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
@ -94,6 +94,7 @@ class _UniT2LoginState extends State<UniT2Login> {
}));
}
}, builder: (context, state) {
print(state);
if (state is VersionLoaded) {
return Builder(builder: (context) {
if (state.versionInfo!.version != state.apkVersion) {
@ -251,9 +252,7 @@ class _UniT2LoginState extends State<UniT2Login> {
onPressed: () {
final progress =
ProgressHUD.of(context);
FocusScope.of(context).unfocus();
if (_formKey.currentState!
.saveAndValidate()) {
password = _formKey.currentState!
@ -263,7 +262,6 @@ class _UniT2LoginState extends State<UniT2Login> {
progress?.showWithText(
'Logging in...',
);
BlocProvider.of<UserBloc>(context)
.add(UserLogin(
username: username,

View File

@ -302,28 +302,28 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
children: [
SelectedState(
//TODO add api data
title: state.roleId == 41 ||
state.roleId == 13 ||
state.roleId == 17 ||
state.roleId == 22
title: state.roleIdRoleName.roleName.toLowerCase() == "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' ||
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
? state.assignedArea.stationName
: state.roleId == 7
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson'
? state.assignedArea.brgydesc
: state.roleId == 10
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president'
? state.assignedArea.purokdesc
: state.roleId == 16
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
? "Agency"
: "",
subtitle: state.roleId == 41 ||
state.roleId == 13 ||
state.roleId == 17 ||
state.roleId == 22
subtitle: state.roleIdRoleName.roleName.toLowerCase() == "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' ||
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
? "Station"
: state.roleId == 7
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson'
? "Barangay"
: state.roleId == 10
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president'
? "Purok"
: state.roleId == 16
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
? "Agency"
: "",
),

View File

@ -20,9 +20,9 @@ import '../../../../theme-data.dart/form-style.dart';
import '../../../../utils/global.dart';
class QRCodeScannerSettings extends StatefulWidget {
final int roleId;
final int userId;
const QRCodeScannerSettings({super.key, required this.roleId, required this.userId});
final RoleIdRoleName roleIdRoleName;
final int userId;
const QRCodeScannerSettings({super.key, required this.roleIdRoleName, required this.userId});
@override
State<QRCodeScannerSettings> createState() => _QRCodeScannerSettingsState();
@ -172,7 +172,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
////STATION
Container(
child: state.roleId == 41
child: state.roleIdRoleName.roleName.toLowerCase() == "41"
? DropdownButtonFormField(
isExpanded: true,
validator: FormBuilderValidators
@ -219,7 +219,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
},
////BARANGAY
)
: state.roleId == 7
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay nurse'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -270,7 +270,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
)
:
////PUROK
state.roleId == 10
state.roleIdRoleName.roleName.toLowerCase() == 'checkpoint in-charge'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -323,7 +323,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
)
:
////Registration InCharge
state.roleId == 22
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -398,7 +398,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
],
)
: ////QR Code Scanner
state.roleId == 13
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -469,7 +469,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
)
:
////Establishment Point-Person
state.roleId == 16
state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -516,8 +516,8 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
],
)
: ////Office Branch Chief
state.roleId ==
17
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief'
? Column(
crossAxisAlignment:
CrossAxisAlignment.start,
@ -578,10 +578,6 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
onPressed: () {
if (_formKey.currentState!
.saveAndValidate()) {
print(scanMode);
print(_includeOtherInputs);
print(checkerId);
print(assignedArea);
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext context) {
@ -595,7 +591,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
entranceExit: scanMode,
includeOtherInputs:
_includeOtherInputs,
roleId: state.roleId)),
roleIdRoleName: widget.roleIdRoleName)),
child: const QRCodeScanner(),
);
}));
@ -615,7 +611,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<PassCheckBloc>().add(GetPassCheckAreas(roleId: widget.roleId, userId: widget.userId));
context.read<PassCheckBloc>().add(GetPassCheckAreas(roleIdRoleName: widget.roleIdRoleName, userId: widget.userId));
});
}
return Container();

View File

@ -39,16 +39,16 @@ class AuthService {
Map<String, String> baseHeaders = {'Content-Type': 'application/json'};
Map<dynamic, dynamic> responseStatus = {};
String path = Url.instance.authentication();
// try {
try {
http.Response response = await Request.instance
.postRequest(path: path, param: {}, headers: baseHeaders, body: body);
Map data = jsonDecode(response.body);
responseStatus = data;
return responseStatus;
// } catch (e) {
// throw (e.toString());
// }
} catch (e) {
throw (e.toString());
}
}
Future<Map<dynamic,dynamic>> qrLogin({String? uuid, String? password}) async {

View File

@ -8,6 +8,7 @@ import 'package:unit2/model/roles/pass_check/agency_area_type.dart';
import 'package:unit2/model/roles/pass_check/assign_role_area_type.dart';
import 'package:unit2/model/roles/pass_check/barangay_assign_area.dart';
import 'package:unit2/model/roles/pass_check/passer_info.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart';
import 'package:unit2/utils/global.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/utils/request.dart';
@ -20,10 +21,10 @@ class PassCheckServices {
static PassCheckServices get instance => _instance;
Future<List<dynamic>> getPassCheckArea(
{required int roleId, required int userId}) async {
{required RoleIdRoleName roleIdRoleName, required int userId}) async {
String path = Url.instance.getAssignAreas();
Map<String, String> params = {
"assigned_role__role__id": roleId.toString(),
"assigned_role__role__name__icontains": roleIdRoleName.roleName,
"assigned_role__user__id": userId.toString()
};
List<dynamic>? statusResponse;

View File

@ -67,9 +67,12 @@ class AppRouter {
return BlocProvider(
create: (context) => PassCheckBloc()
..add(GetPassCheckAreas(
roleId: arguments.roleId, userId: arguments.userId)),
roleIdRoleName: RoleIdRoleName(
roleId: arguments.roleIdRoleName.roleId,
roleName: arguments.roleIdRoleName.roleName),
userId: arguments.userId)),
child: QRCodeScannerSettings(
roleId: arguments.roleId,
roleIdRoleName: arguments.roleIdRoleName,
userId: arguments.userId,
),
);

View File

@ -22,20 +22,20 @@ class Request {
response = await get(Uri.https(host, path!, param), headers: headers)
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -43,12 +43,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("get request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (onError);
}
return response;
@ -65,20 +65,20 @@ class Request {
headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -86,12 +86,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;
@ -107,20 +107,20 @@ class Request {
response = await put(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -128,12 +128,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;
@ -149,20 +149,20 @@ class Request {
response = await patch(
path: host + path, headers: headers, body: body, param: param);
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -170,12 +170,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;
@ -192,32 +192,32 @@ class Request {
headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
} on HttpException catch (_) {
throw const HttpException(httpError);
} on Error catch (e) {
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;