mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Merge pull request #144 from SyncrowIOT/SP-1333-FE-set-barrier-dismissable-to-true
Sp 1333 fe set barrier dismissable to true
This commit is contained in:
@ -145,13 +145,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TagChipDisplay(
|
TagChipDisplay(
|
||||||
context,
|
|
||||||
screenWidth: screenWidth,
|
|
||||||
spaceModel: updatedSpaceModel,
|
spaceModel: updatedSpaceModel,
|
||||||
products: products,
|
products: products,
|
||||||
subspaces: subspaces,
|
subspaces: subspaces,
|
||||||
allTags: allTags,
|
allTags: allTags,
|
||||||
spaceNameController: spaceNameController,
|
spaceName: spaceNameController.text,
|
||||||
pageContext: pageContext,
|
pageContext: pageContext,
|
||||||
otherSpaceModels: otherSpaceModels,
|
otherSpaceModels: otherSpaceModels,
|
||||||
allSpaceModels: allSpaceModels,
|
allSpaceModels: allSpaceModels,
|
||||||
|
@ -10,139 +10,152 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_
|
|||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class TagChipDisplay extends StatelessWidget {
|
class TagChipDisplay extends StatelessWidget {
|
||||||
final double screenWidth;
|
const TagChipDisplay({
|
||||||
|
required this.spaceModel,
|
||||||
|
required this.products,
|
||||||
|
required this.subspaces,
|
||||||
|
required this.allTags,
|
||||||
|
required this.spaceName,
|
||||||
|
required this.projectTags,
|
||||||
|
this.pageContext,
|
||||||
|
this.otherSpaceModels,
|
||||||
|
this.allSpaceModels,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final SpaceTemplateModel? spaceModel;
|
final SpaceTemplateModel? spaceModel;
|
||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final List<SubspaceTemplateModel>? subspaces;
|
final List<SubspaceTemplateModel>? subspaces;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final TextEditingController spaceNameController;
|
final String spaceName;
|
||||||
final BuildContext? pageContext;
|
final BuildContext? pageContext;
|
||||||
final List<String>? otherSpaceModels;
|
final List<String>? otherSpaceModels;
|
||||||
final List<SpaceTemplateModel>? allSpaceModels;
|
final List<SpaceTemplateModel>? allSpaceModels;
|
||||||
final List<Tag> projectTags;
|
final List<Tag> projectTags;
|
||||||
|
|
||||||
const TagChipDisplay(BuildContext context,
|
Map<ProductModel, int> get _groupedTags {
|
||||||
{Key? key,
|
final spaceTags = spaceModel?.tags ?? <Tag>[];
|
||||||
required this.screenWidth,
|
|
||||||
required this.spaceModel,
|
final subspaces = spaceModel?.subspaceModels ?? [];
|
||||||
required this.products,
|
final subspaceTags = subspaces.expand((e) => e.tags ?? <Tag>[]).toList();
|
||||||
required this.subspaces,
|
|
||||||
required this.allTags,
|
return TagHelper.groupTags([...spaceTags, ...subspaceTags]);
|
||||||
required this.spaceNameController,
|
}
|
||||||
this.pageContext,
|
|
||||||
this.otherSpaceModels,
|
|
||||||
this.allSpaceModels,
|
|
||||||
required this.projectTags})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return (spaceModel?.tags?.isNotEmpty == true ||
|
final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
|
||||||
spaceModel?.subspaceModels?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
final hasSubspaceTags =
|
||||||
true)
|
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ?? false;
|
||||||
? SizedBox(
|
|
||||||
width: screenWidth * 0.25,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.textFieldGreyColor,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
border: Border.all(
|
|
||||||
color: ColorsManager.textFieldGreyColor,
|
|
||||||
width: 3.0, // Border width
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8.0,
|
|
||||||
runSpacing: 8.0,
|
|
||||||
children: [
|
|
||||||
// Combine tags from spaceModel and subspaces
|
|
||||||
...TagHelper.groupTags([
|
|
||||||
...?spaceModel?.tags,
|
|
||||||
...?spaceModel?.subspaceModels?.expand((subspace) => subspace.tags ?? [])
|
|
||||||
]).entries.map(
|
|
||||||
(entry) => Chip(
|
|
||||||
avatar: SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
label: Text(
|
|
||||||
'x${entry.value}', // Show count
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall!
|
|
||||||
.copyWith(color: ColorsManager.spaceColor),
|
|
||||||
),
|
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
side: const BorderSide(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
EditChip(onTap: () async {
|
|
||||||
// Use the Navigator's context for showDialog
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
await showDialog<bool>(
|
if (hasTags || hasSubspaceTags) {
|
||||||
barrierDismissible: false,
|
return Container(
|
||||||
context: context,
|
width: context.screenWidth * 0.25,
|
||||||
builder: (context) => AssignTagModelsDialog(
|
padding: const EdgeInsets.all(8),
|
||||||
products: products,
|
decoration: BoxDecoration(
|
||||||
allSpaceModels: allSpaceModels,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
subspaces: subspaces,
|
borderRadius: BorderRadius.circular(15),
|
||||||
pageContext: pageContext,
|
border: Border.all(
|
||||||
allTags: allTags,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
spaceModel: spaceModel,
|
width: 3,
|
||||||
otherSpaceModels: otherSpaceModels,
|
),
|
||||||
initialTags: TagHelper.generateInitialTags(
|
),
|
||||||
subspaces: subspaces, spaceTagModels: spaceModel?.tags ?? []),
|
child: Wrap(
|
||||||
title: 'Edit Device',
|
spacing: 8,
|
||||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
runSpacing: 8,
|
||||||
spaceModel?.tags ?? [], subspaces),
|
children: [
|
||||||
spaceName: spaceModel?.modelName ?? '',
|
..._groupedTags.entries.map((entry) => _buildChip(context, entry)),
|
||||||
projectTags: projectTags,
|
_buildEditChip(context),
|
||||||
));
|
],
|
||||||
})
|
),
|
||||||
],
|
);
|
||||||
),
|
}
|
||||||
),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
await showDialog<bool>(
|
return _buildAddDevicesButton(context);
|
||||||
barrierDismissible: false,
|
}
|
||||||
context: context,
|
|
||||||
builder: (context) => AddDeviceTypeModelWidget(
|
Widget _buildEditChip(BuildContext context) {
|
||||||
products: products,
|
return EditChip(
|
||||||
subspaces: subspaces,
|
onTap: () => showDialog<void>(
|
||||||
allTags: allTags,
|
context: context,
|
||||||
spaceName: spaceNameController.text,
|
builder: (context) => AssignTagModelsDialog(
|
||||||
pageContext: pageContext,
|
products: products,
|
||||||
isCreate: true,
|
allSpaceModels: allSpaceModels,
|
||||||
spaceModel: spaceModel,
|
subspaces: subspaces,
|
||||||
otherSpaceModels: otherSpaceModels,
|
pageContext: pageContext,
|
||||||
projectTags: projectTags,
|
allTags: allTags,
|
||||||
),
|
spaceModel: spaceModel,
|
||||||
);
|
otherSpaceModels: otherSpaceModels,
|
||||||
},
|
initialTags: TagHelper.generateInitialTags(
|
||||||
style: TextButton.styleFrom(
|
subspaces: subspaces,
|
||||||
padding: EdgeInsets.zero,
|
spaceTagModels: spaceModel?.tags ?? [],
|
||||||
),
|
),
|
||||||
child: const ButtonContentWidget(
|
title: 'Edit Device',
|
||||||
icon: Icons.add,
|
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||||
label: 'Add Devices',
|
spaceModel?.tags ?? [],
|
||||||
),
|
subspaces,
|
||||||
);
|
),
|
||||||
|
spaceName: spaceModel?.modelName ?? '',
|
||||||
|
projectTags: projectTags,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildChip(
|
||||||
|
BuildContext context,
|
||||||
|
MapEntry<ProductModel, int> entry,
|
||||||
|
) {
|
||||||
|
return Chip(
|
||||||
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
side: const BorderSide(
|
||||||
|
color: ColorsManager.spaceColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
avatar: SvgPicture.asset(
|
||||||
|
entry.key.icon ?? Assets.gateway,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
height: 24,
|
||||||
|
width: 24,
|
||||||
|
),
|
||||||
|
label: Text(
|
||||||
|
'${entry.value}',
|
||||||
|
style: context.textTheme.bodySmall!.copyWith(
|
||||||
|
color: ColorsManager.spaceColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAddDevicesButton(BuildContext context) {
|
||||||
|
return TextButton(
|
||||||
|
onPressed: () => showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AddDeviceTypeModelWidget(
|
||||||
|
products: products,
|
||||||
|
subspaces: subspaces,
|
||||||
|
allTags: allTags,
|
||||||
|
spaceName: spaceName,
|
||||||
|
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