mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 06:14:55 +00:00
bugs fixes
This commit is contained in:
@ -161,15 +161,12 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
void _fetchStatus(InitCurtain event, Emitter<CurtainState> emit) async {
|
void _fetchStatus(InitCurtain event, Emitter<CurtainState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(CurtainLoadingState());
|
emit(CurtainLoadingState());
|
||||||
// Fetch the status from the API
|
|
||||||
var response = await DevicesAPI.getDeviceStatus(curtainId);
|
var response = await DevicesAPI.getDeviceStatus(curtainId);
|
||||||
List<StatusModel> statusModelList = [];
|
List<StatusModel> statusModelList = [];
|
||||||
for (var status in response['status']) {
|
for (var status in response['status']) {
|
||||||
statusModelList.add(StatusModel.fromJson(status));
|
statusModelList.add(StatusModel.fromJson(status));
|
||||||
}
|
}
|
||||||
// Get the open percentage from the response
|
|
||||||
openPercentage = double.tryParse(statusModelList[1].value.toString())!;
|
openPercentage = double.tryParse(statusModelList[1].value.toString())!;
|
||||||
// Calculate curtain width and blind height based on the open percentage
|
|
||||||
curtainWidth = 270 - (openPercentage / 100) * curtainOpeningSpace;
|
curtainWidth = 270 - (openPercentage / 100) * curtainOpeningSpace;
|
||||||
blindHeight = 310 - (openPercentage / 100) * blindOpeningSpace;
|
blindHeight = 310 - (openPercentage / 100) * blindOpeningSpace;
|
||||||
|
|
||||||
@ -216,7 +213,6 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
|
|
||||||
if (groupList.isNotEmpty) {
|
if (groupList.isNotEmpty) {
|
||||||
groupList.firstWhere((element) {
|
groupList.firstWhere((element) {
|
||||||
print('object=====${element.percentControl}');
|
|
||||||
if (element.percentControl > 1) {
|
if (element.percentControl > 1) {
|
||||||
allSwitchesOn = true;
|
allSwitchesOn = true;
|
||||||
}
|
}
|
||||||
@ -285,7 +281,6 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
|
|
||||||
if (response2['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.
|
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
emit(FailedState());
|
emit(FailedState());
|
||||||
@ -297,7 +292,6 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
void _groupAllOff(GroupAllOffEvent event, Emitter<CurtainState> emit) async {
|
void _groupAllOff(GroupAllOffEvent event, Emitter<CurtainState> emit) async {
|
||||||
emit(LoadingNewSate(curtainModel: deviceStatus));
|
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// Set all devices to 'close'
|
|
||||||
for (int i = 0; i < groupList.length; i++) {
|
for (int i = 0; i < groupList.length; i++) {
|
||||||
groupList[i].percentControl = 0;
|
groupList[i].percentControl = 0;
|
||||||
}
|
}
|
||||||
@ -315,12 +309,10 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
|||||||
|
|
||||||
if (response2['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.
|
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
emit(FailedState());
|
emit(FailedState());
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
// Optionally add an initial event if needed.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,7 +100,6 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
|||||||
doorAlarm = event.isDoorAlarmEnabled;
|
doorAlarm = event.isDoorAlarmEnabled;
|
||||||
emit(UpdateState(doorSensor: deviceStatus));
|
emit(UpdateState(doorSensor: deviceStatus));
|
||||||
|
|
||||||
// API call to update the state, if necessary
|
|
||||||
await DevicesAPI.controlDevice(
|
await DevicesAPI.controlDevice(
|
||||||
DeviceControlModel(
|
DeviceControlModel(
|
||||||
deviceId: DSId,
|
deviceId: DSId,
|
||||||
@ -119,33 +118,26 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
|||||||
|
|
||||||
Future<void> fetchLogsForLastMonth(
|
Future<void> fetchLogsForLastMonth(
|
||||||
ReportLogsInitial event, Emitter<DoorSensorState> emit) async {
|
ReportLogsInitial event, Emitter<DoorSensorState> emit) async {
|
||||||
// Get the current date and time
|
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
|
|
||||||
// Calculate the date one month ago
|
|
||||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||||
|
|
||||||
// Convert the date to milliseconds since epoch (Unix timestamp in milliseconds)
|
|
||||||
int startTime = lastMonth.millisecondsSinceEpoch;
|
int startTime = lastMonth.millisecondsSinceEpoch;
|
||||||
int endTime = now.millisecondsSinceEpoch;
|
int endTime = now.millisecondsSinceEpoch;
|
||||||
try {
|
try {
|
||||||
emit(DoorSensorLoadingState());
|
emit(DoorSensorLoadingState());
|
||||||
var response = await DevicesAPI.getReportLogs(
|
var response = await DevicesAPI.getReportLogs(
|
||||||
startTime:
|
startTime:
|
||||||
startTime.toString(), // Convert to String if the API expects it
|
startTime.toString(),
|
||||||
endTime: endTime.toString(), // Convert to String if the API expects it
|
endTime: endTime.toString(),
|
||||||
deviceUuid: DSId,
|
deviceUuid: DSId,
|
||||||
code: 'doorcontact_state',
|
code: 'doorcontact_state',
|
||||||
);
|
);
|
||||||
print('response======${response}');
|
|
||||||
recordGroups = response;
|
recordGroups = response;
|
||||||
// Process response here
|
|
||||||
emit(UpdateState(doorSensor: deviceStatus));
|
emit(UpdateState(doorSensor: 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
|
|
||||||
print('Error fetching logs: ${errorMessage}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -724,7 +724,8 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
|||||||
threeTouchId,
|
threeTouchId,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
print('Invalid statusSelected or optionSelected');
|
emit(const FailedState(
|
||||||
|
error: 'Invalid statusSelected or optionSelected'));
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
|
|||||||
@ -670,7 +670,7 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
|||||||
twoTouchId,
|
twoTouchId,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
print('Invalid statusSelected or optionSelected');
|
emit( const FailedState(error: 'Invalid statusSelected or optionSelected'));
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
|
|||||||
@ -138,9 +138,10 @@ class GarageDoorScreen extends StatelessWidget {
|
|||||||
Assets
|
Assets
|
||||||
.garageSchedule),
|
.garageSchedule),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const Flexible(
|
||||||
|
child: SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
)),
|
||||||
const Flexible(
|
const Flexible(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: BodySmall(
|
child: BodySmall(
|
||||||
@ -187,9 +188,10 @@ class GarageDoorScreen extends StatelessWidget {
|
|||||||
Assets
|
Assets
|
||||||
.garageCountdown),
|
.garageCountdown),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const Flexible(
|
||||||
|
child: SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
)),
|
||||||
const Flexible(
|
const Flexible(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: BodySmall(
|
child: BodySmall(
|
||||||
@ -238,9 +240,10 @@ class GarageDoorScreen extends StatelessWidget {
|
|||||||
Assets
|
Assets
|
||||||
.doorRecordsIcon),
|
.doorRecordsIcon),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const Flexible(
|
||||||
|
child: SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
)),
|
||||||
const Flexible(
|
const Flexible(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: BodySmall(
|
child: BodySmall(
|
||||||
@ -282,9 +285,10 @@ class GarageDoorScreen extends StatelessWidget {
|
|||||||
child: SvgPicture.asset(Assets
|
child: SvgPicture.asset(Assets
|
||||||
.garagePreferencesIcon),
|
.garagePreferencesIcon),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const Flexible(
|
||||||
|
child: SizedBox(
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
)),
|
||||||
const Flexible(
|
const Flexible(
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: BodySmall(
|
child: BodySmall(
|
||||||
|
|||||||
@ -97,9 +97,12 @@ class PreferencesPage extends StatelessWidget {
|
|||||||
Transform.scale(
|
Transform.scale(
|
||||||
scale: .8,
|
scale: .8,
|
||||||
child: CupertinoSwitch(
|
child: CupertinoSwitch(
|
||||||
value: garageDoorBloc.deviceStatus.doorState1 != 'unclosed_time',
|
value: garageDoorBloc.deviceStatus
|
||||||
|
.doorState1 !=
|
||||||
|
'unclosed_time',
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context.read<GarageDoorBloc>()
|
context
|
||||||
|
.read<GarageDoorBloc>()
|
||||||
.add(
|
.add(
|
||||||
ToggleAlarmEvent(
|
ToggleAlarmEvent(
|
||||||
value
|
value
|
||||||
@ -156,27 +159,27 @@ class PreferencesPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: Container(
|
||||||
child: ListTile(
|
padding: EdgeInsets.only(top: 12, bottom: 12),
|
||||||
contentPadding: EdgeInsets.zero,
|
child: Row(
|
||||||
leading: const BodyMedium(
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const BodyMedium(
|
||||||
text: 'Opening and Closing Time',
|
text: 'Opening and Closing Time',
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
trailing: Container(
|
Row(
|
||||||
height: 90,
|
|
||||||
width: 120,
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.center,
|
CrossAxisAlignment.center,
|
||||||
mainAxisAlignment:
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
BodyMedium(
|
BodyMedium(
|
||||||
fontColor: ColorsManager.textGray,
|
fontColor: ColorsManager.textGray,
|
||||||
text:
|
text:
|
||||||
'${garageDoorBloc.secondSelected.toString()} Seconds',
|
'${garageDoorBloc.secondSelected.toString()} Seconds',
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
|
fontSize: 13,
|
||||||
),
|
),
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.arrow_forward_ios,
|
Icons.arrow_forward_ios,
|
||||||
@ -185,7 +188,8 @@ class PreferencesPage extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)),
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -177,8 +177,8 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
record.value == 'true'
|
record.value == 'true'
|
||||||
? "Normal"
|
? "Leak Detected"
|
||||||
: "Leak Detected",
|
: "Normal",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight:
|
fontWeight:
|
||||||
FontWeight.bold,
|
FontWeight.bold,
|
||||||
@ -207,6 +207,8 @@ class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
|
|||||||
Container(
|
Container(
|
||||||
height: 10,
|
height: 10,
|
||||||
width: 20,
|
width: 20,
|
||||||
|
child:
|
||||||
|
const Center(child: Text('No data available.')),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -39,7 +39,6 @@ class DevicesAPI {
|
|||||||
body: controlModel.toJson(),
|
body: controlModel.toJson(),
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
print(json);
|
|
||||||
return json;
|
return json;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -70,7 +69,6 @@ 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),
|
||||||
|
|||||||
Reference in New Issue
Block a user