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:
@ -18,6 +18,7 @@ class DefaultButton extends StatelessWidget {
|
|||||||
this.height,
|
this.height,
|
||||||
this.padding,
|
this.padding,
|
||||||
this.borderColor,
|
this.borderColor,
|
||||||
|
this.elevation,
|
||||||
});
|
});
|
||||||
final void Function()? onPressed;
|
final void Function()? onPressed;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -33,6 +34,7 @@ class DefaultButton extends StatelessWidget {
|
|||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
final Color? foregroundColor;
|
final Color? foregroundColor;
|
||||||
final Color? borderColor;
|
final Color? borderColor;
|
||||||
|
final double? elevation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -45,7 +47,9 @@ class DefaultButton extends StatelessWidget {
|
|||||||
textStyle: WidgetStateProperty.all(
|
textStyle: WidgetStateProperty.all(
|
||||||
customTextStyle ??
|
customTextStyle ??
|
||||||
Theme.of(context).textTheme.bodySmall!.copyWith(
|
Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
fontSize: 13, color: foregroundColor, fontWeight: FontWeight.normal),
|
fontSize: 13,
|
||||||
|
color: foregroundColor,
|
||||||
|
fontWeight: FontWeight.normal),
|
||||||
),
|
),
|
||||||
foregroundColor: WidgetStateProperty.all(
|
foregroundColor: WidgetStateProperty.all(
|
||||||
isSecondary
|
isSecondary
|
||||||
@ -54,7 +58,8 @@ class DefaultButton extends StatelessWidget {
|
|||||||
? foregroundColor ?? Colors.white
|
? foregroundColor ?? Colors.white
|
||||||
: Colors.black,
|
: Colors.black,
|
||||||
),
|
),
|
||||||
backgroundColor: WidgetStateProperty.resolveWith<Color>((Set<WidgetState> states) {
|
backgroundColor: WidgetStateProperty.resolveWith<Color>(
|
||||||
|
(Set<WidgetState> states) {
|
||||||
return enabled
|
return enabled
|
||||||
? backgroundColor ?? ColorsManager.primaryColor
|
? backgroundColor ?? ColorsManager.primaryColor
|
||||||
: Colors.black.withOpacity(0.2);
|
: Colors.black.withOpacity(0.2);
|
||||||
@ -74,6 +79,7 @@ class DefaultButton extends StatelessWidget {
|
|||||||
minimumSize: WidgetStateProperty.all(
|
minimumSize: WidgetStateProperty.all(
|
||||||
const Size.fromHeight(50),
|
const Size.fromHeight(50),
|
||||||
),
|
),
|
||||||
|
elevation: WidgetStateProperty.all(elevation ?? 0),
|
||||||
),
|
),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: height ?? 50,
|
height: height ?? 50,
|
||||||
|
@ -46,11 +46,11 @@ class AcDeviceBatchControlView extends StatelessWidget
|
|||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
ToggleWidget(
|
ToggleWidget(
|
||||||
icon: Assets.acLock,
|
|
||||||
deviceId: devicesIds.first,
|
deviceId: devicesIds.first,
|
||||||
code: 'switch',
|
code: 'switch',
|
||||||
value: state.status.acSwitch,
|
value: state.status.acSwitch,
|
||||||
label: 'ThermoState',
|
label: 'ThermoState',
|
||||||
|
icon: Assets.ac,
|
||||||
onChange: (value) {
|
onChange: (value) {
|
||||||
context.read<AcBloc>().add(AcBatchControlEvent(
|
context.read<AcBloc>().add(AcBatchControlEvent(
|
||||||
devicesIds: devicesIds,
|
devicesIds: devicesIds,
|
||||||
|
@ -8,6 +8,7 @@ import 'package:syncrow_web/pages/device_managment/ac/view/control_list/ac_toggl
|
|||||||
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/current_temp.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/current_temp.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/fan_speed.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/fan_speed.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
@ -64,12 +65,21 @@ class AcDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
code: 'level',
|
code: 'level',
|
||||||
deviceId: device.uuid!,
|
deviceId: device.uuid!,
|
||||||
),
|
),
|
||||||
AcToggle(
|
ToggleWidget(
|
||||||
value: state.status.childLock,
|
|
||||||
code: 'child_lock',
|
|
||||||
deviceId: device.uuid!,
|
deviceId: device.uuid!,
|
||||||
description: 'Child Lock',
|
code: 'child_lock',
|
||||||
|
value: state.status.childLock,
|
||||||
|
label: 'Child Lock',
|
||||||
icon: state.status.childLock ? Assets.unlock : Assets.acLock,
|
icon: state.status.childLock ? Assets.unlock : Assets.acLock,
|
||||||
|
onChange: (value) {
|
||||||
|
context.read<AcBloc>().add(
|
||||||
|
AcControlEvent(
|
||||||
|
deviceId: device.uuid!,
|
||||||
|
code: 'child_lock',
|
||||||
|
value: value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -37,8 +37,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
offlineCount = state.offlineCount;
|
offlineCount = state.offlineCount;
|
||||||
lowBatteryCount = state.lowBatteryCount;
|
lowBatteryCount = state.lowBatteryCount;
|
||||||
isControlButtonEnabled = state.isControlButtonEnabled;
|
isControlButtonEnabled = state.isControlButtonEnabled;
|
||||||
selectedDevices =
|
selectedDevices = state.selectedDevice ??
|
||||||
state.selectedDevice ?? context.read<DeviceManagementBloc>().selectedDevices;
|
context.read<DeviceManagementBloc>().selectedDevices;
|
||||||
} else if (state is DeviceManagementFiltered) {
|
} else if (state is DeviceManagementFiltered) {
|
||||||
devicesToShow = state.filteredDevices;
|
devicesToShow = state.filteredDevices;
|
||||||
selectedIndex = state.selectedIndex;
|
selectedIndex = state.selectedIndex;
|
||||||
@ -46,8 +46,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
offlineCount = state.offlineCount;
|
offlineCount = state.offlineCount;
|
||||||
lowBatteryCount = state.lowBatteryCount;
|
lowBatteryCount = state.lowBatteryCount;
|
||||||
isControlButtonEnabled = state.isControlButtonEnabled;
|
isControlButtonEnabled = state.isControlButtonEnabled;
|
||||||
selectedDevices =
|
selectedDevices = state.selectedDevice ??
|
||||||
state.selectedDevice ?? context.read<DeviceManagementBloc>().selectedDevices;
|
context.read<DeviceManagementBloc>().selectedDevices;
|
||||||
} else if (state is DeviceManagementInitial) {
|
} else if (state is DeviceManagementInitial) {
|
||||||
devicesToShow = [];
|
devicesToShow = [];
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
@ -61,13 +61,15 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
'Low Battery ($lowBatteryCount)',
|
'Low Battery ($lowBatteryCount)',
|
||||||
];
|
];
|
||||||
|
|
||||||
final buttonLabel = (selectedDevices.length > 1) ? 'Batch Control' : 'Control';
|
final buttonLabel =
|
||||||
|
(selectedDevices.length > 1) ? 'Batch Control' : 'Control';
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding:
|
padding: isLargeScreenSize(context)
|
||||||
isLargeScreenSize(context) ? const EdgeInsets.all(30) : const EdgeInsets.all(15),
|
? const EdgeInsets.all(30)
|
||||||
|
: const EdgeInsets.all(15),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -76,7 +78,9 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
tabs: tabs,
|
tabs: tabs,
|
||||||
selectedIndex: selectedIndex,
|
selectedIndex: selectedIndex,
|
||||||
onTabChanged: (index) {
|
onTabChanged: (index) {
|
||||||
context.read<DeviceManagementBloc>().add(SelectedFilterChanged(index));
|
context
|
||||||
|
.read<DeviceManagementBloc>()
|
||||||
|
.add(SelectedFilterChanged(index));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
@ -98,12 +102,14 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (selectedDevices.length > 1) {
|
} else if (selectedDevices.length > 1) {
|
||||||
final productTypes =
|
final productTypes = selectedDevices
|
||||||
selectedDevices.map((device) => device.productType).toSet();
|
.map((device) => device.productType)
|
||||||
|
.toSet();
|
||||||
if (productTypes.length == 1) {
|
if (productTypes.length == 1) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => DeviceBatchControlDialog(
|
builder: (context) =>
|
||||||
|
DeviceBatchControlDialog(
|
||||||
devices: selectedDevices,
|
devices: selectedDevices,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -117,7 +123,9 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: isControlButtonEnabled ? Colors.white : Colors.grey,
|
color: isControlButtonEnabled
|
||||||
|
? Colors.white
|
||||||
|
: Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -136,7 +144,9 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
cellDecoration: containerDecoration,
|
cellDecoration: containerDecoration,
|
||||||
onRowSelected: (index, isSelected, row) {
|
onRowSelected: (index, isSelected, row) {
|
||||||
final selectedDevice = devicesToShow[index];
|
final selectedDevice = devicesToShow[index];
|
||||||
context.read<DeviceManagementBloc>().add(SelectDevice(selectedDevice));
|
context
|
||||||
|
.read<DeviceManagementBloc>()
|
||||||
|
.add(SelectDevice(selectedDevice));
|
||||||
},
|
},
|
||||||
withCheckBox: true,
|
withCheckBox: true,
|
||||||
size: context.screenSize,
|
size: context.screenSize,
|
||||||
@ -154,21 +164,25 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
],
|
],
|
||||||
data: devicesToShow.map((device) {
|
data: devicesToShow.map((device) {
|
||||||
return [
|
return [
|
||||||
device.categoryName ?? '',
|
|
||||||
device.name ?? '',
|
device.name ?? '',
|
||||||
|
device.categoryName ?? '',
|
||||||
device.uuid ?? '',
|
device.uuid ?? '',
|
||||||
device.unit?.name ?? '',
|
device.unit?.name ?? '',
|
||||||
device.room?.name ?? '',
|
device.room?.name ?? '',
|
||||||
device.batteryLevel != null ? '${device.batteryLevel}%' : '-',
|
device.batteryLevel != null
|
||||||
formatDateTime(
|
? '${device.batteryLevel}%'
|
||||||
DateTime.fromMillisecondsSinceEpoch((device.createTime ?? 0) * 1000)),
|
: '-',
|
||||||
|
formatDateTime(DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
(device.createTime ?? 0) * 1000)),
|
||||||
device.online == true ? 'Online' : 'Offline',
|
device.online == true ? 'Online' : 'Offline',
|
||||||
formatDateTime(
|
formatDateTime(DateTime.fromMillisecondsSinceEpoch(
|
||||||
DateTime.fromMillisecondsSinceEpoch((device.updateTime ?? 0) * 1000)),
|
(device.updateTime ?? 0) * 1000)),
|
||||||
];
|
];
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onSelectionChanged: (selectedRows) {
|
onSelectionChanged: (selectedRows) {
|
||||||
context.read<DeviceManagementBloc>().add(UpdateSelection(selectedRows));
|
context
|
||||||
|
.read<DeviceManagementBloc>()
|
||||||
|
.add(UpdateSelection(selectedRows));
|
||||||
},
|
},
|
||||||
initialSelectedIds: context
|
initialSelectedIds: context
|
||||||
.read<DeviceManagementBloc>()
|
.read<DeviceManagementBloc>()
|
||||||
|
@ -70,8 +70,8 @@ class _DeviceItem extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
width: 60,
|
width: 60,
|
||||||
height: 60,
|
height: 60,
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
borderRadius: BorderRadius.circular(100),
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
),
|
),
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
@ -80,7 +80,9 @@ class MainDoorSensorControlView extends StatelessWidget
|
|||||||
icon: Assets.openCloseDoor,
|
icon: Assets.openCloseDoor,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
status: status.doorContactState,
|
status: status.doorContactState,
|
||||||
textColor: ColorsManager.red,
|
textColor: status.doorContactState
|
||||||
|
? ColorsManager.red
|
||||||
|
: ColorsManager.blackColor,
|
||||||
paddingAmount: 8,
|
paddingAmount: 8,
|
||||||
),
|
),
|
||||||
IconNameStatusContainer(
|
IconNameStatusContainer(
|
||||||
|
@ -1,47 +1,113 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.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/pages/device_managment/shared/device_controls_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.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});
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DeviceControlsContainer(
|
return DeviceControlsContainer(
|
||||||
child: GestureDetector(
|
child: _showConfirmation
|
||||||
onTap: callFactoryReset,
|
? Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
Text(
|
||||||
ClipOval(
|
'Factory Reset',
|
||||||
child: Container(
|
style: context.textTheme.titleMedium!.copyWith(
|
||||||
color: ColorsManager.whiteColors,
|
fontWeight: FontWeight.bold,
|
||||||
height: 60,
|
color: ColorsManager.blackColor,
|
||||||
width: 60,
|
),
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(12.0),
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.factoryReset,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
)),
|
'Are you sure?',
|
||||||
Text(
|
style: context.textTheme.bodySmall!.copyWith(
|
||||||
'Factory Reset',
|
color: ColorsManager.grayColor,
|
||||||
style: context.textTheme.titleMedium!.copyWith(
|
),
|
||||||
fontWeight: FontWeight.w400,
|
),
|
||||||
color: ColorsManager.blackColor,
|
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: [
|
TableRow(children: [
|
||||||
_buildInfoRow('Virtual Address:', '${device.ip}'),
|
_buildInfoRow('Virtual Address:', device.ip ?? '-'),
|
||||||
const SizedBox.shrink(),
|
const SizedBox.shrink(),
|
||||||
]),
|
]),
|
||||||
TableRow(
|
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(
|
TableRow(
|
||||||
children: [
|
children: [
|
||||||
_buildInfoRow('Status:', 'Online', statusColor: Colors.green),
|
_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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -65,6 +65,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
|||||||
Emitter<WaterHeaterState> emit,
|
Emitter<WaterHeaterState> emit,
|
||||||
) {
|
) {
|
||||||
final currentState = state as WaterHeaterDeviceStatusLoaded;
|
final currentState = state as WaterHeaterDeviceStatusLoaded;
|
||||||
|
|
||||||
emit(currentState.copyWith(selectedTime: event.selectedTime));
|
emit(currentState.copyWith(selectedTime: event.selectedTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class InitializeAddScheduleEvent extends WaterHeaterEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UpdateSelectedTimeEvent extends WaterHeaterEvent {
|
class UpdateSelectedTimeEvent extends WaterHeaterEvent {
|
||||||
final TimeOfDay selectedTime;
|
final TimeOfDay? selectedTime;
|
||||||
|
|
||||||
const UpdateSelectedTimeEvent(this.selectedTime);
|
const UpdateSelectedTimeEvent(this.selectedTime);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class WaterHeaterDeviceStatusLoaded extends WaterHeaterState {
|
|||||||
isInchingActive: isInchingActive ?? this.isInchingActive,
|
isInchingActive: isInchingActive ?? this.isInchingActive,
|
||||||
schedules: schedules ?? this.schedules,
|
schedules: schedules ?? this.schedules,
|
||||||
selectedDays: selectedDays ?? this.selectedDays,
|
selectedDays: selectedDays ?? this.selectedDays,
|
||||||
selectedTime: selectedTime ?? this.selectedTime,
|
selectedTime: selectedTime,
|
||||||
functionOn: functionOn ?? this.functionOn,
|
functionOn: functionOn ?? this.functionOn,
|
||||||
isEditing: isEditing ?? this.isEditing,
|
isEditing: isEditing ?? this.isEditing,
|
||||||
);
|
);
|
||||||
|
@ -12,6 +12,7 @@ class ScheduleDialogHelper {
|
|||||||
final bloc = context.read<WaterHeaterBloc>();
|
final bloc = context.read<WaterHeaterBloc>();
|
||||||
|
|
||||||
if (schedule == null) {
|
if (schedule == null) {
|
||||||
|
bloc.add((const UpdateSelectedTimeEvent(null)));
|
||||||
bloc.add(InitializeAddScheduleEvent(
|
bloc.add(InitializeAddScheduleEvent(
|
||||||
selectedTime: null,
|
selectedTime: null,
|
||||||
selectedDays: List.filled(7, false),
|
selectedDays: List.filled(7, false),
|
||||||
@ -95,7 +96,7 @@ class ScheduleDialogHelper {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
state.selectedTime == null || schedule == null
|
state.selectedTime == null
|
||||||
? 'Time'
|
? 'Time'
|
||||||
: state.selectedTime!.format(context),
|
: state.selectedTime!.format(context),
|
||||||
style: context.textTheme.bodySmall!.copyWith(
|
style: context.textTheme.bodySmall!.copyWith(
|
||||||
@ -180,7 +181,7 @@ class ScheduleDialogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static List<bool> _convertDaysStringToBooleans(List<String> selectedDays) {
|
static List<bool> _convertDaysStringToBooleans(List<String> selectedDays) {
|
||||||
final daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
final daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
List<bool> daysBoolean = List.filled(7, false);
|
List<bool> daysBoolean = List.filled(7, false);
|
||||||
|
|
||||||
for (int i = 0; i < daysOfWeek.length; i++) {
|
for (int i = 0; i < daysOfWeek.length; i++) {
|
||||||
@ -195,7 +196,7 @@ class ScheduleDialogHelper {
|
|||||||
static Widget _buildDayCheckboxes(
|
static Widget _buildDayCheckboxes(
|
||||||
BuildContext context, List<bool> selectedDays,
|
BuildContext context, List<bool> selectedDays,
|
||||||
{bool? isEdit}) {
|
{bool? isEdit}) {
|
||||||
final dayLabels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
final dayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: List.generate(7, (index) {
|
children: List.generate(7, (index) {
|
||||||
|
@ -62,6 +62,7 @@ class WaterHeaterDeviceControlView extends StatelessWidget
|
|||||||
deviceId: device.uuid!,
|
deviceId: device.uuid!,
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
value: status.heaterSwitch,
|
value: status.heaterSwitch,
|
||||||
|
icon: Assets.waterHeater,
|
||||||
label: 'Water Heater',
|
label: 'Water Heater',
|
||||||
onChange: (value) {
|
onChange: (value) {
|
||||||
context.read<WaterHeaterBloc>().add(ToggleWaterHeaterEvent(
|
context.read<WaterHeaterBloc>().add(ToggleWaterHeaterEvent(
|
||||||
|
@ -52,12 +52,13 @@ class _BuildScheduleViewState extends State<BuildScheduleView> {
|
|||||||
if (state.scheduleMode == ScheduleModes.schedule)
|
if (state.scheduleMode == ScheduleModes.schedule)
|
||||||
ScheduleManagementUI(
|
ScheduleManagementUI(
|
||||||
state: state,
|
state: state,
|
||||||
onAddSchedule: () =>
|
onAddSchedule: () {
|
||||||
ScheduleDialogHelper.showAddScheduleDialog(
|
ScheduleDialogHelper.showAddScheduleDialog(
|
||||||
context,
|
context,
|
||||||
schedule: null,
|
schedule: null,
|
||||||
index: null,
|
index: null,
|
||||||
isEdit: false),
|
isEdit: false);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
if (state.scheduleMode == ScheduleModes.countdown ||
|
if (state.scheduleMode == ScheduleModes.countdown ||
|
||||||
state.scheduleMode == ScheduleModes.inching)
|
state.scheduleMode == ScheduleModes.inching)
|
||||||
|
@ -210,7 +210,7 @@ class ScheduleTableWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _getSelectedDays(List<bool> selectedDays) {
|
String _getSelectedDays(List<bool> selectedDays) {
|
||||||
final days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
final days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
List<String> selectedDaysStr = [];
|
List<String> selectedDaysStr = [];
|
||||||
for (int i = 0; i < selectedDays.length; i++) {
|
for (int i = 0; i < selectedDays.length; i++) {
|
||||||
if (selectedDays[i]) {
|
if (selectedDays[i]) {
|
||||||
|
Reference in New Issue
Block a user