Fixed conflicts

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
cyzoox 2023-10-09 09:46:27 +08:00
commit 0b031dd545
77 changed files with 4651 additions and 3092 deletions

View File

@ -51,10 +51,13 @@ class LearningDevelopmentBloc
attachmentCategories = attachmentCategories =
await AttachmentServices.instance.getCategories(); await AttachmentServices.instance.getCategories();
} }
if(learningsAndDevelopments.isEmpty){
List<LearningDevelopement> learnings = await LearningDevelopmentServices List<LearningDevelopement> learnings = await LearningDevelopmentServices
.instance .instance
.getLearningDevelopments(event.profileId, event.token); .getLearningDevelopments(event.profileId, event.token);
learningsAndDevelopments = learnings; learningsAndDevelopments = learnings;
}
emit(LearningDevelopmentLoadedState( emit(LearningDevelopmentLoadedState(
learningsAndDevelopment: learningsAndDevelopments,attachmentCategory: attachmentCategories)); learningsAndDevelopment: learningsAndDevelopments,attachmentCategory: attachmentCategories));
} catch (e) { } catch (e) {

View File

@ -64,6 +64,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
primaryBasicInformation: globalCurrentProfile!)); primaryBasicInformation: globalCurrentProfile!));
} else { } else {
currentProfileInformation = event.primaryBasicInformation; currentProfileInformation = event.primaryBasicInformation;
globalCurrentProfile = currentProfileInformation;
emit(BasicInformationProfileLoaded( emit(BasicInformationProfileLoaded(
primaryBasicInformation: currentProfileInformation!)); primaryBasicInformation: currentProfileInformation!));
} }
@ -108,7 +109,7 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
0, ProfileOtherInfo(id: null, name: "NONE", description: null)); 0, ProfileOtherInfo(id: null, name: "NONE", description: null));
} }
emit(BasicInformationEditingState( emit(BasicInformationEditingState(
primaryInformation: currentProfileInformation!, primaryInformation: globalCurrentProfile!,
extensions: nameExtensions, extensions: nameExtensions,
sexes: sexes, sexes: sexes,
bloodTypes: bloodType, bloodTypes: bloodType,

View File

@ -13,9 +13,12 @@ class GetAgencies extends AgencyEvent{
class AddAgency extends AgencyEvent{ class AddAgency extends AgencyEvent{
final Agency agency; final Agency agency;
const AddAgency({required this.agency}); const AddAgency({required this.agency});
List<Object> get props => [agency
];
} }
class GetEstPointPersonAgencies extends AgencyEvent{ class GetEstPointPersonAgencies extends AgencyEvent{
final List<AssignedArea>? assignedAreas; final List<AssignedArea>? assignedAreas;
const GetEstPointPersonAgencies({required this.assignedAreas}); const GetEstPointPersonAgencies({required this.assignedAreas});
} }

View File

@ -60,7 +60,7 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
} }
}); });
on<AddAssignArea>((event, emit) async { on<AddAssignArea>((event, emit) async {
// try { try {
emit(AssignAreaLoadingState()); emit(AssignAreaLoadingState());
Map<dynamic, dynamic> response = await RbacAssignedAreaServices.instance Map<dynamic, dynamic> response = await RbacAssignedAreaServices.instance
.add( .add(
@ -77,11 +77,6 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
break; break;
} }
} }
// newAssignArea = userAssignedAreas.firstWhere((var element) {
// return element.assignedRole?.role?.id == event.roleId &&
// element.assignedRole?.user?.id == event.userId;
// });
if (newAssignArea?.assignedArea != null) { if (newAssignArea?.assignedArea != null) {
userAssignedAreas.removeWhere((element) => userAssignedAreas.removeWhere((element) =>
element.assignedRole!.role!.id == event.roleId && element.assignedRole!.role!.id == event.roleId &&
@ -120,8 +115,8 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea); newAreas.add(newArea);
} }
} }
newAssignArea?.assignedArea = newAreas; newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!); userAssignedAreas.add(newAssignArea);
//// purok //// purok
} }
if (event.areaTypeId == 2) { if (event.areaTypeId == 2) {
@ -149,8 +144,8 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea); newAreas.add(newArea);
} }
} }
newAssignArea?.assignedArea = newAreas; newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!); userAssignedAreas.add(newAssignArea);
} }
////statiom ////statiom
if (event.areaTypeId == 4) { if (event.areaTypeId == 4) {
@ -200,8 +195,8 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea); newAreas.add(newArea);
} }
} }
newAssignArea?.assignedArea = newAreas; newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!); userAssignedAreas.add(newAssignArea);
} }
////agency ////agency
if (event.areaTypeId == 3) { if (event.areaTypeId == 3) {
@ -231,16 +226,16 @@ class AssignAreaBloc extends Bloc<AssignAreaEvent, AssignAreaState> {
newAreas.add(newArea); newAreas.add(newArea);
} }
} }
newAssignArea?.assignedArea = newAreas; newAssignArea.assignedArea = newAreas;
userAssignedAreas.add(newAssignArea!); userAssignedAreas.add(newAssignArea);
} }
emit(AssignAreaAddedState(response: response)); emit(AssignAreaAddedState(response: response));
} else { } else {
emit(AssignAreaAddedState(response: response)); emit(AssignAreaAddedState(response: response));
} }
// } catch (e) { } catch (e) {
// emit(AssignAreaErorState(message: e.toString())); emit(AssignAreaErorState(message: e.toString()));
// } }
}); });
on<LoadAssignedAreas>((event, emit) async { on<LoadAssignedAreas>((event, emit) async {
emit(AssignedAreaLoadedState( emit(AssignedAreaLoadedState(

View File

@ -66,7 +66,7 @@ class ModuleObjectsBloc extends Bloc<ModuleObjectsEvent, ModuleObjectsState> {
emit(ModuleObjectLoadingState()); emit(ModuleObjectLoadingState());
try { try {
bool success = await RbacModuleObjectsServices.instance bool success = await RbacModuleObjectsServices.instance
.deleteRbacModuleObject(moduleObjectId: event.moduleObjectId); .delete(moduleObjectId: event.moduleObjectId);
if (success) { if (success) {
moduleObjects moduleObjects
.removeWhere((element) => element.id == event.moduleObjectId); .removeWhere((element) => element.id == event.moduleObjectId);

View File

@ -0,0 +1,82 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/model/rbac/permission_assignment.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/sevices/roles/rbac_operations/permission_assignment_services.dart';
import 'package:unit2/sevices/roles/rbac_operations/permission_service.dart';
import 'package:unit2/sevices/roles/rbac_operations/role_services.dart';
part 'permission_assignment_event.dart';
part 'permission_assignment_state.dart';
class PermissionAssignmentBloc
extends Bloc<PermissionAssignmentEvent, PermissionAssignmentState> {
PermissionAssignmentBloc() : super(PermissionAssignmentInitial()) {
List<PermissionAssignment> permissionAssignments = [];
List<RBACPermission> permissions = [];
List<RBAC> roles = [];
on<GetPermissionAssignments>((event, emit) async {
try {
emit(PermissionAssignmentLoadingScreen());
if (permissionAssignments.isEmpty) {
permissionAssignments = await RbacPermissionAssignmentServices
.instance
.getPermissionAssignment();
}
if (permissions.isEmpty) {
permissions =
await RbacPermissionServices.instance.getRbacPermission();
}
if (roles.isEmpty) {
roles = await RbacRoleServices.instance.getRbacRoles();
}
emit(PermissionAssignmentLoadedState(
permissionAssignments: permissionAssignments,
permissions: permissions,
roles: roles));
} catch (e) {
emit(PermissionAssignmentErrorState(message: e.toString()));
}
});
on<AddPersmissionAssignment>((event, emit) async {
try {
emit(PermissionAssignmentLoadingScreen());
Map<dynamic, dynamic> statusResponse =
await RbacPermissionAssignmentServices.instance
.addPermissionAssignment(
assignerId: event.assignerId,
opsId: event.opsId,
roleId: event.roleId);
if (statusResponse['success']) {
if (statusResponse['data'] != null) {
for (var rbac in statusResponse['data']) {
PermissionAssignment permissionAssignment =
PermissionAssignment.fromJson(rbac);
permissionAssignments.add(permissionAssignment);
}
}
emit(PermissionAssignmentAddedState(status: statusResponse));
} else {
emit(PermissionAssignmentAddedState(status: statusResponse));
}
} catch (e) {
emit(PermissionAssignmentErrorState(message: e.toString()));
}
});
on<DeletePermissionAssignment>((event, emit) async {
try {
emit(PermissionAssignmentLoadingScreen());
bool success = await RbacPermissionAssignmentServices.instance
.deletePermissionAssignment(id: event.id);
if (success) {
permissionAssignments
.removeWhere((element) => element.id == event.id);
}
emit(PermissionAssignmentDeletedState(success: success));
} catch (e) {
emit(PermissionAssignmentErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,28 @@
part of 'permission_assignment_bloc.dart';
class PermissionAssignmentEvent extends Equatable {
const PermissionAssignmentEvent();
@override
List<Object> get props => [];
}
class GetPermissionAssignments extends PermissionAssignmentEvent{
}
class DeletePermissionAssignment extends PermissionAssignmentEvent{
final int id;
const DeletePermissionAssignment({required this.id});
@override
List<Object> get props => [id];
}
class AddPersmissionAssignment extends PermissionAssignmentEvent{
final int assignerId;
final List<int> opsId;
final int roleId;
const AddPersmissionAssignment({required this.assignerId, required this.opsId, required this.roleId});
@override
List<Object> get props => [assignerId,opsId,roleId];
}

View File

@ -0,0 +1,45 @@
part of 'permission_assignment_bloc.dart';
class PermissionAssignmentState extends Equatable {
const PermissionAssignmentState();
@override
List<Object> get props => [];
}
class PermissionAssignmentInitial extends PermissionAssignmentState {}
class PermissionAssignmentLoadingScreen extends PermissionAssignmentState {}
class PermissionAssignmentLoadedState extends PermissionAssignmentState {
final List<PermissionAssignment> permissionAssignments;
final List<RBACPermission> permissions;
final List<RBAC> roles;
const PermissionAssignmentLoadedState(
{required this.permissionAssignments,
required this.permissions,
required this.roles});
@override
List<Object> get props => [permissionAssignments, permissions, roles];
}
class PermissionAssignmentErrorState extends PermissionAssignmentState {
final String message;
const PermissionAssignmentErrorState({required this.message});
@override
List<Object> get props => [message];
}
class PermissionAssignmentDeletedState extends PermissionAssignmentState {
final bool success;
const PermissionAssignmentDeletedState({required this.success});
@override
List<Object> get props => [success];
}
class PermissionAssignmentAddedState extends PermissionAssignmentState {
final Map<dynamic, dynamic> status;
const PermissionAssignmentAddedState({required this.status});
@override
List<Object> get props => [status];
}

View File

@ -25,7 +25,8 @@ class RoleModuleBloc extends Bloc<RoleModuleEvent, RoleModuleState> {
if (roles.isEmpty) { if (roles.isEmpty) {
roles = await RbacRoleServices.instance.getRbacRoles(); roles = await RbacRoleServices.instance.getRbacRoles();
} }
emit(RoleModuleLoadedState(roleModules: roleModules,modules: modules,roles: roles)); emit(RoleModuleLoadedState(
roleModules: roleModules, modules: modules, roles: roles));
} catch (e) { } catch (e) {
emit(RoleModuleErrorState(message: e.toString())); emit(RoleModuleErrorState(message: e.toString()));
} }
@ -40,9 +41,12 @@ class RoleModuleBloc extends Bloc<RoleModuleEvent, RoleModuleState> {
moduleIds: event.moduleIds); moduleIds: event.moduleIds);
if (statusResponse['success']) { if (statusResponse['success']) {
List<int?> ids = roleModules.map((e) => e.id).toList();
statusResponse['data'].forEach((var roleMod) { statusResponse['data'].forEach((var roleMod) {
RoleModules newRoleModule = RoleModules.fromJson(roleMod); RoleModules newRoleModule = RoleModules.fromJson(roleMod);
if (!ids.contains(newRoleModule.id)) {
roleModules.add(newRoleModule); roleModules.add(newRoleModule);
}
emit(RoleModuleAddedState(response: statusResponse)); emit(RoleModuleAddedState(response: statusResponse));
}); });
} else { } else {

View File

@ -36,11 +36,14 @@ class RolesUnderBloc extends Bloc<RolesUnderEvent, RolesUnderState> {
.add(roleId: event.roleId, rolesId: event.roleUnderIds); .add(roleId: event.roleId, rolesId: event.roleUnderIds);
if (statusResponse['success']) { if (statusResponse['success']) {
List<int> ids = rolesUnder.map((e) => e.id).toList();
statusResponse['data'].forEach((var roleMod) { statusResponse['data'].forEach((var roleMod) {
RolesUnder newRoleUnder = RolesUnder.fromJson(roleMod); RolesUnder newRoleUnder = RolesUnder.fromJson(roleMod);
if (!ids.contains(newRoleUnder.id)) {
rolesUnder.add(newRoleUnder); rolesUnder.add(newRoleUnder);
emit(RoleUnderAddedState(response: statusResponse)); }
}); });
emit(RoleUnderAddedState(response: statusResponse));
} else { } else {
emit(RoleUnderAddedState(response: statusResponse)); emit(RoleUnderAddedState(response: statusResponse));
} }

View File

@ -40,9 +40,13 @@ class UserBloc extends Bloc<UserEvent, UserState> {
final String? saved = CREDENTIALS?.get('saved'); final String? saved = CREDENTIALS?.get('saved');
username = CREDENTIALS?.get('username'); username = CREDENTIALS?.get('username');
password = CREDENTIALS?.get('password'); password = CREDENTIALS?.get('password');
print(username); if(apkVersion != _versionInfo!.id ){
print(password); emit(VersionLoaded(
if (saved != null) { versionInfo: _versionInfo,
apkVersion: _apkVersion,
username: event.username,
password: event.password));
}else if (saved != null) {
save = true; save = true;
add(UserLogin(username: username, password: password)); add(UserLogin(username: username, password: password));
} else { } else {

View File

@ -1,6 +1,6 @@
class VersionInfo { class VersionInfo {
VersionInfo({ VersionInfo({
this.version, this.id,
this.versionInfo, this.versionInfo,
this.dateReleased, this.dateReleased,
this.development, this.development,
@ -11,7 +11,7 @@ class VersionInfo {
this.x8664DownloadUrl, this.x8664DownloadUrl,
}); });
String? version; String? id;
String? versionInfo; String? versionInfo;
DateTime? dateReleased; DateTime? dateReleased;
bool? development; bool? development;
@ -22,7 +22,7 @@ class VersionInfo {
String? x8664DownloadUrl; String? x8664DownloadUrl;
factory VersionInfo.fromJson(Map<String, dynamic> json) => VersionInfo( factory VersionInfo.fromJson(Map<String, dynamic> json) => VersionInfo(
version: json["version"], id: json["id"],
versionInfo: json["version_info"], versionInfo: json["version_info"],
dateReleased: DateTime.parse(json["date_released"]), dateReleased: DateTime.parse(json["date_released"]),
development: json["development"], development: json["development"],
@ -34,7 +34,7 @@ class VersionInfo {
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"version": version, "version": id,
"version_info": versionInfo, "version_info": versionInfo,
"date_released": "date_released":
"${dateReleased!.year.toString().padLeft(4, '0')}-${dateReleased!.month.toString().padLeft(2, '0')}-${dateReleased!.day.toString().padLeft(2, '0')}", "${dateReleased!.year.toString().padLeft(4, '0')}-${dateReleased!.month.toString().padLeft(2, '0')}-${dateReleased!.day.toString().padLeft(2, '0')}",

View File

@ -51,38 +51,4 @@ class AssignedRole {
}; };
} }
class CreatedBy {
final int id;
final String username;
final String firstName;
final String lastName;
final String email;
final bool isActive;
CreatedBy({
required this.id,
required this.username,
required this.firstName,
required this.lastName,
required this.email,
required this.isActive,
});
factory CreatedBy.fromJson(Map<String, dynamic> json) => CreatedBy(
id: json["id"],
username: json["username"],
firstName: json["first_name"],
lastName: json["last_name"],
email: json["email"],
isActive: json["is_active"],
);
Map<String, dynamic> toJson() => {
"id": id,
"username": username,
"first_name": firstName,
"last_name": lastName,
"email": email,
"is_active": isActive,
};
}

View File

@ -0,0 +1,174 @@
// To parse this JSON data, do
//
// final permissionAssignment = permissionAssignmentFromJson(jsonString);
import 'package:meta/meta.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'dart:convert';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/model/rbac/user.dart';
PermissionAssignment permissionAssignmentFromJson(String str) => PermissionAssignment.fromJson(json.decode(str));
String permissionAssignmentToJson(PermissionAssignment data) => json.encode(data.toJson());
class PermissionAssignment {
final int? id;
final RBAC? role;
final RBACPermission? permission;
final DateTime? createdAt;
final DateTime? updatedAt;
final User? createdBy;
final User? updatedBy;
PermissionAssignment({
required this.id,
required this.role,
required this.permission,
required this.createdAt,
required this.updatedAt,
required this.createdBy,
required this.updatedBy,
});
factory PermissionAssignment.fromJson(Map<String, dynamic> json) => PermissionAssignment(
id: json["id"],
role: json["role"] == null? null: RBAC.fromJson(json["role"]),
permission:json["permission"] == null?null: RBACPermission.fromJson(json["permission"]),
createdAt: json['created_at'] == null?null: DateTime.parse(json["created_at"]),
updatedAt:json['updated_at'] == null?null: DateTime.parse(json["updated_at"]),
createdBy:json["created_by"] == null?null: User.fromJson(json["created_by"]),
updatedBy: json["updated_by"] == null? null:User.fromJson(json["created_by"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"role": role?.toJson(),
"permission": permission?.toJson(),
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt,
"created_by": createdBy?.toJson(),
"updated_by": updatedBy,
};
}
class CreatedBy {
final int id;
final String username;
final String firstName;
final String lastName;
final String email;
final bool isActive;
CreatedBy({
required this.id,
required this.username,
required this.firstName,
required this.lastName,
required this.email,
required this.isActive,
});
factory CreatedBy.fromJson(Map<String, dynamic> json) => CreatedBy(
id: json["id"],
username: json["username"],
firstName: json["first_name"],
lastName: json["last_name"],
email: json["email"],
isActive: json["is_active"],
);
Map<String, dynamic> toJson() => {
"id": id,
"username": username,
"first_name": firstName,
"last_name": lastName,
"email": email,
"is_active": isActive,
};
}
class Permission {
final int id;
final Role object;
final Role operation;
final DateTime createdAt;
final dynamic updatedAt;
final CreatedBy createdBy;
final dynamic updatedBy;
Permission({
required this.id,
required this.object,
required this.operation,
required this.createdAt,
required this.updatedAt,
required this.createdBy,
required this.updatedBy,
});
factory Permission.fromJson(Map<String, dynamic> json) => Permission(
id: json["id"],
object: Role.fromJson(json["object"]),
operation: Role.fromJson(json["operation"]),
createdAt: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"],
createdBy: CreatedBy.fromJson(json["created_by"]),
updatedBy: json["updated_by"],
);
Map<String, dynamic> toJson() => {
"id": id,
"object": object.toJson(),
"operation": operation.toJson(),
"created_at": createdAt.toIso8601String(),
"updated_at": updatedAt,
"created_by": createdBy.toJson(),
"updated_by": updatedBy,
};
}
class Role {
final int id;
final String name;
final String slug;
final String shorthand;
final DateTime createdAt;
final dynamic updatedAt;
final CreatedBy createdBy;
final dynamic updatedBy;
Role({
required this.id,
required this.name,
required this.slug,
required this.shorthand,
required this.createdAt,
required this.updatedAt,
required this.createdBy,
required this.updatedBy,
});
factory Role.fromJson(Map<String, dynamic> json) => Role(
id: json["id"],
name: json["name"],
slug: json["slug"],
shorthand: json["shorthand"],
createdAt: DateTime.parse(json["created_at"]),
updatedAt: json["updated_at"],
createdBy: CreatedBy.fromJson(json["created_by"]),
updatedBy: json["updated_by"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"slug": slug,
"shorthand": shorthand,
"created_at": createdAt.toIso8601String(),
"updated_at": updatedAt,
"created_by": createdBy.toJson(),
"updated_by": updatedBy,
};
}

View File

@ -0,0 +1,35 @@
class User {
final int id;
final String? username;
final String? firstName;
final String? lastName;
final String? email;
final bool? isActive;
User({
required this.id,
required this.username,
required this.firstName,
required this.lastName,
required this.email,
required this.isActive,
});
factory User.fromJson(Map<String, dynamic> json) => User(
id: json["id"],
username: json["username"],
firstName: json["first_name"],
lastName: json["last_name"],
email: json["email"],
isActive: json["is_active"],
);
Map<String, dynamic> toJson() => {
"id": id,
"username": username,
"first_name": firstName,
"last_name": lastName,
"email": email,
"is_active": isActive,
};
}

View File

@ -23,9 +23,9 @@ import '../../../../utils/alerts.dart';
class CitizenShipScreen extends StatefulWidget { class CitizenShipScreen extends StatefulWidget {
final int profileId; final int profileId;
final String token; final String token;
final List<Citizenship> citizenships;
const CitizenShipScreen( const CitizenShipScreen(
{super.key, required this.profileId, required this.token}); {super.key, required this.profileId, required this.token , required this.citizenships});
@override @override
State<CitizenShipScreen> createState() => _CitizenShipScreenState(); State<CitizenShipScreen> createState() => _CitizenShipScreenState();
@ -421,7 +421,9 @@ class _CitizenShipScreenState extends State<CitizenShipScreen> {
if (state is CitizenshipErrorState) { if (state is CitizenshipErrorState) {
return Scaffold( return Scaffold(
body: SomethingWentWrong( body: SomethingWentWrong(
message: state.message, onpressed: () {})); message: state.message, onpressed: () {
context.read<CitizenshipBloc>().add(GetCitizenship(citizenship: widget.citizenships));
}));
} }
return Container(); return Container();
}, },

View File

@ -10,6 +10,7 @@ import 'package:unit2/sevices/profile/contact_services.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/form-style.dart'; import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/global_context.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import '../../../../../theme-data.dart/colors.dart'; import '../../../../../theme-data.dart/colors.dart';
@ -84,7 +85,7 @@ class _AddContactInformationScreenState
serviceTypeId: serviceTypeId:
selectedServiceType!.id!); selectedServiceType!.id!);
} catch (e) { } catch (e) {
context NavigationService.navigatorKey.currentContext!
.read<ContactBloc>() .read<ContactBloc>()
.add(CallErrorEvent(message: e.toString())); .add(CallErrorEvent(message: e.toString()));
} }
@ -129,6 +130,7 @@ class _AddContactInformationScreenState
? selectedServiceType?.id == 2 ? selectedServiceType?.id == 2
//// Landline //// Landline
? FormBuilderTextField( ? FormBuilderTextField(
keyboardType: TextInputType.number,
controller: numberMailController, controller: numberMailController,
inputFormatters: [landLineFormatter], inputFormatters: [landLineFormatter],
name: 'number-mail', name: 'number-mail',
@ -150,7 +152,7 @@ class _AddContactInformationScreenState
errorText: "This field is required"), errorText: "This field is required"),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Mobile number *", "Mobile number *",
"+63 (9xx) xxx - xxxx"), "+63 (9xx) xxx - xxxx").copyWith(helperText: "Please input your mobile number excluding the 0"),
) )
: selectedServiceType!.id == 4 : selectedServiceType!.id == 4
////Social Media ////Social Media
@ -167,6 +169,7 @@ class _AddContactInformationScreenState
: selectedServiceType!.id == 3 : selectedServiceType!.id == 3
////Email Address ////Email Address
? FormBuilderTextField( ? FormBuilderTextField(
keyboardType: TextInputType.emailAddress,
controller: numberMailController, controller: numberMailController,
name: 'number-mail', name: 'number-mail',
validator: FormBuilderValidators validator: FormBuilderValidators

View File

@ -37,7 +37,7 @@ class _EditContactInformationScreenState
var mobileFormatter = MaskTextInputFormatter( var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (###) ###-####", mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")}, filter: {"#": RegExp(r'^[0-9][0-9]*$')},
type: MaskAutoCompletionType.lazy, type: MaskAutoCompletionType.lazy,
initialText: "0"); initialText: "0");
@ -149,6 +149,7 @@ class _EditContactInformationScreenState
? selectedServiceType?.id == 2 ? selectedServiceType?.id == 2
//// Landline //// Landline
? FormBuilderTextField( ? FormBuilderTextField(
keyboardType: TextInputType.number,
controller: numberMailController, controller: numberMailController,
name: 'number-mail', name: 'number-mail',
inputFormatters: [landLineFormatter], inputFormatters: [landLineFormatter],
@ -162,6 +163,7 @@ class _EditContactInformationScreenState
selectedServiceType!.id == 19 selectedServiceType!.id == 19
//// Mobile number //// Mobile number
? FormBuilderTextField( ? FormBuilderTextField(
keyboardType: TextInputType.number,
controller: numberMailController, controller: numberMailController,
name: 'number-mail', name: 'number-mail',
inputFormatters: [mobileFormatter], inputFormatters: [mobileFormatter],
@ -172,10 +174,12 @@ class _EditContactInformationScreenState
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Mobile number *", "Mobile number *",
"+63 (9xx) xxx - xxxx"), "+63 (9xx) xxx - xxxx"),
) )
: selectedServiceType!.id == 4 : selectedServiceType!.id == 4
////Social Media ////Social Media
? FormBuilderTextField( ? FormBuilderTextField(
controller: numberMailController, controller: numberMailController,
name: 'number-mail', name: 'number-mail',
validator: validator:
@ -188,6 +192,7 @@ class _EditContactInformationScreenState
: selectedServiceType!.id == 3 : selectedServiceType!.id == 3
////Email Address ////Email Address
? FormBuilderTextField( ? FormBuilderTextField(
keyboardType: TextInputType.emailAddress,
controller: controller:
numberMailController, numberMailController,
name: 'number-mail', name: 'number-mail',

View File

@ -1,10 +1,6 @@
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_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import '../../../../../bloc/profile/family/family_bloc.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 '../../../../../theme-data.dart/form-style.dart'; import '../../../../../theme-data.dart/form-style.dart';
@ -26,6 +22,7 @@ class AddMobileNumber extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
FormBuilderTextField( FormBuilderTextField(
keyboardType: TextInputType.number,
name: 'number_mail', name: 'number_mail',
inputFormatters: [mobileFormatter], inputFormatters: [mobileFormatter],
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(

View File

@ -349,7 +349,8 @@ class _SpouseAlertState extends State<SpouseAlert> {
], ],
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: widget.positions suggestions: widget.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -383,7 +383,8 @@ class _SpouseEditAlertState extends State<SpouseEditAlert> {
suggestionDirection: suggestionDirection:
SuggestionDirection.down, SuggestionDirection.down,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: widget.positions suggestions: widget.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -128,7 +128,8 @@ class _AddEducationScreenState extends State<AddEducationScreen> {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.schools suggestions: state.schools
.map((School school) => .map((School school) =>
SearchFieldListItem(school.name!, SearchFieldListItem(school.name!,
@ -190,7 +191,8 @@ class _AddEducationScreenState extends State<AddEducationScreen> {
UpperCaseTextFormatter() UpperCaseTextFormatter()
], ],
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.programs suggestions: state.programs
.map((Course program) => .map((Course program) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -165,7 +165,8 @@ class _EditEducationScreenState extends State<EditEducationScreen> {
}, },
controller: currentSchoolController, controller: currentSchoolController,
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.schools suggestions: state.schools
.map((School school) => .map((School school) =>
SearchFieldListItem(school.name!, SearchFieldListItem(school.name!,
@ -230,7 +231,8 @@ class _EditEducationScreenState extends State<EditEducationScreen> {
SuggestionAction.unfocus, SuggestionAction.unfocus,
controller: currentProgramController, controller: currentProgramController,
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.programs suggestions: state.programs
.map((Course program) => .map((Course program) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -45,7 +45,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget {
AttachmentCategory? selectedAttachmentCategory; AttachmentCategory? selectedAttachmentCategory;
List<AttachmentCategory> attachmentCategories = []; List<AttachmentCategory> attachmentCategories = [];
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar( appBar: AppBar(
title: context.watch<LearningDevelopmentBloc>().state title: context.watch<LearningDevelopmentBloc>().state
is LearningDevelopmentAddingState is LearningDevelopmentAddingState

View File

@ -267,7 +267,7 @@ class _EditLearningAndDevelopmentScreenState
controller: currentTopicController, controller: currentTopicController,
focusNode: topicFocusNode, focusNode: topicFocusNode,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.topics suggestions: state.topics
.map((LearningDevelopmentType .map((LearningDevelopmentType
topic) => topic) =>

View File

@ -92,7 +92,7 @@ class _AddVoluntaryWorkScreenState extends State<AddVoluntaryWorkScreen> {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.positions suggestions: state.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -128,7 +128,7 @@ class _EditVoluntaryWorkScreenState extends State<EditVoluntaryWorkScreen> {
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
controller: positionController, controller: positionController,
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.positions suggestions: state.positions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -98,7 +98,7 @@ class _AddWorkHistoryScreenState extends State<AddWorkHistoryScreen> {
return SearchField( return SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
itemHeight: 70, itemHeight: 70,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.agencyPositions suggestions: state.agencyPositions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -121,7 +121,7 @@ class _EditWorkHistoryScreenState extends State<EditWorkHistoryScreen> {
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [UpperCaseTextFormatter()],
controller: oldPositionController, controller: oldPositionController,
itemHeight: 100, itemHeight: 100,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.agencyPositions suggestions: state.agencyPositions
.map((PositionTitle position) => .map((PositionTitle position) =>
SearchFieldListItem(position.title!, SearchFieldListItem(position.title!,

View File

@ -48,15 +48,27 @@ import '../unit2/homepage.dart/components/menu.dart';
import 'components/main_menu.dart'; import 'components/main_menu.dart';
import 'components/submenu.dart'; import 'components/submenu.dart';
class ProfileInfo extends StatelessWidget { class ProfileInfo extends StatefulWidget {
const ProfileInfo({super.key}); const ProfileInfo({super.key});
@override
State<ProfileInfo> createState() => _ProfileInfoState();
}
class _ProfileInfoState extends State<ProfileInfo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
int? profileId; int? profileId;
String? token; String? token;
Profile profile; Profile profile;
return Scaffold( return WillPopScope(
onWillPop: () async{
setState(() {
});
return true;
},
child: Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: primary, backgroundColor: primary,
centerTitle: true, centerTitle: true,
@ -71,11 +83,12 @@ class ProfileInfo extends StatelessWidget {
profileId = state.userData!.user!.login!.user!.profileId; profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!; token = state.userData!.user!.login!.token!;
if (globalCurrentProfile == null) { if (globalCurrentProfile == null) {
profile = state.userData!.employeeInfo!.profile!; profile = state.userData!.employeeInfo!.profile!;
globalCurrentProfile = profile;
} else { } else {
profile = globalCurrentProfile!; profile = globalCurrentProfile!;
} }
print(profile.lastName);
return BlocConsumer<ProfileBloc, ProfileState>( return BlocConsumer<ProfileBloc, ProfileState>(
listener: ( listener: (
context, context,
@ -186,6 +199,10 @@ class ProfileInfo extends StatelessWidget {
.basicInfo .basicInfo
.citizenships)), .citizenships)),
child: CitizenShipScreen( child: CitizenShipScreen(
citizenships: state
.profileInformation
.basicInfo
.citizenships,
profileId: profileId!, token: token!), profileId: profileId!, token: token!),
); );
})); }));
@ -402,6 +419,7 @@ class ProfileInfo extends StatelessWidget {
} }
return Container(); return Container();
}), }),
)); )),
);
} }
} }

View File

@ -5,6 +5,7 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:fluttericon/font_awesome_icons.dart'; import 'package:fluttericon/font_awesome_icons.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:searchfield/searchfield.dart'; import 'package:searchfield/searchfield.dart';
import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/agency/agency_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
@ -28,6 +29,7 @@ class RbacAgencyScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
List<Agency> agencies = [];
List<Category> agencyCategory = []; List<Category> agencyCategory = [];
Category? selectedAgencyCategory; Category? selectedAgencyCategory;
bool? isPrivate; bool? isPrivate;
@ -38,7 +40,37 @@ class RbacAgencyScreen extends StatelessWidget {
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Agencies"), title: const Text("Agencies"),
actions: [ actions: context.watch<AgencyBloc>().state is AgencyLoadingState || context.watch<AgencyBloc>().state is AgencyErrorState || context.watch<AgencyBloc>().state is AgencyAddesState?[]:[
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: primary),
builder: (Agency rbac) {
return Column(
children: [
ListTile(
title: Text(rbac.name!),
),
const Divider(),
],
);
},
filter: (Agency rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Agency found :("),
),
items: agencies,
searchLabel: "Search Agency",
suggestion: const Center(
child: Text("Search agency by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () { AddLeading(onPressed: () {
parent = context; parent = context;
showDialog( showDialog(
@ -220,6 +252,7 @@ class RbacAgencyScreen extends StatelessWidget {
builder: (context, state) { builder: (context, state) {
final parent = context; final parent = context;
if (state is AgenciesLoaded) { if (state is AgenciesLoaded) {
agencies = state.agencies;
agencyCategory = state.agencyCategory; agencyCategory = state.agencyCategory;
if (state.agencies.isNotEmpty) { if (state.agencies.isNotEmpty) {
return ListView.builder( return ListView.builder(
@ -262,7 +295,7 @@ class RbacAgencyScreen extends StatelessWidget {
}); });
} else { } else {
return const EmptyData( return const EmptyData(
message: "No Object available. Please click + to add."); message: "No Agency available. Please click + to add.");
} }
}if (state is AgencyErrorState) { }if (state is AgencyErrorState) {
return SomethingWentWrong( return SomethingWentWrong(

View File

@ -82,7 +82,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
areaType = null; areaType = null;
return AlertDialog( return AlertDialog(
title: const Text("Add New Role"), title: const Text("Add New Assigned area"),
content: FormBuilder( content: FormBuilder(
key: formKey, key: formKey,
child: StatefulBuilder(builder: (context, setState) { child: StatefulBuilder(builder: (context, setState) {
@ -1005,7 +1005,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
if (state is AssignedAreaDeletedState) { if (state is AssignedAreaDeletedState) {
if (state.success) { if (state.success) {
successAlert(context, "Delete Successfull!", successAlert(context, "Delete Successfull!",
"Role Module Deleted Successfully", () { "Assign Area Deleted Successfully", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context context
.read<AssignAreaBloc>() .read<AssignAreaBloc>()
@ -1013,7 +1013,7 @@ class _RbacAssignedAreaScreenState extends State<RbacAssignedAreaScreen> {
}); });
} else { } else {
errorAlert( errorAlert(
context, "Delete Failed", "Role Module Delete Failed", context, "Delete Failed", "Assign Area Deletion Failed",
() { () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context context

View File

@ -5,7 +5,9 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/module/module_bloc.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart'; import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart'; import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
@ -23,12 +25,206 @@ class RbacModuleScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
final bloc = BlocProvider.of<ModuleBloc>(context);
List<RBAC> modules = [];
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Module Screen"), title: const Text("Module Screen"),
actions: [ actions:
context.watch<ModuleBloc>().state is ModuleLoadingState ||
context.watch<ModuleBloc>().state is ModuleErrorState ||
context.watch<ModuleBloc>().state is ModuleAddedState ||
context.watch<ModuleBloc>().state is ModuleDeletedState ||
context.watch<ModuleBloc>().state is ModuleAddedState ||
context.watch<ModuleBloc>().state is ModuleUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
const SizedBox(
width: 12,
),
Expanded(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder: (BuildContext
context) {
return AlertDialog(
title: const Text(
"Update Module"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize
.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Module name *",
"Module name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.shorthand,
validator: FormBuilderValidators
.maxLength(
50,
errorText:
"Max characters only 50"),
name:
"shorthand",
decoration: normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
////Update
bloc.add(UpdateRbacModule(
moduleId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text("Update"))),
],
),
),
);
});
}
if (value == 1) {
////delete
Navigator.pop(context);
confirmAlert(context, () {
context
.read<ModuleBloc>()
.add(DeleteRbacModule(
moduleId:
rbac.id!));
}, "Delete?",
"Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Module found :("),
),
items: modules,
searchLabel: "Search Module",
suggestion: const Center(
child: Text("Search module by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () { AddLeading(onPressed: () {
BuildContext parent = context; BuildContext parent = context;
showDialog( showDialog(
@ -53,17 +249,20 @@ class RbacModuleScreen extends StatelessWidget {
), ),
FormBuilderTextField( FormBuilderTextField(
name: "slug", name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"), decoration:
normalTextFieldStyle("Slug ", "Slug"),
), ),
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
FormBuilderTextField( FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50, validator:
errorText: "Max characters only 50"), FormBuilderValidators.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand", name: "shorthand",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Shorthand ", "Shorthand"), "Shorthand ", "Shorthand"),
), ),
const SizedBox( const SizedBox(
height: 12, height: 12,
@ -72,17 +271,20 @@ class RbacModuleScreen extends StatelessWidget {
width: double.infinity, width: double.infinity,
height: 50, height: 50,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate()) { .saveAndValidate()) {
String name = formKey String name = formKey
.currentState!.value['object_name']; .currentState!
String? slug = .value['object_name'];
formKey.currentState!.value['slug']; String? slug = formKey
.currentState!
.value['slug'];
String? short = formKey String? short = formKey
.currentState!.value['shorthand']; .currentState!
.value['shorthand'];
parent.read<ModuleBloc>().add( parent.read<ModuleBloc>().add(
AddRbacModule( AddRbacModule(
id: id, id: id,
@ -162,7 +364,7 @@ class RbacModuleScreen extends StatelessWidget {
context.read<ModuleBloc>().add(GetModule()); context.read<ModuleBloc>().add(GetModule());
}); });
} else { } else {
errorAlert(context, "Delete Failed", "Module Delete Failed", errorAlert(context, "Delete Failed", "Module Deletion Failed",
() { () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<ModuleBloc>().add(GetModule()); context.read<ModuleBloc>().add(GetModule());
@ -174,6 +376,7 @@ class RbacModuleScreen extends StatelessWidget {
final parent = context; final parent = context;
if (state is ModuleLoaded) { if (state is ModuleLoaded) {
if (state.module.isNotEmpty) { if (state.module.isNotEmpty) {
modules = state.module;
return ListView.builder( return ListView.builder(
padding: padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10), const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -191,8 +394,12 @@ class RbacModuleScreen extends StatelessWidget {
Expanded( Expanded(
child: Row( child: Row(
children: [ children: [
CircleAvatar(child: Text('${index+1}'),), CircleAvatar(
const SizedBox(width: 12,), child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Text(state.module[index].name!, Text(state.module[index].name!,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
@ -211,7 +418,8 @@ class RbacModuleScreen extends StatelessWidget {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: const Text("Update Module"), title:
const Text("Update Module"),
content: FormBuilder( content: FormBuilder(
key: formKey, key: formKey,
child: Column( child: Column(
@ -355,7 +563,7 @@ class RbacModuleScreen extends StatelessWidget {
}); });
} else { } else {
return const EmptyData( return const EmptyData(
message: "No Role available. Please click + to add."); message: "No Module available. Please click + to add.");
} }
} }
if (state is ModuleErrorState) { if (state is ModuleErrorState) {

View File

@ -1,4 +1,3 @@
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_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
@ -33,16 +32,25 @@ class RbacModuleObjectsScreen extends StatelessWidget {
List<ValueItem> selectedValueItemObjects = []; List<ValueItem> selectedValueItemObjects = [];
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
elevation: 0, elevation: 0,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Module Object Screen"), title: const Text("Module Object Screen"),
actions: [ actions: context.watch<ModuleObjectsBloc>().state
is ModuleObjectLoadingState ||
context.watch<ModuleObjectsBloc>().state
is ModuleObjectsErrorState ||
context.watch<ModuleObjectsBloc>().state
is ModuleObjectAddedState ||
context.watch<ModuleObjectsBloc>().state
is ModuleObjectDeletedState
? []
: [
AddLeading(onPressed: () { AddLeading(onPressed: () {
showDialog( showDialog(
context: NavigationService.navigatorKey.currentState!.context, context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) { builder: (BuildContext context) {
valueItemObjects = objects.map((e) { valueItemObjects = objects.map((e) {
return ValueItem(label: e.name!, value: e.name); return ValueItem(label: e.name!, value: e.name);
@ -58,8 +66,8 @@ class RbacModuleObjectsScreen extends StatelessWidget {
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
errorText: "This field is required"), errorText: "This field is required"),
name: "module", name: "module",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Module", "Module"), "Module", "Module"),
items: modules.isEmpty items: modules.isEmpty
? [] ? []
: modules.map((e) { : modules.map((e) {
@ -76,7 +84,8 @@ class RbacModuleObjectsScreen extends StatelessWidget {
MultiSelectDropDown( MultiSelectDropDown(
onOptionSelected: onOptionSelected:
(List<ValueItem> selectedOptions) { (List<ValueItem> selectedOptions) {
selectedValueItemObjects = selectedOptions; selectedValueItemObjects =
selectedOptions;
}, },
borderColor: Colors.grey, borderColor: Colors.grey,
borderWidth: 1, borderWidth: 1,
@ -85,10 +94,11 @@ class RbacModuleObjectsScreen extends StatelessWidget {
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
options: valueItemObjects, options: valueItemObjects,
selectionType: SelectionType.multi, selectionType: SelectionType.multi,
chipConfig: chipConfig: const ChipConfig(
const ChipConfig(wrapType: WrapType.wrap), wrapType: WrapType.wrap),
dropdownHeight: 300, dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16), optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon: selectedOptionIcon:
const Icon(Icons.check_circle), const Icon(Icons.check_circle),
), ),
@ -99,27 +109,31 @@ class RbacModuleObjectsScreen extends StatelessWidget {
height: 50, height: 50,
width: double.maxFinite, width: double.maxFinite,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate() && .saveAndValidate() &&
selectedValueItemObjects.isNotEmpty) { selectedValueItemObjects
.isNotEmpty) {
int assignerId = id; int assignerId = id;
int moduleId = selectedModule!.id!; int moduleId = selectedModule!.id!;
List<int> objectId = []; List<int> objectId = [];
for (var object in objects) { for (var object in objects) {
selectedValueItemObjects selectedValueItemObjects
.forEach((element) { .forEach((element) {
if (element.label.toLowerCase() == if (element.label
object.name?.toLowerCase()) { .toLowerCase() ==
object.name
?.toLowerCase()) {
objectId.add(object.id!); objectId.add(object.id!);
} }
}); });
} }
Navigator.of(context).pop(); Navigator.of(context).pop();
parent.read<ModuleObjectsBloc>().add( parent
AddRbacModuleObjects( .read<ModuleObjectsBloc>()
.add(AddRbacModuleObjects(
assignerId: assignerId, assignerId: assignerId,
moduleId: moduleId, moduleId: moduleId,
objectsId: objectId)); objectsId: objectId));
@ -140,7 +154,6 @@ class RbacModuleObjectsScreen extends StatelessWidget {
indicatorWidget: const SpinKitFadingCircle(color: Colors.white), indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<ModuleObjectsBloc, ModuleObjectsState>( child: BlocConsumer<ModuleObjectsBloc, ModuleObjectsState>(
listener: (context, state) { listener: (context, state) {
if (state is ModuleObjectLoadingState) { if (state is ModuleObjectLoadingState) {
final progress = ProgressHUD.of(context); final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait..."); progress!.showWithText("Please wait...");
@ -157,13 +170,13 @@ class RbacModuleObjectsScreen extends StatelessWidget {
if (state is ModuleObjectDeletedState) { if (state is ModuleObjectDeletedState) {
if (state.success) { if (state.success) {
successAlert( successAlert(
context, "Delete Successfull!", "Role Deleted Successfully", context, "Delete Successfull!", "Module Object Deleted Successfully",
() { () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<ModuleObjectsBloc>().add(GetModuleObjects()); context.read<ModuleObjectsBloc>().add(GetModuleObjects());
}); });
} else { } else {
errorAlert(context, "Delete Failed", "Role Delete Failed", () { errorAlert(context, "Delete Failed", "Module Object Deletion Failed", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<ModuleObjectsBloc>().add(GetModuleObjects()); context.read<ModuleObjectsBloc>().add(GetModuleObjects());
}); });
@ -270,19 +283,22 @@ class RbacModuleObjectsScreen extends StatelessWidget {
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.titleMedium! .titleMedium!
.copyWith(color: primary,fontWeight: FontWeight.bold), .copyWith(
color: primary, fontWeight: FontWeight.bold),
), ),
); );
}, },
); );
} else { } else {
return const EmptyData( return const EmptyData(
message: "No Role available. Please click + to add."); message:
"No Module Object available. Please click + to add.");
} }
} }
if (state is ModuleObjectsErrorState) { if (state is ModuleObjectsErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, onpressed: () { message: state.message,
onpressed: () {
parent.read<ModuleObjectsBloc>().add(GetModuleObjects()); parent.read<ModuleObjectsBloc>().add(GetModuleObjects());
}); });
} }

View File

@ -5,7 +5,9 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart'; import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
import '../../../theme-data.dart/box_shadow.dart'; import '../../../theme-data.dart/box_shadow.dart';
@ -24,12 +26,197 @@ class RbacObjectScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
final bloc = BlocProvider.of<ObjectBloc>(context);
List<RBAC> objects = [];
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Objects Screen"), title: const Text("Objects Screen"),
actions: [ actions:
context.watch<ObjectBloc>().state is ObjectLoadingState ||
context.watch<ObjectBloc>().state is ObjectAddedState ||
context.watch<ObjectBloc>().state is ObjectErrorState ||
context.watch<ObjectBloc>().state is ObjectDeletedState ||
context.watch<ObjectBloc>().state is ObjectUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder: (BuildContext
context) {
return AlertDialog(
title: const Text(
"Update Object"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize
.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Object name *",
"Object name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.shorthand,
validator: FormBuilderValidators
.maxLength(
50,
errorText:
"Max characters only 50"),
name:
"shorthand",
decoration: normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
bloc.add(UpdateRbacObject(
objectId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text("Update"))),
],
),
),
);
});
}
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
bloc.add(DeleteRbacObject(
objectId: rbac.id!));
}, "Delete?",
"Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Role found :("),
),
items: objects,
searchLabel: "Search Object",
suggestion: const Center(
child: Text("Search object by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () { AddLeading(onPressed: () {
BuildContext parent = context; BuildContext parent = context;
showDialog( showDialog(
@ -54,17 +241,20 @@ class RbacObjectScreen extends StatelessWidget {
), ),
FormBuilderTextField( FormBuilderTextField(
name: "slug", name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"), decoration:
normalTextFieldStyle("Slug ", "Slug"),
), ),
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
FormBuilderTextField( FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50, validator:
errorText: "Max characters only 50"), FormBuilderValidators.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand", name: "shorthand",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Shorthand ", "Shorthand"), "Shorthand ", "Shorthand"),
), ),
const SizedBox( const SizedBox(
height: 12, height: 12,
@ -73,17 +263,20 @@ class RbacObjectScreen extends StatelessWidget {
width: double.infinity, width: double.infinity,
height: 50, height: 50,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate()) { .saveAndValidate()) {
String name = formKey String name = formKey
.currentState!.value['object_name']; .currentState!
String? slug = .value['object_name'];
formKey.currentState!.value['slug']; String? slug = formKey
.currentState!
.value['slug'];
String? short = formKey String? short = formKey
.currentState!.value['shorthand']; .currentState!
.value['shorthand'];
parent.read<ObjectBloc>().add( parent.read<ObjectBloc>().add(
AddRbacObject( AddRbacObject(
id: id, id: id,
@ -162,7 +355,7 @@ class RbacObjectScreen extends StatelessWidget {
context.read<ObjectBloc>().add(GetObjects()); context.read<ObjectBloc>().add(GetObjects());
}); });
} else { } else {
errorAlert(context, "Delete Failed", "Object Delete Failed", errorAlert(context, "Delete Failed", "Object Deletion Failed",
() { () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<ObjectBloc>().add(GetObjects()); context.read<ObjectBloc>().add(GetObjects());
@ -174,6 +367,7 @@ class RbacObjectScreen extends StatelessWidget {
final parent = context; final parent = context;
if (state is ObjectLoaded) { if (state is ObjectLoaded) {
if (state.objects.isNotEmpty) { if (state.objects.isNotEmpty) {
objects = state.objects;
return ListView.builder( return ListView.builder(
padding: padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10), const EdgeInsets.symmetric(vertical: 8, horizontal: 10),

View File

@ -5,7 +5,9 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart'; import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/widgets/error_state.dart'; import 'package:unit2/widgets/error_state.dart';
import '../../../theme-data.dart/box_shadow.dart'; import '../../../theme-data.dart/box_shadow.dart';
@ -24,11 +26,203 @@ class RbacOperationScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
final bloc = BlocProvider.of<OperationBloc>(context);
List<RBAC> operations = [];
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: primary, backgroundColor: primary,
title: const Text("Operations Screen"), title: const Text("Operations Screen"),
actions: [ centerTitle: true,
actions: context.watch<OperationBloc>().state
is OperationLoadingState ||
context.watch<OperationBloc>().state is OperationErrorState ||
context.watch<OperationBloc>().state is OperationAddedState ||
context.watch<OperationBloc>().state is OperationDeletedState ||
context.watch<OperationBloc>().state is OperationUpdatedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder:
(BuildContext context) {
return AlertDialog(
title: const Text(
"Update Operation"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Operation name *",
"Operation name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue: rbac
.shorthand,
validator: FormBuilderValidators
.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand",
decoration:
normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child:
ElevatedButton(
style: mainBtnStyle(
primary,
Colors
.transparent,
second),
onPressed:
() {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
bloc.add(UpdateRbacOperation(
operationId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text(
"Update"))),
],
),
),
);
});
}
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
context
.read<OperationBloc>()
.add(DeleteRbacOperation(
operationId: rbac.id!));
}, "Delete?", "Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBAC rbac) {
return [rbac.name];
},
failure: const Center(
child: Text("No Operation found :("),
),
items: operations,
searchLabel: "Search Operation",
suggestion: const Center(
child: Text("Search operation by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () { AddLeading(onPressed: () {
BuildContext parent = context; BuildContext parent = context;
showDialog( showDialog(
@ -53,7 +247,8 @@ class RbacOperationScreen extends StatelessWidget {
), ),
FormBuilderTextField( FormBuilderTextField(
name: "slug", name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"), decoration:
normalTextFieldStyle("Slug ", "Slug"),
), ),
const SizedBox( const SizedBox(
height: 8, height: 8,
@ -62,8 +257,8 @@ class RbacOperationScreen extends StatelessWidget {
validator: FormBuilderValidators.maxLength(50, validator: FormBuilderValidators.maxLength(50,
errorText: "Max characters only 50"), errorText: "Max characters only 50"),
name: "shorthand", name: "shorthand",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Shorthand ", "Shorthand"), "Shorthand ", "Shorthand"),
), ),
const SizedBox( const SizedBox(
height: 12, height: 12,
@ -72,17 +267,18 @@ class RbacOperationScreen extends StatelessWidget {
width: double.infinity, width: double.infinity,
height: 50, height: 50,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate()) { .saveAndValidate()) {
String name = formKey String name = formKey.currentState!
.currentState!.value['object_name']; .value['object_name'];
String? slug = String? slug = formKey
formKey.currentState!.value['slug']; .currentState!.value['slug'];
String? short = formKey String? short = formKey
.currentState!.value['shorthand']; .currentState!
.value['shorthand'];
parent.read<OperationBloc>().add( parent.read<OperationBloc>().add(
AddRbacOperation( AddRbacOperation(
id: id, id: id,
@ -162,8 +358,8 @@ class RbacOperationScreen extends StatelessWidget {
context.read<OperationBloc>().add(GetOperations()); context.read<OperationBloc>().add(GetOperations());
}); });
} else { } else {
errorAlert(context, "Delete Failed", "Operation Delete Failed", errorAlert(
() { context, "Delete Failed", "Operation Deletion Failed", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<OperationBloc>().add(GetOperations()); context.read<OperationBloc>().add(GetOperations());
}); });
@ -174,6 +370,7 @@ class RbacOperationScreen extends StatelessWidget {
final parent = context; final parent = context;
if (state is OperationsLoaded) { if (state is OperationsLoaded) {
if (state.operations.isNotEmpty) { if (state.operations.isNotEmpty) {
operations = state.operations;
return ListView.builder( return ListView.builder(
padding: padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10), const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -191,8 +388,12 @@ class RbacOperationScreen extends StatelessWidget {
Expanded( Expanded(
child: Row( child: Row(
children: [ children: [
CircleAvatar(child: Text('${index+1}'),), CircleAvatar(
const SizedBox(width: 12,), child: Text('${index + 1}'),
),
const SizedBox(
width: 12,
),
Text(state.operations[index].name!, Text(state.operations[index].name!,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
@ -211,7 +412,8 @@ class RbacOperationScreen extends StatelessWidget {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: const Text("Update Operation"), title: const Text(
"Update Operation"),
content: FormBuilder( content: FormBuilder(
key: formKey, key: formKey,
child: Column( child: Column(
@ -355,7 +557,7 @@ class RbacOperationScreen extends StatelessWidget {
}); });
} else { } else {
return const EmptyData( return const EmptyData(
message: "No Role available. Please click + to add."); message: "No Operation available. Please click + to add.");
} }
} }
if (state is OperationErrorState) { if (state is OperationErrorState) {

View File

@ -7,7 +7,9 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart'; import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:search_page/search_page.dart';
import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/model/rbac/rbac.dart'; import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart'; import 'package:unit2/screens/superadmin/role/shared_pop_up_menu.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
@ -32,6 +34,8 @@ class RbacPermissionScreen extends StatelessWidget {
List<RBAC> operations = []; List<RBAC> operations = [];
List<ValueItem> valueItemOperations = []; List<ValueItem> valueItemOperations = [];
List<ValueItem> selectedValueItemOperations = []; List<ValueItem> selectedValueItemOperations = [];
List<RBACPermission> permissions = [];
final bloc = BlocProvider.of<PermissionBloc>(context);
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
BuildContext? parent; BuildContext? parent;
return Scaffold( return Scaffold(
@ -39,10 +43,92 @@ class RbacPermissionScreen extends StatelessWidget {
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Permissions Screen"), title: const Text("Permissions Screen"),
actions: [ actions: context.watch<PermissionBloc>().state is PermissonLoadingState ||
context.watch<PermissionBloc>().state is PermissionErrorState ||
context.watch<PermissionBloc>().state is PermissionDeletedState ||
context.watch<PermissionBloc>().state is PermissionAddedState
? []
: [
IconButton(
onPressed: () {
showSearch(
context: context,
delegate: SearchPage(
barTheme: ThemeData(cardColor: Colors.white),
builder: (RBACPermission rbac) {
return Column(
children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Text(
"${rbac.object?.name} - ${rbac.operation?.name}",
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight.w500,
color: primary)),
),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
bloc.add(DeleteRbacPermission(
permissionId: rbac.id!));
}, "Delete?", "Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
);
},
filter: (RBACPermission rbac) {
return [
rbac.object!.name! + rbac.operation!.name!
];
},
failure: const Center(
child: Text("No permission found :("),
),
items: permissions,
searchLabel: "Search Permission",
suggestion: const Center(
child: Text("Search permission by name"),
)),
);
},
icon: const Icon(Icons.search)),
AddLeading(onPressed: () { AddLeading(onPressed: () {
showDialog( showDialog(
context: NavigationService.navigatorKey.currentState!.context, context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) { builder: (BuildContext context) {
valueItemOperations = operations.map((e) { valueItemOperations = operations.map((e) {
return ValueItem(label: e.name!, value: e.name); return ValueItem(label: e.name!, value: e.name);
@ -58,8 +144,8 @@ class RbacPermissionScreen extends StatelessWidget {
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
errorText: "This field is required"), errorText: "This field is required"),
name: "object", name: "object",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Permission", "Permission"), "Permission", "Permission"),
items: objects.isEmpty items: objects.isEmpty
? [] ? []
: objects.map((e) { : objects.map((e) {
@ -76,7 +162,8 @@ class RbacPermissionScreen extends StatelessWidget {
MultiSelectDropDown( MultiSelectDropDown(
onOptionSelected: onOptionSelected:
(List<ValueItem> selectedOptions) { (List<ValueItem> selectedOptions) {
selectedValueItemOperations = selectedOptions; selectedValueItemOperations =
selectedOptions;
}, },
borderColor: Colors.grey, borderColor: Colors.grey,
borderWidth: 1, borderWidth: 1,
@ -85,10 +172,11 @@ class RbacPermissionScreen extends StatelessWidget {
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
options: valueItemOperations, options: valueItemOperations,
selectionType: SelectionType.multi, selectionType: SelectionType.multi,
chipConfig: chipConfig: const ChipConfig(
const ChipConfig(wrapType: WrapType.wrap), wrapType: WrapType.wrap),
dropdownHeight: 300, dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16), optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon: selectedOptionIcon:
const Icon(Icons.check_circle), const Icon(Icons.check_circle),
), ),
@ -99,8 +187,8 @@ class RbacPermissionScreen extends StatelessWidget {
height: 50, height: 50,
width: double.maxFinite, width: double.maxFinite,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate() && .saveAndValidate() &&
@ -113,15 +201,15 @@ class RbacPermissionScreen extends StatelessWidget {
for (var operation in operations) { for (var operation in operations) {
selectedValueItemOperations selectedValueItemOperations
.forEach((element) { .forEach((element) {
if (element.label.toLowerCase() == if (element.label
operation.name?.toLowerCase()) { .toLowerCase() ==
operation.name
?.toLowerCase()) {
opIds.add(operation.id!); opIds.add(operation.id!);
} }
}); });
} }
opIds.forEach((element) {
print(element);
});
Navigator.pop(context); Navigator.pop(context);
parent!.read<PermissionBloc>().add( parent!.read<PermissionBloc>().add(
AddRbacPermission( AddRbacPermission(
@ -181,8 +269,8 @@ class RbacPermissionScreen extends StatelessWidget {
context.read<PermissionBloc>().add(GetPermissions()); context.read<PermissionBloc>().add(GetPermissions());
}); });
} else { } else {
errorAlert(context, "Delete Failed", "Permission Delete Failed", errorAlert(
() { context, "Delete Failed", "Permission Deletion Failed", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<PermissionBloc>().add(GetPermissions()); context.read<PermissionBloc>().add(GetPermissions());
}); });
@ -195,6 +283,7 @@ class RbacPermissionScreen extends StatelessWidget {
objects = state.objects; objects = state.objects;
operations = state.operations; operations = state.operations;
if (state.permissions.isNotEmpty) { if (state.permissions.isNotEmpty) {
permissions = state.permissions;
return ListView.builder( return ListView.builder(
padding: padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 10), const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
@ -235,17 +324,15 @@ class RbacPermissionScreen extends StatelessWidget {
elevation: 3, elevation: 3,
onSelected: (value) { onSelected: (value) {
if (value == 1) { if (value == 1) {
confirmAlert(context, () { confirmAlert(context, () {
context.read<PermissionBloc>().add( context.read<PermissionBloc>().add(
DeleteRbacPermission( DeleteRbacPermission(
permissionId: state.permissions[index].id!)); permissionId: state
.permissions[index].id!));
}, "Delete?", "Confirm Delete?"); }, "Delete?", "Confirm Delete?");
} }
}, },
menuItems: [ menuItems: [
popMenuItem( popMenuItem(
text: "Remove", text: "Remove",
value: 1, value: 1,
@ -273,7 +360,8 @@ class RbacPermissionScreen extends StatelessWidget {
} }
if (state is PermissionErrorState) { if (state is PermissionErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, onpressed: () { message: state.message,
onpressed: () {
parent!.read<PermissionBloc>().add(GetPermissions()); parent!.read<PermissionBloc>().add(GetPermissions());
}); });
} }

View File

@ -0,0 +1,325 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
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:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/rbac/rbac_operations/permission_assignment/permission_assignment_bloc.dart';
import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/theme-data.dart/btn-style.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/alerts.dart';
import 'package:unit2/widgets/Leadings/add_leading.dart';
import 'package:unit2/widgets/empty_data.dart';
import 'package:unit2/widgets/error_state.dart';
class RbacPermissionAssignmentScreen extends StatelessWidget {
final int id;
const RbacPermissionAssignmentScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
final parent = context;
Map<String, List<Content>> permissionAssignments = {};
List<RBACPermission> permissions = [];
List<ValueItem> valueItemPermission = [];
List<ValueItem> selectedValueItemPermission = [];
List<RBAC> roles = [];
RBAC? selectedRole;
final formKey = GlobalKey<FormBuilderState>();
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Permission Assignment"),
actions: context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentLoadingScreen ||
context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentErrorState ||
context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentAddedState ||
context.watch<PermissionAssignmentBloc>().state
is PermissionAssignmentDeletedState
? []
: [
AddLeading(onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
valueItemPermission = permissions.map((e) {
return ValueItem(
label: "${e.object!.name} - ${e.operation!.name}",
value: e.id.toString());
}).toList();
return AlertDialog(
title: const Text("Add Permission"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration:
normalTextFieldStyle("Role", "Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemPermission =
selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Operations",
padding: const EdgeInsets.all(8),
options: valueItemPermission,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemPermission
.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> opIds =
selectedValueItemPermission
.map((e) {
return int.parse(e.value!);
}).toList();
Navigator.pop(context);
parent
.read<
PermissionAssignmentBloc>()
.add(AddPersmissionAssignment(
assignerId: assignerId,
opsId: opIds,
roleId: roleId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child:
BlocConsumer<PermissionAssignmentBloc, PermissionAssignmentState>(
listener: (context, state) {
if (state is PermissionAssignmentLoadingScreen) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is PermissionAssignmentErrorState ||
state is PermissionAssignmentLoadedState ||
state is PermissionAssignmentAddedState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
if (state is PermissionAssignmentDeletedState) {
if (state.success) {
successAlert(context, "Delete Successfull!",
"Permission Assignment Deleted Successfully", () {
Navigator.of(context).pop();
context
.read<PermissionAssignmentBloc>()
.add(GetPermissionAssignments());
});
} else {
errorAlert(context, "Delete Failed",
"Permission Assignment Deletion Failed", () {
Navigator.of(context).pop();
context
.read<PermissionAssignmentBloc>()
.add(GetPermissionAssignments());
});
}
}
if (state is PermissionAssignmentAddedState) {
if (state.status['success']) {
successAlert(context, "Add Successfull!",
"Permission Assignment Added Successfully", () {
Navigator.of(context).pop();
context
.read<PermissionAssignmentBloc>()
.add(GetPermissionAssignments());
});
} else {
errorAlert(context, "Adding Failed",
"Permission Assignment Adding Failed", () {
Navigator.of(context).pop();
context
.read<PermissionAssignmentBloc>()
.add(GetPermissionAssignments());
});
}
}
},
builder: (context, state) {
if (state is PermissionAssignmentLoadedState) {
if (state.permissionAssignments.isNotEmpty) {
permissions = state.permissions;
roles = state.roles;
permissionAssignments = {};
for (var permissionAssignment in state.permissionAssignments) {
if (!permissionAssignments.keys.contains(
permissionAssignment.role!.name!.toLowerCase())) {
permissionAssignments.addAll(
{permissionAssignment.role!.name!.toLowerCase(): []});
permissionAssignments[
permissionAssignment.role!.name!.toLowerCase()]!
.add(Content(
id: permissionAssignment.id!,
name:
"${permissionAssignment.permission!.object!.name} - ${permissionAssignment.permission!.operation!.name} "));
} else {
permissionAssignments[
permissionAssignment.role!.name!.toLowerCase()]!
.add(Content(
id: permissionAssignment.id!,
name:
"${permissionAssignment.permission!.object!.name} - ${permissionAssignment.permission!.operation!.name} "));
}
}
return GroupListView(
sectionsCount: permissionAssignments.keys.toList().length,
countOfItemInSection: (int section) {
return permissionAssignments.values
.toList()[section]
.length;
},
itemBuilder: (BuildContext context, IndexPath index) {
return ListTile(
dense: true,
trailing: IconButton(
color: Colors.grey.shade600,
icon: const Icon(Icons.delete),
onPressed: () {
confirmAlert(context, () {
context.read<PermissionAssignmentBloc>().add(
DeletePermissionAssignment(
id: permissionAssignments.values
.toList()[index.section][index.index]
.id));
}, "Delete?", "Confirm Delete?");
},
),
title: Row(
children: [
CircleAvatar(
child: Text("${index.index + 1}",
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(color: Colors.white))),
const SizedBox(
width: 20,
),
Expanded(
child: Text(
permissionAssignments.values
.toList()[index.section][index.index]
.name
.toUpperCase(),
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(color: primary),
),
),
],
),
);
},
separatorBuilder: (context, index) {
return const Divider();
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: Colors.white,
title: Text(
permissionAssignments.keys
.toList()[section]
.toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
color: primary, fontWeight: FontWeight.bold),
),
);
},
);
} else {
const EmptyData(
message:
"Permission Assignment available. Please click + to add",
);
}
}
if (state is PermissionAssignmentErrorState) {
return SomethingWentWrong(
message: state.message,
onpressed: () {
context
.read<PermissionAssignmentBloc>()
.add(GetPermissionAssignments());
});
}
return Container();
},
),
),
);
}
}
class Content {
final int id;
final String name;
const Content({required this.id, required this.name});
}

View File

@ -25,6 +25,7 @@ class RbacRoleScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bloc = BlocProvider.of<RoleBloc>(context);
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
List<RBAC> roles = []; List<RBAC> roles = [];
return Scaffold( return Scaffold(
@ -32,16 +33,181 @@ class RbacRoleScreen extends StatelessWidget {
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Role Screen"), title: const Text("Role Screen"),
actions: [ actions:
context.watch<RoleBloc>().state is RoleLoadingState ||
context.watch<RoleBloc>().state is RoleErrorState ||
context.watch<RoleBloc>().state is RoleDeletedState? ||
context.watch<RoleBloc>().state is RoleAddedState? ||
context.watch<RoleBloc>().state is RoleUpdatedState
? []
: [
IconButton( IconButton(
onPressed: () { onPressed: () {
showSearch( showSearch(
context: context, context: context,
delegate: SearchPage( delegate: SearchPage(
barTheme: ThemeData(cardColor: primary), barTheme: ThemeData(cardColor: Colors.white),
builder: (RBAC rbac) { builder: (RBAC rbac) {
return ListTile( return Column(
title: Text(rbac.name!), children: [
Container(
width: screenWidth,
decoration: box1(),
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: Text(rbac.name!,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
fontWeight:
FontWeight
.w500,
color: primary)),
),
],
)),
AppPopupMenu<int>(
offset: const Offset(-10, -10),
elevation: 3,
onSelected: (value) {
if (value == 2) {
showDialog(
context: context,
builder: (BuildContext
context) {
return AlertDialog(
title: const Text(
"Update Role"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize:
MainAxisSize
.min,
children: [
FormBuilderTextField(
initialValue:
rbac.name,
name:
"object_name",
decoration: normalTextFieldStyle(
"Role name *",
"Role name "),
validator: FormBuilderValidators
.required(
errorText:
"This field is required"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.slug,
name: "slug",
decoration:
normalTextFieldStyle(
"Slug ",
"Slug"),
),
const SizedBox(
height: 8,
),
FormBuilderTextField(
initialValue:
rbac.shorthand,
validator: FormBuilderValidators
.maxLength(
50,
errorText:
"Max characters only 50"),
name:
"shorthand",
decoration: normalTextFieldStyle(
"Shorthand ",
"Shorthand"),
),
const SizedBox(
height: 12,
),
SizedBox(
width: double
.infinity,
height: 50,
child: ElevatedButton(
style: mainBtnStyle(primary, Colors.transparent, second),
onPressed: () {
if (formKey
.currentState!
.saveAndValidate()) {
Navigator.pop(context);
String
name =
formKey.currentState!.value['object_name'];
String?
slug =
formKey.currentState!.value['slug'];
String?
short =
formKey.currentState!.value['shorthand'];
bloc.add(UpdateRbacRole(
roleId: rbac.id!,
name: name,
slug: slug,
short: short,
createdBy: rbac.createdBy?.id,
updatedBy: id));
Navigator.pop(context);
}
},
child: const Text("Update"))),
],
),
),
);
});
}
if (value == 1) {
confirmAlert(context, () {
Navigator.pop(context);
bloc
.add(DeleteRbacRole(
roleId: rbac.id!));
}, "Delete?",
"Confirm Delete?");
}
},
menuItems: [
popMenuItem(
text: "Update",
value: 2,
icon: Icons.edit),
popMenuItem(
text: "Remove",
value: 1,
icon: Icons.delete),
],
icon: const Icon(
Icons.more_vert,
color: Colors.grey,
),
tooltip: "Options",
),
],
),
),
const SizedBox(
height: 5,
)
],
); );
}, },
filter: (RBAC rbac) { filter: (RBAC rbac) {
@ -82,17 +248,20 @@ class RbacRoleScreen extends StatelessWidget {
), ),
FormBuilderTextField( FormBuilderTextField(
name: "slug", name: "slug",
decoration: normalTextFieldStyle("Slug ", "Slug"), decoration:
normalTextFieldStyle("Slug ", "Slug"),
), ),
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
FormBuilderTextField( FormBuilderTextField(
validator: FormBuilderValidators.maxLength(50, validator:
errorText: "Max characters only 50"), FormBuilderValidators.maxLength(50,
errorText:
"Max characters only 50"),
name: "shorthand", name: "shorthand",
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Shorthand ", "Shorthand"), "Shorthand ", "Shorthand"),
), ),
const SizedBox( const SizedBox(
height: 12, height: 12,
@ -101,18 +270,22 @@ class RbacRoleScreen extends StatelessWidget {
width: double.infinity, width: double.infinity,
height: 50, height: 50,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate()) { .saveAndValidate()) {
String name = formKey String name = formKey
.currentState!.value['object_name']; .currentState!
String? slug = .value['object_name'];
formKey.currentState!.value['slug']; String? slug = formKey
.currentState!
.value['slug'];
String? short = formKey String? short = formKey
.currentState!.value['shorthand']; .currentState!
parent.read<RoleBloc>().add(AddRbacRole( .value['shorthand'];
parent.read<RoleBloc>().add(
AddRbacRole(
id: id, id: id,
name: name, name: name,
shorthand: short, shorthand: short,

View File

@ -36,7 +36,7 @@ class RbacRoleAssignment extends StatelessWidget {
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("User Roles Screens"), title: const Text("User Roles Screens"),
actions: [ actions: context.watch<RoleAssignmentBloc>().state is RoleAssignmentLoadingState || context.watch<RoleAssignmentBloc>().state is RoleAssignmentErrorState || context.watch<RoleAssignmentBloc>().state is UserNotExistError || context.watch<RoleAssignmentBloc>().state is RoleAddedState? []: [
AddLeading(onPressed: () { AddLeading(onPressed: () {
BuildContext parent = context; BuildContext parent = context;
showDialog( showDialog(
@ -131,13 +131,13 @@ class RbacRoleAssignment extends StatelessWidget {
if (state is AssignedRoleDeletedState) { if (state is AssignedRoleDeletedState) {
if (state.success) { if (state.success) {
successAlert(context, "Delete Successfull!", successAlert(context, "Delete Successfull!",
"Role Module Deleted Successfully", () { "Role Deleted Successfully", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<RoleAssignmentBloc>().add(LoadAssignedRole()); context.read<RoleAssignmentBloc>().add(LoadAssignedRole());
}); });
} else { } else {
errorAlert( errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () { context, "Delete Failed", "Role Deletion Failed", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<RoleAssignmentBloc>().add(LoadAssignedRole()); context.read<RoleAssignmentBloc>().add(LoadAssignedRole());
}); });

View File

@ -36,7 +36,7 @@ class RbacRoleExtendScreen extends StatelessWidget {
elevation: 0, elevation: 0,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Role Extend"), title: const Text("Role Extend"),
actions: [ actions: context.watch<RoleExtendBloc>().state is RoleExtendLoadingState || context.watch<RoleExtendBloc>().state is RoleExtendErrorState || context.watch<RoleExtendBloc>().state is RoleExtendAddedState || context.watch<RoleExtendBloc>().state is RoleExtendDeletedState? []:[
AddLeading(onPressed: () { AddLeading(onPressed: () {
showDialog( showDialog(
context: NavigationService.navigatorKey.currentState!.context, context: NavigationService.navigatorKey.currentState!.context,
@ -49,6 +49,7 @@ class RbacRoleExtendScreen extends StatelessWidget {
content: FormBuilder( content: FormBuilder(
key: formKey, key: formKey,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
FormBuilderDropdown<RBAC>( FormBuilderDropdown<RBAC>(

View File

@ -34,11 +34,19 @@ class RbacRoleModuleScreen extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: primary, backgroundColor: primary,
title: const Text("Role Modules Screen"), title: const Text("Role Module Screen" ),
actions: [ centerTitle: true,
actions: context.watch<RoleModuleBloc>().state
is RoleModuleLoadingState ||
context.watch<RoleModuleBloc>().state is RoleModuleErrorState ||
context.watch<RoleModuleBloc>().state is RoleModuleAddedState ||
context.watch<RoleModuleBloc>().state is RoleModuleDeletedState
? []
: [
AddLeading(onPressed: () { AddLeading(onPressed: () {
showDialog( showDialog(
context: NavigationService.navigatorKey.currentState!.context, context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) { builder: (BuildContext context) {
valueItemModules = modules.map((e) { valueItemModules = modules.map((e) {
return ValueItem(label: e.name!, value: e.name); return ValueItem(label: e.name!, value: e.name);
@ -54,7 +62,8 @@ class RbacRoleModuleScreen extends StatelessWidget {
validator: FormBuilderValidators.required( validator: FormBuilderValidators.required(
errorText: "This field is required"), errorText: "This field is required"),
name: "role", name: "role",
decoration: normalTextFieldStyle("Role", "Role"), decoration:
normalTextFieldStyle("Role", "Role"),
items: roles.isEmpty items: roles.isEmpty
? [] ? []
: roles.map((e) { : roles.map((e) {
@ -71,7 +80,8 @@ class RbacRoleModuleScreen extends StatelessWidget {
MultiSelectDropDown( MultiSelectDropDown(
onOptionSelected: onOptionSelected:
(List<ValueItem> selectedOptions) { (List<ValueItem> selectedOptions) {
selectedValueItemModules = selectedOptions; selectedValueItemModules =
selectedOptions;
}, },
borderColor: Colors.grey, borderColor: Colors.grey,
borderWidth: 1, borderWidth: 1,
@ -80,10 +90,11 @@ class RbacRoleModuleScreen extends StatelessWidget {
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
options: valueItemModules, options: valueItemModules,
selectionType: SelectionType.multi, selectionType: SelectionType.multi,
chipConfig: chipConfig: const ChipConfig(
const ChipConfig(wrapType: WrapType.wrap), wrapType: WrapType.wrap),
dropdownHeight: 300, dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16), optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon: selectedOptionIcon:
const Icon(Icons.check_circle), const Icon(Icons.check_circle),
), ),
@ -94,20 +105,23 @@ class RbacRoleModuleScreen extends StatelessWidget {
height: 50, height: 50,
width: double.maxFinite, width: double.maxFinite,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
if (formKey.currentState! if (formKey.currentState!
.saveAndValidate() && .saveAndValidate() &&
selectedValueItemModules.isNotEmpty) { selectedValueItemModules
.isNotEmpty) {
int assignerId = id; int assignerId = id;
int roleId = selectedRole!.id!; int roleId = selectedRole!.id!;
List<int> modulesId = []; List<int> modulesId = [];
for (var module in modules) { for (var module in modules) {
selectedValueItemModules selectedValueItemModules
.forEach((element) { .forEach((element) {
if (element.label.toLowerCase() == if (element.label
module.name?.toLowerCase()) { .toLowerCase() ==
module.name
?.toLowerCase()) {
modulesId.add(module.id!); modulesId.add(module.id!);
} }
}); });
@ -156,7 +170,7 @@ class RbacRoleModuleScreen extends StatelessWidget {
}); });
} else { } else {
errorAlert( errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () { context, "Delete Failed", "Role Module Deletion Failed", () {
Navigator.of(context).pop(); Navigator.of(context).pop();
context.read<RoleModuleBloc>().add(GetRoleModules()); context.read<RoleModuleBloc>().add(GetRoleModules());
}); });
@ -258,19 +272,21 @@ class RbacRoleModuleScreen extends StatelessWidget {
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.titleMedium! .titleMedium!
.copyWith(color: primary,fontWeight: FontWeight.bold), .copyWith(
color: primary, fontWeight: FontWeight.bold),
), ),
); );
}, },
); );
} else { } else {
return const EmptyData( return const EmptyData(
message: "No Role available. Please click + to add."); message: "No Role Module available. Please click + to add.");
} }
} }
if (state is RoleModuleErrorState) { if (state is RoleModuleErrorState) {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, onpressed: () { message: state.message,
onpressed: () {
context.read<RoleModuleBloc>().add(GetRoleModules()); context.read<RoleModuleBloc>().add(GetRoleModules());
}); });
} }

View File

@ -0,0 +1,307 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
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:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.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/btn-style.dart';
import '../../../theme-data.dart/colors.dart';
import '../../../theme-data.dart/form-style.dart';
import '../../../utils/alerts.dart';
import '../../../utils/global_context.dart';
import '../../../widgets/empty_data.dart';
class RbacRoleUnderScreen extends StatelessWidget {
final int id;
const RbacRoleUnderScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
final parent = context;
Map<String, List<Content>> rolesUnder = {};
List<RBAC> roles = [];
RBAC? selectedRole;
List<ValueItem> valueItemRoles = [];
List<ValueItem> selectedValueItemRoles = [];
final formKey = GlobalKey<FormBuilderState>();
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Assignable Roles"),
actions: context.watch<RolesUnderBloc>().state
is RoleUnderLoadingState? ||
context.watch<RolesUnderBloc>().state is RoleUnderErrorState ||
context.watch<RolesUnderBloc>().state
is RoleUnderDeletedState ||
context.watch<RolesUnderBloc>().state is RoleUnderAddedState
? []
: [
AddLeading(onPressed: () {
showDialog(
context:
NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemRoles = roles.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Role Under"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration: normalTextFieldStyle(
"Main Role", "Main Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemRoles = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Roles Under",
padding: const EdgeInsets.all(8),
options: valueItemRoles,
selectionType: SelectionType.multi,
chipConfig: const ChipConfig(
wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle:
const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(primary,
Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemRoles
.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> rolesId = [];
for (var role in roles) {
selectedValueItemRoles
.forEach((element) {
if (element.label
.toLowerCase() ==
role.name?.toLowerCase()) {
rolesId.add(role.id!);
}
});
}
Navigator.of(context).pop();
parent.read<RolesUnderBloc>().add(
AddRoleUnder(
roleId: roleId,
roleUnderIds: rolesId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<RolesUnderBloc, RolesUnderState>(
listener: (context, state) {
if (state is RoleUnderLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is RoleUnderLoadedState ||
state is RoleUnderErrorState ||
state is RoleUnderDeletedState ||
state is RoleUnderAddedState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////Deleted State
if (state is RoleUnderDeletedState) {
if (state.success) {
successAlert(
context, "Delete Successfull!", "Role Deleted Successfully",
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
////Added State
if (state is RoleUnderAddedState) {
if (state.response['success']) {
successAlert(
context, "Adding Successfull!", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(context, "Adding Failed", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
},
builder: (context, state) {
if (state is RoleUnderLoadedState) {
rolesUnder = {};
roles = state.roles;
if (state.rolesUnder.isNotEmpty) {
for (var roleUnder in state.rolesUnder) {
if (!rolesUnder.keys
.contains(roleUnder.roleUnderMain.name!.toLowerCase())) {
rolesUnder.addAll(
{roleUnder.roleUnderMain.name!.toLowerCase(): []});
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
} else {
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
}
}
}
if (state.rolesUnder.isNotEmpty) {
return GroupListView(
sectionsCount: rolesUnder.keys.toList().length,
countOfItemInSection: (int section) {
return rolesUnder.values.toList()[section].length;
},
itemBuilder: (BuildContext context, IndexPath index) {
return ListTile(
trailing: IconButton(
color: Colors.grey.shade500,
icon: const Icon(Icons.delete),
onPressed: () {
confirmAlert(context,(){
context.read<RolesUnderBloc>().add(DeleteRoleUnder(roleUnderId:rolesUnder.values .toList()[index.section][index.index].id));
}, "Delete", "Delete Role?");
},
),
title: Row(
children: [
CircleAvatar(
child: Text("${index.index + 1}",
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(color: Colors.white))),
const SizedBox(
width: 20,
),
Expanded(
child: Text(
rolesUnder.values
.toList()[index.section][index.index]
.name
.toUpperCase(),
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)),
),
],
),
);
},
separatorBuilder: (context, index) {
return const Divider();
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: Colors.white,
dense: true,
title: Text(
rolesUnder.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(
color: primary, fontWeight: FontWeight.bold),
),
);
},
);
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
}
}
if (state is RoleUnderErrorState) {
return SomethingWentWrong(
message: state.message,
onpressed: () {
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
return Container();
},
),
),
);
}
}
class Content {
final int id;
final String name;
const Content({required this.id, required this.name});
}

View File

@ -1,296 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
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:group_list_view/group_list_view.dart';
import 'package:multi_dropdown/multiselect_dropdown.dart';
import 'package:unit2/bloc/rbac/rbac_operations/roles_under/roles_under_bloc.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/btn-style.dart';
import '../../../theme-data.dart/colors.dart';
import '../../../theme-data.dart/form-style.dart';
import '../../../utils/alerts.dart';
import '../../../utils/global_context.dart';
import '../../../widgets/empty_data.dart';
class RbacRoleUnderScreen extends StatelessWidget {
final int id;
const RbacRoleUnderScreen({super.key, required this.id});
@override
Widget build(BuildContext context) {
final parent = context;
Map<String, List<Content>> rolesUnder = {};
List<RBAC> roles = [];
RBAC? selectedRole;
List<ValueItem> valueItemRoles = [];
List<ValueItem> selectedValueItemRoles = [];
final formKey = GlobalKey<FormBuilderState>();
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: primary,
title: const Text("Assignable Roles"),
actions: [
AddLeading(onPressed: () {
showDialog(
context: NavigationService.navigatorKey.currentState!.context,
builder: (BuildContext context) {
valueItemRoles = roles.map((e) {
return ValueItem(label: e.name!, value: e.name);
}).toList();
return AlertDialog(
title: const Text("Add Role Under"),
content: FormBuilder(
key: formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FormBuilderDropdown<RBAC>(
validator: FormBuilderValidators.required(
errorText: "This field is required"),
name: "role",
decoration: normalTextFieldStyle(
"Main Role", "Main Role"),
items: roles.isEmpty
? []
: roles.map((e) {
return DropdownMenuItem(
value: e, child: Text(e.name!));
}).toList(),
onChanged: (RBAC? role) {
selectedRole = role;
},
),
const SizedBox(
height: 12,
),
MultiSelectDropDown(
onOptionSelected:
(List<ValueItem> selectedOptions) {
selectedValueItemRoles = selectedOptions;
},
borderColor: Colors.grey,
borderWidth: 1,
borderRadius: 5,
hint: "Roles Under",
padding: const EdgeInsets.all(8),
options: valueItemRoles,
selectionType: SelectionType.multi,
chipConfig:
const ChipConfig(wrapType: WrapType.wrap),
dropdownHeight: 300,
optionTextStyle: const TextStyle(fontSize: 16),
selectedOptionIcon:
const Icon(Icons.check_circle),
),
const SizedBox(
height: 12,
),
SizedBox(
height: 50,
width: double.maxFinite,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {
if (formKey.currentState!
.saveAndValidate() &&
selectedValueItemRoles.isNotEmpty) {
int assignerId = id;
int roleId = selectedRole!.id!;
List<int> rolesId = [];
for (var role in roles) {
selectedValueItemRoles
.forEach((element) {
if (element.label.toLowerCase() ==
role.name?.toLowerCase()) {
rolesId.add(role.id!);
}
});
}
Navigator.of(context).pop();
parent.read<RolesUnderBloc>().add(
AddRoleUnder(
roleId: roleId,
roleUnderIds: rolesId));
}
},
child: const Text("Submit")),
)
],
)),
);
});
})
],
),
body: ProgressHUD(
padding: const EdgeInsets.all(24),
backgroundColor: Colors.black87,
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<RolesUnderBloc, RolesUnderState>(
listener: (context, state) {
if (state is RoleUnderLoadingState) {
final progress = ProgressHUD.of(context);
progress!.showWithText("Please wait...");
}
if (state is RoleUnderLoadedState ||
state is RoleUnderErrorState ||
state is RoleUnderDeletedState ||
state is RoleUnderAddedState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
////Deleted State
if (state is RoleUnderDeletedState) {
if (state.success) {
successAlert(context, "Delete Successfull!",
"Role Deleted Successfully", () {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(
context, "Delete Failed", "Role Module Delete Failed", () {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
////Added State
if (state is RoleUnderAddedState) {
if (state.response['success']) {
successAlert(
context, "Adding Successfull!", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
} else {
errorAlert(context, "Adding Failed", state.response['message'],
() {
Navigator.of(context).pop();
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
}
},
builder: (context, state) {
if (state is RoleUnderLoadedState) {
rolesUnder = {};
roles = state.roles;
if (state.rolesUnder.isNotEmpty) {
for (var roleUnder in state.rolesUnder) {
if (!rolesUnder.keys
.contains(roleUnder.roleUnderMain.name!.toLowerCase())) {
rolesUnder.addAll(
{roleUnder.roleUnderMain.name!.toLowerCase(): []});
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
} else {
rolesUnder[roleUnder.roleUnderMain.name!.toLowerCase()]!
.add(Content(
id: roleUnder.id,
name: roleUnder.roleUnderChild.name!));
}
}
}
if (state.rolesUnder.isNotEmpty) {
return GroupListView(
sectionsCount: rolesUnder.keys.toList().length,
countOfItemInSection: (int section) {
return rolesUnder.values.toList()[section].length;
},
itemBuilder: (BuildContext context, IndexPath index) {
return ListTile(
trailing: IconButton(
color: Colors.grey.shade500,
icon: const Icon(Icons.delete),
onPressed: () {
context.read<RolesUnderBloc>().add(DeleteRoleUnder(
roleUnderId: rolesUnder.values
.toList()[index.section][index.index]
.id));
},
),
title: Row(
children: [
CircleAvatar(
child: Text("${index.index + 1}",
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(color: Colors.white))),
const SizedBox(
width: 20,
),
Expanded(
child: Text(
rolesUnder.values
.toList()[index.section][index.index]
.name
.toUpperCase(),
style: Theme.of(context)
.textTheme
.labelLarge!
.copyWith(
fontWeight: FontWeight.w500,
color: primary)
),
),
],
),
);
},
separatorBuilder: (context, index) {
return const Divider();
},
groupHeaderBuilder: (BuildContext context, int section) {
return ListTile(
tileColor: Colors.white,
dense: true,
title: Text(
rolesUnder.keys.toList()[section].toUpperCase(),
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(color: primary,fontWeight: FontWeight.bold),
),
);
},
);
} else {
return const EmptyData(
message: "No Role available. Please click + to add.");
}
}
if (state is RoleUnderErrorState) {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<RolesUnderBloc>().add(GetRolesUnder());
});
}
return Container();
},
),
),
);
}
}
class Content {
final int id;
final String name;
const Content({required this.id, required this.name});
}

View File

@ -5,7 +5,6 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:searchfield/searchfield.dart'; import 'package:searchfield/searchfield.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/station/station_bloc.dart';
import 'package:unit2/model/rbac/rbac_station.dart'; import 'package:unit2/model/rbac/rbac_station.dart';
import 'package:unit2/model/utils/agency.dart'; import 'package:unit2/model/utils/agency.dart';
@ -62,7 +61,12 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
centerTitle: true, centerTitle: true,
backgroundColor: primary, backgroundColor: primary,
title: const Text("Station Screen"), title: const Text("Station Screen"),
actions: [ actions: context.watch<StationBloc>().state is StationLoadingState ||
context.watch<StationBloc>().state is StationErrorState ||
context.watch<StationBloc>().state is RbacStationAddedState ||
context.watch<StationBloc>().state is FilterStationState
? []
: [
AddLeading(onPressed: () { AddLeading(onPressed: () {
BuildContext parent = context; BuildContext parent = context;
mainParentStations = []; mainParentStations = [];
@ -82,7 +86,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
content: SingleChildScrollView( content: SingleChildScrollView(
child: FormBuilder( child: FormBuilder(
key: formKey, key: formKey,
child: StatefulBuilder(builder: (context, setState) { child:
StatefulBuilder(builder: (context, setState) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -119,7 +124,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
: mainParentStations.map((e) { : mainParentStations.map((e) {
return DropdownMenuItem( return DropdownMenuItem(
value: e, value: e,
child: Text(e.stationName!), child: Text(
e.stationName!),
); );
}).toList(), }).toList(),
onChanged: (RbacStation? e) { onChanged: (RbacStation? e) {
@ -128,18 +134,20 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
parentStations = []; parentStations = [];
for (RbacStation station for (RbacStation station
in stations) { in stations) {
if (station.mainParentStation == if (station
.mainParentStation ==
selectedMainParentStation! selectedMainParentStation!
.id) { .id) {
parentStations.add(station); parentStations
.add(station);
} }
} }
parentStations.add( parentStations.add(
selectedMainParentStation!); selectedMainParentStation!);
}); });
}, },
validator: validator: FormBuilderValidators
FormBuilderValidators.required( .required(
errorText: errorText:
"This field is required"), "This field is required"),
), ),
@ -153,7 +161,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
? const SizedBox.shrink() ? const SizedBox.shrink()
: FormBuilderDropdown<RbacStation>( : FormBuilderDropdown<RbacStation>(
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Parent Station", "Parent Station"), "Parent Station",
"Parent Station"),
name: "parent-stations", name: "parent-stations",
onChanged: (RbacStation? e) { onChanged: (RbacStation? e) {
setState(() { setState(() {
@ -165,11 +174,12 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
: parentStations.map((e) { : parentStations.map((e) {
return DropdownMenuItem( return DropdownMenuItem(
value: e, value: e,
child: Text(e.stationName!), child: Text(
e.stationName!),
); );
}).toList(), }).toList(),
validator: validator: FormBuilderValidators
FormBuilderValidators.required( .required(
errorText: errorText:
"This field is required"), "This field is required"),
), ),
@ -180,20 +190,22 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
////Station Type ////Station Type
SearchField( SearchField(
itemHeight: 50, itemHeight: 50,
suggestionsDecoration: box1(), suggestionsDecoration:
searchFieldDecoration(),
suggestions: stationTypes suggestions: stationTypes
.map((StationType stationType) => .map((StationType stationType) =>
SearchFieldListItem( SearchFieldListItem(
stationType.typeName!, stationType.typeName!,
item: stationType, item: stationType,
child: Padding( child: Padding(
padding: padding: const EdgeInsets
const EdgeInsets.symmetric( .symmetric(
horizontal: 10), horizontal: 10),
child: ListTile( child: ListTile(
title: Text( title: Text(
stationType.typeName!, stationType.typeName!,
overflow: TextOverflow.visible, overflow:
TextOverflow.visible,
)), )),
))) )))
.toList(), .toList(),
@ -205,11 +217,14 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
}, },
focusNode: stationTypeFocusNode, focusNode: stationTypeFocusNode,
searchInputDecoration: searchInputDecoration:
normalTextFieldStyle("Station Type *", "") normalTextFieldStyle(
"Station Type *", "")
.copyWith( .copyWith(
suffixIcon: GestureDetector( suffixIcon: GestureDetector(
onTap: () => stationTypeFocusNode.unfocus(), onTap: () =>
child: const Icon(Icons.arrow_drop_down), stationTypeFocusNode.unfocus(),
child:
const Icon(Icons.arrow_drop_down),
)), )),
onSuggestionTap: (position) { onSuggestionTap: (position) {
setState(() { setState(() {
@ -222,10 +237,12 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
controller: addStationTypeController, controller: addStationTypeController,
onpressed: () { onpressed: () {
setState(() { setState(() {
StationType stationType = StationType( StationType stationType =
StationType(
id: null, id: null,
typeName: typeName:
addStationTypeController.text, addStationTypeController
.text,
color: null, color: null,
order: null, order: null,
isActive: null, isActive: null,
@ -269,7 +286,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
"Location of the station within this parent?", "Location of the station within this parent?",
'Location of the station within this parent?'), 'Location of the station within this parent?'),
name: 'isWithinParent', name: 'isWithinParent',
title: Text(isWithinParent ? "YES" : "NO"), title:
Text(isWithinParent ? "YES" : "NO"),
), ),
const SizedBox( const SizedBox(
height: 12, height: 12,
@ -279,12 +297,13 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
children: [ children: [
Flexible( Flexible(
child: FormBuilderTextField( child: FormBuilderTextField(
validator: validator: FormBuilderValidators
FormBuilderValidators.required( .required(
errorText: errorText:
"This Field is required"), "This Field is required"),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Station name", "Station name"), "Station name",
"Station name"),
name: "station-name"), name: "station-name"),
), ),
const SizedBox( const SizedBox(
@ -293,8 +312,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
//// Acronym //// Acronym
Flexible( Flexible(
child: FormBuilderTextField( child: FormBuilderTextField(
validator: validator: FormBuilderValidators
FormBuilderValidators.required( .required(
errorText: errorText:
"This Field is required"), "This Field is required"),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
@ -348,10 +367,11 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
isHospital = !isHospital; isHospital = !isHospital;
}); });
}, },
decoration: decoration: normalTextFieldStyle(
normalTextFieldStyle("Is Hospital", ''), "Is Hospital", ''),
name: 'isHospital', name: 'isHospital',
title: Text(isHospital == true ? "YES" : "NO"), title: Text(
isHospital == true ? "YES" : "NO"),
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
@ -360,8 +380,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
width: double.infinity, width: double.infinity,
height: 50, height: 50,
child: ElevatedButton( child: ElevatedButton(
style: mainBtnStyle( style: mainBtnStyle(primary,
primary, Colors.transparent, second), Colors.transparent, second),
onPressed: () { onPressed: () {
RbacStation? newStation; RbacStation? newStation;
if (formKey.currentState! if (formKey.currentState!
@ -370,25 +390,30 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
.currentState! .currentState!
.value['station-name']; .value['station-name'];
String? acronym = formKey String? acronym = formKey
.currentState!.value['acronym'];
String? code = formKey
.currentState!.value['code'];
String? fullcode = formKey
.currentState!.value['fullcode'];
String? description = formKey
.currentState! .currentState!
.value['station-description']; .value['acronym'];
String? code = formKey
.currentState!
.value['code'];
String? fullcode = formKey
.currentState!
.value['fullcode'];
String? description =
formKey.currentState!.value[
'station-description'];
newStation = RbacStation( newStation = RbacStation(
id: null, id: null,
stationName: stationName, stationName: stationName,
stationType: selectedStationType, stationType:
selectedStationType,
hierarchyOrderNo: mainParent hierarchyOrderNo: mainParent
? 1 ? 1
: selectedParentStation! : selectedParentStation!
.hierarchyOrderNo! + .hierarchyOrderNo! +
1, 1,
headPosition: headPosition:
selectedPositiontitle?.title, selectedPositiontitle
?.title,
governmentAgency: governmentAgency:
GovernmentAgency( GovernmentAgency(
agencyid: agencyid:
@ -396,11 +421,14 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
agencyname: null, agencyname: null,
agencycatid: null, agencycatid: null,
privateEntity: null, privateEntity: null,
contactinfoid: null), contactinfoid:
null),
acronym: acronym, acronym: acronym,
parentStation: mainParent parentStation:
mainParent
? null ? null
: selectedParentStation!.id!, : selectedParentStation!
.id!,
code: code, code: code,
fullcode: fullcode, fullcode: fullcode,
childStationInfo: null, childStationInfo: null,
@ -415,7 +443,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
isactive: true, isactive: true,
sellingStation: null); sellingStation: null);
Navigator.pop(context); Navigator.pop(context);
rbacStationBloc.add(AddRbacStation( rbacStationBloc.add(
AddRbacStation(
station: newStation)); station: newStation));
} }
}, },
@ -444,7 +473,9 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
Padding( Padding(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
child: SearchField( child: SearchField(
inputFormatters: [UpperCaseTextFormatter()], inputFormatters: [
UpperCaseTextFormatter()
],
itemHeight: 100, itemHeight: 100,
focusNode: agencyFocusNode, focusNode: agencyFocusNode,
suggestions: agencies suggestions: agencies
@ -454,12 +485,14 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
child: ListTile( child: ListTile(
title: Text( title: Text(
agency.name!, agency.name!,
overflow: TextOverflow.visible, overflow:
TextOverflow.visible,
), ),
))) )))
.toList(), .toList(),
searchInputDecoration: searchInputDecoration:
normalTextFieldStyle("Filter", "").copyWith( normalTextFieldStyle("Filter", "")
.copyWith(
suffixIcon: IconButton( suffixIcon: IconButton(
icon: const Icon(Icons.arrow_drop_down), icon: const Icon(Icons.arrow_drop_down),
onPressed: () { onPressed: () {
@ -651,7 +684,8 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
children: [ children: [
Padding( Padding(
padding: padding:
const EdgeInsets.all( const EdgeInsets
.all(
6), 6),
child: child:
Text( Text(
@ -872,7 +906,9 @@ class _RbacStationScreenState extends State<RbacStationScreen> {
return SomethingWentWrong( return SomethingWentWrong(
message: state.message, message: state.message,
onpressed: () { onpressed: () {
context.read<StationBloc>().add(GetStations(agencyId: selectedAgencyId)); context
.read<StationBloc>()
.add(GetStations(agencyId: selectedAgencyId));
}); });
} }

View File

@ -6,7 +6,6 @@ import 'package:flutter_svg/svg.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:signature/signature.dart';
import 'package:unit2/model/login_data/user_info/user_data.dart'; import 'package:unit2/model/login_data/user_info/user_data.dart';
import 'package:unit2/screens/unit2/basic-info/components/qr_image.dart'; import 'package:unit2/screens/unit2/basic-info/components/qr_image.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
@ -46,45 +45,45 @@ class BasicInfo extends StatelessWidget {
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
const CoverImage(), const CoverImage(),
// Positioned( Positioned(
// top: blockSizeVertical * 15.5, top: blockSizeVertical * 15.5,
// child: Stack( child: Stack(
// alignment: Alignment.center, alignment: Alignment.center,
// children: [ children: [
// CachedNetworkImage( CachedNetworkImage(
// imageUrl: fileUrl, imageUrl: fileUrl,
// imageBuilder: (context, imageProvider) => imageBuilder: (context, imageProvider) =>
// Container( Container(
// width: 160, width: 160,
// height: 160, height: 160,
// decoration: BoxDecoration( decoration: BoxDecoration(
// border: Border.all( border: Border.all(
// color: Colors.black26, width: 3), color: Colors.black26, width: 3),
// shape: BoxShape.circle, shape: BoxShape.circle,
// image: DecorationImage( image: DecorationImage(
// image: imageProvider, image: imageProvider,
// fit: BoxFit.cover), fit: BoxFit.cover),
// ), ),
// ), ),
// placeholder: (context, url) => placeholder: (context, url) =>
// const CircularProgressIndicator(), const CircularProgressIndicator(),
// errorWidget: (context, url, error) => errorWidget: (context, url, error) =>
// Container( Container(
// width: 160, width: 160,
// height: 160, height: 160,
// decoration: BoxDecoration( decoration: BoxDecoration(
// border: Border.all( border: Border.all(
// color: Colors.white, width: 3), color: Colors.white, width: 3),
// shape: BoxShape.circle, shape: BoxShape.circle,
// ), ),
// child: SvgPicture.asset( child: SvgPicture.asset(
// 'assets/svgs/male.svg', 'assets/svgs/male.svg',
// ), ),
// ), ),
// ), ),
// ], ],
// ), ),
// ), ),
Positioned( Positioned(
top: 10, top: 10,
left: 20, left: 20,
@ -137,13 +136,14 @@ class BuildInformation extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
globalFistname = globalFistname ?? userData.user!.login!.user!.firstName!.toUpperCase(); globalFistname =
globalLastname =globalLastname ?? userData.user!.login!.user!.lastName!.toUpperCase(); globalFistname ?? userData.employeeInfo!.profile!.firstName!.toUpperCase();
globalMiddleName = globalMiddleName == null globalLastname =
? (userData.employeeInfo == null globalLastname ?? userData.employeeInfo!.profile!.lastName!.toUpperCase();
globalMiddleName = globalMiddleName ??
(userData.employeeInfo == null
? '' ? ''
: userData.employeeInfo!.profile?.middleName?.toUpperCase()) : userData.employeeInfo!.profile?.middleName?.toUpperCase());
: '';
globalSex = globalSex ?? userData.employeeInfo!.profile!.sex!.toUpperCase(); globalSex = globalSex ?? userData.employeeInfo!.profile!.sex!.toUpperCase();
globalBday = globalBday ?? userData.employeeInfo!.profile!.birthdate; globalBday = globalBday ?? userData.employeeInfo!.profile!.birthdate;
final uuid = userData.employeeInfo!.uuid; final uuid = userData.employeeInfo!.uuid;

View File

@ -10,6 +10,7 @@ import 'package:unit2/bloc/rbac/rbac_operations/module_objects/module_objects_bl
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/permission_assignment/permission_assignment_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role_extend/role_extend_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/role_extend/role_extend_bloc.dart';
import 'package:unit2/bloc/rbac/rbac_operations/role_module/role_module_bloc.dart'; import 'package:unit2/bloc/rbac/rbac_operations/role_module/role_module_bloc.dart';
@ -21,10 +22,11 @@ import 'package:unit2/screens/superadmin/module/module_screen.dart';
import 'package:unit2/screens/superadmin/object/object_screen.dart'; import 'package:unit2/screens/superadmin/object/object_screen.dart';
import 'package:unit2/screens/superadmin/operation/operation_screen.dart'; import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
import 'package:unit2/screens/superadmin/permission/permission_screen.dart'; import 'package:unit2/screens/superadmin/permission/permission_screen.dart';
import 'package:unit2/screens/superadmin/permission_assignment/permission_assignment_screen.dart';
import 'package:unit2/screens/superadmin/role/role_screen.dart'; import 'package:unit2/screens/superadmin/role/role_screen.dart';
import 'package:unit2/screens/superadmin/role_assignment.dart/role_assignment_screen.dart'; import 'package:unit2/screens/superadmin/role_assignment.dart/role_assignment_screen.dart';
import 'package:unit2/screens/superadmin/role_extend/role_extend_screen.dart'; import 'package:unit2/screens/superadmin/role_extend/role_extend_screen.dart';
import 'package:unit2/screens/superadmin/roles_under/roles_under_screen.dart'; import 'package:unit2/screens/superadmin/roles_under/assignable_roles.dart';
import 'package:unit2/screens/superadmin/stations/stations_screen.dart'; import 'package:unit2/screens/superadmin/stations/stations_screen.dart';
import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart'; import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
@ -77,7 +79,7 @@ class SuperAdminMenu extends StatelessWidget {
object.moduleName == 'superadmin' object.moduleName == 'superadmin'
? CardLabel( ? CardLabel(
icon: iconGenerator(name: object.object.name!), icon: iconGenerator(name: object.object.name!),
title: object.object.name!, title: object.object.name!.toLowerCase() == 'role based access control'? 'RBAC': object.object.name!,
ontap: () { ontap: () {
if (object.object.name == 'Role') { if (object.object.name == 'Role') {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
@ -196,7 +198,21 @@ class SuperAdminMenu extends StatelessWidget {
); );
})); }));
} }
if(object.object.name == 'Role Based Access Control'){
Navigator.pushNamed(context, '/rbac');
}
if(object.object.name == 'Permission Assignment'){
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) {
return BlocProvider(
create: (context) =>
PermissionAssignmentBloc()..add(GetPermissionAssignments()),
child: RbacPermissionAssignmentScreen(
id: id,
),
);
}));
}
if (object.object.name == 'Station') { if (object.object.name == 'Station') {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {

View File

@ -18,9 +18,9 @@ class _MenuScreenState extends State<MenuScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String firstName =globalFistname?? final String firstName =globalFistname??
widget.userData!.user!.login!.user!.firstName!.toUpperCase(); widget.userData!.employeeInfo!.profile!.firstName!.toUpperCase();
final String lastname = globalLastname?? final String lastname = globalLastname??
widget.userData!.user!.login!.user!.lastName!.toUpperCase(); widget.userData!.employeeInfo!.profile!.lastName!.toUpperCase();
return Drawer( return Drawer(
child: SizedBox( child: SizedBox(
height: screenHeight, height: screenHeight,

View File

@ -1,6 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:better_open_file/better_open_file.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:easy_app_installer/easy_app_installer.dart'; import 'package:easy_app_installer/easy_app_installer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -9,20 +11,19 @@ import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:unit2/model/login_data/version_info.dart';
import 'package:unit2/screens/unit2/login/components/showAlert.dart'; import 'package:unit2/screens/unit2/login/components/showAlert.dart';
import 'package:unit2/theme-data.dart/btn-style.dart'; import 'package:unit2/theme-data.dart/btn-style.dart';
import '../../../../bloc/user/user_bloc.dart'; import '../../../../bloc/user/user_bloc.dart';
import '../../../../theme-data.dart/colors.dart'; import '../../../../theme-data.dart/colors.dart';
import '../../../../utils/cpu_architecture.dart';
import '../../../../utils/text_container.dart';
import '../../../../widgets/wave.dart'; import '../../../../widgets/wave.dart';
class Update extends StatefulWidget { class Update extends StatefulWidget {
final String apkVersion; final String apkVersion;
final String currenVersion; final VersionInfo versionInfo;
const Update( const Update(
{super.key, required this.apkVersion, required this.currenVersion}); {super.key, required this.apkVersion, required this.versionInfo});
@override @override
State<Update> createState() => _UpdateState(); State<Update> createState() => _UpdateState();
@ -74,14 +75,14 @@ class _UpdateState extends State<Update> {
], ],
), ),
const SizedBox( const SizedBox(
height: 10, height: 25,
), ),
RichText( RichText(
textAlign: TextAlign.justify, textAlign: TextAlign.justify,
text: TextSpan( text: TextSpan(
text: 'Your app version ', text: 'Your app version ',
style: const TextStyle( style: const TextStyle(
fontSize: 16, fontSize: 14,
color: Colors.black, color: Colors.black,
), ),
children: <TextSpan>[ children: <TextSpan>[
@ -95,7 +96,7 @@ class _UpdateState extends State<Update> {
" did not match with the latest version ", " did not match with the latest version ",
style: TextStyle(color: Colors.black)), style: TextStyle(color: Colors.black)),
TextSpan( TextSpan(
text: widget.currenVersion.toString(), text: widget.versionInfo.versionInfo,
style: const TextStyle( style: const TextStyle(
color: primary, color: primary,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
@ -105,7 +106,7 @@ class _UpdateState extends State<Update> {
style: TextStyle(color: Colors.black)), style: TextStyle(color: Colors.black)),
])), ])),
const SizedBox( const SizedBox(
height: 12.0, height: 25,
), ),
Container( Container(
child: downloading child: downloading
@ -131,15 +132,20 @@ class _UpdateState extends State<Update> {
style: mainBtnStyle( style: mainBtnStyle(
primary, Colors.transparent, second), primary, Colors.transparent, second),
onPressed: () async { onPressed: () async {
final progress = ProgressHUD.of(context);
progress?.showWithText(
'Please wait...',
);
setState(() { setState(() {
downloading = true; downloading = true;
progressRating = '0'; progressRating = '0';
}); });
try {
await openFile(); await openFile();
} catch (e) {
showAlert(context, () {
setState(() {
downloading = false;
progressRating = '0';
});
});
}
}, },
label: const Text( label: const Text(
"Download Latest App Version.")), "Download Latest App Version.")),
@ -168,9 +174,9 @@ class _UpdateState extends State<Update> {
Future<void> openFile() async { Future<void> openFile() async {
try { try {
final filePath = await downloadFile(); final filePath = await downloadFile();
await openAPK(filePath); await OpenFile.open(filePath);
} catch (e) { } catch (e) {
print(e.toString()); throw e.toString();
} }
} }
@ -181,16 +187,36 @@ class _UpdateState extends State<Update> {
} }
} }
Future<String> downloadFile() async {
final progress = ProgressHUD.of(context); Future<String> getCPUArchitecture() async {
String downloadURL = "";
DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
AndroidDeviceInfo androidDeviceInfo = await deviceInfoPlugin.androidInfo;
try{
List<String> cpuArchitecture = androidDeviceInfo.supportedAbis;
if (cpuArchitecture.first == 'arm64-v8a') {
downloadURL = widget.versionInfo.arm64v8aDownloadUrl!;
}
else if (cpuArchitecture.first == 'armeabi-v7a') {
downloadURL = widget.versionInfo.armeabiv7aDownloadUrl!;
} else {
downloadURL = widget.versionInfo.x8664DownloadUrl!;
}
print(downloadURL);
}catch(e){
throw e.toString();
}
return downloadURL;
}
Future<String?> downloadFile() async {
final appStorage = await getApplicationDocumentsDirectory(); final appStorage = await getApplicationDocumentsDirectory();
String? appDir;
try { try {
String url = await getCPUArchitecture(); String url = await getCPUArchitecture();
final response = await dio.download(url, '${appStorage.path}/uniT.apk', final response = await dio.download(url, '${appStorage.path}/uniT.apk',
deleteOnError: true, deleteOnError: true,
options: Options( options: Options(
receiveTimeout: 20000,
sendTimeout: 20000,
receiveDataWhenStatusError: true, receiveDataWhenStatusError: true,
responseType: ResponseType.bytes, responseType: ResponseType.bytes,
followRedirects: false, followRedirects: false,
@ -202,47 +228,24 @@ class _UpdateState extends State<Update> {
downloading = true; downloading = true;
}); });
if (progressRating == '100') { if (progressRating == '100') {
final progress = ProgressHUD.of(context);
progress!.dismiss();
setState(() { setState(() {
downloading = false; downloading = false;
isDownloaded = true; isDownloaded = true;
}); });
} }
appDir = '${appStorage.path}/uniT.apk';
}); });
} on TimeoutException catch (_) { } on TimeoutException catch (e) {
progress!.dismiss(); throw e.toString();
showAlert(context, () { } on SocketException catch (e) {
setState(() { throw e.toString();
downloading = false; } on Error catch (e) {
}); throw e.toString();
}); } catch (e) {
throw TimeoutException(timeoutError); throw e.toString();
} on SocketException catch (_) {
progress!.dismiss();
showAlert(context, () {
setState(() {
downloading = false;
});
});
throw const SocketException(timeoutError);
} on DioError catch (_) {
progress!.dismiss();
showAlert(context, () {
setState(() {
downloading = false;
});
});
throw TimeoutException(timeoutError);
} catch (_) {
progress!.dismiss();
showAlert(context, () {
setState(() {
downloading = false;
});
});
throw TimeoutException(timeoutError);
} }
return '${appStorage.path}/uniT.apk';
return appDir!;
} }
} }

View File

@ -108,7 +108,7 @@ class _UniT2LoginState extends State<UniT2Login> {
}, builder: (context, state) { }, builder: (context, state) {
if (state is VersionLoaded) { if (state is VersionLoaded) {
return Builder(builder: (context) { return Builder(builder: (context) {
if (state.versionInfo?.version != state.apkVersion) { if (state.versionInfo?.id == state.apkVersion) {
return SizedBox( return SizedBox(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Stack( child: Stack(
@ -355,7 +355,7 @@ class _UniT2LoginState extends State<UniT2Login> {
//New update available //New update available
return Update( return Update(
apkVersion: state.apkVersion!, apkVersion: state.apkVersion!,
currenVersion: state.versionInfo!.version!, versionInfo: state.versionInfo!,
); );
} }
}); });

View File

@ -171,7 +171,7 @@ class EstPointPersonStationScreen extends StatelessWidget {
////Station Type ////Station Type
SearchField( SearchField(
itemHeight: 50, itemHeight: 50,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: stationTypes suggestions: stationTypes
.map((StationType stationType) => .map((StationType stationType) =>
SearchFieldListItem( SearchFieldListItem(

View File

@ -1,5 +1,6 @@
import 'package:assets_audio_player/assets_audio_player.dart'; import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:audioplayers/audioplayers.dart'; import 'package:audioplayers/audioplayers.dart';
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:cool_alert/cool_alert.dart'; import 'package:cool_alert/cool_alert.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';
@ -35,13 +36,13 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
player = AudioPlayer(); player = AudioPlayer();
super.initState(); super.initState();
} }
@override @override
void dispose() { void dispose() {
player?.dispose(); player?.dispose();
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -92,17 +93,18 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
context.read<PassCheckBloc>().add(ScanQr(token: state.token)); context.read<PassCheckBloc>().add(ScanQr(token: state.token));
} }
if (state is IncomingScanState) { if (state is IncomingScanState) {
CoolAlert.show( AwesomeDialog(
barrierDismissible: false, dismissOnBackKeyPress: false,
context: context, context: context,
type: CoolAlertType.loading, dialogType: DialogType.info,
text: "Enter Temperature", dismissOnTouchOutside: false,
widget: Padding( body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24), padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
child: FormBuilder( child: FormBuilder(
key: formKey, key: formKey,
child: Column( child: Column(
children: [ children: [
const Text("Enter Temperature",style: TextStyle(color: Colors.black),),
const SizedBox( const SizedBox(
height: 24, height: 24,
), ),
@ -136,20 +138,22 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
) )
], ],
)), )),
)); ),
).show();
} }
if (state is OutGoingScanState) { if (state is OutGoingScanState) {
CoolAlert.show( AwesomeDialog(
barrierDismissible: false, dismissOnBackKeyPress: false,
context: context, context: context,
type: CoolAlertType.loading, dialogType: DialogType.info,
text: "Enter Destination", dismissOnTouchOutside: false,
widget: Padding( body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24), padding: const EdgeInsets.symmetric(horizontal: 24,vertical: 24),
child: FormBuilder( child: FormBuilder(
key: formKey, key: formKey,
child: Column( child: Column(
children: [ children: [
const Text("Enter Destination"),
const SizedBox( const SizedBox(
height: 24, height: 24,
), ),
@ -185,7 +189,8 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
) )
], ],
)), )),
)); )).show();
} }
}, },
builder: (context, state) { builder: (context, state) {
@ -302,28 +307,56 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
children: [ children: [
SelectedState( SelectedState(
//TODO add api data //TODO add api data
title: state.roleIdRoleName.roleName.toLowerCase() == "41" || title: state.roleIdRoleName.roleName
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' || .toLowerCase() ==
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' || "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge' 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.assignedArea.stationName
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson' : state.roleIdRoleName.roleName
.toLowerCase() ==
'barangay chairperson'
? state.assignedArea.brgydesc ? state.assignedArea.brgydesc
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president' : state.roleIdRoleName.roleName
.toLowerCase() ==
'purok president'
? state.assignedArea.purokdesc ? state.assignedArea.purokdesc
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person' : state.roleIdRoleName.roleName
.toLowerCase() ==
'establishment point-person'
? "Agency" ? "Agency"
: "", : "",
subtitle: state.roleIdRoleName.roleName.toLowerCase() == "41" || subtitle: state.roleIdRoleName.roleName
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' || .toLowerCase() ==
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' || "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge' state.roleIdRoleName.roleName
.toLowerCase() ==
'qr code scanner' ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'office/branch chief' ||
state.roleIdRoleName.roleName
.toLowerCase() ==
'registration in-charge'
? "Station" ? "Station"
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson' : state.roleIdRoleName.roleName
.toLowerCase() ==
'barangay chairperson'
? "Barangay" ? "Barangay"
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president' : state.roleIdRoleName.roleName
.toLowerCase() ==
'purok president'
? "Purok" ? "Purok"
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person' : state.roleIdRoleName.roleName
.toLowerCase() ==
'establishment point-person'
? "Agency" ? "Agency"
: "", : "",
), ),

View File

@ -222,7 +222,7 @@ class _RBACScreenState extends State<RBACScreen> {
builder: (context, setState) { builder: (context, setState) {
return SearchField( return SearchField(
itemHeight: 40, itemHeight: 40,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.role suggestions: state.role
.map((RBAC role) => .map((RBAC role) =>
SearchFieldListItem( SearchFieldListItem(
@ -305,7 +305,7 @@ class _RBACScreenState extends State<RBACScreen> {
builder: (context, setState) { builder: (context, setState) {
return SearchField( return SearchField(
itemHeight: 40, itemHeight: 40,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.modules suggestions: state.modules
.map((RBAC module) => .map((RBAC module) =>
SearchFieldListItem( SearchFieldListItem(
@ -602,7 +602,7 @@ class _RBACScreenState extends State<RBACScreen> {
), ),
SearchField( SearchField(
itemHeight: 40, itemHeight: 40,
suggestionsDecoration: box1(), suggestionsDecoration: searchFieldDecoration(),
suggestions: state.objects suggestions: state.objects
.map((RBAC object) => SearchFieldListItem(object.name!, .map((RBAC object) => SearchFieldListItem(object.name!,
item: object, item: object,

View File

@ -1,6 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/utils/global.dart';
import 'package:unit2/screens/profile/components/other_information/org_membership/add_modal.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
@ -10,17 +9,15 @@ import 'package:http/http.dart' as http;
class AgencyServices { class AgencyServices {
static final AgencyServices _instance = AgencyServices(); static final AgencyServices _instance = AgencyServices();
static AgencyServices get instance => _instance; static AgencyServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<Agency>> getAgencies() async {
List<Agency> agencies = [];
String path = Url.instance.agencies();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
String path = Url.instance.agencies();
Future<List<Agency>> getAgencies() async {
List<Agency> agencies = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, headers: headers, param: {}); .getRequest(path: path, headers: headers, param: {});
@ -38,14 +35,9 @@ class AgencyServices {
} }
return agencies; return agencies;
} }
Future<Map<dynamic, dynamic>> add({required Agency agency}) async { Future<Map<dynamic, dynamic>> add({required Agency agency}) async {
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
String path = Url.instance.postAgencies();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"name": agency.name, "name": agency.name,
"category_id": agency.category!.id, "category_id": agency.category!.id,
@ -53,7 +45,8 @@ class AgencyServices {
"contact_info": null, "contact_info": null,
}; };
try { try {
http.Response response = await Request.instance.postRequest(param: {},path: path, body: body,headers: headers); http.Response response = await Request.instance
.postRequest(param: {}, path: path, body: body, headers: headers);
if (response.statusCode == 201) { if (response.statusCode == 201) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
statusResponse = data; statusResponse = data;

View File

@ -1,24 +1,22 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/profile/assigned_area.dart'; import 'package:unit2/model/profile/assigned_area.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../../../utils/request.dart'; import '../../../utils/request.dart';
class RbacAssignedAreaServices { class RbacAssignedAreaServices {
static final RbacAssignedAreaServices _instance = RbacAssignedAreaServices(); static final RbacAssignedAreaServices _instance = RbacAssignedAreaServices();
static RbacAssignedAreaServices get instance => _instance; static RbacAssignedAreaServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<UserAssignedArea>> getAssignedArea({required int id}) async {
List<UserAssignedArea> userAssignedAreas = [];
String path = Url.instance.getAssignAreas(); String path = Url.instance.getAssignAreas();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<UserAssignedArea>> getAssignedArea({required int id}) async {
List<UserAssignedArea> userAssignedAreas = [];
Map<String, String> param = { Map<String, String> param = {
"assigned_role__user__id": id.toString(), "assigned_role__user__id": id.toString(),
}; };
@ -39,17 +37,15 @@ class RbacAssignedAreaServices {
} }
return userAssignedAreas; return userAssignedAreas;
} }
Future<bool> deleteAssignedArea({required int areaId}) async { Future<bool> deleteAssignedArea({required int areaId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getAssignAreas()}$areaId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance.deleteRequest(
.deleteRequest(path: path, headers: headers, body: {}, param: {}); path: "${path + areaId.toString()}/",
headers: headers,
body: {},
param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} else { } else {
@ -60,21 +56,23 @@ class RbacAssignedAreaServices {
} }
return success; return success;
} }
Future<Map<dynamic, dynamic>> add ({required int userId, required int roleId, required int areaTypeId, required String areaId}) async{
String path = Url.instance.getAssignAreas(); Future<Map<dynamic, dynamic>> add(
Map<String, String> headers = { {required int userId,
'Content-Type': 'application/json; charset=UTF-8', required int roleId,
'X-Client-Key': xClientKey, required int areaTypeId,
'X-Client-Secret': xClientKeySecret required String areaId}) async {
};
Map<dynamic, dynamic>? responseStatus = {}; Map<dynamic, dynamic>? responseStatus = {};
Map body = { Map body = {
"user_id": userId, "user_id": userId,
"role_id": roleId, "role_id": roleId,
"assigned_areas": [{"areatypeid":areaTypeId,"areaid":areaId}] "assigned_areas": [
{"areatypeid": areaTypeId, "areaid": areaId}
]
}; };
try { try {
http.Response response = await Request.instance.postRequest(path: path, headers: headers, body: body, param: {}); http.Response response = await Request.instance
.postRequest(path: path, headers: headers, body: body, param: {});
if (response.statusCode == 201) { if (response.statusCode == 201) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
responseStatus = data; responseStatus = data;

View File

@ -1,7 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/login_data/user_info/module.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import '../../../model/rbac/rbac_rbac.dart'; import '../../../model/rbac/rbac_rbac.dart';
import '../../../utils/request.dart'; import '../../../utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
@ -10,16 +9,14 @@ class RbacModuleObjectsServices {
static final RbacModuleObjectsServices _instance = static final RbacModuleObjectsServices _instance =
RbacModuleObjectsServices(); RbacModuleObjectsServices();
static RbacModuleObjectsServices get instance => _instance; static RbacModuleObjectsServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<ModuleObjects>> getModuleObjects() async {
List<ModuleObjects> moduleObjects = [];
String path = Url.instance.getModuleObjects();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret':xClientSecret
}; };
String path = Url.instance.getModuleObjects();
Future<List<ModuleObjects>> getModuleObjects() async {
List<ModuleObjects> moduleObjects = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -38,19 +35,12 @@ class RbacModuleObjectsServices {
return moduleObjects; return moduleObjects;
} }
////Add
Future<Map<dynamic, dynamic>> add({ Future<Map<dynamic, dynamic>> add({
required int assignerId, required int assignerId,
required int? moduleId, required int? moduleId,
required List<int> objectsId, required List<int> objectsId,
}) async { }) async {
String path = Url.instance.getModuleObjects();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"module_id": moduleId, "module_id": moduleId,
"objects": objectsId, "objects": objectsId,
@ -76,17 +66,11 @@ class RbacModuleObjectsServices {
return statusResponse; return statusResponse;
} }
Future<bool> deleteRbacModuleObject({required int moduleObjectId}) async { Future<bool> delete({required int moduleObjectId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getModuleObjects()}$moduleObjectId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: "${path+moduleObjectId.toString()}/", headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,24 +1,21 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/rbac.dart'; import 'package:unit2/model/rbac/rbac.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacModuleServices { class RbacModuleServices {
static final RbacModuleServices _instance = RbacModuleServices(); static final RbacModuleServices _instance = RbacModuleServices();
static RbacModuleServices get instance => _instance; static RbacModuleServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RBAC>> getRbacModule() async {
List<RBAC> modules = [];
String path = Url.instance.getModules(); String path = Url.instance.getModules();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key':xClientKey, 'X-Client-Key':xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret':xClientSecret
}; };
Future<List<RBAC>> getRbacModule() async {
List<RBAC> modules = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -43,13 +40,7 @@ class RbacModuleServices {
required String? slug, required String? slug,
required String? short, required String? short,
required int id}) async { required int id}) async {
String path = Url.instance.getModules();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -88,13 +79,7 @@ class RbacModuleServices {
required int? createdBy, required int? createdBy,
required int updatedBy, required int updatedBy,
}) async { }) async {
String path = "${Url.instance.getModules()}$moduleId/";
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -106,7 +91,7 @@ class RbacModuleServices {
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.putRequest(path: path, body: body, headers: headers, param: {}); .putRequest(path: "${path+moduleId.toString()}/", body: body, headers: headers, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
statusResponse = data; statusResponse = data;
@ -126,15 +111,9 @@ class RbacModuleServices {
Future<bool> deleteRbacModule({required int moduleId}) async { Future<bool> deleteRbacModule({required int moduleId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getModules()}$moduleId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: '${path+moduleId.toString()}/', headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,24 +1,21 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/rbac.dart'; import 'package:unit2/model/rbac/rbac.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacObjectServices { class RbacObjectServices {
static final RbacObjectServices _instance = RbacObjectServices(); static final RbacObjectServices _instance = RbacObjectServices();
static RbacObjectServices get instance => _instance; static RbacObjectServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RBAC>> getRbacObjects() async {
List<RBAC> objects = [];
String path = Url.instance.getObject(); String path = Url.instance.getObject();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RBAC>> getRbacObjects() async {
List<RBAC> objects = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -43,13 +40,7 @@ class RbacObjectServices {
required String? slug, required String? slug,
required String? short, required String? short,
required int id}) async { required int id}) async {
String path = Url.instance.getObject();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -67,7 +58,7 @@ class RbacObjectServices {
} else { } else {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
String message = data['message']; String message = data['message'];
statusResponse.addAll({'message': "Error Adding Object"}); statusResponse.addAll({'message': message});
statusResponse.addAll( statusResponse.addAll(
{'success': false}, {'success': false},
); );
@ -87,13 +78,8 @@ class RbacObjectServices {
required int? createdBy, required int? createdBy,
required int updatedBy, required int updatedBy,
}) async { }) async {
String path = "${Url.instance.getObject()}$objectId/";
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -104,14 +90,14 @@ class RbacObjectServices {
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.putRequest(path: path, body: body, headers: headers, param: {}); .putRequest(path: "${path+objectId.toString()}/", body: body, headers: headers, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
statusResponse = data; statusResponse = data;
} else { } else {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
String message = data['message']; String message = data['message'];
statusResponse.addAll({'message': "Error Updating Object"}); statusResponse.addAll({'message': message});
statusResponse.addAll( statusResponse.addAll(
{'success': false}, {'success': false},
); );
@ -124,15 +110,9 @@ class RbacObjectServices {
Future<bool> deleteRbacRole({required int objectId}) async { Future<bool> deleteRbacRole({required int objectId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getObject()}$objectId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: "${path+objectId.toString()}/", headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,24 +1,21 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/rbac.dart'; import 'package:unit2/model/rbac/rbac.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacOperationServices { class RbacOperationServices {
static final RbacOperationServices _instance = RbacOperationServices(); static final RbacOperationServices _instance = RbacOperationServices();
static RbacOperationServices get instance => _instance; static RbacOperationServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RBAC>> getRbacOperations() async {
List<RBAC> roles = [];
String path = Url.instance.getOperations(); String path = Url.instance.getOperations();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RBAC>> getRbacOperations() async {
List<RBAC> roles = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -43,13 +40,7 @@ class RbacOperationServices {
required String? slug, required String? slug,
required String? short, required String? short,
required int id}) async { required int id}) async {
String path = Url.instance.getOperations();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -87,13 +78,7 @@ class RbacOperationServices {
required int? createdBy, required int? createdBy,
required int updatedBy, required int updatedBy,
}) async { }) async {
String path = "${Url.instance.getRbacOperations()}$operationId/";
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -104,7 +89,7 @@ class RbacOperationServices {
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.putRequest(path: path, body: body, headers: headers, param: {}); .putRequest(path: '${path+operationId.toString()}/', body: body, headers: headers, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
statusResponse = data; statusResponse = data;
@ -124,15 +109,9 @@ class RbacOperationServices {
Future<bool> delete({required int operation}) async { Future<bool> delete({required int operation}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getRbacOperations()}$operation/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: '${path+operation.toString()}/', headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -0,0 +1,83 @@
import 'dart:convert';
import 'package:unit2/model/rbac/permission_assignment.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart';
import 'package:http/http.dart' as http;
class RbacPermissionAssignmentServices {
static final RbacPermissionAssignmentServices _instance =
RbacPermissionAssignmentServices();
static RbacPermissionAssignmentServices get instance => _instance;
String path = Url.instance.getPermissionAssignment();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientSecret
};
Future<List<PermissionAssignment>> getPermissionAssignment() async {
List<PermissionAssignment> permissionAssignments = [];
try {
http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers);
if (response.statusCode == 200) {
Map data = jsonDecode(response.body);
if (data['data'] != null) {
for (var rbac in data['data']) {
PermissionAssignment permissionAssignment =
PermissionAssignment.fromJson(rbac);
permissionAssignments.add(permissionAssignment);
}
}
}
} catch (e) {
e.toString();
}
return permissionAssignments;
}
Future<bool> deletePermissionAssignment({required int id}) async {
bool success = false;
try {
http.Response response = await Request.instance
.deleteRequest(path: "${path+id.toString()}/", headers: headers, body: {}, param: {});
if (response.statusCode == 200) {
success = true;
}
} catch (e) {
throw e.toString();
}
return success;
}
Future<Map<dynamic, dynamic>> addPermissionAssignment(
{required int assignerId,
required List<int> opsId,
required int roleId}) async {
Map<dynamic, dynamic> statusResponse = {};
Map body = {
"role_id": roleId,
"permissions": opsId,
"assigner_user_id": assignerId
};
try {
http.Response response = await Request.instance
.postRequest(param: {}, path: path, body: body, headers: headers);
if (response.statusCode == 201) {
Map data = jsonDecode(response.body);
statusResponse = data;
} else {
Map data = jsonDecode(response.body);
String message = data['message'];
statusResponse.addAll({'message': message});
statusResponse.addAll(
{'success': false},
);
}
} catch (e) {
throw e.toString();
}
return statusResponse;
}
}

View File

@ -1,25 +1,21 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/permission.dart'; import 'package:unit2/model/rbac/permission.dart';
import 'package:unit2/model/rbac/rbac.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacPermissionServices { class RbacPermissionServices {
static final RbacPermissionServices _instance = RbacPermissionServices(); static final RbacPermissionServices _instance = RbacPermissionServices();
static RbacPermissionServices get instance => _instance; static RbacPermissionServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RBACPermission>> getRbacPermission() async {
List<RBACPermission> permissions = [];
String path = Url.instance.getPersmissions(); String path = Url.instance.getPersmissions();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key':xClientKey, 'X-Client-Key':xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RBACPermission>> getRbacPermission() async {
List<RBACPermission> permissions = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -46,13 +42,7 @@ class RbacPermissionServices {
required int? objectId, required int? objectId,
required List<int> operationsId, required List<int> operationsId,
}) async { }) async {
String path = Url.instance.getPersmissions();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"object_id": objectId, "object_id": objectId,
"operations": operationsId, "operations": operationsId,
@ -80,15 +70,9 @@ class RbacPermissionServices {
Future<bool> deletePermission ({required int permissionId}) async { Future<bool> deletePermission ({required int permissionId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getPersmissions()}$permissionId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: "${path+permissionId.toString()}/", headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,30 +1,27 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/assigned_role.dart'; import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/model/rbac/rbac.dart'; import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../../../model/profile/basic_information/primary-information.dart'; import '../../../model/profile/basic_information/primary-information.dart';
class RbacRoleAssignmentServices { class RbacRoleAssignmentServices {
static final RbacRoleAssignmentServices _instance = static final RbacRoleAssignmentServices _instance =
RbacRoleAssignmentServices(); RbacRoleAssignmentServices();
static RbacRoleAssignmentServices get instance => _instance; static RbacRoleAssignmentServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<AssignedRole>> getAssignedRoles(
{required String firstname, required String lastname}) async {
List<AssignedRole> assignedRoles = [];
String path = Url.instance.getRoleAssignment(); String path = Url.instance.getRoleAssignment();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<AssignedRole>> getAssignedRoles(
{required String firstname, required String lastname}) async {
List<AssignedRole> assignedRoles = [];
Map<String, String> param = { Map<String, String> param = {
"user__first_name__icontains": firstname, "user__first_name__icontains": firstname,
"user__last_name__icontains": lastname "user__last_name__icontains": lastname
@ -49,15 +46,9 @@ class RbacRoleAssignmentServices {
Future<bool> deleteAssignedRole({required int roleId}) async { Future<bool> deleteAssignedRole({required int roleId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getRoleAssignment()}$roleId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: '${path+roleId.toString()}/', headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }
@ -72,13 +63,7 @@ class RbacRoleAssignmentServices {
required int? assignerId, required int? assignerId,
required List<int> roles, required List<int> roles,
}) async { }) async {
String path = Url.instance.getRoleAssignment();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"user_id": userId, "user_id": userId,
"roles": roles, "roles": roles,

View File

@ -1,26 +1,23 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/role_extend.dart'; import 'package:unit2/model/rbac/role_extend.dart';
import 'package:unit2/model/rbac/role_under.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import '../../../utils/request.dart'; import '../../../utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacRoleExtendServices { class RbacRoleExtendServices {
static final RbacRoleExtendServices _instance = RbacRoleExtendServices(); static final RbacRoleExtendServices _instance = RbacRoleExtendServices();
static RbacRoleExtendServices get instance => _instance; static RbacRoleExtendServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RolesExtend>> getRolesExtend() async {
List<RolesExtend> rolesextend = [];
String path = Url.instance.getRoleExtend(); String path = Url.instance.getRoleExtend();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
// try { Future<List<RolesExtend>> getRolesExtend() async {
List<RolesExtend> rolesextend = [];
try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
if (response.statusCode == 200) { if (response.statusCode == 200) {
@ -32,9 +29,9 @@ class RbacRoleExtendServices {
} }
} }
} }
// } catch (e) { } catch (e) {
// throw e.toString(); throw e.toString();
// } }
return rolesextend; return rolesextend;
} }
@ -43,13 +40,7 @@ class RbacRoleExtendServices {
required int? roleId, required int? roleId,
required List<int> rolesExtendsId, required List<int> rolesExtendsId,
}) async { }) async {
String path = Url.instance.getRoleExtend();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"role_main_id": roleId, "role_main_id": roleId,
"roles_extend": rolesExtendsId, "roles_extend": rolesExtendsId,
@ -76,15 +67,12 @@ class RbacRoleExtendServices {
Future<bool> delete({required int roleExtendId}) async { Future<bool> delete({required int roleExtendId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getRoleExtend()}$roleExtendId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance.deleteRequest(
.deleteRequest(path: path, headers: headers, body: {}, param: {}); path: '${path + roleExtendId.toString()}/',
headers: headers,
body: {},
param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,9 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/login_data/user_info/module.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/model/rbac/role_module.dart'; import 'package:unit2/model/rbac/role_module.dart';
import '../../../model/rbac/rbac_rbac.dart'; import 'package:unit2/utils/global.dart';
import '../../../utils/request.dart'; import '../../../utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
@ -11,17 +10,14 @@ class RbacRoleModuleServices {
static final RbacRoleModuleServices _instance = static final RbacRoleModuleServices _instance =
RbacRoleModuleServices(); RbacRoleModuleServices();
static RbacRoleModuleServices get instance => _instance; static RbacRoleModuleServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RoleModules>> getRoleModules() async {
List<RoleModules> roleModules = [];
String path = Url.instance.getRoleModules(); String path = Url.instance.getRoleModules();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RoleModules>> getRoleModules() async {
List<RoleModules> roleModules = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -46,13 +42,7 @@ class RbacRoleModuleServices {
required int? roleId, required int? roleId,
required List<int> moduleIds, required List<int> moduleIds,
}) async { }) async {
String path = Url.instance.getRoleModules();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"role_id": roleId, "role_id": roleId,
"modules": moduleIds, "modules": moduleIds,
@ -80,15 +70,9 @@ class RbacRoleModuleServices {
Future<bool> deleteRbacRoleModule({required int moduleObjectId}) async { Future<bool> deleteRbacRoleModule({required int moduleObjectId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getRoleModules()}$moduleObjectId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: "${path+moduleObjectId.toString()}/", headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,25 +1,21 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/rbac/rbac.dart'; import 'package:unit2/model/rbac/rbac.dart';
import 'package:unit2/sevices/profile/education_services.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacRoleServices { class RbacRoleServices {
static final RbacRoleServices _instance = RbacRoleServices(); static final RbacRoleServices _instance = RbacRoleServices();
static RbacRoleServices get instance => _instance; static RbacRoleServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RBAC>> getRbacRoles() async {
List<RBAC> roles = [];
String path = Url.instance.getRbacRoles(); String path = Url.instance.getRbacRoles();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RBAC>> getRbacRoles() async {
List<RBAC> roles = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -45,13 +41,7 @@ class RbacRoleServices {
required String? slug, required String? slug,
required String? short, required String? short,
required int id}) async { required int id}) async {
String path = Url.instance.getRbacRoles();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -89,13 +79,7 @@ class RbacRoleServices {
required int? createdBy, required int? createdBy,
required int updatedBy, required int updatedBy,
}) async { }) async {
String path = "${Url.instance.getRbacRoles()}$roleId/";
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String? newSlug = slug?.replaceAll(" ", "-"); String? newSlug = slug?.replaceAll(" ", "-");
Map body = { Map body = {
"name": name, "name": name,
@ -105,8 +89,11 @@ class RbacRoleServices {
"updated_by_id": updatedBy "updated_by_id": updatedBy
}; };
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance.putRequest(
.putRequest(path: path, body: body, headers: headers, param: {}); path: "${path + roleId.toString()}/",
body: body,
headers: headers,
param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map data = jsonDecode(response.body); Map data = jsonDecode(response.body);
statusResponse = data; statusResponse = data;
@ -126,15 +113,12 @@ class RbacRoleServices {
Future<bool> deleteRbacRole({required int roleId}) async { Future<bool> deleteRbacRole({required int roleId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getRbacRoles()}$roleId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance.deleteRequest(
.deleteRequest(path: path, headers: headers, body: {}, param: {}); path: "${path + roleId.toString()}/",
headers: headers,
body: {},
param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -2,23 +2,21 @@ import 'dart:convert';
import 'package:unit2/model/rbac/role_under.dart'; import 'package:unit2/model/rbac/role_under.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:unit2/utils/global.dart';
import '../../../utils/request.dart'; import '../../../utils/request.dart';
import '../../../utils/urls.dart'; import '../../../utils/urls.dart';
class RbacRoleUnderServices { class RbacRoleUnderServices {
static final RbacRoleUnderServices _instance = RbacRoleUnderServices(); static final RbacRoleUnderServices _instance = RbacRoleUnderServices();
static RbacRoleUnderServices get instance => _instance; static RbacRoleUnderServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RolesUnder>> getRolesUnder() async {
List<RolesUnder> rolesUnder = [];
String path = Url.instance.getRolesUnder(); String path = Url.instance.getRolesUnder();
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RolesUnder>> getRolesUnder() async {
List<RolesUnder> rolesUnder = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: {}, path: path, headers: headers); .getRequest(param: {}, path: path, headers: headers);
@ -42,13 +40,8 @@ class RbacRoleUnderServices {
required int? roleId, required int? roleId,
required List<int> rolesId, required List<int> rolesId,
}) async { }) async {
String path = Url.instance.getRolesUnder();
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
Map body = { Map body = {
"role_main_id": roleId, "role_main_id": roleId,
"roles_under": rolesId, "roles_under": rolesId,
@ -76,15 +69,9 @@ class RbacRoleUnderServices {
Future<bool> deleteRbacRoleUnder({required int roleUnderId}) async { Future<bool> deleteRbacRoleUnder({required int roleUnderId}) async {
bool success = false; bool success = false;
String path = "${Url.instance.getRolesUnder ()}$roleUnderId/";
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.deleteRequest(path: path, headers: headers, body: {}, param: {}); .deleteRequest(path: "${path+roleUnderId.toString()}/", headers: headers, body: {}, param: {});
if (response.statusCode == 200) { if (response.statusCode == 200) {
success = true; success = true;
} }

View File

@ -1,27 +1,24 @@
import 'dart:convert'; import 'dart:convert';
import 'package:unit2/model/utils/position.dart'; import 'package:unit2/model/utils/position.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/request.dart'; import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import '../../../model/rbac/rbac_station.dart'; import '../../../model/rbac/rbac_station.dart';
import '../../../model/rbac/station_type.dart'; import '../../../model/rbac/station_type.dart';
import '../../../model/roles/pass_check/station_assign_area.dart';
class RbacStationServices { class RbacStationServices {
static final RbacStationServices _instance = RbacStationServices(); static final RbacStationServices _instance = RbacStationServices();
static RbacStationServices get instance => _instance; static RbacStationServices get instance => _instance;
String xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
String xClientKeySecret = "unitcYqAN7GGalyz";
Future<List<RbacStation>> getStations({required String agencyId}) async {
List<RbacStation> stations = [];
String path = Url.instance.getStation(); String path = Url.instance.getStation();
Map<String, String> param = {"government_agency_id": agencyId.toString()};
Map<String, String> headers = { Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey, 'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret 'X-Client-Secret': xClientSecret
}; };
Future<List<RbacStation>> getStations({required String agencyId}) async {
List<RbacStation> stations = [];
Map<String, String> param = {"government_agency_id": agencyId.toString()};
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(param: param, path: path, headers: headers); .getRequest(param: param, path: path, headers: headers);
@ -42,9 +39,6 @@ class RbacStationServices {
Future<List<StationType>> getStationTypes() async { Future<List<StationType>> getStationTypes() async {
String path = Url.instance.getStationType(); String path = Url.instance.getStationType();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
List<StationType> stationTypes = []; List<StationType> stationTypes = [];
try { try {
@ -67,11 +61,7 @@ class RbacStationServices {
Future<List<PositionTitle>> getPositionTitle() async { Future<List<PositionTitle>> getPositionTitle() async {
String path = Url.instance.getPositionTitle(); String path = Url.instance.getPositionTitle();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
List<PositionTitle> positions = []; List<PositionTitle> positions = [];
try { try {
http.Response response = await Request.instance http.Response response = await Request.instance
.getRequest(path: path, param: {}, headers: headers); .getRequest(path: path, param: {}, headers: headers);
@ -93,13 +83,7 @@ class RbacStationServices {
Future<Map<dynamic, dynamic>> addStation( Future<Map<dynamic, dynamic>> addStation(
{required RbacStation station}) async { {required RbacStation station}) async {
Map<dynamic, dynamic> statusResponse = {}; Map<dynamic, dynamic> statusResponse = {};
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
'X-Client-Key': xClientKey,
'X-Client-Secret': xClientKeySecret
};
String path = Url.instance.postStation(); String path = Url.instance.postStation();
try { try {
Map body = { Map body = {
"station_name": station.stationName, "station_name": station.stationName,

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:searchfield/searchfield.dart';
BoxDecoration box1(){ BoxDecoration box1(){
return const BoxDecoration( return const BoxDecoration(
@ -6,3 +7,9 @@ BoxDecoration box1(){
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(3))); borderRadius: BorderRadius.all(Radius.circular(3)));
} }
SuggestionDecoration searchFieldDecoration(){
return SuggestionDecoration(
boxShadow:const [BoxShadow(color: Colors.black12,spreadRadius: 5,blurRadius: 5)] ,
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(3)));
}

View File

@ -13,7 +13,7 @@ Future<String> getCPUArchitecture() async {
try { try {
Response response = await dio.get(apkUrl, Response response = await dio.get(apkUrl,
options: Options( options: Options(
receiveTimeout: 20000, receiveTimeout:const Duration(seconds: 25),
receiveDataWhenStatusError: true, receiveDataWhenStatusError: true,
responseType: ResponseType.json, responseType: ResponseType.json,
followRedirects: false, followRedirects: false,
@ -37,8 +37,8 @@ Future<String> getCPUArchitecture() async {
throw TimeoutException("Connection timeout"); throw TimeoutException("Connection timeout");
} on SocketException catch (_) { } on SocketException catch (_) {
throw const SocketException("Connection timeout"); throw const SocketException("Connection timeout");
} on DioError catch (_) { } on DioException catch (e) {
throw DioErrorType.connectTimeout; throw e.toString();
} }
return downloadURL; return downloadURL;
} }

View File

@ -3,7 +3,8 @@ import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
var mobileFormatter = MaskTextInputFormatter( var mobileFormatter = MaskTextInputFormatter(
mask: "+63 (###) ###-####", mask: "+63 (###) ###-####",
filter: {"#": RegExp(r"^[1-9][0-9]*$")}, filter: {"#": RegExp(r'^[0-9][0-9]*$')
},
type: MaskAutoCompletionType.lazy, type: MaskAutoCompletionType.lazy,
initialText: "0"); initialText: "0");

View File

@ -10,7 +10,6 @@ double safeAreaHorizontal = 0;
double safeAreaVertical = 0; double safeAreaVertical = 0;
double safeBlockHorizontal = 0; double safeBlockHorizontal = 0;
double safeBlockVertical = 0; double safeBlockVertical = 0;
const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z"; const xClientKey = "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z";
const xClientSecret = "unitcYqAN7GGalyz"; const xClientSecret = "unitcYqAN7GGalyz";
String? globalFistname; String? globalFistname;
@ -20,6 +19,18 @@ const xClientSecret = "unitcYqAN7GGalyz";
String? globalSex; String? globalSex;
Profile? globalCurrentProfile; Profile? globalCurrentProfile;
const String urlDownloadArmeabiv7aAPK =
"https://agusandelnorte.gov.ph/media/public/transparency/downloadables/UniT-App/v1.0.1/beta/unit_app_v1_0_1_beta_armeabi-v7a-release.apk?download";
const String urlDownloadX8664APK =
"https://agusandelnorte.gov.ph/media/public/transparency/downloadables/UniT-App/v1.0.1/beta/unit_app_v1_0_1_beta_x86_64-release.apk?download";
const String urlDownloadarm64v8aAPK =
"https://agusandelnorte.gov.ph/media/public/transparency/downloadables/UniT-App/v1.0.1/beta/unit_app_v1_0_1_beta_arm64-v8a-release.apk?download";
//// hive boxes //// hive boxes
Box? CREDENTIALS; Box? CREDENTIALS;
Box? SOS; Box? SOS;

View File

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:unit2/utils/text_container.dart'; import 'package:unit2/utils/text_container.dart';
import 'package:unit2/utils/urls.dart'; import 'package:unit2/utils/urls.dart';
@ -19,7 +18,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await get(Uri.http(host, path!, param), headers: headers) response = await get(Uri.https(host, path!, param), headers: headers)
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
// Fluttertoast.showToast( // Fluttertoast.showToast(
@ -61,7 +60,7 @@ class Request {
Map<String, String>? param}) async { Map<String, String>? param}) async {
Response response; Response response;
try { try {
response = await post(Uri.http(host, path!, param), response = await post(Uri.https(host, path!, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
@ -104,7 +103,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response = await put(Uri.http(host, path, param), response = await put(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body)); headers: headers, body: jsonEncode(body));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {
// Fluttertoast.showToast( // Fluttertoast.showToast(
@ -188,7 +187,7 @@ class Request {
required Map<String, dynamic>? param}) async { required Map<String, dynamic>? param}) async {
Response response; Response response;
try { try {
response = await delete(Uri.http(host, path, param), response = await delete(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body)) headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout)); .timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) { } on TimeoutException catch (_) {

View File

@ -309,7 +309,10 @@ class Url {
} }
String getRoleAssignment() { String getRoleAssignment() {
return "api/account/auth/role_assignment/"; return "/api/account/auth/role_assignment/";
}
String getPermissionAssignment(){
return "/api/account/auth/permission_assignment/";
} }
String getStationType() { String getStationType() {
@ -334,7 +337,7 @@ class Url {
} }
String getProvinces() { String getProvinces() {
return "api/web_app/location/province/"; return "/api/web_app/location/province/";
} }
String getCities() { String getCities() {

View File

@ -21,18 +21,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: animate_do name: animate_do
sha256: "9aeacc1a7238f971c039bdf45d13c628be554a242e0251c4ddda09d19a1a923f" sha256: "91b3e0306ba2096c7a7e1ee1ba96f491e25e92034c215f4bf8de6a7251c4bef1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.1.2"
animated_splash_screen:
dependency: "direct main"
description:
name: animated_splash_screen
sha256: f45634db6ec4e8cf034c53e03f3bd83898a16fe3c9286bf5510b6831dfcf2124
url: "https://pub.dev"
source: hosted
version: "1.3.0"
app_popup_menu: app_popup_menu:
dependency: "direct main" dependency: "direct main"
description: description:
@ -85,58 +77,58 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: audioplayers name: audioplayers
sha256: "61583554386721772f9309f509e17712865b38565a903c761f96b1115a979282" sha256: "8e94499b5c123df14cf17c16639de5ff3373e57e537f727e367487fbb7491363"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.0" version: "5.1.0"
audioplayers_android: audioplayers_android:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_android name: audioplayers_android
sha256: dbdc9b7f2aa2440314c638aa55aadd45c7705e8340d5eddf2e3fb8da32d4ae2c sha256: "1c12b60cc10a3b8617ca3f88b927e7e03768f470d9b4f747efd3d58a8a07ee1b"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "4.0.1"
audioplayers_darwin: audioplayers_darwin:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_darwin name: audioplayers_darwin
sha256: "6aea96df1d12f7ad5a71d88c6d1b22a216211a9564219920124c16768e456e9d" sha256: "2fb6133ffcf28fb3f9d3e11f8a3ef190e5fedb2b7b95ea865b56a21d1163e670"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.0" version: "5.0.1"
audioplayers_linux: audioplayers_linux:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_linux name: audioplayers_linux
sha256: "396b62ac62c92dd26c3bc5106583747f57a8b325ebd2b41e5576f840cfc61338" sha256: cca3f272c7186dd2e0025b8864e1413ac5e081d74b17e28b02ceb2df4c110235
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "3.0.0"
audioplayers_platform_interface: audioplayers_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_platform_interface name: audioplayers_platform_interface
sha256: f7daaed4659143094151ecf6bacd927d29ab8acffba98c110c59f0b81ae51143 sha256: "47eae55e99ced11589998cf27e4eaabf5b475a7bd8bea7516ee6c2536a2e1abf"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.0.1" version: "6.0.0"
audioplayers_web: audioplayers_web:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_web name: audioplayers_web
sha256: ec84fd46eed1577148ed4113f5998a36a18da4fce7170c37ce3e21b631393339 sha256: "9f155590c6ba9ba469df637f4729264e4234dc3941ece4690dad63ffac19b5af"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.0" version: "4.0.0"
audioplayers_windows: audioplayers_windows:
dependency: transitive dependency: transitive
description: description:
name: audioplayers_windows name: audioplayers_windows
sha256: "1d3aaac98a192b8488167711ba1e67d8b96333e8d0572ede4e2912e5bbce69a3" sha256: "8813b712ba919bb324bde5e3ba97edc81bface945953a54a3dea70b5608bcc70"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.2" version: "3.0.0"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -165,10 +157,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: badges name: badges
sha256: "6e7f3ec561ec08f47f912cfe349d4a1707afdc8dda271e17b046aa6d42c89e77" sha256: a7b6bbd60dce418df0db3058b53f9d083c22cdb5132a052145dc267494df0b84
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.2"
barcode_scan2: barcode_scan2:
dependency: "direct main" dependency: "direct main"
description: description:
@ -177,6 +169,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
better_open_file:
dependency: "direct main"
description:
name: better_open_file
sha256: aa67d9bc38160401e48023833f93c789b4e2b1c0eb8b6643bd5816d0c1c65dbd
url: "https://pub.dev"
source: hosted
version: "3.6.4"
bloc: bloc:
dependency: transitive dependency: transitive
description: description:
@ -341,10 +341,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: cool_alert name: cool_alert
sha256: "48a0b6c04914b6dc7e8d7eaccf2adf21bace6533a3eda0aeb412e0d7a03dc00a" sha256: "080a6c3503a4cded8f626cdead23f17ea40ff066ff50847d71a7a264032ab092"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.0" version: "2.0.1"
cross_file: cross_file:
dependency: transitive dependency: transitive
description: description:
@ -394,13 +394,13 @@ packages:
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
device_info_plus: device_info_plus:
dependency: transitive dependency: "direct main"
description: description:
name: device_info_plus name: device_info_plus
sha256: f52ab3b76b36ede4d135aab80194df8925b553686f0fa12226b4e2d658e45903 sha256: "86add5ef97215562d2e090535b0a16f197902b10c369c558a100e74ea06e8659"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "8.2.2" version: "9.0.3"
device_info_plus_platform_interface: device_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -413,10 +413,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: dio name: dio
sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.6" version: "5.3.3"
easy_app_installer: easy_app_installer:
dependency: "direct main" dependency: "direct main"
description: description:
@ -477,10 +477,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: file_picker name: file_picker
sha256: "9d6e95ec73abbd31ec54d0e0df8a961017e165aba1395e462e5b31ea0c165daf" sha256: be325344c1f3070354a1d84a231a1ba75ea85d413774ec4bdf444c023342e030
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.3.1" version: "5.5.0"
file_utils: file_utils:
dependency: transitive dependency: transitive
description: description:
@ -562,10 +562,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_form_builder name: flutter_form_builder
sha256: "9551c7379adc01a3a3a1100057396407c9534ea8adc937d14a0edd96fcd9e1dc" sha256: "8973beed34b6d951d36bf688b52e9e3040b47b763c35c320bd6f4c2f6b13f3a2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.8.0" version: "9.1.1"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -607,10 +607,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_speed_dial name: flutter_speed_dial
sha256: "41d7ad0bc224248637b3a5e0b9083e912a75445bdb450cf82b8ed06d7af7c61d" sha256: "698a037274a66dbae8697c265440e6acb6ab6cae9ac5f95c749e7944d8f28d41"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.2.0" version: "7.0.0"
flutter_spinkit: flutter_spinkit:
dependency: "direct main" dependency: "direct main"
description: description:
@ -631,10 +631,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_svg name: flutter_svg
sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" sha256: "8c5d68a82add3ca76d792f058b186a0599414f279f00ece4830b9b231b570338"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.6" version: "2.0.7"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -673,10 +673,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: form_builder_validators name: form_builder_validators
sha256: f2d90439c56345c23ad8d0c2912e4002cd02563d816f4387c9495051c10d3321 sha256: "19aa5282b7cede82d0025ab031a98d0554b84aa2ba40f12013471a3b3e22bf02"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "8.6.1" version: "9.1.0"
frontend_server_client: frontend_server_client:
dependency: transitive dependency: transitive
description: description:
@ -737,18 +737,18 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: hive_generator name: hive_generator
sha256: "81fd20125cb2ce8fd23623d7744ffbaf653aae93706c9bd3bf7019ea0ace3938" sha256: "06cb8f58ace74de61f63500564931f9505368f45f98958bd7a6c35ba24159db4"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.3" version: "2.0.1"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.13.6" version: "1.1.0"
http_multi_server: http_multi_server:
dependency: transitive dependency: transitive
description: description:
@ -777,10 +777,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: image name: image
sha256: "8e9d133755c3e84c73288363e6343157c383a0c6c56fc51afcc5d4d7180306d6" sha256: a72242c9a0ffb65d03de1b7113bc4e189686fc07c7147b8b41811d0dd0e0d9bf
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.3.0" version: "4.0.17"
intl: intl:
dependency: "direct main" dependency: "direct main"
description: description:
@ -825,26 +825,26 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: location name: location
sha256: "9051959f6f2ccadd887b28b66e9cbbcc25b6838e37cf9e894c421ccc0ebf80b5" sha256: "06be54f682c9073cbfec3899eb9bc8ed90faa0e17735c9d9fa7fe426f5be1dd1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.4.0" version: "5.0.3"
location_platform_interface: location_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: location_platform_interface name: location_platform_interface
sha256: "62eeaf1658e92e4459b727f55a3c328eccbac8ba043fa6d262ac5286ad48384c" sha256: "8aa1d34eeecc979d7c9fe372931d84f6d2ebbd52226a54fe1620de6fdc0753b1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.0" version: "3.1.2"
location_web: location_web:
dependency: transitive dependency: transitive
description: description:
name: location_web name: location_web
sha256: "6c08c408a040534c0269c4ff9fe17eebb5a36dea16512fbaf116b9c8bc21545b" sha256: ec484c66e8a4ff1ee5d044c203f4b6b71e3a0556a97b739a5bc9616de672412b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "4.2.0"
logging: logging:
dependency: transitive dependency: transitive
description: description:
@ -857,10 +857,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: lottie name: lottie
sha256: "893da7a0022ec2fcaa616f34529a081f617e86cc501105b856e5a3184c58c7c2" sha256: b8bdd54b488c54068c57d41ae85d02808da09e2bee8b8dd1f59f441e7efa60cd
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.3" version: "2.6.0"
mask_text_input_formatter: mask_text_input_formatter:
dependency: "direct main" dependency: "direct main"
description: description:
@ -905,18 +905,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: modal_progress_hud_nsn name: modal_progress_hud_nsn
sha256: "408b9bcce97567de94637de932260e50be48db1842edc761aeea61670e5ec30c" sha256: "0b0d95e5ce3e1884390624fbe79fcf90d7de10abe05d26c0e276c25e7130e3e0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.0" version: "0.4.0"
multi_dropdown: multi_dropdown:
dependency: "direct main" dependency: "direct main"
description: description:
name: multi_dropdown name: multi_dropdown
sha256: "65b8f505b251c5173e8eff64c09cd37460d8f8be906c2069a03815ad2641dcd1" sha256: "2db9b41ae543a9277defc2b5ba95622acb72ed0fb49d6dead357a1639371bee3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.9" version: "2.1.0"
multi_select_flutter: multi_select_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
@ -969,10 +969,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: package_info_plus name: package_info_plus
sha256: "10259b111176fba5c505b102e3a5b022b51dd97e30522e906d6922c745584745" sha256: "6ff267fcd9d48cb61c8df74a82680e8b82e940231bb5f68356672fde0397334a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.2" version: "4.1.0"
package_info_plus_platform_interface: package_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -981,14 +981,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
page_transition:
dependency: transitive
description:
name: page_transition
sha256: dee976b1f23de9bbef5cd512fe567e9f6278caee11f5eaca9a2115c19dc49ef6
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -1065,18 +1057,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: permission_handler name: permission_handler
sha256: "63e5216aae014a72fe9579ccd027323395ce7a98271d9defa9d57320d001af81" sha256: ad65ba9af42a3d067203641de3fd9f547ded1410bad3b84400c2b4899faede70
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.4.3" version: "11.0.0"
permission_handler_android: permission_handler_android:
dependency: transitive dependency: transitive
description: description:
name: permission_handler_android name: permission_handler_android
sha256: d74e77a5ecd38649905db0a7d05ef16bed42ff263b9efb73ed794317c5764ec3 sha256: f2543a236584a5e8be79076f858022f100ce690e31530e6fa4c32ac94f276d3a
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.3.4" version: "11.0.3"
permission_handler_apple: permission_handler_apple:
dependency: transitive dependency: transitive
description: description:
@ -1089,10 +1081,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: permission_handler_platform_interface name: permission_handler_platform_interface
sha256: "7c6b1500385dd1d2ca61bb89e2488ca178e274a69144d26bbd65e33eae7c02a9" sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.11.3" version: "3.11.5"
permission_handler_windows: permission_handler_windows:
dependency: transitive dependency: transitive
description: description:
@ -1105,10 +1097,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: petitparser name: petitparser
sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.1.0" version: "5.4.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -1241,18 +1233,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: rive name: rive
sha256: f3b8af0898c987d68019e91d92257edd902c28c816e49de033a7272e86bd5425 sha256: f2117a96a189758bc79bf7933865625c7a44a420ae537d2a8f6c492900136a71
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.11.4" version: "0.11.17"
rive_common: rive_common:
dependency: transitive dependency: transitive
description: description:
name: rive_common name: rive_common
sha256: f6687f9d70e6fd3888a9b0e9c0b307966d2ce74cf00cfb01dce906c3bbada52f sha256: e41f12917cb58e0c9376836490ebaa431e12744da0c67e19dad8d4bee9fedd46
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.1.0" version: "0.2.7"
rxdart: rxdart:
dependency: transitive dependency: transitive
description: description:
@ -1289,10 +1281,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: searchfield name: searchfield
sha256: "62b6653d7194de5a7ea724124846b996d0d211cd3eeeec2e5ca84423650f66f8" sha256: ea1eccae9f6d07dbbfef0bf341dd93b22df453b939461c5473a0be6186f2d720
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.8" version: "0.8.4"
share_plus: share_plus:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1385,10 +1377,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: signature name: signature
sha256: ad23383717dfa926204695ef6928ff513a77387be1b4a8c685099ce3ec35e5f8 sha256: d95143b8e310b395ea0be59a46bb69fa24106cb6ec79815fc56fd320268e24e6
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.3.0" version: "5.4.0"
simple_chips_input: simple_chips_input:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1486,58 +1478,66 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_flutter_core name: syncfusion_flutter_core
sha256: "8db8f55c77f56968681447d3837c10f27a9e861e238a898fda116c7531def979" sha256: aea119c8117953fa5decf4a313b431e556b0959cd35ff88f8fbdc0eda9bedb06
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.10" version: "23.1.36"
syncfusion_flutter_pdf: syncfusion_flutter_pdf:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_flutter_pdf name: syncfusion_flutter_pdf
sha256: a42186922a416c2c9634a8f221aee261101babc2d30b1a1e908a7f034e743046 sha256: "76a50a1d580714c078e2827adbd8b00d5f5c606879d07c44c5d99f0e864edda1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.4" version: "23.1.36"
syncfusion_flutter_pdfviewer: syncfusion_flutter_pdfviewer:
dependency: "direct main" dependency: "direct main"
description: description:
name: syncfusion_flutter_pdfviewer name: syncfusion_flutter_pdfviewer
sha256: "2dc016f251c675f8e4923135c485356473b4d89c677670164292159cd1dd4f45" sha256: e5eaabd0a31fff16caead0d6d66d4c9946de7e46c89da7736de23cd4b2e6f676
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.3" version: "23.1.36"
syncfusion_flutter_signaturepad:
dependency: transitive
description:
name: syncfusion_flutter_signaturepad
sha256: ea6b218d127e0315b3309ee072a1d304c76aa7c497a196b3474f9c6b38c01f82
url: "https://pub.dev"
source: hosted
version: "23.1.36"
syncfusion_pdfviewer_macos: syncfusion_pdfviewer_macos:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_macos name: syncfusion_pdfviewer_macos
sha256: "8cc925cae532c0fa17e849165796d962107f45b86e66ee334dcaabf6b7305c82" sha256: "6f928bee1f786b8d1939d3c4142c5cc2de2c13d19262d302878935a2bc33850c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.10" version: "23.1.36"
syncfusion_pdfviewer_platform_interface: syncfusion_pdfviewer_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_platform_interface name: syncfusion_pdfviewer_platform_interface
sha256: "08039ecdb8f79454fb367c6bf5a833846a666039415d2b5d76a7e59a5b3ff710" sha256: "0251864fb82e2bd92a1b17e8562fe342e78cd530e26b0d2f54e94a441ccb4584"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.10" version: "23.1.36"
syncfusion_pdfviewer_web: syncfusion_pdfviewer_web:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_web name: syncfusion_pdfviewer_web
sha256: "8e5ed0d313a1aa3869e4f2e8d079bc9bfa37ce79d91be7bb328e456f37b7995f" sha256: eb224f52e86326dbf08ea12978c3db0b4e376866a84d4fcb131fc06ec93cbe20
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.10" version: "23.1.36"
syncfusion_pdfviewer_windows: syncfusion_pdfviewer_windows:
dependency: transitive dependency: transitive
description: description:
name: syncfusion_pdfviewer_windows name: syncfusion_pdfviewer_windows
sha256: "3e93f281135fb0562f7e6c343d2db741cf3cbd78c5b04884eef9af414408bc77" sha256: aca74797a97512f4d3ca2be0ed49193fae7e5fd29a9b1b1139429d39c9216bf9
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "21.2.10" version: "23.1.36"
synchronized: synchronized:
dependency: transitive dependency: transitive
description: description:
@ -1598,12 +1598,12 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: url_launcher name: url_launcher
sha256: eb1e00ab44303d50dd487aab67ebc575456c146c6af44422f9c13889984c00f3 sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.1.11" version: "6.1.14"
url_launcher_android: url_launcher_android:
dependency: "direct main" dependency: transitive
description: description:
name: url_launcher_android name: url_launcher_android
sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330 sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330
@ -1666,6 +1666,30 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.7" version: "3.0.7"
vector_graphics:
dependency: transitive
description:
name: vector_graphics
sha256: "670f6e07aca990b4a2bcdc08a784193c4ccdd1932620244c3a86bb72a0eac67f"
url: "https://pub.dev"
source: hosted
version: "1.1.7"
vector_graphics_codec:
dependency: transitive
description:
name: vector_graphics_codec
sha256: "7451721781d967db9933b63f5733b1c4533022c0ba373a01bdd79d1a5457f69f"
url: "https://pub.dev"
source: hosted
version: "1.1.7"
vector_graphics_compiler:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: "80a13c613c8bde758b1464a1755a7b3a8f2b6cec61fbf0f5a53c94c30f03ba2e"
url: "https://pub.dev"
source: hosted
version: "1.1.7"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -1702,10 +1726,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.4" version: "5.0.6"
win32_registry:
dependency: transitive
description:
name: win32_registry
sha256: e4506d60b7244251bc59df15656a3093501c37fb5af02105a944d73eb95be4c9
url: "https://pub.dev"
source: hosted
version: "1.1.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
@ -1718,10 +1750,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: xml name: xml
sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.2.2" version: "6.3.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
@ -1731,5 +1763,10 @@ packages:
source: hosted source: hosted
version: "3.1.2" version: "3.1.2"
sdks: sdks:
<<<<<<< HEAD
dart: ">=3.1.0-185.0.dev <4.0.0" dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0" flutter: ">=3.7.0"
=======
dart: ">=3.1.0 <4.0.0"
flutter: ">=3.10.0"
>>>>>>> develop

View File

@ -36,15 +36,15 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
flutter_custom_clippers: ^2.0.0 flutter_custom_clippers: ^2.0.0
flutter_svg: ^1.1.6 flutter_svg: ^2.0.7
flutter_form_builder: ^7.7.0 flutter_form_builder: ^9.1.1
form_builder_validators: any form_builder_validators: ^9.1.0
fluttericon: ^2.0.0 fluttericon: ^2.0.0
fluttertoast: ^8.1.1 fluttertoast: ^8.1.1
flutter_zoom_drawer: ^3.0.3 flutter_zoom_drawer: ^3.0.3
cached_network_image: ^3.2.3 cached_network_image: ^3.2.3
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0
animate_do: ^3.0.2 animate_do: ^3.1.2
flutter_spinkit: ^5.1.0 flutter_spinkit: ^5.1.0
toggle_switch: ^2.0.1 toggle_switch: ^2.0.1
convex_bottom_bar: ^3.1.0+1 convex_bottom_bar: ^3.1.0+1
@ -54,34 +54,34 @@ dependencies:
flutter_progress_hud: ^2.0.2 flutter_progress_hud: ^2.0.2
barcode_scan2: ^4.2.1 barcode_scan2: ^4.2.1
qr_flutter: ^4.0.0 qr_flutter: ^4.0.0
signature: ^5.3.0 signature: ^5.4.0
awesome_dialog: ^3.0.2 awesome_dialog: ^3.0.2
system_info2: ^2.0.4 system_info2: ^2.0.4
flutter_bloc: ^8.0.0 flutter_bloc: ^8.0.0
equatable: ^2.0.5 equatable: ^2.0.5
package_info_plus: ^3.0.2 package_info_plus: 4.1.0
easy_app_installer: ^1.0.0 easy_app_installer: ^1.0.0
path_provider: ^2.0.14 path_provider: ^2.0.14
dio: ^4.0.6 dio: ^5.3.3
cool_alert: ^1.1.0 cool_alert: ^2.0.1
permission_handler: ^10.2.0 permission_handler: ^11.0.0
expandable_group: ^0.0.8 expandable_group: ^0.0.8
badges: ^3.0.2 badges: ^3.1.2
app_popup_menu: ^1.0.0 app_popup_menu: ^1.0.0
modal_progress_hud_nsn: ^0.3.0 modal_progress_hud_nsn: ^0.4.0
searchfield: ^0.7.5 searchfield: ^0.8.4
filter_list: ^1.0.2 filter_list: ^1.0.2
simple_chips_input: ^1.0.0 simple_chips_input: ^1.0.0
hive: ^2.0.5 hive: ^2.0.5
hive_flutter: ^1.1.0 hive_flutter: ^1.1.0
mask_text_input_formatter: ^2.4.0 mask_text_input_formatter: ^2.4.0
location: ^4.3.0 location: ^5.0.3
platform_device_id: ^1.0.1 platform_device_id: ^1.0.1
multi_dropdown: ^1.0.9 multi_dropdown: ^2.1.0
searchable_paginated_dropdown: ^1.2.0 searchable_paginated_dropdown: ^1.2.0
audioplayers: ^4.1.0 audioplayers: ^5.1.0
assets_audio_player: ^3.0.6 assets_audio_player: ^3.0.6
flutter_speed_dial: ^6.2.0 flutter_speed_dial: ^7.0.0
im_stepper: ^1.0.1+1 im_stepper: ^1.0.1+1
shared_preferences: ^2.0.20 shared_preferences: ^2.0.20
multiselect: any multiselect: any
@ -90,16 +90,17 @@ dependencies:
flutter_staggered_animations: ^1.1.1 flutter_staggered_animations: ^1.1.1
group_list_view: ^1.1.1 group_list_view: ^1.1.1
search_page: ^2.3.0 search_page: ^2.3.0
file_picker: ^5.3.1 file_picker: ^5.5.0
expandable: ^5.0.1 expandable: ^5.0.1
flutter_simple_treeview: ^3.0.2 flutter_simple_treeview: ^3.0.2
syncfusion_flutter_pdfviewer: ^21.2.3 syncfusion_flutter_pdfviewer: ^23.1.36
url_launcher: ^6.1.11 url_launcher: ^6.1.14
url_launcher_android: ^6.0.38
share_plus: ^7.1.0 share_plus: ^7.1.0
animated_splash_screen: ^1.3.0 animated_splash_screen: ^1.3.0
sqflite: ^2.3.0 sqflite: ^2.3.0
device_info_plus: ^9.0.3
better_open_file: ^3.6.4
dependency_overrides: dependency_overrides:
intl: ^0.18.0 intl: ^0.18.0
@ -116,7 +117,7 @@ dev_dependencies:
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0
build_runner: ^2.1.7 build_runner: ^2.1.7
hive_generator: ^1.1.2 hive_generator: ^2.0.1
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec

View File

@ -7,7 +7,7 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <audioplayers_windows/audioplayers_windows_plugin.h> #include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <modal_progress_hud_nsn/modal_progress_hud_nsn_plugin.h> #include <modal_progress_hud_nsn/modal_progress_hud_nsn_plugin_c_api.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h> #include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <platform_device_id_windows/platform_device_id_windows_plugin.h> #include <platform_device_id_windows/platform_device_id_windows_plugin.h>
#include <rive_common/rive_plugin.h> #include <rive_common/rive_plugin.h>
@ -18,8 +18,8 @@
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar( AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
ModalProgressHudNsnPluginRegisterWithRegistrar( ModalProgressHudNsnPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ModalProgressHudNsnPlugin")); registry->GetRegistrarForPlugin("ModalProgressHudNsnPluginCApi"));
PermissionHandlerWindowsPluginRegisterWithRegistrar( PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
PlatformDeviceIdWindowsPluginRegisterWithRegistrar( PlatformDeviceIdWindowsPluginRegisterWithRegistrar(