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