diff --git a/assets/icons/duplicate.svg b/assets/icons/duplicate.svg
new file mode 100644
index 00000000..1faa1bab
--- /dev/null
+++ b/assets/icons/duplicate.svg
@@ -0,0 +1,16 @@
+
diff --git a/assets/icons/edit_space.svg b/assets/icons/edit_space.svg
new file mode 100644
index 00000000..417cd5bd
--- /dev/null
+++ b/assets/icons/edit_space.svg
@@ -0,0 +1,22 @@
+
diff --git a/assets/icons/space_delete.svg b/assets/icons/space_delete.svg
new file mode 100644
index 00000000..90c3413e
--- /dev/null
+++ b/assets/icons/space_delete.svg
@@ -0,0 +1,9 @@
+
diff --git a/lib/common/edit_chip.dart b/lib/common/edit_chip.dart
new file mode 100644
index 00000000..7607834d
--- /dev/null
+++ b/lib/common/edit_chip.dart
@@ -0,0 +1,39 @@
+import 'package:flutter/material.dart';
+import 'package:syncrow_web/utils/color_manager.dart';
+
+class EditChip extends StatelessWidget {
+ final String label;
+ final VoidCallback onTap;
+ final Color labelColor;
+ final Color backgroundColor;
+ final Color borderColor;
+ final double borderRadius;
+
+ const EditChip({
+ Key? key,
+ this.label = 'Edit',
+ required this.onTap,
+ this.labelColor = ColorsManager.spaceColor,
+ this.backgroundColor = ColorsManager.whiteColors,
+ this.borderColor = ColorsManager.spaceColor,
+ this.borderRadius = 16.0,
+ }) : super(key: key);
+
+ @override
+ Widget build(BuildContext context) {
+ return GestureDetector(
+ onTap: onTap,
+ child: Chip(
+ label: Text(
+ label,
+ style: TextStyle(color: labelColor),
+ ),
+ backgroundColor: backgroundColor,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(borderRadius),
+ side: BorderSide(color: borderColor),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/common/buttons/default_button.dart b/lib/pages/common/buttons/default_button.dart
index 4aa748b7..ecca6138 100644
--- a/lib/pages/common/buttons/default_button.dart
+++ b/lib/pages/common/buttons/default_button.dart
@@ -19,12 +19,14 @@ class DefaultButton extends StatelessWidget {
this.padding,
this.borderColor,
this.elevation,
+ this.borderWidth = 1.0,
});
final void Function()? onPressed;
final Widget child;
final double? height;
final bool isSecondary;
final double? borderRadius;
+ final double borderWidth;
final bool enabled;
final double? padding;
final bool isDone;
@@ -66,13 +68,16 @@ class DefaultButton extends StatelessWidget {
}),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
- side: BorderSide(color: borderColor ?? Colors.transparent),
+ side: BorderSide(
+ color: borderColor ?? Colors.transparent,
+ width: borderWidth,
+ ),
borderRadius: BorderRadius.circular(borderRadius ?? 20),
),
),
fixedSize: height != null
- ? WidgetStateProperty.all(Size.fromHeight(height!))
- : null,
+ ? WidgetStateProperty.all(Size.fromHeight(height!))
+ : null,
padding: WidgetStateProperty.all(
EdgeInsets.all(padding ?? 10),
),
diff --git a/lib/pages/spaces_management/add_device_type/bloc/add_device_model_bloc.dart b/lib/pages/spaces_management/add_device_type/bloc/add_device_model_bloc.dart
index 10f3327e..e84851c5 100644
--- a/lib/pages/spaces_management/add_device_type/bloc/add_device_model_bloc.dart
+++ b/lib/pages/spaces_management/add_device_type/bloc/add_device_model_bloc.dart
@@ -1,38 +1,74 @@
import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_state.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
import 'package:syncrow_web/pages/spaces_management/add_device_type/bloc/add_device_type_model_event.dart';
-class AddDeviceTypeBloc
- extends Bloc> {
- AddDeviceTypeBloc(List initialProducts)
- : super(initialProducts) {
+class AddDeviceTypeBloc extends Bloc {
+ AddDeviceTypeBloc() : super(AddDeviceInitial()) {
+ on(_onInitializeTagModels);
on(_onUpdateProductCount);
}
- void _onUpdateProductCount(
- UpdateProductCountEvent event, Emitter> emit) {
- final existingProduct = state.firstWhere(
- (p) => p.productId == event.productId,
- orElse: () => SelectedProduct(productId: event.productId, count: 0,productName: event.productName,product: event.product ),
- );
+ void _onInitializeTagModels(
+ InitializeDevice event, Emitter emit) {
+ emit(AddDeviceLoaded(
+ selectedProducts: event.addedProducts,
+ initialTag: event.initialTags,
+ ));
+ }
- if (event.count > 0) {
- if (!state.contains(existingProduct)) {
- emit([
- ...state,
- SelectedProduct(productId: event.productId, count: event.count, productName: event.productName, product: event.product)
- ]);
+ void _onUpdateProductCount(
+ UpdateProductCountEvent event, Emitter emit) {
+ final currentState = state;
+
+ if (currentState is AddDeviceLoaded) {
+ final existingProduct = currentState.selectedProducts.firstWhere(
+ (p) => p.productId == event.productId,
+ orElse: () => SelectedProduct(
+ productId: event.productId,
+ count: 0,
+ productName: event.productName,
+ product: event.product,
+ ),
+ );
+
+ List updatedProducts;
+
+ if (event.count > 0) {
+ if (!currentState.selectedProducts.contains(existingProduct)) {
+ updatedProducts = [
+ ...currentState.selectedProducts,
+ SelectedProduct(
+ productId: event.productId,
+ count: event.count,
+ productName: event.productName,
+ product: event.product,
+ ),
+ ];
+ } else {
+ updatedProducts = currentState.selectedProducts.map((p) {
+ if (p.productId == event.productId) {
+ return SelectedProduct(
+ productId: p.productId,
+ count: event.count,
+ productName: p.productName,
+ product: p.product,
+ );
+ }
+ return p;
+ }).toList();
+ }
} else {
- final updatedList = state.map((p) {
- if (p.productId == event.productId) {
- return SelectedProduct(productId: p.productId, count: event.count, productName: p.productName,product: p.product);
- }
- return p;
- }).toList();
- emit(updatedList);
+ // Remove the product if the count is 0
+ updatedProducts = currentState.selectedProducts
+ .where((p) => p.productId != event.productId)
+ .toList();
}
- } else {
- emit(state.where((p) => p.productId != event.productId).toList());
+
+ // Emit the updated state
+ emit(AddDeviceLoaded(
+ selectedProducts: updatedProducts,
+ initialTag: currentState.initialTag));
}
}
}
diff --git a/lib/pages/spaces_management/add_device_type/bloc/add_device_state.dart b/lib/pages/spaces_management/add_device_type/bloc/add_device_state.dart
new file mode 100644
index 00000000..e1fa2593
--- /dev/null
+++ b/lib/pages/spaces_management/add_device_type/bloc/add_device_state.dart
@@ -0,0 +1,36 @@
+import 'package:equatable/equatable.dart';
+import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
+import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
+
+abstract class AddDeviceState extends Equatable {
+ const AddDeviceState();
+
+ @override
+ List