added space model select

This commit is contained in:
hannathkadher
2025-01-12 01:15:44 +04:00
parent bfbc32d51b
commit 15640ff0df
3 changed files with 107 additions and 46 deletions

View File

@ -29,7 +29,6 @@ class CommunityStructureArea extends StatefulWidget {
final List<SpaceModel> spaces; final List<SpaceModel> spaces;
final List<SpaceTemplateModel>? spaceModels; final List<SpaceTemplateModel>? spaceModels;
CommunityStructureArea({ CommunityStructureArea({
this.selectedCommunity, this.selectedCommunity,
this.selectedSpace, this.selectedSpace,
@ -53,7 +52,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
bool isEditingName = false; bool isEditingName = false;
late TransformationController _transformationController; late TransformationController _transformationController;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -292,8 +290,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
products: widget.products, products: widget.products,
spaceModels: widget.spaceModels, spaceModels: widget.spaceModels,
parentSpace: parentIndex != null ? spaces[parentIndex] : null, parentSpace: parentIndex != null ? spaces[parentIndex] : null,
onCreateSpace: (String name, String icon, onCreateSpace: (String name,
List<SelectedProduct> selectedProducts) { String icon,
List<SelectedProduct> selectedProducts,
SpaceTemplateModel? spaceModel) {
setState(() { setState(() {
// Set the first space in the center or use passed position // Set the first space in the center or use passed position
@ -306,6 +306,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
isPrivate: false, isPrivate: false,
children: [], children: [],
status: SpaceStatus.newSpace, status: SpaceStatus.newSpace,
spaceModel: spaceModel,
); );
if (parentIndex != null && direction != null) { if (parentIndex != null && direction != null) {
@ -342,12 +343,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
icon: space.icon, icon: space.icon,
editSpace: space, editSpace: space,
isEdit: true, isEdit: true,
onCreateSpace: (String name, String icon, onCreateSpace: (String name,
List<SelectedProduct> selectedProducts) { String icon,
List<SelectedProduct> selectedProducts,
SpaceTemplateModel? spaceModel) {
setState(() { setState(() {
// Update the space's properties // Update the space's properties
space.name = name; space.name = name;
space.icon = icon; space.icon = icon;
space.spaceModel = spaceModel;
if (space.status != SpaceStatus.newSpace) { if (space.status != SpaceStatus.newSpace) {
space.status = SpaceStatus.modified; // Mark as modified space.status = SpaceStatus.modified; // Mark as modified

View File

@ -14,8 +14,8 @@ import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/constants/space_icon_const.dart'; import 'package:syncrow_web/utils/constants/space_icon_const.dart';
class CreateSpaceDialog extends StatefulWidget { class CreateSpaceDialog extends StatefulWidget {
final Function(String, String, List<SelectedProduct> selectedProducts) final Function(String, String, List<SelectedProduct> selectedProducts,
onCreateSpace; SpaceTemplateModel? spaceModel) onCreateSpace;
final List<ProductModel>? products; final List<ProductModel>? products;
final String? name; final String? name;
final String? icon; final String? icon;
@ -43,6 +43,7 @@ class CreateSpaceDialog extends StatefulWidget {
class CreateSpaceDialogState extends State<CreateSpaceDialog> { class CreateSpaceDialogState extends State<CreateSpaceDialog> {
String selectedIcon = Assets.location; String selectedIcon = Assets.location;
SpaceTemplateModel? selectedSpaceModel;
String enteredName = ''; String enteredName = '';
List<SelectedProduct> selectedProducts = []; List<SelectedProduct> selectedProducts = [];
late TextEditingController nameController; late TextEditingController nameController;
@ -201,6 +202,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
if (selectedSpaceModel == null)
DefaultButton( DefaultButton(
onPressed: () { onPressed: () {
_showLinkSpaceModelDialog(context); _showLinkSpaceModelDialog(context);
@ -219,7 +221,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
padding: const EdgeInsets.only(left: 6.0), padding: const EdgeInsets.only(left: 6.0),
child: SvgPicture.asset( child: SvgPicture.asset(
Assets.link, Assets.link,
width: screenWidth * 0.015, // Adjust icon size width:
screenWidth * 0.015, // Adjust icon size
height: screenWidth * 0.015, height: screenWidth * 0.015,
), ),
), ),
@ -236,6 +239,56 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
), ),
), ),
), ),
if (selectedSpaceModel != null)
Container(
width: screenWidth * 0.35,
padding: const EdgeInsets.symmetric(
vertical: 10.0, horizontal: 16.0),
decoration: BoxDecoration(
color: ColorsManager.boxColor,
borderRadius: BorderRadius.circular(10),
),
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
children: [
Chip(
label: Text(
selectedSpaceModel?.modelName ?? '',
style: const TextStyle(
color: ColorsManager.spaceColor),
),
backgroundColor: ColorsManager.whiteColors,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: const BorderSide(
color: ColorsManager.transparentColor,
width: 0,
),
),
deleteIcon: Container(
width: 24,
height: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: ColorsManager.lightGrayColor,
width: 1.5,
),
),
child: const Icon(
Icons.close,
size: 16,
color: ColorsManager.lightGrayColor,
),
),
onDeleted: () => setState(() {
this.selectedSpaceModel = null;
})),
],
),
),
const SizedBox(height: 25), const SizedBox(height: 25),
const Row( const Row(
children: [ children: [
@ -374,8 +427,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
? enteredName ? enteredName
: (widget.name ?? ''); : (widget.name ?? '');
if (newName.isNotEmpty) { if (newName.isNotEmpty) {
widget.onCreateSpace( widget.onCreateSpace(newName, selectedIcon,
newName, selectedIcon, selectedProducts); selectedProducts, selectedSpaceModel);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} }
@ -427,6 +480,9 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
spaceModels: widget.spaceModels ?? [], spaceModels: widget.spaceModels ?? [],
onSave: (selectedModel) { onSave: (selectedModel) {
if (selectedModel != null) { if (selectedModel != null) {
setState(() {
this.selectedSpaceModel = selectedModel;
});
print('Selected Model: ${selectedModel.modelName}'); print('Selected Model: ${selectedModel.modelName}');
} else { } else {
print('No model selected'); print('No model selected');

View File

@ -134,6 +134,7 @@ class SubspaceModelCreate extends StatelessWidget {
), ),
), ),
), ),
); );
} }
} }