mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
149 lines
4.7 KiB
Dart
149 lines
4.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
|
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
|
|
|
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
|
|
class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
|
final AllDevicesModel device;
|
|
|
|
const DeviceControlDialog({super.key, required this.device});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Dialog(
|
|
backgroundColor: Colors.white,
|
|
insetPadding: const EdgeInsets.all(20),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
child: SizedBox(
|
|
width: 798,
|
|
height: context.screenHeight * 0.7,
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const SizedBox(),
|
|
Text(
|
|
device.categoryName ?? 'Device Control',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 22,
|
|
color: ColorsManager.dialogBlueTitle,
|
|
),
|
|
),
|
|
Container(
|
|
width: 25,
|
|
decoration: BoxDecoration(
|
|
color: Colors.transparent,
|
|
shape: BoxShape.circle,
|
|
border: Border.all(
|
|
color: Colors.grey,
|
|
width: 1.0,
|
|
),
|
|
),
|
|
child: IconButton(
|
|
padding: EdgeInsets.all(1),
|
|
icon: const Icon(
|
|
Icons.close,
|
|
color: Colors.grey,
|
|
size: 18,
|
|
),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
_buildDeviceInfoSection(),
|
|
const SizedBox(height: 20),
|
|
//// BUILD DEVICE CONTROLS
|
|
///
|
|
//// ROUTE TO SPECIFIC CONTROL VIEW BASED ON DEVICE CATEGORY
|
|
routeControlsWidgets(device: device),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildDeviceInfoSection() {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 50),
|
|
child: Table(
|
|
children: [
|
|
TableRow(
|
|
children: [
|
|
_buildInfoRow('Product Name:', device.categoryName ?? 'N/A'),
|
|
_buildInfoRow('Device ID:', device.uuid ?? ''),
|
|
],
|
|
),
|
|
TableRow(children: [
|
|
_buildInfoRow('Virtual Address:',
|
|
'Area - Street 1 - Building 1 - First Floor'),
|
|
const SizedBox.shrink(),
|
|
]),
|
|
TableRow(
|
|
children: [
|
|
_buildInfoRow('Unit Name:', device.unit?.name ?? 'N/A'),
|
|
_buildInfoRow('Room:', device.room?.name ?? 'N/A'),
|
|
],
|
|
),
|
|
TableRow(
|
|
children: [
|
|
_buildInfoRow('Installation Date and Time:', '09/08/2024 13:30'),
|
|
const SizedBox.shrink(),
|
|
],
|
|
),
|
|
TableRow(
|
|
children: [
|
|
_buildInfoRow('Status:', 'Online', statusColor: Colors.green),
|
|
_buildInfoRow('Last Offline Date and Time:', '-'),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildInfoRow(String title, String value, {Color? statusColor}) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: 12,
|
|
color: ColorsManager.lightGreyColor,
|
|
),
|
|
),
|
|
const SizedBox(width: 10),
|
|
Text(
|
|
value,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: statusColor ?? Colors.black,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|