mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Replaced conditional with an if statement in TagChipDisplay
.
This commit is contained in:
@ -40,106 +40,108 @@ class TagChipDisplay extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return (spaceModel?.tags?.isNotEmpty == true ||
|
if ((spaceModel?.tags?.isNotEmpty == true ||
|
||||||
spaceModel?.subspaceModels
|
spaceModel?.subspaceModels
|
||||||
?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||||
true)
|
true)) {
|
||||||
? SizedBox(
|
return SizedBox(
|
||||||
width: screenWidth * 0.25,
|
width: screenWidth * 0.25,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.textFieldGreyColor,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
borderRadius: BorderRadius.circular(15),
|
borderRadius: BorderRadius.circular(15),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: ColorsManager.textFieldGreyColor,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
width: 3.0,
|
width: 3.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
spacing: 8.0,
|
spacing: 8.0,
|
||||||
runSpacing: 8.0,
|
runSpacing: 8.0,
|
||||||
children: [
|
children: [
|
||||||
...TagHelper.groupTags([
|
...TagHelper.groupTags([
|
||||||
...?spaceModel?.tags,
|
...?spaceModel?.tags,
|
||||||
...?spaceModel?.subspaceModels?.expand((e) => e.tags ?? [])
|
...?spaceModel?.subspaceModels?.expand((e) => e.tags ?? [])
|
||||||
]).entries.map(
|
]).entries.map(
|
||||||
(entry) => Chip(
|
(entry) => Chip(
|
||||||
avatar: SizedBox(
|
avatar: SizedBox(
|
||||||
width: 24,
|
width: 24,
|
||||||
height: 24,
|
height: 24,
|
||||||
child: SvgPicture.asset(
|
child: SvgPicture.asset(
|
||||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
entry.key.icon ?? 'assets/icons/gateway.svg',
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
),
|
|
||||||
),
|
|
||||||
label: Text(
|
|
||||||
'x${entry.value}',
|
|
||||||
style: context.textTheme.bodySmall!.copyWith(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
side: const BorderSide(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
EditChip(
|
label: Text(
|
||||||
onTap: () => showDialog<bool>(
|
'x${entry.value}',
|
||||||
context: context,
|
style: context.textTheme.bodySmall!.copyWith(
|
||||||
builder: (context) => AssignTagModelsDialog(
|
color: ColorsManager.spaceColor,
|
||||||
products: products,
|
),
|
||||||
allSpaceModels: allSpaceModels,
|
),
|
||||||
subspaces: subspaces,
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
pageContext: pageContext,
|
shape: RoundedRectangleBorder(
|
||||||
allTags: allTags,
|
borderRadius: BorderRadius.circular(16),
|
||||||
spaceModel: spaceModel,
|
side: const BorderSide(
|
||||||
otherSpaceModels: otherSpaceModels,
|
color: ColorsManager.spaceColor,
|
||||||
initialTags: TagHelper.generateInitialTags(
|
|
||||||
subspaces: subspaces,
|
|
||||||
spaceTagModels: spaceModel?.tags ?? []),
|
|
||||||
title: 'Edit Device',
|
|
||||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
|
||||||
spaceModel?.tags ?? [],
|
|
||||||
subspaces,
|
|
||||||
),
|
),
|
||||||
spaceName: spaceModel?.modelName ?? '',
|
|
||||||
projectTags: projectTags,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
EditChip(
|
||||||
),
|
onTap: () => showDialog<bool>(
|
||||||
),
|
context: context,
|
||||||
)
|
builder: (context) => AssignTagModelsDialog(
|
||||||
: TextButton(
|
products: products,
|
||||||
onPressed: () {
|
allSpaceModels: allSpaceModels,
|
||||||
showDialog<void>(
|
subspaces: subspaces,
|
||||||
context: context,
|
pageContext: pageContext,
|
||||||
builder: (context) => AddDeviceTypeModelWidget(
|
allTags: allTags,
|
||||||
products: products,
|
spaceModel: spaceModel,
|
||||||
subspaces: subspaces,
|
otherSpaceModels: otherSpaceModels,
|
||||||
allTags: allTags,
|
initialTags: TagHelper.generateInitialTags(
|
||||||
spaceName: spaceNameController.text,
|
subspaces: subspaces,
|
||||||
pageContext: pageContext,
|
spaceTagModels: spaceModel?.tags ?? []),
|
||||||
isCreate: true,
|
title: 'Edit Device',
|
||||||
spaceModel: spaceModel,
|
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||||
otherSpaceModels: otherSpaceModels,
|
spaceModel?.tags ?? [],
|
||||||
projectTags: projectTags,
|
subspaces,
|
||||||
|
),
|
||||||
|
spaceName: spaceModel?.modelName ?? '',
|
||||||
|
projectTags: projectTags,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
style: TextButton.styleFrom(
|
),
|
||||||
padding: EdgeInsets.zero,
|
),
|
||||||
),
|
);
|
||||||
child: const ButtonContentWidget(
|
} else {
|
||||||
icon: Icons.add,
|
return TextButton(
|
||||||
label: 'Add Devices',
|
onPressed: () {
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AddDeviceTypeModelWidget(
|
||||||
|
products: products,
|
||||||
|
subspaces: subspaces,
|
||||||
|
allTags: allTags,
|
||||||
|
spaceName: spaceNameController.text,
|
||||||
|
pageContext: pageContext,
|
||||||
|
isCreate: true,
|
||||||
|
spaceModel: spaceModel,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
projectTags: projectTags,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
child: const ButtonContentWidget(
|
||||||
|
icon: Icons.add,
|
||||||
|
label: 'Add Devices',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user