mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 17:47:53 +00:00
@ -45,7 +45,7 @@ class ConfirmMergeDialog extends StatelessWidget {
|
||||
elevation: 3,
|
||||
),
|
||||
child: Text(
|
||||
'Cancel',
|
||||
"Cancel",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
@ -66,7 +66,7 @@ class ConfirmMergeDialog extends StatelessWidget {
|
||||
elevation: 3,
|
||||
),
|
||||
child: Text(
|
||||
'Ok',
|
||||
"Ok",
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 16,
|
||||
|
@ -56,7 +56,7 @@ class ConfirmOverwriteDialog extends StatelessWidget {
|
||||
elevation: 3,
|
||||
),
|
||||
child: Text(
|
||||
'Cancel',
|
||||
"Cancel",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
@ -86,7 +86,7 @@ class ConfirmOverwriteDialog extends StatelessWidget {
|
||||
elevation: 3,
|
||||
),
|
||||
child: Text(
|
||||
'Ok',
|
||||
"Ok",
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 16,
|
||||
|
@ -9,12 +9,13 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_model_create_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/tag_chips_display_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
|
||||
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_model_create_widget.dart';
|
||||
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
@ -28,21 +29,22 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const CreateSpaceModelDialog(
|
||||
{super.key,
|
||||
{Key? key,
|
||||
this.products,
|
||||
this.allTags,
|
||||
this.spaceModel,
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.allSpaceModels,
|
||||
required this.projectTags});
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final spaceModelApi = SpaceModelManagementApi();
|
||||
final SpaceModelManagementApi _spaceModelApi = SpaceModelManagementApi();
|
||||
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final spaceNameController = TextEditingController(
|
||||
final TextEditingController spaceNameController = TextEditingController(
|
||||
text: spaceModel?.modelName ?? '',
|
||||
);
|
||||
|
||||
@ -54,7 +56,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
child: BlocProvider(
|
||||
create: (_) {
|
||||
final bloc = CreateSpaceModelBloc(
|
||||
spaceModelApi,
|
||||
_spaceModelApi,
|
||||
);
|
||||
if (spaceModel != null) {
|
||||
bloc.add(UpdateSpaceTemplate(spaceModel!, otherSpaceModels));
|
||||
@ -69,8 +71,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
|
||||
spaceNameController.addListener(() {
|
||||
bloc.add(UpdateSpaceTemplateName(
|
||||
name: spaceNameController.text,
|
||||
allModels: otherSpaceModels ?? []));
|
||||
name: spaceNameController.text, allModels: otherSpaceModels ?? []));
|
||||
});
|
||||
|
||||
return bloc;
|
||||
@ -88,9 +89,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
spaceModel?.uuid == null
|
||||
? 'Create New Space Model'
|
||||
: 'Edit Space Model',
|
||||
spaceModel?.uuid == null ? 'Create New Space Model' : 'Edit Space Model',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineLarge
|
||||
@ -102,10 +101,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
child: TextField(
|
||||
controller: spaceNameController,
|
||||
onChanged: (value) {
|
||||
context.read<CreateSpaceModelBloc>().add(
|
||||
UpdateSpaceTemplateName(
|
||||
name: value,
|
||||
allModels: otherSpaceModels ?? []));
|
||||
context.read<CreateSpaceModelBloc>().add(UpdateSpaceTemplateName(
|
||||
name: value, allModels: otherSpaceModels ?? []));
|
||||
},
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
@ -179,84 +176,55 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
!isNameValid)
|
||||
? null
|
||||
: () {
|
||||
final updatedSpaceTemplate =
|
||||
updatedSpaceModel.copyWith(
|
||||
modelName:
|
||||
spaceNameController.text.trim(),
|
||||
final updatedSpaceTemplate = updatedSpaceModel.copyWith(
|
||||
modelName: spaceNameController.text.trim(),
|
||||
);
|
||||
if (updatedSpaceModel.uuid == null) {
|
||||
context
|
||||
.read<CreateSpaceModelBloc>()
|
||||
.add(
|
||||
context.read<CreateSpaceModelBloc>().add(
|
||||
CreateSpaceTemplate(
|
||||
spaceTemplate:
|
||||
updatedSpaceTemplate,
|
||||
spaceTemplate: updatedSpaceTemplate,
|
||||
onCreate: (newModel) {
|
||||
if (pageContext != null) {
|
||||
pageContext!.read<SpaceModelBloc>().add(
|
||||
CreateSpaceModel(newSpaceModel: newModel));
|
||||
pageContext!
|
||||
.read<SpaceModelBloc>()
|
||||
.add(CreateSpaceModel(
|
||||
newSpaceModel:
|
||||
newModel));
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceManagementBloc>()
|
||||
.add(
|
||||
UpdateSpaceModelCache(
|
||||
newModel));
|
||||
.read<SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(newModel));
|
||||
}
|
||||
Navigator.of(context)
|
||||
.pop(); // Close the dialog
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (pageContext != null) {
|
||||
final currentState = pageContext!
|
||||
.read<SpaceModelBloc>()
|
||||
.state;
|
||||
if (currentState
|
||||
is SpaceModelLoaded) {
|
||||
final spaceModels =
|
||||
List<SpaceTemplateModel>.from(
|
||||
currentState.spaceModels);
|
||||
final currentState =
|
||||
pageContext!.read<SpaceModelBloc>().state;
|
||||
if (currentState is SpaceModelLoaded) {
|
||||
final spaceModels = List<SpaceTemplateModel>.from(
|
||||
currentState.spaceModels);
|
||||
|
||||
final currentSpaceModel =
|
||||
spaceModels
|
||||
.cast<SpaceTemplateModel?>()
|
||||
.firstWhere(
|
||||
(sm) =>
|
||||
sm?.uuid ==
|
||||
updatedSpaceModel
|
||||
.uuid,
|
||||
final SpaceTemplateModel? currentSpaceModel =
|
||||
spaceModels.cast<SpaceTemplateModel?>().firstWhere(
|
||||
(sm) => sm?.uuid == updatedSpaceModel.uuid,
|
||||
orElse: () => null,
|
||||
);
|
||||
if (currentSpaceModel != null) {
|
||||
context
|
||||
.read<CreateSpaceModelBloc>()
|
||||
.add(ModifySpaceTemplate(
|
||||
spaceTemplate:
|
||||
currentSpaceModel,
|
||||
updatedSpaceTemplate:
|
||||
updatedSpaceTemplate,
|
||||
spaceTemplate: currentSpaceModel,
|
||||
updatedSpaceTemplate: updatedSpaceTemplate,
|
||||
onUpdate: (newModel) {
|
||||
if (pageContext !=
|
||||
null) {
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceModelBloc>()
|
||||
.add(UpdateSpaceModel(
|
||||
if (pageContext != null) {
|
||||
pageContext!.read<SpaceModelBloc>().add(
|
||||
UpdateSpaceModel(
|
||||
spaceModelUuid:
|
||||
newModel.uuid ??
|
||||
''));
|
||||
newModel.uuid ?? ''));
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(
|
||||
newModel));
|
||||
.read<SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(newModel));
|
||||
}
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
Navigator.of(context).pop();
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -265,11 +233,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
},
|
||||
backgroundColor: ColorsManager.secondaryColor,
|
||||
borderRadius: 10,
|
||||
foregroundColor: ((state.errorMessage != null &&
|
||||
state.errorMessage != '') ||
|
||||
!isNameValid)
|
||||
? ColorsManager.whiteColorsWithOpacity
|
||||
: ColorsManager.whiteColors,
|
||||
foregroundColor:
|
||||
((state.errorMessage != null && state.errorMessage != '') ||
|
||||
!isNameValid)
|
||||
? ColorsManager.whiteColorsWithOpacity
|
||||
: ColorsManager.whiteColors,
|
||||
child: const Text('OK'),
|
||||
),
|
||||
),
|
||||
|
@ -1,10 +1,9 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/linking_successful.dart';
|
||||
|
||||
|
||||
class CustomLoadingIndicator extends StatefulWidget {
|
||||
const CustomLoadingIndicator({super.key});
|
||||
|
||||
@override
|
||||
_CustomLoadingIndicatorState createState() => _CustomLoadingIndicatorState();
|
||||
}
|
||||
@ -51,22 +50,22 @@ class _CustomLoadingIndicatorState extends State<CustomLoadingIndicator>
|
||||
class LoadingPainter extends CustomPainter {
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()
|
||||
final Paint paint = Paint()
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
final radius = size.width / 2;
|
||||
final center = Offset(size.width / 2, size.height / 2);
|
||||
final double radius = size.width / 2;
|
||||
final Offset center = Offset(size.width / 2, size.height / 2);
|
||||
|
||||
for (var i = 0; i < 12; i++) {
|
||||
final angle = (i * 30) * (pi / 180);
|
||||
final startX = center.dx + radius * cos(angle);
|
||||
final startY = center.dy + radius * sin(angle);
|
||||
final endX = center.dx + (radius - 8) * cos(angle);
|
||||
final endY = center.dy + (radius - 8) * sin(angle);
|
||||
for (int i = 0; i < 12; i++) {
|
||||
final double angle = (i * 30) * (pi / 180);
|
||||
final double startX = center.dx + radius * cos(angle);
|
||||
final double startY = center.dy + radius * sin(angle);
|
||||
final double endX = center.dx + (radius - 8) * cos(angle);
|
||||
final double endY = center.dy + (radius - 8) * sin(angle);
|
||||
|
||||
paint.color = Colors.blue.withValues(alpha: i / 12); // Gradient effect
|
||||
paint.color = Colors.blue.withOpacity(i / 12); // Gradient effect
|
||||
canvas.drawLine(Offset(startX, startY), Offset(endX, endY), paint);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class DeleteSpaceModelDialog extends StatelessWidget {
|
||||
final VoidCallback onConfirmDelete;
|
||||
|
||||
const DeleteSpaceModelDialog({super.key, required this.onConfirmDelete});
|
||||
const DeleteSpaceModelDialog({Key? key, required this.onConfirmDelete})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -19,7 +20,7 @@ class DeleteSpaceModelDialog extends StatelessWidget {
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
title: Center(
|
||||
child: Text(
|
||||
'Delete Space Model',
|
||||
"Delete Space Model",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
@ -33,13 +34,13 @@ class DeleteSpaceModelDialog extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Are you sure you want to delete?',
|
||||
"Are you sure you want to delete?",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
'The existing sub-spaces, devices, and routines will remain associated with the spaces, but the connection will be removed.',
|
||||
"The existing sub-spaces, devices, and routines will remain associated with the spaces, but the connection will be removed.",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
@ -59,7 +60,7 @@ class DeleteSpaceModelDialog extends StatelessWidget {
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(); // Close dialog
|
||||
},
|
||||
label: 'Cancel',
|
||||
label: "Cancel",
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
|
@ -47,9 +47,9 @@ class _LinkSpaceModelSpacesDialogState
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
widget.spaceModel.createdAt.toString();
|
||||
final formattedDate =
|
||||
String formattedDate =
|
||||
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
|
||||
final formattedTime =
|
||||
String formattedTime =
|
||||
DateFormat('HH:mm:ss').format(widget.spaceModel.createdAt!);
|
||||
|
||||
return Expanded(
|
||||
@ -70,7 +70,7 @@ class _LinkSpaceModelSpacesDialogState
|
||||
children: [
|
||||
const Center(
|
||||
child: Text(
|
||||
'Link Space Model to Spaces',
|
||||
"Link Space Model to Spaces",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -81,21 +81,22 @@ class _LinkSpaceModelSpacesDialogState
|
||||
const Divider(),
|
||||
const SizedBox(height: 16),
|
||||
_buildDetailRow(
|
||||
'Space model name:', widget.spaceModel.modelName),
|
||||
"Space model name:", widget.spaceModel.modelName),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'Creation date and time:',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
"Creation date and time:",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'$formattedDate $formattedTime',
|
||||
"$formattedDate $formattedTime",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black),
|
||||
@ -106,14 +107,14 @@ class _LinkSpaceModelSpacesDialogState
|
||||
),
|
||||
// _buildDetailRow("Creation date and time:",
|
||||
// widget.spaceModel.createdAt.toString()),
|
||||
_buildDetailRow('Created by:', 'Admin'),
|
||||
_buildDetailRow("Created by:", "Admin"),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'Link to:',
|
||||
"Link to:",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const Text(
|
||||
'Please select all the spaces where you would like to link the Routine.',
|
||||
"Please select all the spaces where you would like to link the Routine.",
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@ -123,7 +124,7 @@ class _LinkSpaceModelSpacesDialogState
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: ColoredBox(
|
||||
child: Container(
|
||||
color: ColorsManager.whiteColors,
|
||||
child: SpaceTreeView(
|
||||
isSide: true,
|
||||
@ -169,7 +170,7 @@ class _LinkSpaceModelSpacesDialogState
|
||||
),
|
||||
),
|
||||
),
|
||||
child: _buildButton('Cancel', Colors.grey, () {
|
||||
child: _buildButton("Cancel", Colors.grey, () {
|
||||
Navigator.of(context).pop();
|
||||
}),
|
||||
),
|
||||
@ -190,14 +191,14 @@ class _LinkSpaceModelSpacesDialogState
|
||||
),
|
||||
),
|
||||
child: _buildButton(
|
||||
'Confirm',
|
||||
"Confirm",
|
||||
ColorsManager.onSecondaryColor,
|
||||
() {
|
||||
final spaceModelBloc = context.read<LinkSpaceToModelBloc>();
|
||||
if (!spaceModelBloc.hasSelectedSpaces) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Please select at least one space')),
|
||||
content: Text("Please select at least one space")),
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
|
@ -62,7 +62,7 @@ class LinkingAttentionDialog extends StatelessWidget {
|
||||
elevation: 3,
|
||||
),
|
||||
child: Text(
|
||||
'Overwrite',
|
||||
"Overwrite",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
@ -93,7 +93,7 @@ class LinkingAttentionDialog extends StatelessWidget {
|
||||
elevation: 3,
|
||||
),
|
||||
child: Text(
|
||||
'Merge',
|
||||
"Merge",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
|
@ -23,7 +23,7 @@ void showOverwriteDialog(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Overwrite',
|
||||
"Overwrite",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -32,13 +32,13 @@ void showOverwriteDialog(
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Text(
|
||||
'Are you sure you want to overwrite?',
|
||||
"Are you sure you want to overwrite?",
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
'Selected spaces already have linked space model / sub-spaces and devices',
|
||||
"Selected spaces already have linked space model / sub-spaces and devices",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
@ -61,7 +61,7 @@ void showOverwriteDialog(
|
||||
elevation: 0,
|
||||
),
|
||||
child: const Text(
|
||||
'Cancel',
|
||||
"Cancel",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.black,
|
||||
@ -88,7 +88,7 @@ void showOverwriteDialog(
|
||||
elevation: 3,
|
||||
),
|
||||
child: const Text(
|
||||
'OK',
|
||||
"OK",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
|
Reference in New Issue
Block a user