mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
curtain wizard & bugs fixes
This commit is contained in:
@ -27,7 +27,7 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
on<CloseCurtain>(_onCloseCurtain);
|
on<CloseCurtain>(_onCloseCurtain);
|
||||||
on<PauseCurtain>(_onPauseCurtain);
|
on<PauseCurtain>(_onPauseCurtain);
|
||||||
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
||||||
on<InitialWizardEvent>(_fetchOneTouchWizardStatus);
|
on<InitialWizardEvent>(_fetchWizardStatus);
|
||||||
on<GroupAllOffEvent>(_groupAllOff);
|
on<GroupAllOffEvent>(_groupAllOff);
|
||||||
on<GroupAllOnEvent>(_groupAllOn);
|
on<GroupAllOnEvent>(_groupAllOn);
|
||||||
}
|
}
|
||||||
@ -187,12 +187,11 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
List<GroupCurtainModel> groupList = [];
|
List<GroupCurtainModel> groupList = [];
|
||||||
bool allSwitchesOn = true;
|
bool allSwitchesOn = true;
|
||||||
List<DeviceModel> devicesList = [];
|
List<DeviceModel> devicesList = [];
|
||||||
CurtainModel deviceStatus = CurtainModel(
|
CurtainModel deviceStatus = CurtainModel(control: 'stop', percent: 0);
|
||||||
control: 'stop',
|
void _fetchWizardStatus(
|
||||||
);
|
|
||||||
void _fetchOneTouchWizardStatus(
|
|
||||||
InitialWizardEvent event, Emitter<CurtainState> emit) async {
|
InitialWizardEvent event, Emitter<CurtainState> emit) async {
|
||||||
emit(CurtainLoadingState());
|
emit(LoadingInitialState());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
devicesList = [];
|
devicesList = [];
|
||||||
groupList = [];
|
groupList = [];
|
||||||
@ -212,14 +211,14 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
deviceId: devicesList[i].uuid ?? '',
|
deviceId: devicesList[i].uuid ?? '',
|
||||||
deviceName: devicesList[i].name ?? '',
|
deviceName: devicesList[i].name ?? '',
|
||||||
firstSwitch: deviceStatus.control,
|
firstSwitch: deviceStatus.control,
|
||||||
percentControl: 0));
|
percentControl: deviceStatus.percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupList.isNotEmpty) {
|
if (groupList.isNotEmpty) {
|
||||||
groupList.firstWhere((element) {
|
groupList.firstWhere((element) {
|
||||||
print('object=====${element.firstSwitch}');
|
print('object=====${element.percentControl}');
|
||||||
if (element.firstSwitch == 'close') {
|
if (element.percentControl > 1) {
|
||||||
allSwitchesOn = false;
|
allSwitchesOn = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -241,15 +240,16 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
// Update the firstSwitch value in the groupList based on the deviceId
|
// Update the firstSwitch value in the groupList based on the deviceId
|
||||||
groupList.forEach((element) {
|
groupList.forEach((element) {
|
||||||
if (element.deviceId == event.deviceId) {
|
if (element.deviceId == event.deviceId) {
|
||||||
element.firstSwitch = event.value; // Set the new value from the event
|
element.percentControl =
|
||||||
|
event.value; // Set the new value from the event
|
||||||
}
|
}
|
||||||
if (element.firstSwitch != 'open') {
|
if (element.percentControl > 1) {
|
||||||
allSwitchesValue = false; // Check if any switch is not 'open'
|
allSwitchesValue = true; // Check if any switch is not 'open'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final response = await DevicesAPI.deviceBatchController(
|
final response = await DevicesAPI.deviceBatchController(
|
||||||
code: 'control',
|
code: 'percent_control',
|
||||||
devicesUuid: [event.deviceId],
|
devicesUuid: [event.deviceId],
|
||||||
value: event.value, // Use the value from the event
|
value: event.value, // Use the value from the event
|
||||||
);
|
);
|
||||||
@ -268,9 +268,8 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
void _groupAllOn(GroupAllOnEvent event, Emitter<CurtainState> emit) async {
|
void _groupAllOn(GroupAllOnEvent event, Emitter<CurtainState> emit) async {
|
||||||
emit(LoadingNewSate(curtainModel: deviceStatus));
|
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// Set all devices to 'open'
|
|
||||||
for (int i = 0; i < groupList.length; i++) {
|
for (int i = 0; i < groupList.length; i++) {
|
||||||
groupList[i].firstSwitch = 'open';
|
groupList[i].percentControl = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(UpdateGroupState(curtainList: groupList, allSwitches: true));
|
emit(UpdateGroupState(curtainList: groupList, allSwitches: true));
|
||||||
@ -278,19 +277,13 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
List<String> allDeviceIds =
|
List<String> allDeviceIds =
|
||||||
groupList.map((device) => device.deviceId).toList();
|
groupList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
final response1 = await DevicesAPI.deviceBatchController(
|
|
||||||
code: 'control',
|
|
||||||
devicesUuid: allDeviceIds,
|
|
||||||
value: 'open', // Set the devices to 'open'
|
|
||||||
);
|
|
||||||
|
|
||||||
final response2 = await DevicesAPI.deviceBatchController(
|
final response2 = await DevicesAPI.deviceBatchController(
|
||||||
code: 'control',
|
code: 'percent_control',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: 'open',
|
value: 100,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response1['failedResults'].toString() != '[]') {
|
if (response2['failedResults'].toString() != '[]') {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
// Handle retry or error if needed.
|
// Handle retry or error if needed.
|
||||||
}
|
}
|
||||||
@ -306,7 +299,7 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
try {
|
try {
|
||||||
// Set all devices to 'close'
|
// Set all devices to 'close'
|
||||||
for (int i = 0; i < groupList.length; i++) {
|
for (int i = 0; i < groupList.length; i++) {
|
||||||
groupList[i].firstSwitch = 'close';
|
groupList[i].percentControl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(UpdateGroupState(curtainList: groupList, allSwitches: false));
|
emit(UpdateGroupState(curtainList: groupList, allSwitches: false));
|
||||||
@ -314,19 +307,13 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
List<String> allDeviceIds =
|
List<String> allDeviceIds =
|
||||||
groupList.map((device) => device.deviceId).toList();
|
groupList.map((device) => device.deviceId).toList();
|
||||||
|
|
||||||
final response1 = await DevicesAPI.deviceBatchController(
|
|
||||||
code: 'control',
|
|
||||||
devicesUuid: allDeviceIds,
|
|
||||||
value: 'close', // Set the devices to 'close'
|
|
||||||
);
|
|
||||||
|
|
||||||
final response2 = await DevicesAPI.deviceBatchController(
|
final response2 = await DevicesAPI.deviceBatchController(
|
||||||
code: 'control',
|
code: 'percent_control',
|
||||||
devicesUuid: allDeviceIds,
|
devicesUuid: allDeviceIds,
|
||||||
value: 'close',
|
value: 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response1['failedResults'].toString() != '[]') {
|
if (response2['failedResults'].toString() != '[]') {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
// Handle retry or error if needed.
|
// Handle retry or error if needed.
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class InitialWizardEvent extends CurtainEvent {}
|
|||||||
|
|
||||||
|
|
||||||
class ChangeFirstWizardSwitchStatusEvent extends CurtainEvent {
|
class ChangeFirstWizardSwitchStatusEvent extends CurtainEvent {
|
||||||
final String value;
|
final int value;
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
const ChangeFirstWizardSwitchStatusEvent(
|
const ChangeFirstWizardSwitchStatusEvent(
|
||||||
{required this.value, this.deviceId = ''});
|
{required this.value, this.deviceId = ''});
|
||||||
|
@ -41,6 +41,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
|||||||
on<GroupAllOffEvent>(_groupAllOff);
|
on<GroupAllOffEvent>(_groupAllOff);
|
||||||
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
||||||
on<ToggleAlarmEvent>(_toggleAlarmEvent);
|
on<ToggleAlarmEvent>(_toggleAlarmEvent);
|
||||||
|
on<DeleteScheduleEvent>(deleteSchedule);
|
||||||
//_toggleAlarmEvent
|
//_toggleAlarmEvent
|
||||||
}
|
}
|
||||||
void _onClose(OnClose event, Emitter<GarageDoorSensorState> emit) {
|
void _onClose(OnClose event, Emitter<GarageDoorSensorState> emit) {
|
||||||
@ -167,7 +168,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
|||||||
startTime: startTime.toString(),
|
startTime: startTime.toString(),
|
||||||
endTime: endTime.toString(),
|
endTime: endTime.toString(),
|
||||||
deviceUuid: GDId,
|
deviceUuid: GDId,
|
||||||
code: 'doorcontact_state',
|
code: 'switch_1',
|
||||||
);
|
);
|
||||||
recordGroups = response;
|
recordGroups = response;
|
||||||
emit(UpdateState(garageSensor: deviceStatus));
|
emit(UpdateState(garageSensor: deviceStatus));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:firebase_database/firebase_database.dart';
|
import 'package:firebase_database/firebase_database.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_event.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_state.dart';
|
||||||
@ -51,15 +50,12 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle functions for each switch
|
|
||||||
void _toggleLowBattery(
|
void _toggleLowBattery(
|
||||||
ToggleLowBatteryEvent event, Emitter<WaterLeakState> emit) async {
|
ToggleLowBatteryEvent event, Emitter<WaterLeakState> emit) async {
|
||||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||||
try {
|
try {
|
||||||
lowBattery = event.isLowBatteryEnabled;
|
lowBattery = event.isLowBatteryEnabled;
|
||||||
emit(UpdateState(waterSensor: deviceStatus));
|
emit(UpdateState(waterSensor: deviceStatus));
|
||||||
|
|
||||||
// API call to update the state, if necessary
|
|
||||||
await DevicesAPI.controlDevice(
|
await DevicesAPI.controlDevice(
|
||||||
DeviceControlModel(
|
DeviceControlModel(
|
||||||
deviceId: WLId,
|
deviceId: WLId,
|
||||||
@ -100,8 +96,6 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
try {
|
try {
|
||||||
waterAlarm = event.isWaterLeakAlarmEnabled;
|
waterAlarm = event.isWaterLeakAlarmEnabled;
|
||||||
emit(UpdateState(waterSensor: deviceStatus));
|
emit(UpdateState(waterSensor: deviceStatus));
|
||||||
|
|
||||||
// API call to update the state, if necessary
|
|
||||||
await DevicesAPI.controlDevice(
|
await DevicesAPI.controlDevice(
|
||||||
DeviceControlModel(
|
DeviceControlModel(
|
||||||
deviceId: WLId,
|
deviceId: WLId,
|
||||||
@ -120,7 +114,6 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
|
|
||||||
Future<void> fetchLogsForLastMonth(
|
Future<void> fetchLogsForLastMonth(
|
||||||
ReportLogsInitial event, Emitter<WaterLeakState> emit) async {
|
ReportLogsInitial event, Emitter<WaterLeakState> emit) async {
|
||||||
// Get the current date and time
|
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||||
int startTime = lastMonth.millisecondsSinceEpoch;
|
int startTime = lastMonth.millisecondsSinceEpoch;
|
||||||
@ -131,17 +124,14 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
startTime: startTime.toString(),
|
startTime: startTime.toString(),
|
||||||
endTime: endTime.toString(),
|
endTime: endTime.toString(),
|
||||||
deviceUuid: WLId,
|
deviceUuid: WLId,
|
||||||
code: 'watercontact_state',
|
code: 'watersensor_state',
|
||||||
);
|
);
|
||||||
recordGroups = response;
|
recordGroups = response;
|
||||||
emit(UpdateState(waterSensor: deviceStatus));
|
emit(UpdateState(waterSensor: deviceStatus));
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['message'];
|
String errorMessage = errorData['message'];
|
||||||
// Handle error
|
|
||||||
emit(WaterLeakFailedState(errorMessage: errorMessage));
|
emit(WaterLeakFailedState(errorMessage: errorMessage));
|
||||||
|
|
||||||
debugPrint('Error fetching logs: ${errorMessage}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,21 +2,28 @@ import 'package:syncrow_app/features/devices/model/status_model.dart';
|
|||||||
|
|
||||||
class CurtainModel {
|
class CurtainModel {
|
||||||
String control;
|
String control;
|
||||||
|
int percent;
|
||||||
|
|
||||||
CurtainModel({
|
CurtainModel({
|
||||||
required this.control,
|
required this.control,
|
||||||
|
required this.percent,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory CurtainModel.fromJson(List<StatusModel> jsonList) {
|
factory CurtainModel.fromJson(List<StatusModel> jsonList) {
|
||||||
late String _control;
|
late String _control;
|
||||||
|
late int _percent;
|
||||||
for (int i = 0; i < jsonList.length; i++) {
|
for (int i = 0; i < jsonList.length; i++) {
|
||||||
if (jsonList[i].code == 'control') {
|
if (jsonList[i].code == 'control') {
|
||||||
_control = jsonList[i].value ?? false;
|
_control = jsonList[i].value ?? false;
|
||||||
}
|
}
|
||||||
|
if (jsonList[i].code == 'percent_control') {
|
||||||
|
_percent = jsonList[i].value ?? 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//percent_control
|
||||||
return CurtainModel(
|
return CurtainModel(
|
||||||
control: _control,
|
control: _control,
|
||||||
|
percent: _percent,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,8 @@ class ACsList extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: devicesStatuesList[index].acSwitch,
|
switchValue: devicesStatuesList[index].acSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ACsBloc>(context).add(AcSwitch(
|
BlocProvider.of<ACsBloc>(context).add(AcSwitch(
|
||||||
|
@ -28,6 +28,8 @@ class CurtainsList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Curtains'),
|
const BodySmall(text: 'All Curtains'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'Close',
|
||||||
|
on: 'Open',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<CurtainBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<CurtainBloc>(context).add(GroupAllOnEvent());
|
||||||
@ -49,13 +51,13 @@ class CurtainsList extends StatelessWidget {
|
|||||||
BodySmall(text: curtainsList[index].deviceName),
|
BodySmall(text: curtainsList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
switchValue: curtainsList[index].firstSwitch == 'open',
|
off: 'close',
|
||||||
|
on: 'open',
|
||||||
|
switchValue: curtainsList[index].percentControl > 1,
|
||||||
action: () {
|
action: () {
|
||||||
// Toggle between 'open' and 'close' based on current value
|
// Toggle between 'open' and 'close' based on current value
|
||||||
final newValue =
|
final newValue =
|
||||||
curtainsList[index].firstSwitch == 'open'
|
curtainsList[index].percentControl > 1 ? 0 : 100;
|
||||||
? 'close'
|
|
||||||
: 'open';
|
|
||||||
BlocProvider.of<CurtainBloc>(context).add(
|
BlocProvider.of<CurtainBloc>(context).add(
|
||||||
ChangeFirstWizardSwitchStatusEvent(
|
ChangeFirstWizardSwitchStatusEvent(
|
||||||
value: newValue,
|
value: newValue,
|
||||||
|
@ -29,23 +29,6 @@ class GarageDoorScreen extends StatelessWidget {
|
|||||||
child: BlocBuilder<GarageDoorBloc, GarageDoorSensorState>(
|
child: BlocBuilder<GarageDoorBloc, GarageDoorSensorState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final garageBloc = BlocProvider.of<GarageDoorBloc>(context);
|
final garageBloc = BlocProvider.of<GarageDoorBloc>(context);
|
||||||
// GarageDoorModel model = GarageDoorModel(
|
|
||||||
// tr_timecon: 0,
|
|
||||||
// countdown1: 0,
|
|
||||||
// countdownAlarm: 0,
|
|
||||||
// doorContactState: false,
|
|
||||||
// doorControl1: '',
|
|
||||||
// doorState1: '',
|
|
||||||
// switch1: false,
|
|
||||||
// voiceControl1: false,
|
|
||||||
// batteryPercentage: 0,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if (state is LoadingNewSate) {
|
|
||||||
// model = state.doorSensor;
|
|
||||||
// } else if (state is UpdateState) {
|
|
||||||
// model = state.garageSensor;
|
|
||||||
// }
|
|
||||||
return state is GarageDoorLoadingState
|
return state is GarageDoorLoadingState
|
||||||
? const Center(
|
? const Center(
|
||||||
child:
|
child:
|
||||||
|
@ -26,6 +26,8 @@ class GarageList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<GarageDoorBloc>(context)
|
BlocProvider.of<GarageDoorBloc>(context)
|
||||||
@ -49,6 +51,8 @@ class GarageList extends StatelessWidget {
|
|||||||
BodySmall(text: garageList[index].deviceName),
|
BodySmall(text: garageList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: garageList[index].firstSwitch,
|
switchValue: garageList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<GarageDoorBloc>(context).add(
|
BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
|
@ -97,12 +97,9 @@ class PreferencesPage extends StatelessWidget {
|
|||||||
Transform.scale(
|
Transform.scale(
|
||||||
scale: .8,
|
scale: .8,
|
||||||
child: CupertinoSwitch(
|
child: CupertinoSwitch(
|
||||||
value: garageDoorBloc.deviceStatus
|
value: garageDoorBloc.deviceStatus.doorState1 != 'unclosed_time',
|
||||||
.doorState1 ==
|
|
||||||
'unclosed_time',
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context
|
context.read<GarageDoorBloc>()
|
||||||
.read<GarageDoorBloc>()
|
|
||||||
.add(
|
.add(
|
||||||
ToggleAlarmEvent(
|
ToggleAlarmEvent(
|
||||||
value
|
value
|
||||||
|
@ -48,6 +48,8 @@ class LightsList extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: false,
|
switchValue: false,
|
||||||
action: () {},
|
action: () {},
|
||||||
),
|
),
|
||||||
|
@ -26,6 +26,8 @@ class OneGangList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<OneGangBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<OneGangBloc>(context).add(GroupAllOnEvent());
|
||||||
@ -47,6 +49,8 @@ class OneGangList extends StatelessWidget {
|
|||||||
BodySmall(text: oneGangList[index].deviceName),
|
BodySmall(text: oneGangList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: oneGangList[index].firstSwitch,
|
switchValue: oneGangList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<OneGangBloc>(context).add(
|
BlocProvider.of<OneGangBloc>(context).add(
|
||||||
|
@ -27,12 +27,15 @@ class OneTouchList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOnEvent());
|
||||||
},
|
},
|
||||||
secondAction: () {
|
secondAction: () {
|
||||||
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOffEvent());
|
BlocProvider.of<OneTouchBloc>(context)
|
||||||
|
.add(GroupAllOffEvent());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
@ -48,6 +51,8 @@ class OneTouchList extends StatelessWidget {
|
|||||||
BodySmall(text: oneTouchList[index].deviceName),
|
BodySmall(text: oneTouchList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: oneTouchList[index].firstSwitch,
|
switchValue: oneTouchList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<OneTouchBloc>(context).add(
|
BlocProvider.of<OneTouchBloc>(context).add(
|
||||||
|
@ -8,7 +8,8 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
class ThreeGangList extends StatelessWidget {
|
class ThreeGangList extends StatelessWidget {
|
||||||
const ThreeGangList({super.key, required this.threeGangList, required this.allSwitches});
|
const ThreeGangList(
|
||||||
|
{super.key, required this.threeGangList, required this.allSwitches});
|
||||||
|
|
||||||
final List<GroupThreeGangModel> threeGangList;
|
final List<GroupThreeGangModel> threeGangList;
|
||||||
final bool allSwitches;
|
final bool allSwitches;
|
||||||
@ -25,12 +26,16 @@ class ThreeGangList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<ThreeGangBloc>(context)
|
||||||
|
.add(GroupAllOnEvent());
|
||||||
},
|
},
|
||||||
secondAction: () {
|
secondAction: () {
|
||||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOffEvent());
|
BlocProvider.of<ThreeGangBloc>(context)
|
||||||
|
.add(GroupAllOffEvent());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
@ -43,34 +48,48 @@ class ThreeGangList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: '${threeGangList[index].deviceName} beside light'),
|
BodySmall(
|
||||||
|
text:
|
||||||
|
'${threeGangList[index].deviceName} beside light'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: threeGangList[index].firstSwitch,
|
switchValue: threeGangList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||||
|
ChangeFirstSwitchStatusEvent(
|
||||||
value: threeGangList[index].firstSwitch,
|
value: threeGangList[index].firstSwitch,
|
||||||
deviceId: threeGangList[index].deviceId));
|
deviceId: threeGangList[index].deviceId));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: '${threeGangList[index].deviceName} ceiling light'),
|
BodySmall(
|
||||||
|
text:
|
||||||
|
'${threeGangList[index].deviceName} ceiling light'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: threeGangList[index].secondSwitch,
|
switchValue: threeGangList[index].secondSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeSecondSwitchStatusEvent(
|
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||||
|
ChangeSecondSwitchStatusEvent(
|
||||||
value: threeGangList[index].secondSwitch,
|
value: threeGangList[index].secondSwitch,
|
||||||
deviceId: threeGangList[index].deviceId));
|
deviceId: threeGangList[index].deviceId));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: '${threeGangList[index].deviceName} spotlight'),
|
BodySmall(
|
||||||
|
text: '${threeGangList[index].deviceName} spotlight'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: threeGangList[index].thirdSwitch,
|
switchValue: threeGangList[index].thirdSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeThirdSwitchStatusEvent(
|
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||||
|
ChangeThirdSwitchStatusEvent(
|
||||||
value: threeGangList[index].thirdSwitch,
|
value: threeGangList[index].thirdSwitch,
|
||||||
deviceId: threeGangList[index].deviceId));
|
deviceId: threeGangList[index].deviceId));
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,8 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
class ThreeTouchList extends StatelessWidget {
|
class ThreeTouchList extends StatelessWidget {
|
||||||
const ThreeTouchList({super.key, required this.threeTouchList, required this.allSwitches});
|
const ThreeTouchList(
|
||||||
|
{super.key, required this.threeTouchList, required this.allSwitches});
|
||||||
|
|
||||||
final List<GroupThreeTouchModel> threeTouchList;
|
final List<GroupThreeTouchModel> threeTouchList;
|
||||||
final bool allSwitches;
|
final bool allSwitches;
|
||||||
@ -25,12 +26,16 @@ class ThreeTouchList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeTouchBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<ThreeTouchBloc>(context)
|
||||||
|
.add(GroupAllOnEvent());
|
||||||
},
|
},
|
||||||
secondAction: () {
|
secondAction: () {
|
||||||
BlocProvider.of<ThreeTouchBloc>(context).add(GroupAllOffEvent());
|
BlocProvider.of<ThreeTouchBloc>(context)
|
||||||
|
.add(GroupAllOffEvent());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
@ -43,34 +48,49 @@ class ThreeTouchList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: '${threeTouchList[index].deviceName} beside light'),
|
BodySmall(
|
||||||
|
text:
|
||||||
|
'${threeTouchList[index].deviceName} beside light'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: threeTouchList[index].firstSwitch,
|
switchValue: threeTouchList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeTouchBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
BlocProvider.of<ThreeTouchBloc>(context).add(
|
||||||
|
ChangeFirstSwitchStatusEvent(
|
||||||
value: threeTouchList[index].firstSwitch,
|
value: threeTouchList[index].firstSwitch,
|
||||||
deviceId: threeTouchList[index].deviceId));
|
deviceId: threeTouchList[index].deviceId));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: '${threeTouchList[index].deviceName} ceiling light'),
|
BodySmall(
|
||||||
|
text:
|
||||||
|
'${threeTouchList[index].deviceName} ceiling light'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: threeTouchList[index].secondSwitch,
|
switchValue: threeTouchList[index].secondSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeTouchBloc>(context).add(ChangeSecondSwitchStatusEvent(
|
BlocProvider.of<ThreeTouchBloc>(context).add(
|
||||||
|
ChangeSecondSwitchStatusEvent(
|
||||||
value: threeTouchList[index].secondSwitch,
|
value: threeTouchList[index].secondSwitch,
|
||||||
deviceId: threeTouchList[index].deviceId));
|
deviceId: threeTouchList[index].deviceId));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: '${threeTouchList[index].deviceName} spotlight'),
|
BodySmall(
|
||||||
|
text:
|
||||||
|
'${threeTouchList[index].deviceName} spotlight'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: threeTouchList[index].thirdSwitch,
|
switchValue: threeTouchList[index].thirdSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<ThreeTouchBloc>(context).add(ChangeThirdSwitchStatusEvent(
|
BlocProvider.of<ThreeTouchBloc>(context).add(
|
||||||
|
ChangeThirdSwitchStatusEvent(
|
||||||
value: threeTouchList[index].thirdSwitch,
|
value: threeTouchList[index].thirdSwitch,
|
||||||
deviceId: threeTouchList[index].deviceId));
|
deviceId: threeTouchList[index].deviceId));
|
||||||
},
|
},
|
||||||
|
@ -26,6 +26,8 @@ class TwoGangList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<TwoGangBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<TwoGangBloc>(context).add(GroupAllOnEvent());
|
||||||
@ -47,6 +49,8 @@ class TwoGangList extends StatelessWidget {
|
|||||||
BodySmall(text: twoGangList[index].deviceName),
|
BodySmall(text: twoGangList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: twoGangList[index].firstSwitch,
|
switchValue: twoGangList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<TwoGangBloc>(context).add(
|
BlocProvider.of<TwoGangBloc>(context).add(
|
||||||
@ -59,6 +63,8 @@ class TwoGangList extends StatelessWidget {
|
|||||||
BodySmall(text: twoGangList[index].deviceName),
|
BodySmall(text: twoGangList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: twoGangList[index].secondSwitch,
|
switchValue: twoGangList[index].secondSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<TwoGangBloc>(context).add(
|
BlocProvider.of<TwoGangBloc>(context).add(
|
||||||
|
@ -26,12 +26,15 @@ class TwoTouchList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<TwoTouchBloc>(context).add(GroupAllOnEvent());
|
BlocProvider.of<TwoTouchBloc>(context).add(GroupAllOnEvent());
|
||||||
},
|
},
|
||||||
secondAction: () {
|
secondAction: () {
|
||||||
BlocProvider.of<TwoTouchBloc>(context).add(GroupAllOffEvent());
|
BlocProvider.of<TwoTouchBloc>(context)
|
||||||
|
.add(GroupAllOffEvent());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
@ -47,6 +50,8 @@ class TwoTouchList extends StatelessWidget {
|
|||||||
BodySmall(text: twoTouchList[index].deviceName),
|
BodySmall(text: twoTouchList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: twoTouchList[index].firstSwitch,
|
switchValue: twoTouchList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<TwoTouchBloc>(context).add(
|
BlocProvider.of<TwoTouchBloc>(context).add(
|
||||||
@ -59,6 +64,8 @@ class TwoTouchList extends StatelessWidget {
|
|||||||
BodySmall(text: twoTouchList[index].deviceName),
|
BodySmall(text: twoTouchList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: twoTouchList[index].secondSwitch,
|
switchValue: twoTouchList[index].secondSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<TwoTouchBloc>(context).add(
|
BlocProvider.of<TwoTouchBloc>(context).add(
|
||||||
|
@ -25,6 +25,8 @@ class WHList extends StatelessWidget {
|
|||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Lights'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<WaterHeaterBloc>(context)
|
BlocProvider.of<WaterHeaterBloc>(context)
|
||||||
@ -48,6 +50,8 @@ class WHList extends StatelessWidget {
|
|||||||
BodySmall(text: whList[index].deviceName),
|
BodySmall(text: whList[index].deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
|
off: 'OFF',
|
||||||
|
on: 'ON',
|
||||||
switchValue: whList[index].firstSwitch,
|
switchValue: whList[index].firstSwitch,
|
||||||
action: () {
|
action: () {
|
||||||
BlocProvider.of<WaterHeaterBloc>(context).add(
|
BlocProvider.of<WaterHeaterBloc>(context).add(
|
||||||
|
@ -7,9 +7,13 @@ class DevicesDefaultSwitch extends StatelessWidget {
|
|||||||
{super.key,
|
{super.key,
|
||||||
required this.switchValue,
|
required this.switchValue,
|
||||||
required this.action,
|
required this.action,
|
||||||
|
required this.on,
|
||||||
|
required this.off,
|
||||||
this.secondAction});
|
this.secondAction});
|
||||||
|
|
||||||
final bool switchValue;
|
final bool switchValue;
|
||||||
|
final String on;
|
||||||
|
final String off;
|
||||||
final Function action;
|
final Function action;
|
||||||
final Function? secondAction;
|
final Function? secondAction;
|
||||||
|
|
||||||
@ -36,7 +40,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: BodyMedium(
|
child: BodyMedium(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
text: "ON",
|
text: on,
|
||||||
fontColor: switchValue ? Colors.white : null,
|
fontColor: switchValue ? Colors.white : null,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
),
|
),
|
||||||
@ -67,7 +71,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: BodyMedium(
|
child: BodyMedium(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
text: "OFF",
|
text: off,
|
||||||
fontColor: switchValue ? null : Colors.white,
|
fontColor: switchValue ? null : Colors.white,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
),
|
),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
@ -60,11 +61,8 @@ class DevicesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
|
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
|
||||||
// Map<String, dynamic> params = {"homeId": spaceId, "pageSize": 100, "pageNo": 1};
|
|
||||||
|
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.groupBySpace.replaceAll('{unitUuid}', spaceId),
|
path: ApiEndpoints.groupBySpace.replaceAll('{unitUuid}', spaceId),
|
||||||
// queryParameters: params,
|
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json),
|
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json),
|
||||||
);
|
);
|
||||||
@ -72,12 +70,12 @@ class DevicesAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<Map<String, dynamic>> getDeviceStatus(String deviceId) async {
|
static Future<Map<String, dynamic>> getDeviceStatus(String deviceId) async {
|
||||||
|
print(deviceId);
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.deviceFunctionsStatus
|
path: ApiEndpoints.deviceFunctionsStatus
|
||||||
.replaceAll('{deviceUuid}', deviceId),
|
.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
print('json======${json}');
|
|
||||||
return json;
|
return json;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -124,6 +122,7 @@ class DevicesAPI {
|
|||||||
return <DeviceModel>[];
|
return <DeviceModel>[];
|
||||||
}
|
}
|
||||||
List<DeviceModel> devices = [];
|
List<DeviceModel> devices = [];
|
||||||
|
|
||||||
for (var device in json) {
|
for (var device in json) {
|
||||||
devices.add(DeviceModel.fromJson(device));
|
devices.add(DeviceModel.fromJson(device));
|
||||||
}
|
}
|
||||||
@ -386,13 +385,11 @@ class DevicesAPI {
|
|||||||
String? code,
|
String? code,
|
||||||
var value,
|
var value,
|
||||||
}) async {
|
}) async {
|
||||||
print({"devicesUuid": devicesUuid, "code": code, "value": value});
|
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.controlBatch,
|
path: ApiEndpoints.controlBatch,
|
||||||
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
print('json-=-=-=-=-=-${json}');
|
|
||||||
return json;
|
return json;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -815,7 +815,7 @@ extension lightStatusExtension on lightStatus {
|
|||||||
case lightStatus.switchPosition:
|
case lightStatus.switchPosition:
|
||||||
return "On/Off Status";
|
return "On/Off Status";
|
||||||
case lightStatus.on_off:
|
case lightStatus.on_off:
|
||||||
return "Restart Memory";
|
return "Switch Position";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ description: This is the mobile application project, developed with Flutter for
|
|||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 1.0.4+27
|
version: 1.0.4+28
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.6 <4.0.0"
|
sdk: ">=3.0.6 <4.0.0"
|
||||||
|
Reference in New Issue
Block a user