added validation

This commit is contained in:
hannathkadher
2025-01-06 16:38:44 +04:00
parent a31eb27c92
commit 6ee650e9f8
6 changed files with 278 additions and 131 deletions

View File

@ -16,8 +16,9 @@ import '../../models/subspace_template_model.dart';
class CreateSpaceModelDialog extends StatelessWidget {
final List<ProductModel>? products;
final List<String>? allTags;
const CreateSpaceModelDialog({Key? key, this.products}) : super(key: key);
const CreateSpaceModelDialog({Key? key, this.products, this.allTags}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -79,6 +80,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
builder: (context) => AddDeviceTypeModelWidget(
products: products,
subspaces: subspaces,
allTags: allTags,
),
);
if (result == true) {

View File

@ -69,7 +69,8 @@ class SpaceModelCardWidget extends StatelessWidget {
spacing: 3.0,
runSpacing: 3.0,
children: [
for (var subspace in model.subspaceModels!.take(3))
for (var subspace in model.subspaceModels!
.take(calculateTakeCount(context)))
SubspaceChipWidget(subspace: subspace.subspaceName),
],
),
@ -126,4 +127,16 @@ class SpaceModelCardWidget extends StatelessWidget {
),
);
}
int calculateTakeCount(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
// Adjust the count based on the screen width
if (screenWidth > 1500) {
return 3; // For large screens
} else if (screenWidth > 1200) {
return 2;
} else {
return 1; // For smaller screens
}
}
}