validation fix

This commit is contained in:
hannathkadher
2025-01-23 17:48:11 +04:00
parent dac045146e
commit d4ed4efcd8
4 changed files with 18 additions and 24 deletions

View File

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