duplicate name validation

This commit is contained in:
hannathkadher
2025-01-23 17:02:32 +04:00
parent 5563197e9d
commit dac045146e
3 changed files with 30 additions and 11 deletions

View File

@ -52,12 +52,12 @@ class CreateSpaceModelDialog extends StatelessWidget {
create: (_) {
final bloc = CreateSpaceModelBloc(_spaceModelApi);
if (spaceModel != null) {
bloc.add(UpdateSpaceTemplate(spaceModel!));
bloc.add(UpdateSpaceTemplate(spaceModel!,otherSpaceModels));
} else {
bloc.add(UpdateSpaceTemplate(SpaceTemplateModel(
modelName: '',
subspaceModels: const [],
)));
),otherSpaceModels));
}
spaceNameController.addListener(() {
@ -127,6 +127,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
context
.read<CreateSpaceModelBloc>()
.add(AddSubspacesToSpaceTemplate(updatedSubspaces));
context.read<CreateSpaceModelBloc>().add(
UpdateSpaceTemplateName(
name: spaceNameController.text,
allModels: otherSpaceModels ?? []));
},
),
const SizedBox(height: 10),
@ -150,16 +155,18 @@ class CreateSpaceModelDialog extends StatelessWidget {
Expanded(
child: CancelButton(
label: 'Cancel',
onPressed: (){
Navigator.of(context).pop();},
onPressed: () {
Navigator.of(context).pop();
},
),
),
const SizedBox(width: 10),
Expanded(
child: DefaultButton(
onPressed: state.errorMessage == null &&
onPressed: ( state.errorMessage == null) &&
isNameValid
? () {
final updatedSpaceTemplate =
updatedSpaceModel.copyWith(
modelName:
@ -236,10 +243,10 @@ class CreateSpaceModelDialog extends StatelessWidget {
: null,
backgroundColor: ColorsManager.secondaryColor,
borderRadius: 10,
foregroundColor: state.errorMessage == null &&
isNameValid
? ColorsManager.whiteColors
: ColorsManager.whiteColorsWithOpacity,
foregroundColor:
state.errorMessage == null && isNameValid
? ColorsManager.whiteColors
: ColorsManager.whiteColorsWithOpacity,
child: const Text('OK'),
),
),