refactor: extract EditChip into a private method for improved readability

This commit is contained in:
Faris Armoush
2025-04-15 15:25:19 +03:00
parent 90e0d2f52b
commit a4432656ab

View File

@ -67,7 +67,18 @@ class TagChipDisplay extends StatelessWidget {
runSpacing: 8,
children: [
..._groupedTags.entries.map((entry) => _buildChip(context, entry)),
EditChip(
_buildEditChip(context),
],
),
),
);
} else {
return _buildAddDevicesButton(context);
}
}
Widget _buildEditChip(BuildContext context) {
return EditChip(
onTap: () => showDialog<void>(
context: context,
builder: (context) => AssignTagModelsDialog(
@ -80,7 +91,8 @@ class TagChipDisplay extends StatelessWidget {
otherSpaceModels: otherSpaceModels,
initialTags: TagHelper.generateInitialTags(
subspaces: subspaces,
spaceTagModels: spaceModel?.tags ?? []),
spaceTagModels: spaceModel?.tags ?? [],
),
title: 'Edit Device',
addedProducts: TagHelper.createInitialSelectedProducts(
spaceModel?.tags ?? [],
@ -90,17 +102,10 @@ class TagChipDisplay extends StatelessWidget {
projectTags: projectTags,
),
),
),
],
),
),
);
} else {
return _buildAddDevicesButton(context);
}
}
Chip _buildChip(
Widget _buildChip(
BuildContext context,
MapEntry<ProductModel, int> entry,
) {