mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
push bug fixes
This commit is contained in:
@ -1,47 +1,113 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.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';
|
||||
|
||||
class FactoryResetWidget extends StatelessWidget {
|
||||
class FactoryResetWidget extends StatefulWidget {
|
||||
const FactoryResetWidget({super.key, required this.callFactoryReset});
|
||||
|
||||
final Null Function() callFactoryReset;
|
||||
final Function() callFactoryReset;
|
||||
|
||||
@override
|
||||
State<FactoryResetWidget> createState() => _FactoryResetWidgetState();
|
||||
}
|
||||
|
||||
class _FactoryResetWidgetState extends State<FactoryResetWidget> {
|
||||
bool _showConfirmation = false;
|
||||
|
||||
void _toggleConfirmation() {
|
||||
setState(() {
|
||||
_showConfirmation = !_showConfirmation;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DeviceControlsContainer(
|
||||
child: GestureDetector(
|
||||
onTap: callFactoryReset,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ClipOval(
|
||||
child: Container(
|
||||
color: ColorsManager.whiteColors,
|
||||
height: 60,
|
||||
width: 60,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: SvgPicture.asset(
|
||||
Assets.factoryReset,
|
||||
fit: BoxFit.cover,
|
||||
child: _showConfirmation
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Factory Reset',
|
||||
style: context.textTheme.titleMedium!.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
Text(
|
||||
'Factory Reset',
|
||||
style: context.textTheme.titleMedium!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.blackColor,
|
||||
Text(
|
||||
'Are you sure?',
|
||||
style: context.textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: DefaultButton(
|
||||
height: 20,
|
||||
elevation: 0,
|
||||
onPressed: _toggleConfirmation,
|
||||
backgroundColor: ColorsManager.greyColor,
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: DefaultButton(
|
||||
height: 20,
|
||||
elevation: 0,
|
||||
onPressed: widget.callFactoryReset,
|
||||
backgroundColor: ColorsManager.red,
|
||||
child: Text(
|
||||
'Reset',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(color: ColorsManager.whiteColors),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: GestureDetector(
|
||||
onTap: _toggleConfirmation,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ClipOval(
|
||||
child: Container(
|
||||
color: ColorsManager.whiteColors,
|
||||
height: 60,
|
||||
width: 60,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: SvgPicture.asset(
|
||||
Assets.factoryReset,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Factory Reset',
|
||||
style: context.textTheme.titleMedium!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
||||
],
|
||||
),
|
||||
TableRow(children: [
|
||||
_buildInfoRow('Virtual Address:', '${device.ip}'),
|
||||
_buildInfoRow('Virtual Address:', device.ip ?? '-'),
|
||||
const SizedBox.shrink(),
|
||||
]),
|
||||
TableRow(
|
||||
@ -111,13 +111,30 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox.shrink(),
|
||||
_buildInfoRow(
|
||||
'Battery Level:',
|
||||
device.batteryLevel != null
|
||||
? '${device.batteryLevel ?? 0}%'
|
||||
: "-",
|
||||
statusColor: device.batteryLevel != null
|
||||
? (device.batteryLevel! < 20
|
||||
? ColorsManager.red
|
||||
: ColorsManager.green)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
TableRow(
|
||||
children: [
|
||||
_buildInfoRow('Status:', 'Online', statusColor: Colors.green),
|
||||
_buildInfoRow('Last Offline Date and Time:', '-'),
|
||||
_buildInfoRow(
|
||||
'Last Offline Date and Time:',
|
||||
formatDateTime(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
((device.activeTime ?? 0) * 1000),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
Reference in New Issue
Block a user