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

@ -14,8 +14,8 @@ import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/constants/space_icon_const.dart';
class CreateSpaceDialog extends StatefulWidget {
final Function(String, String, List<SelectedProduct> selectedProducts)
onCreateSpace;
final Function(String, String, List<SelectedProduct> selectedProducts,
SpaceTemplateModel? spaceModel) onCreateSpace;
final List<ProductModel>? products;
final String? name;
final String? icon;
@ -43,6 +43,7 @@ class CreateSpaceDialog extends StatefulWidget {
class CreateSpaceDialogState extends State<CreateSpaceDialog> {
String selectedIcon = Assets.location;
SpaceTemplateModel? selectedSpaceModel;
String enteredName = '';
List<SelectedProduct> selectedProducts = [];
late TextEditingController nameController;
@ -201,41 +202,93 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
),
),
const SizedBox(height: 10),
DefaultButton(
onPressed: () {
_showLinkSpaceModelDialog(context);
},
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: Colors.black,
borderColor: ColorsManager.neutralGray,
borderRadius: 16.0,
padding: 10.0, // Reduced padding for smaller size
child: Align(
alignment: Alignment.centerLeft,
child: Row(
mainAxisSize: MainAxisSize.min,
if (selectedSpaceModel == null)
DefaultButton(
onPressed: () {
_showLinkSpaceModelDialog(context);
},
backgroundColor: ColorsManager.textFieldGreyColor,
foregroundColor: Colors.black,
borderColor: ColorsManager.neutralGray,
borderRadius: 16.0,
padding: 10.0, // Reduced padding for smaller size
child: Align(
alignment: Alignment.centerLeft,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(left: 6.0),
child: SvgPicture.asset(
Assets.link,
width:
screenWidth * 0.015, // Adjust icon size
height: screenWidth * 0.015,
),
),
const SizedBox(width: 3),
Flexible(
child: Text(
'Link a space model',
overflow:
TextOverflow.ellipsis, // Prevent overflow
style: Theme.of(context).textTheme.bodyMedium,
),
),
],
),
),
),
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: [
Padding(
padding: const EdgeInsets.only(left: 6.0),
child: SvgPicture.asset(
Assets.link,
width: screenWidth * 0.015, // Adjust icon size
height: screenWidth * 0.015,
Chip(
label: Text(
selectedSpaceModel?.modelName ?? '',
style: const TextStyle(
color: ColorsManager.spaceColor),
),
),
const SizedBox(width: 3),
Flexible(
child: Text(
'Link a space model',
overflow:
TextOverflow.ellipsis, // Prevent overflow
style: Theme.of(context).textTheme.bodyMedium,
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 Row(
children: [
@ -374,8 +427,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
? enteredName
: (widget.name ?? '');
if (newName.isNotEmpty) {
widget.onCreateSpace(
newName, selectedIcon, selectedProducts);
widget.onCreateSpace(newName, selectedIcon,
selectedProducts, selectedSpaceModel);
Navigator.of(context).pop();
}
}
@ -427,6 +480,9 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
spaceModels: widget.spaceModels ?? [],
onSave: (selectedModel) {
if (selectedModel != null) {
setState(() {
this.selectedSpaceModel = selectedModel;
});
print('Selected Model: ${selectedModel.modelName}');
} else {
print('No model selected');