mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
add device type comes from products
This commit is contained in:
@ -2,14 +2,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/widgets/add_device_type_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class CreateSpaceDialog extends StatefulWidget {
|
||||
final Function(String, String) onCreateSpace;
|
||||
final List<ProductModel>? products;
|
||||
|
||||
const CreateSpaceDialog({super.key, required this.onCreateSpace});
|
||||
const CreateSpaceDialog({super.key, required this.onCreateSpace, this.products});
|
||||
|
||||
@override
|
||||
CreateSpaceDialogState createState() => CreateSpaceDialogState();
|
||||
@ -18,6 +20,7 @@ class CreateSpaceDialog extends StatefulWidget {
|
||||
class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
String selectedIcon = Assets.location;
|
||||
String enteredName = '';
|
||||
Map<String, int> selectedProducts = {};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -60,8 +63,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: SvgPicture.asset(Assets.iconEdit,
|
||||
width: 10, height: 10),
|
||||
child: SvgPicture.asset(Assets.iconEdit, width: 10, height: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -89,8 +91,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(
|
||||
0xFFF5F6F7), // Light gray color when enabled (not focused)
|
||||
color:
|
||||
Color(0xFFF5F6F7), // Light gray color when enabled (not focused)
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
@ -98,8 +100,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(
|
||||
0xFFF5F6F7), // Primary color when focused
|
||||
color: Color(0xFFF5F6F7), // Primary color when focused
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
@ -107,8 +108,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
disabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(
|
||||
0xFFF5F6F7), // Light gray for disabled state
|
||||
color: Color(0xFFF5F6F7), // Light gray for disabled state
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
@ -116,8 +116,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(
|
||||
0xFFF5F6F7), // Red border when there's an error
|
||||
color: Color(0xFFF5F6F7), // Red border when there's an error
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
@ -125,8 +124,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(
|
||||
0xFFF5F6F7), // Red border when there's an error and it's focused
|
||||
color: ColorsManager.boxColor, // Red border when there's an error and it's focused
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
@ -138,36 +136,37 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => const AddDeviceWidget(),
|
||||
builder: (context) => AddDeviceWidget(
|
||||
products: widget.products,
|
||||
onProductsSelected: (selectedProductsMap) {
|
||||
setState(() {
|
||||
selectedProducts = selectedProductsMap;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
// Logic to assign devices or select a model
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ColorsManager.textFieldGreyColor,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 20),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: const BorderSide(
|
||||
// Add border side here
|
||||
color: Color(
|
||||
0xFFE5E5E5), // Define your desired border color
|
||||
color: ColorsManager.neutralGray, // Define your desired border color
|
||||
width: 2.0, // Define border width
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize
|
||||
.min, // Adjust the button size to fit the content
|
||||
mainAxisSize:
|
||||
MainAxisSize.min, // Adjust the button size to fit the content
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets
|
||||
.addIcon, // Replace with your actual icon path
|
||||
Assets.addIcon, // Replace with your actual icon path
|
||||
width: 20, // Set the size of the icon
|
||||
height: 20,
|
||||
),
|
||||
const SizedBox(
|
||||
width:
|
||||
8), // Add spacing between the icon and text
|
||||
const SizedBox(width: 8), // Add spacing between the icon and text
|
||||
const Text(
|
||||
'Add devices / Assign a space model',
|
||||
style: TextStyle(
|
||||
@ -175,15 +174,13 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
fontSize: 16,
|
||||
fontFamily: 'Aftika',
|
||||
fontWeight: FontWeight.w400,
|
||||
height:
|
||||
1.5, // Adjust line height for better spacing
|
||||
height: 1.5, // Adjust line height for better spacing
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -207,13 +204,12 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
child: DefaultButton(
|
||||
onPressed: () {
|
||||
if (enteredName.isNotEmpty) {
|
||||
widget.onCreateSpace(enteredName,
|
||||
selectedIcon); // Pass the name and icon back
|
||||
widget.onCreateSpace(enteredName, selectedIcon); // Pass the name and icon back
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
}
|
||||
},
|
||||
backgroundColor: ColorsManager.secondaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
foregroundColor: ColorsManager.whiteColors,
|
||||
child: const Text('OK'),
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user