space model creation

This commit is contained in:
hannathkadher
2025-01-07 17:34:38 +04:00
parent e7e0149b3a
commit 1228e5e737
13 changed files with 110 additions and 41 deletions

View File

@ -4,6 +4,7 @@ import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
@ -17,13 +18,17 @@ import '../../models/subspace_template_model.dart';
class CreateSpaceModelDialog extends StatelessWidget {
final List<ProductModel>? products;
final List<String>? allTags;
final SpaceTemplateModel? spaceModel;
const CreateSpaceModelDialog({Key? key, this.products, this.allTags}) : super(key: key);
const CreateSpaceModelDialog(
{Key? key, this.products, this.allTags, this.spaceModel})
: super(key: key);
@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
List<SubspaceTemplateModel>? subspaces = []; // Store subspaces here
List<SubspaceTemplateModel>? subspaces = [];
final TextEditingController spaceNameController = TextEditingController();
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
@ -33,6 +38,14 @@ class CreateSpaceModelDialog extends StatelessWidget {
child: BlocProvider(
create: (_) {
final bloc = CreateSpaceModelBloc();
if (spaceModel != null) {
bloc.add(UpdateSpaceTemplate(spaceModel!));
} else {
bloc.add(UpdateSpaceTemplate(SpaceTemplateModel(
modelName: '',
subspaceModels: [],
)));
}
return bloc;
},
child: BlocBuilder<CreateSpaceModelBloc, CreateSpaceModelState>(
@ -51,6 +64,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
SizedBox(
width: screenWidth * 0.25,
child: TextField(
controller: spaceNameController,
style: const TextStyle(color: ColorsManager.blackColor),
decoration: InputDecoration(
filled: true,
@ -81,12 +95,10 @@ class CreateSpaceModelDialog extends StatelessWidget {
products: products,
subspaces: subspaces,
allTags: allTags,
spaceName: spaceNameController.text,
),
);
if (result == true) {
// Handle the result if necessary
print('Devices added successfully');
}
if (result == true) {}
},
style: TextButton.styleFrom(
padding: EdgeInsets.zero,

View File

@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
import 'package:syncrow_web/pages/spaces_management/subspace_model/views/create_subspace_model_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/views/create_subspace_model_dialog.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';