formatted all files.

This commit is contained in:
Faris Armoush
2025-06-12 15:33:32 +03:00
parent 29959f567e
commit 04250ebc98
474 changed files with 5425 additions and 4338 deletions

View File

@ -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,

View File

@ -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,

View File

@ -9,13 +9,12 @@ 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_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/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/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/services/space_model_mang_api.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@ -29,22 +28,21 @@ class CreateSpaceModelDialog extends StatelessWidget {
final List<Tag> projectTags;
const CreateSpaceModelDialog(
{Key? key,
{super.key,
this.products,
this.allTags,
this.spaceModel,
this.pageContext,
this.otherSpaceModels,
this.allSpaceModels,
required this.projectTags})
: super(key: key);
required this.projectTags});
@override
Widget build(BuildContext context) {
final SpaceModelManagementApi _spaceModelApi = SpaceModelManagementApi();
final spaceModelApi = SpaceModelManagementApi();
final screenWidth = MediaQuery.of(context).size.width;
final TextEditingController spaceNameController = TextEditingController(
final spaceNameController = TextEditingController(
text: spaceModel?.modelName ?? '',
);
@ -56,7 +54,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
child: BlocProvider(
create: (_) {
final bloc = CreateSpaceModelBloc(
_spaceModelApi,
spaceModelApi,
);
if (spaceModel != null) {
bloc.add(UpdateSpaceTemplate(spaceModel!, otherSpaceModels));
@ -71,7 +69,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
spaceNameController.addListener(() {
bloc.add(UpdateSpaceTemplateName(
name: spaceNameController.text, allModels: otherSpaceModels ?? []));
name: spaceNameController.text,
allModels: otherSpaceModels ?? []));
});
return bloc;
@ -89,7 +88,9 @@ 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
@ -101,8 +102,10 @@ 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
@ -176,55 +179,84 @@ 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<SpaceManagementBloc>()
.add(UpdateSpaceModelCache(newModel));
.read<SpaceModelBloc>()
.add(CreateSpaceModel(
newSpaceModel:
newModel));
pageContext!
.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 SpaceTemplateModel? currentSpaceModel =
spaceModels.cast<SpaceTemplateModel?>().firstWhere(
(sm) => sm?.uuid == updatedSpaceModel.uuid,
final 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(
spaceModelUuid:
newModel.uuid ?? ''));
if (pageContext !=
null) {
pageContext!
.read<SpaceManagementBloc>()
.add(UpdateSpaceModelCache(newModel));
.read<
SpaceModelBloc>()
.add(UpdateSpaceModel(
spaceModelUuid:
newModel.uuid ??
''));
pageContext!
.read<
SpaceManagementBloc>()
.add(UpdateSpaceModelCache(
newModel));
}
Navigator.of(context).pop();
Navigator.of(context)
.pop();
}));
}
}
@ -233,11 +265,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'),
),
),

View File

@ -1,9 +1,10 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/linking_successful.dart';
import 'package:flutter/material.dart';
class CustomLoadingIndicator extends StatefulWidget {
const CustomLoadingIndicator({super.key});
@override
_CustomLoadingIndicatorState createState() => _CustomLoadingIndicatorState();
}
@ -50,22 +51,22 @@ class _CustomLoadingIndicatorState extends State<CustomLoadingIndicator>
class LoadingPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Paint paint = Paint()
final paint = Paint()
..strokeWidth = 5
..strokeCap = StrokeCap.round
..style = PaintingStyle.stroke;
final double radius = size.width / 2;
final Offset center = Offset(size.width / 2, size.height / 2);
final radius = size.width / 2;
final center = Offset(size.width / 2, size.height / 2);
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);
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);
paint.color = Colors.blue.withOpacity(i / 12); // Gradient effect
paint.color = Colors.blue.withValues(alpha: i / 12); // Gradient effect
canvas.drawLine(Offset(startX, startY), Offset(endX, endY), paint);
}
}

View File

@ -6,8 +6,7 @@ import 'package:syncrow_web/utils/color_manager.dart';
class DeleteSpaceModelDialog extends StatelessWidget {
final VoidCallback onConfirmDelete;
const DeleteSpaceModelDialog({Key? key, required this.onConfirmDelete})
: super(key: key);
const DeleteSpaceModelDialog({super.key, required this.onConfirmDelete});
@override
Widget build(BuildContext context) {
@ -20,7 +19,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
@ -34,13 +33,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
@ -60,7 +59,7 @@ class DeleteSpaceModelDialog extends StatelessWidget {
onPressed: () {
Navigator.of(context).pop(); // Close dialog
},
label: "Cancel",
label: 'Cancel',
),
),
const SizedBox(width: 10),

View File

@ -47,9 +47,9 @@ class _LinkSpaceModelSpacesDialogState
Widget _buildDialogContent() {
widget.spaceModel.createdAt.toString();
String formattedDate =
final formattedDate =
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
String formattedTime =
final 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,22 +81,21 @@ 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: const TextStyle(
fontWeight: FontWeight.bold),
'Creation date and time:',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
"$formattedDate $formattedTime",
'$formattedDate $formattedTime',
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black),
@ -107,14 +106,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),
@ -124,7 +123,7 @@ class _LinkSpaceModelSpacesDialogState
children: [
Expanded(
flex: 7,
child: Container(
child: ColoredBox(
color: ColorsManager.whiteColors,
child: SpaceTreeView(
isSide: true,
@ -170,7 +169,7 @@ class _LinkSpaceModelSpacesDialogState
),
),
),
child: _buildButton("Cancel", Colors.grey, () {
child: _buildButton('Cancel', Colors.grey, () {
Navigator.of(context).pop();
}),
),
@ -191,14 +190,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 {

View File

@ -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

View File

@ -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,