Merge pull request #88 from SyncrowIOT/dev

Dev
This commit is contained in:
Abdullah
2025-02-06 01:03:32 +03:00
committed by GitHub
6 changed files with 194 additions and 162 deletions

View File

@ -37,12 +37,9 @@ class _HomeWebPageState extends State<HomeWebPage> {
onPopInvoked: (didPop) => false, onPopInvoked: (didPop) => false,
child: BlocConsumer<HomeBloc, HomeState>( child: BlocConsumer<HomeBloc, HomeState>(
listener: (BuildContext context, state) { listener: (BuildContext context, state) {
print('state=$state');
if (state is HomeInitial) { if (state is HomeInitial) {
if (homeBloc.user!.hasAcceptedWebAgreement == false && if (homeBloc.user!.hasAcceptedWebAgreement == false && !_dialogShown) {
!_dialogShown) { _dialogShown = true; // Set the flag to true to indicate the dialog is showing.
_dialogShown =
true; // Set the flag to true to indicate the dialog is showing.
Future.delayed(const Duration(seconds: 1), () { Future.delayed(const Duration(seconds: 1), () {
showDialog( showDialog(
context: context, context: context,
@ -101,8 +98,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
width: size.width * 0.68, width: size.width * 0.68,
child: GridView.builder( child: GridView.builder(
itemCount: 3, // Change this count if needed. itemCount: 3, // Change this count if needed.
gridDelegate: gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, // Adjust as needed. crossAxisCount: 3, // Adjust as needed.
crossAxisSpacing: 20.0, crossAxisSpacing: 20.0,
mainAxisSpacing: 20.0, mainAxisSpacing: 20.0,
@ -114,8 +110,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
active: homeBloc.homeItems[index].active!, active: homeBloc.homeItems[index].active!,
name: homeBloc.homeItems[index].title!, name: homeBloc.homeItems[index].title!,
img: homeBloc.homeItems[index].icon!, img: homeBloc.homeItems[index].icon!,
onTap: () => onTap: () => homeBloc.homeItems[index].onPress(context),
homeBloc.homeItems[index].onPress(context),
); );
}, },
), ),

View File

@ -26,126 +26,118 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
create: (BuildContext context) => UsersBloc() create: (BuildContext context) => UsersBloc()
..add(const LoadCommunityAndSpacesEvent()) ..add(const LoadCommunityAndSpacesEvent())
..add(const RoleEvent()), ..add(const RoleEvent()),
child: BlocConsumer<UsersBloc, UsersState>(listener: (context, state) { child: BlocConsumer<UsersBloc, UsersState>(
// print('88888==${state}'); listener: (context, state) {},
// if (state is SpacesLoadedState) { builder: (context, state) {
// print('object'); final _blocRole = BlocProvider.of<UsersBloc>(context);
// _blocRole.add(const CheckRoleStepStatus());
// }
}, builder: (context, state) {
final _blocRole = BlocProvider.of<UsersBloc>(context);
return Dialog( return Dialog(
child: Container( child: Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Colors.white, color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(20))),
borderRadius: BorderRadius.all(Radius.circular(20))), width: 900,
width: 900, child: Column(
child: Column( children: [
children: [ // Title
// Title const Padding(
const Padding( padding: EdgeInsets.all(8.0),
padding: EdgeInsets.all(8.0), child: SizedBox(
child: SizedBox(
child: Text(
"Add New User",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: ColorsManager.secondaryColor),
),
),
),
const Divider(),
Expanded(
child: Row(
children: [
Expanded(
child: Container(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildStep1Indicator(1, "Basics", _blocRole),
_buildStep2Indicator(2, "Spaces", _blocRole),
_buildStep3Indicator(
3, "Role & Permissions", _blocRole),
],
),
),
),
Container(
width: 1,
color: ColorsManager.grayBorder,
),
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
Expanded(
child: _getFormContent(),
),
const SizedBox(height: 20),
],
),
),
),
],
),
),
const Divider(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: const Text("Cancel"),
),
InkWell(
onTap: () {
_blocRole.add(const CheckEmailEvent());
setState(() {
if (currentStep < 3) {
currentStep++;
if (currentStep == 2) {
_blocRole.add(
const CheckStepStatus(isEditUser: false));
} else if (currentStep == 3) {
_blocRole.add(const CheckSpacesStepStatus());
}
} else {
_blocRole.add(SendInviteUsers(context: context));
}
});
},
child: Text( child: Text(
currentStep < 3 ? "Next" : "Save", "Add New User",
style: TextStyle( style: TextStyle(
color: (_blocRole.isCompleteSpaces == false || fontSize: 20,
_blocRole.isCompleteBasics == false || fontWeight: FontWeight.w700,
_blocRole.isCompleteRolePermissions == color: ColorsManager.secondaryColor),
false) &&
currentStep == 3
? ColorsManager.grayColor
: ColorsManager.secondaryColor),
), ),
), ),
], ),
), const Divider(),
Expanded(
child: Row(
children: [
Expanded(
child: Container(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildStep1Indicator(1, "Basics", _blocRole),
_buildStep2Indicator(2, "Spaces", _blocRole),
_buildStep3Indicator(3, "Role & Permissions", _blocRole),
],
),
),
),
Container(
width: 1,
color: ColorsManager.grayBorder,
),
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
Expanded(
child: _getFormContent(),
),
const SizedBox(height: 20),
],
),
),
),
],
),
),
const Divider(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: const Text("Cancel"),
),
InkWell(
onTap: () {
_blocRole.add(const CheckEmailEvent());
setState(() {
if (currentStep < 3) {
currentStep++;
if (currentStep == 2) {
_blocRole.add(const CheckStepStatus(isEditUser: false));
} else if (currentStep == 3) {
_blocRole.add(const CheckSpacesStepStatus());
}
} else {
_blocRole.add(SendInviteUsers(context: context));
}
});
},
child: Text(
currentStep < 3 ? "Next" : "Save",
style: TextStyle(
color: (_blocRole.isCompleteSpaces == false ||
_blocRole.isCompleteBasics == false ||
_blocRole.isCompleteRolePermissions == false) &&
currentStep == 3
? ColorsManager.grayColor
: ColorsManager.secondaryColor),
),
),
],
),
),
],
), ),
], ));
), }));
));
}));
} }
Widget _getFormContent() { Widget _getFormContent() {
@ -204,12 +196,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: currentStep == step color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
? ColorsManager.blackColor fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
: ColorsManager.greyColor,
fontWeight: currentStep == step
? FontWeight.bold
: FontWeight.normal,
), ),
), ),
], ],
@ -272,12 +260,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: currentStep == step color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
? ColorsManager.blackColor fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
: ColorsManager.greyColor,
fontWeight: currentStep == step
? FontWeight.bold
: FontWeight.normal,
), ),
), ),
], ],
@ -334,12 +318,8 @@ class _AddNewUserDialogState extends State<AddNewUserDialog> {
label, label,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: currentStep == step color: currentStep == step ? ColorsManager.blackColor : ColorsManager.greyColor,
? ColorsManager.blackColor fontWeight: currentStep == step ? FontWeight.bold : FontWeight.normal,
: ColorsManager.greyColor,
fontWeight: currentStep == step
? FontWeight.bold
: FontWeight.normal,
), ),
), ),
], ],

View File

@ -42,20 +42,29 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
_spaceModels = List.from(widget.spaceModels ?? []); _spaceModels = List.from(widget.spaceModels ?? []);
} }
@override
@override @override
void didUpdateWidget(covariant LoadedSpaceView oldWidget) { void didUpdateWidget(covariant LoadedSpaceView oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (widget.spaceModels != oldWidget.spaceModels) { if (widget.spaceModels != oldWidget.spaceModels) {
setState(() { WidgetsBinding.instance.addPostFrameCallback((_) {
_spaceModels = List.from(widget.spaceModels ?? []); if (mounted) {
setState(() {
_spaceModels = List.from(widget.spaceModels ?? []);
});
}
}); });
} }
} }
void _onSpaceModelsUpdated(List<SpaceTemplateModel> updatedModels) { void _onSpaceModelsUpdated(List<SpaceTemplateModel> updatedModels) {
if (mounted && updatedModels != _spaceModels) { if (mounted && updatedModels != _spaceModels) {
setState(() { WidgetsBinding.instance.addPostFrameCallback((_) {
_spaceModels = updatedModels; if (mounted) {
setState(() {
_spaceModels = updatedModels;
});
}
}); });
} }
} }

View File

@ -299,7 +299,7 @@ class TagHelper {
static Map<String, dynamic> updateSubspaceTagModels( static Map<String, dynamic> updateSubspaceTagModels(
List<TagModel> updatedTags, List<SubspaceTemplateModel>? subspaces) { List<TagModel> updatedTags, List<SubspaceTemplateModel>? subspaces) {
return TagHelper.updateTags<TagModel>( final result = TagHelper.updateTags<TagModel>(
updatedTags: updatedTags, updatedTags: updatedTags,
subspaces: subspaces, subspaces: subspaces,
getInternalId: (tag) => tag.internalId, getInternalId: (tag) => tag.internalId,
@ -310,6 +310,34 @@ class TagHelper {
setSubspaceTags: (subspace, tags) => subspace.tags = tags, setSubspaceTags: (subspace, tags) => subspace.tags = tags,
checkTagExistInSubspace: checkTagExistInSubspaceModels, checkTagExistInSubspace: checkTagExistInSubspaceModels,
); );
final processedTags = result['updatedTags'] as List<TagModel>;
final processedSubspaces =
List<SubspaceTemplateModel>.from(result['subspaces'] as List<dynamic>);
for (var subspace in processedSubspaces) {
final subspaceTags = subspace.tags;
if (subspaceTags != null) {
for (int i = 0; i < subspaceTags.length; i++) {
final tag = subspaceTags[i];
// Find the updated tag inside processedTags
final changedTag = updatedTags.firstWhere(
(t) => t.internalId == tag.internalId,
orElse: () => tag,
);
if (changedTag.tag != tag.tag) {
subspaceTags[i] = changedTag.copyWith(tag: changedTag.tag);
}
}
}
subspace.tags = subspaceTags;
}
return {'updatedTags': processedTags, 'subspaces': processedSubspaces};
} }
static int? checkTagExistInSubspace(Tag tag, List<dynamic>? subspaces) { static int? checkTagExistInSubspace(Tag tag, List<dynamic>? subspaces) {
@ -328,7 +356,7 @@ class TagHelper {
static Map<String, dynamic> processTags( static Map<String, dynamic> processTags(
List<Tag> updatedTags, List<SubspaceModel>? subspaces) { List<Tag> updatedTags, List<SubspaceModel>? subspaces) {
return TagHelper.updateTags<Tag>( final result = TagHelper.updateTags<Tag>(
updatedTags: updatedTags, updatedTags: updatedTags,
subspaces: subspaces, subspaces: subspaces,
getInternalId: (tag) => tag.internalId, getInternalId: (tag) => tag.internalId,
@ -339,6 +367,33 @@ class TagHelper {
setSubspaceTags: (subspace, tags) => subspace.tags = tags, setSubspaceTags: (subspace, tags) => subspace.tags = tags,
checkTagExistInSubspace: checkTagExistInSubspace, checkTagExistInSubspace: checkTagExistInSubspace,
); );
final processedTags = result['updatedTags'] as List<Tag>;
final processedSubspaces =
List<SubspaceModel>.from(result['subspaces'] as List<dynamic>);
for (var subspace in processedSubspaces) {
final subspaceTags = subspace.tags;
if (subspaceTags != null) {
for (int i = 0; i < subspaceTags.length; i++) {
final tag = subspaceTags[i];
final changedTag = updatedTags.firstWhere(
(t) => t.internalId == tag.internalId,
orElse: () => tag,
);
if (changedTag.tag != tag.tag) {
subspaceTags[i] = changedTag.copyWith(tag: changedTag.tag);
}
}
}
subspace.tags = subspaceTags;
}
return {'updatedTags': processedTags, 'subspaces': processedSubspaces};
} }
static List<String> getAllTagValues( static List<String> getAllTagValues(

View File

@ -130,14 +130,14 @@ class CreateSpaceModelDialog extends StatelessWidget {
SubspaceModelCreate( SubspaceModelCreate(
subspaces: state.space.subspaceModels ?? [], subspaces: state.space.subspaceModels ?? [],
tags: state.space.tags ?? [], tags: state.space.tags ?? [],
onSpaceModelUpdate: (updatedSubspaces,updatedTags) { onSpaceModelUpdate: (updatedSubspaces, updatedTags) {
context context
.read<CreateSpaceModelBloc>() .read<CreateSpaceModelBloc>()
.add(AddSubspacesToSpaceTemplate(updatedSubspaces)); .add(AddSubspacesToSpaceTemplate(updatedSubspaces));
if(updatedTags!=null){ if (updatedTags != null) {
context context
.read<CreateSpaceModelBloc>() .read<CreateSpaceModelBloc>()
.add(AddTagsToSpaceTemplate(updatedTags)); .add(AddTagsToSpaceTemplate(updatedTags));
} }
}, },
), ),

View File

@ -34,9 +34,8 @@ class UserPermissionApi {
path: ApiEndpoints.roleTypes, path: ApiEndpoints.roleTypes,
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
final List<RoleTypeModel> fetchedRoles = (json['data'] as List) final List<RoleTypeModel> fetchedRoles =
.map((item) => RoleTypeModel.fromJson(item)) (json['data'] as List).map((item) => RoleTypeModel.fromJson(item)).toList();
.toList();
return fetchedRoles; return fetchedRoles;
}, },
); );
@ -48,9 +47,7 @@ class UserPermissionApi {
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid), path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
showServerMessage: true, showServerMessage: true,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return (json as List) return (json as List).map((data) => PermissionOption.fromJson(data)).toList();
.map((data) => PermissionOption.fromJson(data))
.toList();
}, },
); );
return response ?? []; return response ?? [];
@ -88,7 +85,6 @@ class UserPermissionApi {
} }
}, },
); );
print('sendInviteUser=$body');
return response ?? []; return response ?? [];
} on DioException catch (e) { } on DioException catch (e) {
@ -196,12 +192,9 @@ class UserPermissionApi {
"disable": status, "disable": status,
"projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c" "projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c"
}; };
print('changeUserStatusById==$bodya');
print('changeUserStatusById==$userUuid');
final response = await _httpService.put( final response = await _httpService.put(
path: ApiEndpoints.changeUserStatus path: ApiEndpoints.changeUserStatus.replaceAll("{invitedUserUuid}", userUuid),
.replaceAll("{invitedUserUuid}", userUuid),
body: bodya, body: bodya,
expectedResponseModel: (json) { expectedResponseModel: (json) {
return json['success']; return json['success'];