Files
syncrow-web/lib/pages/device_managment/shared/device_control_dialog.dart
ashrafzarkanisala f39ce0a72b push door lock
2024-08-27 00:16:00 +03:00

123 lines
3.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: [
Center(
child: Text(
device.categoryName ?? 'Device Control',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22,
color: ColorsManager.dialogBlueTitle,
),
),
),
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: 50, 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,
),
),
],
),
);
}
}