push bug fixes

This commit is contained in:
ashrafzarkanisala
2024-10-01 00:27:03 +03:00
parent 92d32e4d84
commit 9e5d5c0d84
15 changed files with 192 additions and 73 deletions

View File

@ -18,6 +18,7 @@ class DefaultButton extends StatelessWidget {
this.height,
this.padding,
this.borderColor,
this.elevation,
});
final void Function()? onPressed;
final Widget child;
@ -33,6 +34,7 @@ class DefaultButton extends StatelessWidget {
final Color? backgroundColor;
final Color? foregroundColor;
final Color? borderColor;
final double? elevation;
@override
Widget build(BuildContext context) {
@ -45,7 +47,9 @@ class DefaultButton extends StatelessWidget {
textStyle: WidgetStateProperty.all(
customTextStyle ??
Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 13, color: foregroundColor, fontWeight: FontWeight.normal),
fontSize: 13,
color: foregroundColor,
fontWeight: FontWeight.normal),
),
foregroundColor: WidgetStateProperty.all(
isSecondary
@ -54,7 +58,8 @@ class DefaultButton extends StatelessWidget {
? foregroundColor ?? Colors.white
: Colors.black,
),
backgroundColor: WidgetStateProperty.resolveWith<Color>((Set<WidgetState> states) {
backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
return enabled
? backgroundColor ?? ColorsManager.primaryColor
: Colors.black.withOpacity(0.2);
@ -74,6 +79,7 @@ class DefaultButton extends StatelessWidget {
minimumSize: WidgetStateProperty.all(
const Size.fromHeight(50),
),
elevation: WidgetStateProperty.all(elevation ?? 0),
),
child: SizedBox(
height: height ?? 50,

View File

@ -46,11 +46,11 @@ class AcDeviceBatchControlView extends StatelessWidget
),
children: [
ToggleWidget(
icon: Assets.acLock,
deviceId: devicesIds.first,
code: 'switch',
value: state.status.acSwitch,
label: 'ThermoState',
icon: Assets.ac,
onChange: (value) {
context.read<AcBloc>().add(AcBatchControlEvent(
devicesIds: devicesIds,

View File

@ -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/fan_speed.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/helpers/responsice_layout_helper/responsive_layout_helper.dart';
@ -64,12 +65,21 @@ class AcDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
code: 'level',
deviceId: device.uuid!,
),
AcToggle(
value: state.status.childLock,
code: 'child_lock',
ToggleWidget(
deviceId: device.uuid!,
description: 'Child Lock',
code: 'child_lock',
value: state.status.childLock,
label: 'Child Lock',
icon: state.status.childLock ? Assets.unlock : Assets.acLock,
onChange: (value) {
context.read<AcBloc>().add(
AcControlEvent(
deviceId: device.uuid!,
code: 'child_lock',
value: value,
),
);
},
),
],
);

View File

@ -37,8 +37,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
offlineCount = state.offlineCount;
lowBatteryCount = state.lowBatteryCount;
isControlButtonEnabled = state.isControlButtonEnabled;
selectedDevices =
state.selectedDevice ?? context.read<DeviceManagementBloc>().selectedDevices;
selectedDevices = state.selectedDevice ??
context.read<DeviceManagementBloc>().selectedDevices;
} else if (state is DeviceManagementFiltered) {
devicesToShow = state.filteredDevices;
selectedIndex = state.selectedIndex;
@ -46,8 +46,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
offlineCount = state.offlineCount;
lowBatteryCount = state.lowBatteryCount;
isControlButtonEnabled = state.isControlButtonEnabled;
selectedDevices =
state.selectedDevice ?? context.read<DeviceManagementBloc>().selectedDevices;
selectedDevices = state.selectedDevice ??
context.read<DeviceManagementBloc>().selectedDevices;
} else if (state is DeviceManagementInitial) {
devicesToShow = [];
selectedIndex = 0;
@ -61,13 +61,15 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
'Low Battery ($lowBatteryCount)',
];
final buttonLabel = (selectedDevices.length > 1) ? 'Batch Control' : 'Control';
final buttonLabel =
(selectedDevices.length > 1) ? 'Batch Control' : 'Control';
return Column(
children: [
Container(
padding:
isLargeScreenSize(context) ? const EdgeInsets.all(30) : const EdgeInsets.all(15),
padding: isLargeScreenSize(context)
? const EdgeInsets.all(30)
: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -76,7 +78,9 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
tabs: tabs,
selectedIndex: selectedIndex,
onTabChanged: (index) {
context.read<DeviceManagementBloc>().add(SelectedFilterChanged(index));
context
.read<DeviceManagementBloc>()
.add(SelectedFilterChanged(index));
},
),
const SizedBox(height: 20),
@ -98,12 +102,14 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
),
);
} else if (selectedDevices.length > 1) {
final productTypes =
selectedDevices.map((device) => device.productType).toSet();
final productTypes = selectedDevices
.map((device) => device.productType)
.toSet();
if (productTypes.length == 1) {
showDialog(
context: context,
builder: (context) => DeviceBatchControlDialog(
builder: (context) =>
DeviceBatchControlDialog(
devices: selectedDevices,
),
);
@ -117,7 +123,9 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
textAlign: TextAlign.center,
style: TextStyle(
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,
onRowSelected: (index, isSelected, row) {
final selectedDevice = devicesToShow[index];
context.read<DeviceManagementBloc>().add(SelectDevice(selectedDevice));
context
.read<DeviceManagementBloc>()
.add(SelectDevice(selectedDevice));
},
withCheckBox: true,
size: context.screenSize,
@ -154,21 +164,25 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
],
data: devicesToShow.map((device) {
return [
device.categoryName ?? '',
device.name ?? '',
device.categoryName ?? '',
device.uuid ?? '',
device.unit?.name ?? '',
device.room?.name ?? '',
device.batteryLevel != null ? '${device.batteryLevel}%' : '-',
formatDateTime(
DateTime.fromMillisecondsSinceEpoch((device.createTime ?? 0) * 1000)),
device.batteryLevel != null
? '${device.batteryLevel}%'
: '-',
formatDateTime(DateTime.fromMillisecondsSinceEpoch(
(device.createTime ?? 0) * 1000)),
device.online == true ? 'Online' : 'Offline',
formatDateTime(
DateTime.fromMillisecondsSinceEpoch((device.updateTime ?? 0) * 1000)),
formatDateTime(DateTime.fromMillisecondsSinceEpoch(
(device.updateTime ?? 0) * 1000)),
];
}).toList(),
onSelectionChanged: (selectedRows) {
context.read<DeviceManagementBloc>().add(UpdateSelection(selectedRows));
context
.read<DeviceManagementBloc>()
.add(UpdateSelection(selectedRows));
},
initialSelectedIds: context
.read<DeviceManagementBloc>()

View File

@ -70,8 +70,8 @@ class _DeviceItem extends StatelessWidget {
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: ColorsManager.whiteColors,
),
margin: const EdgeInsets.symmetric(horizontal: 4),

View File

@ -80,7 +80,9 @@ class MainDoorSensorControlView extends StatelessWidget
icon: Assets.openCloseDoor,
onTap: () {},
status: status.doorContactState,
textColor: ColorsManager.red,
textColor: status.doorContactState
? ColorsManager.red
: ColorsManager.blackColor,
paddingAmount: 8,
),
IconNameStatusContainer(

View File

@ -1,20 +1,85 @@
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: _showConfirmation
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Factory Reset',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.bold,
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,
@ -31,7 +96,8 @@ class FactoryResetWidget extends StatelessWidget {
fit: BoxFit.cover,
),
),
)),
),
),
Text(
'Factory Reset',
style: context.textTheme.titleMedium!.copyWith(

View File

@ -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),
),
),
),
],
),
],

View File

@ -65,6 +65,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
Emitter<WaterHeaterState> emit,
) {
final currentState = state as WaterHeaterDeviceStatusLoaded;
emit(currentState.copyWith(selectedTime: event.selectedTime));
}

View File

@ -130,7 +130,7 @@ class InitializeAddScheduleEvent extends WaterHeaterEvent {
}
class UpdateSelectedTimeEvent extends WaterHeaterEvent {
final TimeOfDay selectedTime;
final TimeOfDay? selectedTime;
const UpdateSelectedTimeEvent(this.selectedTime);

View File

@ -99,7 +99,7 @@ class WaterHeaterDeviceStatusLoaded extends WaterHeaterState {
isInchingActive: isInchingActive ?? this.isInchingActive,
schedules: schedules ?? this.schedules,
selectedDays: selectedDays ?? this.selectedDays,
selectedTime: selectedTime ?? this.selectedTime,
selectedTime: selectedTime,
functionOn: functionOn ?? this.functionOn,
isEditing: isEditing ?? this.isEditing,
);

View File

@ -12,6 +12,7 @@ class ScheduleDialogHelper {
final bloc = context.read<WaterHeaterBloc>();
if (schedule == null) {
bloc.add((const UpdateSelectedTimeEvent(null)));
bloc.add(InitializeAddScheduleEvent(
selectedTime: null,
selectedDays: List.filled(7, false),
@ -95,7 +96,7 @@ class ScheduleDialogHelper {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
state.selectedTime == null || schedule == null
state.selectedTime == null
? 'Time'
: state.selectedTime!.format(context),
style: context.textTheme.bodySmall!.copyWith(
@ -180,7 +181,7 @@ class ScheduleDialogHelper {
}
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);
for (int i = 0; i < daysOfWeek.length; i++) {
@ -195,7 +196,7 @@ class ScheduleDialogHelper {
static Widget _buildDayCheckboxes(
BuildContext context, List<bool> selectedDays,
{bool? isEdit}) {
final dayLabels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
final dayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
return Row(
children: List.generate(7, (index) {

View File

@ -62,6 +62,7 @@ class WaterHeaterDeviceControlView extends StatelessWidget
deviceId: device.uuid!,
code: 'switch_1',
value: status.heaterSwitch,
icon: Assets.waterHeater,
label: 'Water Heater',
onChange: (value) {
context.read<WaterHeaterBloc>().add(ToggleWaterHeaterEvent(

View File

@ -52,12 +52,13 @@ class _BuildScheduleViewState extends State<BuildScheduleView> {
if (state.scheduleMode == ScheduleModes.schedule)
ScheduleManagementUI(
state: state,
onAddSchedule: () =>
onAddSchedule: () {
ScheduleDialogHelper.showAddScheduleDialog(
context,
schedule: null,
index: null,
isEdit: false),
isEdit: false);
},
),
if (state.scheduleMode == ScheduleModes.countdown ||
state.scheduleMode == ScheduleModes.inching)

View File

@ -210,7 +210,7 @@ class ScheduleTableWidget extends StatelessWidget {
}
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 = [];
for (int i = 0; i < selectedDays.length; i++) {
if (selectedDays[i]) {