link_space model

This commit is contained in:
mohammad
2025-02-10 12:38:20 +03:00
parent a623f1c723
commit 00a9cb1188
14 changed files with 799 additions and 12 deletions

View File

@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class ConfirmMergeDialog extends StatelessWidget {
const ConfirmMergeDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
backgroundColor: ColorsManager.whiteColors,
title: Center(
child: Text(
'Merge',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 30),
)),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Are you sure you want to merge?',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 18),
),
const SizedBox(height: 25),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: ColorsManager.boxColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"Cancel",
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 16),
),
),
),
const SizedBox(width: 10),
Expanded(
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: ColorsManager.secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"Ok",
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 16,
color: ColorsManager.whiteColors,
),
),
),
),
],
),
],
),
);
}
}

View File

@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class ConfirmOverwriteDialog extends StatelessWidget {
const ConfirmOverwriteDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
backgroundColor: ColorsManager.whiteColors,
title: Center(
child: Text(
'Overwrite',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 30),
)),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Are you sure you want to overwrite?',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 18),
),
const SizedBox(height: 25),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: ColorsManager.boxColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"Cancel",
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 16),
),
),
),
const SizedBox(width: 10),
Expanded(
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: ColorsManager.secondaryColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"Ok",
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 16,
color: ColorsManager.whiteColors,
),
),
),
),
],
),
],
),
);
}
}

View File

@ -0,0 +1,110 @@
import 'dart:math';
import 'package:flutter/material.dart';
void showCustomLoadingDialog(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false, // Prevent closing by tapping outside
builder: (BuildContext context) {
Future.delayed(Duration(seconds: 3), () {
Navigator.of(context).pop(); // Auto-close after 3 seconds
});
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
elevation: 10,
backgroundColor: Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 30, horizontal: 50),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Custom loader
CustomLoadingIndicator(),
SizedBox(height: 20),
Text(
"Linking in progress",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
),
],
),
),
);
},
);
}
class CustomLoadingIndicator extends StatefulWidget {
@override
_CustomLoadingIndicatorState createState() => _CustomLoadingIndicatorState();
}
class _CustomLoadingIndicatorState extends State<CustomLoadingIndicator>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: Duration(seconds: 1), // Rotation speed
)..repeat(); // Infinite animation
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return SizedBox(
width: 50,
height: 50,
child: AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Transform.rotate(
angle: _controller.value * 2 * pi, // Full rotation
child: CustomPaint(
painter: LoadingPainter(),
),
);
},
),
);
}
}
class LoadingPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final Paint 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);
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.withOpacity(i / 12); // Gradient effect
canvas.drawLine(Offset(startX, startY), Offset(endX, endY), paint);
}
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}

View File

@ -0,0 +1,190 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_web/pages/roles_and_permission/users_page/add_user_dialog/view/build_tree_view.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.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';
import 'package:syncrow_web/utils/style.dart';
class LinkSpaceModelSpacesDialog extends StatelessWidget {
final SpaceTemplateModel spaceModel;
LinkSpaceModelSpacesDialog({super.key, required this.spaceModel});
TextEditingController searchController = TextEditingController();
@override
Widget build(BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
backgroundColor: Colors.white,
contentPadding: const EdgeInsets.all(20),
content: SizedBox(
width: MediaQuery.of(context).size.width * 0.4,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title
const Center(
child: Text(
"Link Space Model to Spaces",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.blueAccent,
),
),
),
const Divider(),
const SizedBox(height: 16),
// Details Section
_buildDetailRow("Space model name:", spaceModel.modelName),
_buildDetailRow("Creation date and time:", spaceModel.modelName),
_buildDetailRow("Created by:", "Admin"),
const SizedBox(height: 12),
// Link to Section
const Text(
"Link to:",
style: TextStyle(fontWeight: FontWeight.bold),
),
const Text(
"Please select all the spaces where you would like to link the Routine.",
style: TextStyle(fontSize: 12, color: Colors.grey),
),
const SizedBox(height: 8),
// Spaces List
Expanded(
child: SizedBox(
child: Column(
children: [
Expanded(
flex: 2,
child: Container(
decoration: const BoxDecoration(
color: ColorsManager.circleRolesBackground,
borderRadius: BorderRadius.only(
topRight: Radius.circular(20),
topLeft: Radius.circular(20)),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(20)),
border: Border.all(
color: ColorsManager.grayBorder)),
child: TextFormField(
style: const TextStyle(color: Colors.black),
// controller: _blocRole.firstNameController,
onChanged: (value) {
// _blocRole.add(SearchAnode(
// nodes: _blocRole.updatedCommunities,
// searchTerm: value));
},
decoration:
textBoxDecoration(radios: 20)!.copyWith(
fillColor: Colors.white,
suffixIcon: Padding(
padding:
const EdgeInsets.only(right: 16),
child: SvgPicture.asset(
Assets.textFieldSearch,
width: 24,
height: 24,
),
),
hintStyle: context.textTheme.bodyMedium
?.copyWith(
fontWeight: FontWeight.w400,
fontSize: 12,
color: ColorsManager.textGray),
),
),
),
),
],
),
),
),
),
Expanded(
flex: 7,
child: Container(
color: ColorsManager.circleRolesBackground,
padding: const EdgeInsets.all(8.0),
child: Container(
color: ColorsManager.whiteColors,
child: TreeView(userId: ''))))
],
),
),
),
// Buttons
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildButton("Cancel", Colors.grey, () {
Navigator.of(context).pop();
}),
_buildButton("Confirm", Colors.blueAccent, () {
Navigator.of(context).pop();
}),
],
),
],
),
),
);
}
// Method to build a detail row
Widget _buildDetailRow(String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
Expanded(
child: Text(
label,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
value,
style:
TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
),
),
],
),
);
}
// Button Widget
Widget _buildButton(String text, Color color, VoidCallback onPressed) {
return TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
backgroundColor: color.withOpacity(0.2),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: Text(
text,
style: TextStyle(color: color, fontWeight: FontWeight.bold),
),
);
}
}

View File

@ -0,0 +1,111 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/confirm_merge_dialog.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/confirm_overwrite_dialog.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class LinkingAttentionDialog extends StatelessWidget {
const LinkingAttentionDialog({super.key});
@override
Widget build(BuildContext context) {
return AlertDialog(
backgroundColor: ColorsManager.whiteColors,
title: Center(
child: Text(
'Linking Attention',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 30),
)),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Do you want to merge or overwrite?',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 18),
),
const SizedBox(height: 8),
Text(
'Selected spaces already have commissioned Devices',
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 14),
),
const SizedBox(height: 25),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Cancel Button
Expanded(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
showDialog(
context: context,
builder: (BuildContext dialogContext) {
return const ConfirmOverwriteDialog();
},
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: ColorsManager.boxColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"Overwrite",
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 16),
),
),
),
const SizedBox(width: 10),
// OK Button
Expanded(
child: ElevatedButton(
onPressed: () {
Navigator.pop(context);
showDialog(
context: context,
builder: (BuildContext dialogContext) {
return const ConfirmMergeDialog();
},
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: ColorsManager.boxColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"Merge",
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(fontWeight: FontWeight.w400, fontSize: 16),
),
),
),
],
),
],
),
);
}
}

View File

@ -0,0 +1,112 @@
import 'package:flutter/material.dart';
void showOverwriteDialog(BuildContext context) {
showDialog(
context: context,
barrierDismissible: false, // Prevent closing by tapping outside
builder: (BuildContext context) {
return Container(
child: Dialog(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
elevation: 10,
backgroundColor: Colors.white,
child: Container(
width: MediaQuery.of(context).size.width * 0.3,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Title
Text(
"Overwrite",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(height: 15),
// Description
Text(
"Are you sure you want to overwrite?",
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
SizedBox(height: 5),
Text(
"Selected spaces already have linked space model / sub-spaces and devices",
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
),
textAlign: TextAlign.center,
),
SizedBox(height: 25),
// Buttons
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
// Cancel Button
Expanded(
child: ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 14),
backgroundColor: Colors.grey[200],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 0,
),
child: Text(
"Cancel",
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(width: 10),
// OK Button
Expanded(
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
// Add action for OK button
},
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 14),
backgroundColor: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 3,
),
child: Text(
"OK",
style: TextStyle(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
),
],
),
],
),
),
),
),
);
},
);
}