Merged with dev branch

This commit is contained in:
Abdullah Alassaf
2024-07-25 13:35:10 +03:00
24 changed files with 716 additions and 527 deletions

View File

2
.env.development Normal file
View File

@ -0,0 +1,2 @@
ENV_NAME=development
BASE_URL=https://syncrow-dev.azurewebsites.net

View File

2
.env.production Normal file
View File

@ -0,0 +1,2 @@
ENV_NAME=production
BASE_URL=https://syncrow-staging.azurewebsites.net

View File

@ -0,0 +1,2 @@
ENV_NAME=staging
BASE_URL=https://syncrow-staging.azurewebsites.net

2
.gitignore vendored
View File

@ -20,7 +20,7 @@ migrate_working_dir/
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
*.env
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id

View File

@ -64,7 +64,8 @@ class AuthCubit extends Cubit<AuthState> {
return 'Please enter your password';
}
if (value.isNotEmpty) {
if (!RegExp(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$')
if (!RegExp(
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!"#$%&()*+,-./:;<=>?@[\]^_`{|}~])[A-Za-z\d!"#$%&()*+,-./:;<=>?@[\]^_`{|}~]{8,}$')
.hasMatch(value)) {
return 'Password must contain at least:\n - one uppercase letter.\n - one lowercase letter.\n - one number. \n - special character';
}

View File

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart';
@ -12,6 +14,7 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
class ACsBloc extends Bloc<AcsEvent, AcsState> {
final String acId;
AcStatusModel deviceStatus = AcStatusModel(
uuid: '',
acSwitch: true,
modeString: 'hot',
tempSet: 300,
@ -24,6 +27,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
bool allAcsOn = true;
bool allTempSame = true;
int globalTemp = 25;
Timer? _timer;
ACsBloc({required this.acId}) : super(AcsInitialState()) {
on<AcsInitial>(_fetchAcsStatus);
@ -56,11 +60,11 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status));
}
deviceStatus = AcStatusModel.fromJson(statusModelList);
deviceStatus = AcStatusModel.fromJson(response['productUuid'], statusModelList);
emit(GetAcStatusState(acStatusModel: deviceStatus));
}
} catch (e) {
emit(AcsFailedState(error: e.toString()));
emit(AcsFailedState(errorMessage: e.toString()));
return;
}
}
@ -68,8 +72,6 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
_getAllAcs() async {
deviceStatusList = [];
devicesList = [];
allAcsOn = true;
allTempSame = true;
devicesList = await DevicesAPI.getDeviceByGroupName(
HomeCubit.getInstance().selectedSpace?.id ?? '', 'AC');
@ -79,8 +81,210 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status));
}
deviceStatusList.add(AcStatusModel.fromJson(statusModelList));
deviceStatusList.add(AcStatusModel.fromJson(response['productUuid'], statusModelList));
}
_setAllAcsTempsAndSwitches();
}
void _changeAcSwitch(AcSwitch event, Emitter<AcsState> emit) async {
final acSwitchValue = !event.acSwitch;
if (allAcsPage) {
emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) {
ac.acSwitch = acSwitchValue;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
} else {
emit(AcChangeLoading(acStatusModel: deviceStatus));
deviceStatus.acSwitch = acSwitchValue;
emit(AcModifyingState(acStatusModel: deviceStatus));
}
await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'switch', value: acSwitchValue);
}
void _changeAllAcSwitch(ChangeAllSwitch event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
if (deviceStatusList.length == devicesList.length) {
for (int i = 0; i < deviceStatusList.length; i++) {
deviceStatusList[i].acSwitch = event.value;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
_runDeBouncerForAllAcs(code: 'switch', value: event.value);
}
void _increaseAllTemp(IncreaseAllTemp event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
double tempValue = event.value + 0.5;
int value = (tempValue * 10).toInt();
if (!_checkTemperatureValue(tempValue, emit)) {
return;
}
if (deviceStatusList.length == devicesList.length) {
for (int i = 0; i < deviceStatusList.length; i++) {
deviceStatusList[i].tempSet = value;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
_runDeBouncerForAllAcs(code: 'temp_set', value: value);
}
void _decreaseAllTemp(DecreaseAllTemp event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
double tempValue = event.value - 0.5;
int value = (tempValue * 10).toInt();
if (!_checkTemperatureValue(tempValue, emit)) {
return;
}
if (deviceStatusList.length == devicesList.length) {
for (int i = 0; i < deviceStatusList.length; i++) {
deviceStatusList[i].tempSet = value;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
_runDeBouncerForAllAcs(code: 'temp_set', value: value);
}
void _changeLockValue(ChangeLock event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
final lockValue = !event.lockBool;
deviceStatus.childLock = lockValue;
emit(AcModifyingState(acStatusModel: deviceStatus));
_runDeBouncerForOneDevice(deviceId: acId, code: 'child_lock', value: lockValue);
}
void _increaseCoolTo(IncreaseCoolToTemp event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
double tempValue = event.value + 0.5;
int value = (tempValue * 10).toInt();
if (!_checkTemperatureValue(tempValue, emit)) {
return;
}
if (allAcsPage) {
emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) {
ac.tempSet = value;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
} else {
emit(AcChangeLoading(acStatusModel: deviceStatus));
deviceStatus.tempSet = value;
emit(AcModifyingState(acStatusModel: deviceStatus));
}
await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'temp_set', value: value);
}
void _decreaseCoolTo(DecreaseCoolToTemp event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
double tempValue = event.value - 0.5;
int value = (tempValue * 10).toInt();
if (!_checkTemperatureValue(tempValue, emit)) {
return;
}
if (allAcsPage) {
emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) {
ac.tempSet = value;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
} else {
emit(AcChangeLoading(acStatusModel: deviceStatus));
deviceStatus.tempSet = value;
emit(AcModifyingState(acStatusModel: deviceStatus));
}
await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'temp_set', value: value);
}
void _changeAcMode(ChangeAcMode event, Emitter<AcsState> emit) async {
final tempMode = tempModesMap[getNextItem(tempModesMap, event.tempModes)]!;
if (allAcsPage) {
emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) {
ac.modeString = getACModeString(tempMode);
ac.acMode = AcStatusModel.getACMode(getACModeString(tempMode));
}
}
_emitAcsStatus(emit);
} else {
emit(AcChangeLoading(acStatusModel: deviceStatus));
deviceStatus.modeString = getACModeString(tempMode);
deviceStatus.acMode = AcStatusModel.getACMode(getACModeString(tempMode));
emit(AcModifyingState(acStatusModel: deviceStatus));
}
await _runDeBouncerForOneDevice(
deviceId: event.deviceId, code: 'mode', value: getACModeString(tempMode));
}
void _changeFanSpeed(ChangeFanSpeed event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
final fanSpeed = event.fanSpeeds;
if (allAcsPage) {
emit(AcsLoadingState());
for (AcStatusModel ac in deviceStatusList) {
if (ac.uuid == event.productId) {
ac.fanSpeedsString = getNextFanSpeedKey(fanSpeed);
ac.acFanSpeed = AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
}
}
_emitAcsStatus(emit);
} else {
emit(AcChangeLoading(acStatusModel: deviceStatus));
deviceStatus.fanSpeedsString = getNextFanSpeedKey(fanSpeed);
deviceStatus.acFanSpeed = AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
emit(AcModifyingState(acStatusModel: deviceStatus));
}
await _runDeBouncerForOneDevice(
deviceId: event.deviceId, code: 'level', value: getNextFanSpeedKey(fanSpeed));
}
String getACModeString(TempModes value) {
if (value == TempModes.cold) {
return 'cold';
} else if (value == TempModes.hot) {
return 'hot';
} else if (value == TempModes.wind) {
return 'wind';
} else {
return 'cold';
}
}
void _setAllAcsTempsAndSwitches() {
allAcsOn = true;
allTempSame = true;
if (deviceStatusList.isNotEmpty) {
int temp = deviceStatusList[0].tempSet;
deviceStatusList.firstWhere((element) {
@ -99,195 +303,71 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
}
}
void _changeAcSwitch(AcSwitch event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
final acSwitchValue = !event.acSwitch;
try {
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: allAcsPage ? event.deviceId : acId, code: 'switch', value: acSwitchValue),
allAcsPage ? event.deviceId : acId);
if (response['success'] ?? false) {
deviceStatus.acSwitch = acSwitchValue;
_runDeBouncerForAllAcs({required String code, required dynamic value}) {
if (_timer != null) {
_timer!.cancel();
}
} catch (_) {}
if (allAcsPage) {
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
} else {
emit(AcModifyingState(acStatusModel: deviceStatus));
}
}
void _changeAllAcSwitch(ChangeAllSwitch event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
try {
_timer = Timer(const Duration(seconds: 1), () async {
if (deviceStatusList.length == devicesList.length) {
for (int i = 0; i < deviceStatusList.length; i++) {
try {
await DevicesAPI.controlDevice(
DeviceControlModel(deviceId: devicesList[i].uuid, code: 'switch', value: event.value),
DeviceControlModel(deviceId: devicesList[i].uuid, code: code, value: value),
devicesList[i].uuid ?? '');
}
}
} catch (_) {}
await Future.delayed(const Duration(seconds: 1));
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(const AcsInitial(allAcs: true));
}
void _increaseAllTemp(IncreaseAllTemp event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
try {
double tempValue = event.value + 0.5;
int value = (tempValue * 10).toInt();
if (deviceStatusList.length == devicesList.length) {
for (int i = 0; i < deviceStatusList.length; i++) {
await DevicesAPI.controlDevice(
DeviceControlModel(deviceId: devicesList[i].uuid, code: 'temp_set', value: value),
devicesList[i].uuid ?? '');
}
}
} catch (_) {}
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
});
}
void _decreaseAllTemp(DecreaseAllTemp event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
try {
double tempValue = event.value - 0.5;
int value = (tempValue * 10).toInt();
if (deviceStatusList.length == devicesList.length) {
for (int i = 0; i < deviceStatusList.length; i++) {
await DevicesAPI.controlDevice(
DeviceControlModel(deviceId: devicesList[i].uuid, code: 'temp_set', value: value),
devicesList[i].uuid ?? '');
_runDeBouncerForOneDevice({
required String deviceId,
required String code,
required dynamic value,
}) {
if (_timer != null) {
_timer!.cancel();
}
}
} catch (_) {}
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
}
void _changeLockValue(ChangeLock event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
final lockValue = !event.lockBool;
_timer = Timer(const Duration(seconds: 1), () async {
try {
final response = await DevicesAPI.controlDevice(
DeviceControlModel(deviceId: acId, code: 'child_lock', value: lockValue), acId);
DeviceControlModel(deviceId: allAcsPage ? deviceId : acId, code: code, value: value),
allAcsPage ? deviceId : acId);
if (response['success'] ?? false) {
deviceStatus.childLock = lockValue;
if (!response['success']) {
add(AcsInitial(allAcs: allAcsPage));
}
} catch (_) {}
emit(AcModifyingState(acStatusModel: deviceStatus));
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(AcsInitial(allAcs: allAcsPage));
}
});
}
void _increaseCoolTo(IncreaseCoolToTemp event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
double tempValue = event.value + 0.5;
int value = (tempValue * 10).toInt();
try {
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: allAcsPage ? event.deviceId : acId, code: 'temp_set', value: value),
allAcsPage ? event.deviceId : acId);
if (response['success'] ?? false) {
deviceStatus.tempSet = value;
}
} catch (_) {}
if (allAcsPage) {
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
bool _checkTemperatureValue(double value, Emitter<AcsState> emit) {
if (value >= 20 && value <= 30) {
return true;
} else {
emit(AcModifyingState(acStatusModel: deviceStatus));
emit(const AcsFailedState(errorMessage: 'The temperature must be between 20 and 30'));
emit(GetAllAcsStatusState(
allAcsStatues: deviceStatusList,
allAcs: devicesList,
allOn: allAcsOn,
allTempSame: allTempSame,
temp: globalTemp));
return false;
}
}
void _decreaseCoolTo(DecreaseCoolToTemp event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
double tempValue = event.value - 0.5;
int value = (tempValue * 10).toInt();
try {
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: allAcsPage ? event.deviceId : acId, code: 'temp_set', value: value),
allAcsPage ? event.deviceId : acId);
if (response['success'] ?? false) {
deviceStatus.tempSet = value;
}
} catch (_) {}
if (allAcsPage) {
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
} else {
emit(AcModifyingState(acStatusModel: deviceStatus));
}
}
void _changeAcMode(ChangeAcMode event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
final tempMode = tempModesMap[getNextItem(tempModesMap, event.tempModes)]!;
try {
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: allAcsPage ? event.deviceId : acId,
code: 'mode',
value: getACModeString(tempMode)),
allAcsPage ? event.deviceId : acId);
if (response['success'] ?? false) {
deviceStatus.modeString = getACModeString(tempMode);
deviceStatus.acMode = AcStatusModel.getACMode(getACModeString(tempMode));
}
} catch (_) {}
if (allAcsPage) {
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
} else {
emit(AcModifyingState(acStatusModel: deviceStatus));
}
}
void _changeFanSpeed(ChangeFanSpeed event, Emitter<AcsState> emit) async {
emit(AcChangeLoading(acStatusModel: deviceStatus));
final fanSpeed = event.fanSpeeds;
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: allAcsPage ? event.deviceId : acId,
code: 'level',
value: getNextFanSpeedKey(fanSpeed)),
allAcsPage ? event.deviceId : acId);
try {
if (response['success'] ?? false) {
deviceStatus.fanSpeedsString = getNextFanSpeedKey(fanSpeed);
deviceStatus.acFanSpeed = AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
}
} catch (_) {}
if (allAcsPage) {
await Future.delayed(const Duration(seconds: 1));
add(const AcsInitial(allAcs: true));
} else {
emit(AcModifyingState(acStatusModel: deviceStatus));
}
}
String getACModeString(TempModes value) {
if (value == TempModes.cold) {
return 'cold';
} else if (value == TempModes.hot) {
return 'hot';
} else if (value == TempModes.wind) {
return 'wind';
} else {
return 'cold';
}
_emitAcsStatus(Emitter<AcsState> emit) {
emit(GetAllAcsStatusState(
allAcsStatues: deviceStatusList,
allAcs: devicesList,
allOn: allAcsOn,
allTempSame: allTempSame,
temp: globalTemp));
}
}

View File

@ -13,10 +13,11 @@ class AcsLoading extends AcsEvent {}
class AcSwitch extends AcsEvent {
final bool acSwitch;
final String deviceId;
const AcSwitch({required this.acSwitch, this.deviceId = ''});
final String productId;
const AcSwitch({required this.acSwitch, this.deviceId = '', this.productId = ''});
@override
List<Object> get props => [acSwitch, deviceId];
List<Object> get props => [acSwitch, deviceId, productId];
}
class AcsInitial extends AcsEvent {
@ -31,7 +32,8 @@ class ACsChangeStatus extends AcsEvent {}
class IncreaseCoolToTemp extends AcsEvent {
final double value;
final String deviceId;
const IncreaseCoolToTemp({required this.value, this.deviceId = ''});
final String productId;
const IncreaseCoolToTemp({required this.value, this.deviceId = '', this.productId = ''});
@override
List<Object> get props => [value, deviceId];
@ -40,7 +42,9 @@ class IncreaseCoolToTemp extends AcsEvent {
class DecreaseCoolToTemp extends AcsEvent {
final double value;
final String deviceId;
const DecreaseCoolToTemp({required this.value, this.deviceId = ''});
final String productId;
const DecreaseCoolToTemp({required this.value, this.deviceId = '', this.productId = ''});
@override
List<Object> get props => [value, deviceId];
@ -49,19 +53,22 @@ class DecreaseCoolToTemp extends AcsEvent {
class ChangeAcMode extends AcsEvent {
final TempModes tempModes;
final String deviceId;
const ChangeAcMode({required this.tempModes, this.deviceId = ''});
final String productId;
const ChangeAcMode({required this.tempModes, this.deviceId = '', this.productId = ''});
@override
List<Object> get props => [tempModes, deviceId];
List<Object> get props => [tempModes, deviceId, productId];
}
class ChangeFanSpeed extends AcsEvent {
final FanSpeeds fanSpeeds;
final String deviceId;
const ChangeFanSpeed({required this.fanSpeeds, this.deviceId = ''});
final String productId;
const ChangeFanSpeed({required this.fanSpeeds, this.deviceId = '', this.productId = ''});
@override
List<Object> get props => [fanSpeeds, deviceId];
List<Object> get props => [fanSpeeds, deviceId, productId];
}
class ChangeLock extends AcsEvent {

View File

@ -56,10 +56,10 @@ class GetAllAcsStatusState extends AcsState {
}
class AcsFailedState extends AcsState {
final String error;
final String errorMessage;
const AcsFailedState({required this.error});
const AcsFailedState({required this.errorMessage});
@override
List<Object> get props => [error];
List<Object> get props => [errorMessage];
}

View File

@ -95,6 +95,22 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter<ThreeGangState> emit) async {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
if (threeGangGroup) {
bool allSwitchesValue = true;
groupThreeGangList.forEach((element) {
if (element.deviceId == event.deviceId) {
element.firstSwitch = !event.value;
}
if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) {
allSwitchesValue = false;
}
});
emit(UpdateGroupState(threeGangList: groupThreeGangList, allSwitches: allSwitchesValue));
} else {
deviceStatus.firstSwitch = !event.value;
emit(UpdateState(threeGangModel: deviceStatus));
}
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangGroup ? event.deviceId : threeGangId,
@ -102,15 +118,11 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
value: !event.value),
threeGangGroup ? event.deviceId : threeGangId);
if (response['success'] ?? false) {
deviceStatus.firstSwitch = !event.value;
if (!response['success']) {
add(InitialEvent(groupScreen: threeGangGroup));
}
} catch (_) {}
if (threeGangGroup) {
await Future.delayed(const Duration(seconds: 1));
add(const InitialEvent(groupScreen: true));
} else {
emit(UpdateState(threeGangModel: deviceStatus));
} catch (_) {
add(InitialEvent(groupScreen: threeGangGroup));
}
}
@ -118,6 +130,22 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
ChangeSecondSwitchStatusEvent event, Emitter<ThreeGangState> emit) async {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
if (threeGangGroup) {
bool allSwitchesValue = true;
groupThreeGangList.forEach((element) {
if (element.deviceId == event.deviceId) {
element.secondSwitch = !event.value;
}
if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) {
allSwitchesValue = false;
}
});
emit(UpdateGroupState(threeGangList: groupThreeGangList, allSwitches: allSwitchesValue));
} else {
deviceStatus.secondSwitch = !event.value;
emit(UpdateState(threeGangModel: deviceStatus));
}
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangGroup ? event.deviceId : threeGangId,
@ -125,21 +153,33 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
value: !event.value),
threeGangGroup ? event.deviceId : threeGangId);
if (response['success'] ?? false) {
deviceStatus.secondSwitch = !event.value;
if (!response['success']) {
add(InitialEvent(groupScreen: threeGangGroup));
}
} catch (_) {}
if (threeGangGroup) {
await Future.delayed(const Duration(seconds: 1));
add(const InitialEvent(groupScreen: true));
} else {
emit(UpdateState(threeGangModel: deviceStatus));
} catch (_) {
add(InitialEvent(groupScreen: threeGangGroup));
}
}
void _changeThirdSwitch(ChangeThirdSwitchStatusEvent event, Emitter<ThreeGangState> emit) async {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
if (threeGangGroup) {
bool allSwitchesValue = true;
groupThreeGangList.forEach((element) {
if (element.deviceId == event.deviceId) {
element.thirdSwitch = !event.value;
}
if (!element.firstSwitch || !element.secondSwitch || !element.thirdSwitch) {
allSwitchesValue = false;
}
});
emit(UpdateGroupState(threeGangList: groupThreeGangList, allSwitches: allSwitchesValue));
} else {
deviceStatus.thirdSwitch = !event.value;
emit(UpdateState(threeGangModel: deviceStatus));
}
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangGroup ? event.deviceId : threeGangId,
@ -147,15 +187,11 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
value: !event.value),
threeGangGroup ? event.deviceId : threeGangId);
if (response['success'] ?? false) {
deviceStatus.thirdSwitch = !event.value;
if (!response['success']) {
add(InitialEvent(groupScreen: threeGangGroup));
}
} catch (_) {}
if (threeGangGroup) {
await Future.delayed(const Duration(seconds: 1));
add(const InitialEvent(groupScreen: true));
} else {
emit(UpdateState(threeGangModel: deviceStatus));
} catch (_) {
add(InitialEvent(groupScreen: threeGangGroup));
}
}
@ -163,52 +199,82 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
final response = await Future.wait([
DevicesAPI.controlDevice(
DeviceControlModel(deviceId: threeGangId, code: 'switch_1', value: false), threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(deviceId: threeGangId, code: 'switch_2', value: false), threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(deviceId: threeGangId, code: 'switch_3', value: false), threeGangId),
]);
if (response.every((element) => element['success'] ?? false)) {
deviceStatus.firstSwitch = false;
deviceStatus.secondSwitch = false;
deviceStatus.thirdSwitch = false;
}
} catch (_) {}
emit(UpdateState(threeGangModel: deviceStatus));
final response = await Future.wait([
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangId, code: 'switch_1', value: deviceStatus.firstSwitch),
threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangId, code: 'switch_2', value: deviceStatus.secondSwitch),
threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangId, code: 'switch_3', value: deviceStatus.thirdSwitch),
threeGangId),
]);
if (response.every((element) => !element['success'])) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: false));
}
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: false));
}
}
void _allOn(AllOnEvent event, Emitter<ThreeGangState> emit) async {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
final response = await Future.wait([
DevicesAPI.controlDevice(
DeviceControlModel(deviceId: threeGangId, code: 'switch_1', value: true), threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(deviceId: threeGangId, code: 'switch_2', value: true), threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(deviceId: threeGangId, code: 'switch_3', value: true), threeGangId),
]);
if (response.every((element) => element['success'] ?? false)) {
deviceStatus.firstSwitch = true;
deviceStatus.secondSwitch = true;
deviceStatus.thirdSwitch = true;
}
} catch (_) {}
emit(UpdateState(threeGangModel: deviceStatus));
final response = await Future.wait([
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangId, code: 'switch_1', value: deviceStatus.firstSwitch),
threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangId, code: 'switch_2', value: deviceStatus.secondSwitch),
threeGangId),
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: threeGangId, code: 'switch_3', value: deviceStatus.thirdSwitch),
threeGangId),
]);
if (response.every((element) => !element['success'])) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: false));
}
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: false));
}
}
void _groupAllOn(GroupAllOnEvent event, Emitter<ThreeGangState> emit) async {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
for (int i = 0; i < groupThreeGangList.length; i++) {
await Future.wait([
groupThreeGangList[i].firstSwitch = true;
groupThreeGangList[i].secondSwitch = true;
groupThreeGangList[i].thirdSwitch = true;
}
emit(UpdateGroupState(threeGangList: groupThreeGangList, allSwitches: true));
for (int i = 0; i < groupThreeGangList.length; i++) {
final response = await Future.wait([
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: groupThreeGangList[i].deviceId, code: 'switch_1', value: true),
@ -222,18 +288,31 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
deviceId: groupThreeGangList[i].deviceId, code: 'switch_3', value: true),
groupThreeGangList[i].deviceId),
]);
}
} catch (_) {}
await Future.delayed(const Duration(seconds: 1));
if (response.every((element) => !element['success'])) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: true));
break;
}
}
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: true));
}
}
void _groupAllOff(GroupAllOffEvent event, Emitter<ThreeGangState> emit) async {
emit(LoadingNewSate(threeGangModel: deviceStatus));
try {
for (int i = 0; i < groupThreeGangList.length; i++) {
await Future.wait([
groupThreeGangList[i].firstSwitch = false;
groupThreeGangList[i].secondSwitch = false;
groupThreeGangList[i].thirdSwitch = false;
}
emit(UpdateGroupState(threeGangList: groupThreeGangList, allSwitches: false));
for (int i = 0; i < groupThreeGangList.length; i++) {
final response = await Future.wait([
DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: groupThreeGangList[i].deviceId, code: 'switch_1', value: false),
@ -247,10 +326,17 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
deviceId: groupThreeGangList[i].deviceId, code: 'switch_3', value: false),
groupThreeGangList[i].deviceId),
]);
}
} catch (_) {}
await Future.delayed(const Duration(seconds: 1));
if (response.every((element) => !element['success'])) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: true));
break;
}
}
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(const InitialEvent(groupScreen: true));
}
}
void _changeSliding(ChangeSlidingSegment event, Emitter<ThreeGangState> emit) async {

View File

@ -2,6 +2,7 @@ import 'package:syncrow_app/features/devices/model/status_model.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class AcStatusModel {
String uuid;
bool acSwitch;
String modeString;
int tempSet;
@ -12,7 +13,8 @@ class AcStatusModel {
late FanSpeeds acFanSpeed;
AcStatusModel(
{required this.acSwitch,
{required this.uuid,
required this.acSwitch,
required this.modeString,
required this.tempSet,
required this.currentTemp,
@ -22,7 +24,7 @@ class AcStatusModel {
acFanSpeed = getFanSpeed(fanSpeedsString);
}
factory AcStatusModel.fromJson(List<StatusModel> jsonList) {
factory AcStatusModel.fromJson(String id, List<StatusModel> jsonList) {
late bool _acSwitch;
late String _mode;
late int _tempSet;
@ -45,6 +47,7 @@ class AcStatusModel {
}
}
return AcStatusModel(
uuid: id,
acSwitch: _acSwitch,
modeString: _mode,
tempSet: _tempSet,

View File

@ -17,12 +17,13 @@ class DeviceModel {
String? timeZone;
int? updateTime;
String? uuid;
String? productUuid;
DeviceType? productType;
bool isSelected = false;
late List<FunctionModel> functions;
DeviceModel(
{this.activeTime,
// this.id,
this.productUuid,
this.localKey,
this.model,
this.name,
@ -74,13 +75,12 @@ class DeviceModel {
productType: type,
type: json['productType'],
status: [],
);
productUuid: json['productUuid']);
}
Map<String, dynamic> toJson() {
return {
'activeTime': activeTime,
// 'id': id,
'localKey': localKey,
'model': model,
'name': name,

View File

@ -1,9 +1,9 @@
class GroupThreeGangModel {
final String deviceId;
final String deviceName;
final bool firstSwitch;
final bool secondSwitch;
final bool thirdSwitch;
bool firstSwitch;
bool secondSwitch;
bool thirdSwitch;
GroupThreeGangModel({
required this.deviceId,

View File

@ -11,6 +11,7 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface_temp_
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class AcInterface extends StatelessWidget {
const AcInterface({super.key, required this.ac});
@ -22,15 +23,12 @@ class AcInterface extends StatelessWidget {
return BlocConsumer<ACsBloc, AcsState>(
listener: (context, state) {
if (state is AcsFailedState) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(state.error),
),
);
CustomSnackBar.displaySnackBar(state.errorMessage);
}
},
builder: (context, state) {
AcStatusModel statusModel = AcStatusModel(
uuid: ac.uuid ?? '',
acSwitch: true,
modeString: 'hot',
tempSet: 300,

View File

@ -9,14 +9,12 @@ import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
class ACModeControlUnit extends StatelessWidget {
const ACModeControlUnit({
super.key,
required this.acStatus,
required this.deviceId,
});
const ACModeControlUnit(
{super.key, required this.acStatus, required this.deviceId, this.productId = ''});
final AcStatusModel acStatus;
final String deviceId;
final String? productId;
@override
Widget build(BuildContext context) {
@ -28,8 +26,10 @@ class ACModeControlUnit extends StatelessWidget {
child: GestureDetector(
onTap: () {
if (state is! AcChangeLoading && state is! AcsLoadingState) {
BlocProvider.of<ACsBloc>(context)
.add(ChangeFanSpeed(fanSpeeds: acStatus.acFanSpeed, deviceId: deviceId));
BlocProvider.of<ACsBloc>(context).add(ChangeFanSpeed(
fanSpeeds: acStatus.acFanSpeed,
deviceId: deviceId,
productId: productId ?? ''));
}
// else if (state is AcModifyingState) {
// BlocProvider.of<ACsBloc>(context)
@ -54,8 +54,10 @@ class ACModeControlUnit extends StatelessWidget {
// .add(ChangeAcMode(tempModes: state.acStatusModel.acMode));
// }
if (state is! AcChangeLoading && state is! AcsLoadingState) {
BlocProvider.of<ACsBloc>(context)
.add(ChangeAcMode(tempModes: acStatus.acMode, deviceId: deviceId));
BlocProvider.of<ACsBloc>(context).add(ChangeAcMode(
tempModes: acStatus.acMode,
deviceId: deviceId,
productId: productId ?? ''));
}
},
child: DefaultContainer(

View File

@ -35,10 +35,10 @@ class ACTempWidget extends StatelessWidget {
child: InkWell(
onTap: () {
double tempC = temp / 10;
if (tempC > 20) {
BlocProvider.of<ACsBloc>(context)
.add(DecreaseCoolToTemp(value: tempC, deviceId: deviceModel.uuid ?? ''));
}
BlocProvider.of<ACsBloc>(context).add(DecreaseCoolToTemp(
value: tempC,
deviceId: deviceModel.uuid ?? '',
productId: deviceModel.productUuid ?? ''));
},
child: SvgPicture.asset(
Assets.assetsIconsMinus,
@ -57,10 +57,10 @@ class ACTempWidget extends StatelessWidget {
child: InkWell(
onTap: () {
double tempC = temp / 10;
if (tempC < 30) {
BlocProvider.of<ACsBloc>(context)
.add(IncreaseCoolToTemp(value: tempC, deviceId: deviceModel.uuid ?? ''));
}
BlocProvider.of<ACsBloc>(context).add(IncreaseCoolToTemp(
value: tempC,
deviceId: deviceModel.uuid ?? '',
productId: deviceModel.productUuid ?? ''));
},
child: SvgPicture.asset(
Assets.assetsIconsPlus,

View File

@ -9,9 +9,9 @@ import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_un
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_temp_widget.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/universal_ac_temp.dart';
import 'package:syncrow_app/features/devices/view/widgets/universal_switch.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
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/utils/helpers/snack_bar.dart';
class ACsList extends StatelessWidget {
const ACsList({
@ -20,7 +20,12 @@ class ACsList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<ACsBloc, AcsState>(
return BlocConsumer<ACsBloc, AcsState>(
listener: (context, state) {
if (state is AcsFailedState) {
CustomSnackBar.displaySnackBar(state.errorMessage);
}
},
builder: (context, state) {
List<AcStatusModel> devicesStatuesList = [];
List<DeviceModel> devicesList = [];
@ -35,12 +40,14 @@ class ACsList extends StatelessWidget {
temperature = state.temp;
}
return SingleChildScrollView(
child: state is AcChangeLoading || state is AcsLoadingState
? const Center(
child:
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
)
: Column(
// state is AcChangeLoading || state is AcsLoadingState
// ? const Center(
// child:
// DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
// )
// :
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// universal AC controller
@ -83,7 +90,8 @@ class ACsList extends StatelessWidget {
action: () {
BlocProvider.of<ACsBloc>(context).add(AcSwitch(
acSwitch: devicesStatuesList[index].acSwitch,
deviceId: devicesList[index].uuid ?? ''));
deviceId: devicesList[index].uuid ?? '',
productId: devicesList[index].productUuid ?? ''));
},
),
const SizedBox(height: 10),
@ -95,6 +103,7 @@ class ACsList extends StatelessWidget {
ACModeControlUnit(
acStatus: devicesStatuesList[index],
deviceId: devicesList[index].uuid ?? '',
productId: devicesList[index].productUuid ?? '',
),
const SizedBox(height: 10),
],

View File

@ -29,9 +29,7 @@ class UniversalACTemp extends StatelessWidget {
child: InkWell(
onTap: () {
double temperature = temp / 10;
if (temperature < 30) {
BlocProvider.of<ACsBloc>(context).add(DecreaseAllTemp(value: temperature));
}
},
child: SvgPicture.asset(
Assets.assetsIconsMinus,
@ -50,9 +48,7 @@ class UniversalACTemp extends StatelessWidget {
child: InkWell(
onTap: () {
double temperature = temp / 10;
if (temperature > 20) {
BlocProvider.of<ACsBloc>(context).add(IncreaseAllTemp(value: temperature));
}
},
child: SvgPicture.asset(
Assets.assetsIconsPlus,

View File

@ -4,7 +4,6 @@ import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_blo
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_event.dart';
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_state.dart';
import 'package:syncrow_app/features/devices/model/group_three_gang_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
@ -18,11 +17,7 @@ class ThreeGangList extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<ThreeGangBloc, ThreeGangState>(
builder: (context, state) {
return state is LoadingNewSate
? const Center(
child: DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
)
: SingleChildScrollView(
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@ -53,8 +48,7 @@ class ThreeGangList extends StatelessWidget {
DevicesDefaultSwitch(
switchValue: threeGangList[index].firstSwitch,
action: () {
BlocProvider.of<ThreeGangBloc>(context).add(
ChangeFirstSwitchStatusEvent(
BlocProvider.of<ThreeGangBloc>(context).add(ChangeFirstSwitchStatusEvent(
value: threeGangList[index].firstSwitch,
deviceId: threeGangList[index].deviceId));
},
@ -65,8 +59,7 @@ class ThreeGangList extends StatelessWidget {
DevicesDefaultSwitch(
switchValue: threeGangList[index].secondSwitch,
action: () {
BlocProvider.of<ThreeGangBloc>(context).add(
ChangeSecondSwitchStatusEvent(
BlocProvider.of<ThreeGangBloc>(context).add(ChangeSecondSwitchStatusEvent(
value: threeGangList[index].secondSwitch,
deviceId: threeGangList[index].deviceId));
},
@ -77,8 +70,7 @@ class ThreeGangList extends StatelessWidget {
DevicesDefaultSwitch(
switchValue: threeGangList[index].thirdSwitch,
action: () {
BlocProvider.of<ThreeGangBloc>(context).add(
ChangeThirdSwitchStatusEvent(
BlocProvider.of<ThreeGangBloc>(context).add(ChangeThirdSwitchStatusEvent(
value: threeGangList[index].thirdSwitch,
deviceId: threeGangList[index].deviceId));
},

View File

@ -6,6 +6,7 @@ import 'package:syncrow_app/features/menu/view/widgets/menu_list.dart';
import 'package:syncrow_app/features/menu/view/widgets/profile/profile_tab.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
@ -33,6 +34,11 @@ class MenuView extends StatelessWidget {
const SizedBox(
height: 15,
),
const BodyMedium(
text: String.fromEnvironment('FLAVOR', defaultValue: 'production')),
const SizedBox(
height: 15,
),
InkWell(
onTap: () {
AuthCubit.get(context).logout();

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:syncrow_app/firebase_options.dart';
import 'package:syncrow_app/services/locator.dart';
import 'package:syncrow_app/utils/bloc_observer.dart';
@ -15,9 +16,8 @@ void main() {
//to catch all the errors in the app and send them to firebase
runZonedGuarded(() async {
//to load the environment variables
// const environment =
// String.fromEnvironment('FLAVOR', defaultValue: 'production');
// await dotenv.load(fileName: '.env.$environment');
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production');
await dotenv.load(fileName: '.env.$environment');
// //this is to make the app work with the self-signed certificate
// HttpOverrides.global = MyHttpOverrides();

View File

@ -1,165 +1,163 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
abstract class ApiEndpoints {
static const String baseUrl = 'https://syncrow-dev.azurewebsites.net';
// static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost
static String baseUrl = dotenv.env['BASE_URL'] ?? '';
////////////////////////////////////// Authentication ///////////////////////////////
static const String signUp = '$baseUrl/authentication/user/signup';
static const String login = '$baseUrl/authentication/user/login';
static const String deleteUser = '$baseUrl/authentication/user/delete/{id}';
static const String sendOtp = '$baseUrl/authentication/user/send-otp';
static const String verifyOtp = '$baseUrl/authentication/user/verify-otp';
static const String forgetPassword = '$baseUrl/authentication/user/forget-password';
static const String signUp = '/authentication/user/signup';
static const String login = '/authentication/user/login';
static const String deleteUser = '/authentication/user/delete/{id}';
static const String sendOtp = '/authentication/user/send-otp';
static const String verifyOtp = '/authentication/user/verify-otp';
static const String forgetPassword = '/authentication/user/forget-password';
////////////////////////////////////// Spaces ///////////////////////////////////////
///Community Module
//POST
static const String addCommunity = '$baseUrl/community';
static const String addCommunityToUser = '$baseUrl/community/user';
static const String addCommunity = '/community';
static const String addCommunityToUser = '/community/user';
//GET
static const String communityByUuid = '$baseUrl/community/{communityUuid}';
static const String communityChild = '$baseUrl/community/child/{communityUuid}';
static const String communityUser = '$baseUrl/community/user/{userUuid}';
static const String communityByUuid = '/community/{communityUuid}';
static const String communityChild = '/community/child/{communityUuid}';
static const String communityUser = '/community/user/{userUuid}';
//PUT
static const String renameCommunity = '$baseUrl/community/rename/{communityUuid}';
static const String renameCommunity = '/community/rename/{communityUuid}';
///Building Module
//POST
static const String addBuilding = '$baseUrl/building';
static const String addBuildingToUser = '$baseUrl/building/user';
static const String addBuilding = '/building';
static const String addBuildingToUser = '/building/user';
//GET
static const String buildingByUuid = '$baseUrl/building/{buildingUuid}';
static const String buildingChild = '$baseUrl/building/child/{buildingUuid}';
static const String buildingParent = '$baseUrl/building/parent/{buildingUuid}';
static const String buildingUser = '$baseUrl/building/user/{userUuid}';
static const String buildingByUuid = '/building/{buildingUuid}';
static const String buildingChild = '/building/child/{buildingUuid}';
static const String buildingParent = '/building/parent/{buildingUuid}';
static const String buildingUser = '/building/user/{userUuid}';
//PUT
static const String renameBuilding = '$baseUrl/building/rename/{buildingUuid}';
static const String renameBuilding = '/building/rename/{buildingUuid}';
///Floor Module
//POST
static const String addFloor = '$baseUrl/floor';
static const String addFloorToUser = '$baseUrl/floor/user';
static const String addFloor = '/floor';
static const String addFloorToUser = '/floor/user';
//GET
static const String floorByUuid = '$baseUrl/floor/{floorUuid}';
static const String floorChild = '$baseUrl/floor/child/{floorUuid}';
static const String floorParent = '$baseUrl/floor/parent/{floorUuid}';
static const String floorUser = '$baseUrl/floor/user/{userUuid}';
static const String floorByUuid = '/floor/{floorUuid}';
static const String floorChild = '/floor/child/{floorUuid}';
static const String floorParent = '/floor/parent/{floorUuid}';
static const String floorUser = '/floor/user/{userUuid}';
//PUT
static const String renameFloor = '$baseUrl/floor/rename/{floorUuid}';
static const String renameFloor = '/floor/rename/{floorUuid}';
///Unit Module
//POST
static const String addUnit = '$baseUrl/unit';
static const String addUnitToUser = '$baseUrl/unit/user';
static const String addUnit = '/unit';
static const String addUnitToUser = '/unit/user';
//GET
static const String unitByUuid = '$baseUrl/unit/';
static const String unitChild = '$baseUrl/unit/child/';
static const String unitParent = '$baseUrl/unit/parent/{unitUuid}';
static const String unitUser = '$baseUrl/unit/user/';
static const String invitationCode = '$baseUrl/unit/{unitUuid}/invitation-code';
static const String verifyInvitationCode = '$baseUrl/unit/user/verify-code';
static const String unitByUuid = '/unit/';
static const String unitChild = '/unit/child/';
static const String unitParent = '/unit/parent/{unitUuid}';
static const String unitUser = '/unit/user/';
static const String invitationCode = '/unit/{unitUuid}/invitation-code';
static const String verifyInvitationCode = '/unit/user/verify-code';
//PUT
static const String renameUnit = '$baseUrl/unit/rename/{unitUuid}';
static const String renameUnit = '/unit/rename/{unitUuid}';
///Room Module
//POST
static const String addRoom = '$baseUrl/room';
static const String addRoomToUser = '$baseUrl/room/user';
static const String addRoom = '/room';
static const String addRoomToUser = '/room/user';
//GET
static const String roomByUuid = '$baseUrl/room/{roomUuid}';
static const String roomParent = '$baseUrl/room/parent/{roomUuid}';
static const String roomUser = '$baseUrl/room/user/{userUuid}';
static const String roomByUuid = '/room/{roomUuid}';
static const String roomParent = '/room/parent/{roomUuid}';
static const String roomUser = '/room/user/{userUuid}';
//PUT
static const String renameRoom = '$baseUrl/room/rename/{roomUuid}';
static const String renameRoom = '/room/rename/{roomUuid}';
///Group Module
//POST
static const String addGroup = '$baseUrl/group';
static const String controlGroup = '$baseUrl/group/control';
static const String addGroup = '/group';
static const String controlGroup = '/group/control';
//GET
static const String groupBySpace = '$baseUrl/group/{unitUuid}';
static const String devicesByGroupName = '$baseUrl/group/{unitUuid}/devices/{groupName}';
static const String groupBySpace = '/group/{unitUuid}';
static const String devicesByGroupName = '/group/{unitUuid}/devices/{groupName}';
static const String groupByUuid = '$baseUrl/group/{groupUuid}';
static const String groupByUuid = '/group/{groupUuid}';
//DELETE
static const String deleteGroup = '$baseUrl/group/{groupUuid}';
static const String deleteGroup = '/group/{groupUuid}';
////////////////////////////////////// Devices ///////////////////////////////////////
///Device Module
//POST
static const String addDeviceToRoom = '$baseUrl/device/room';
static const String addDeviceToGroup = '$baseUrl/device/group';
static const String controlDevice = '$baseUrl/device/{deviceUuid}/control';
static const String firmwareDevice = '$baseUrl/device/{deviceUuid}/firmware/{firmwareVersion}';
static const String getDevicesByUserId = '$baseUrl/device/user/{userId}';
static const String getDevicesByUnitId = '$baseUrl/device/unit/{unitUuid}';
static const String addDeviceToRoom = '/device/room';
static const String addDeviceToGroup = '/device/group';
static const String controlDevice = '/device/{deviceUuid}/control';
static const String firmwareDevice = '/device/{deviceUuid}/firmware/{firmwareVersion}';
static const String getDevicesByUserId = '/device/user/{userId}';
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
//GET
static const String deviceByRoom = '$baseUrl/device/room';
static const String deviceByUuid = '$baseUrl/device/{deviceUuid}';
static const String deviceFunctions = '$baseUrl/device/{deviceUuid}/functions';
static const String gatewayApi = '$baseUrl/device/gateway/{gatewayUuid}/devices';
static const String deviceFunctionsStatus = '$baseUrl/device/{deviceUuid}/functions/status';
static const String deviceByRoom = '/device/room';
static const String deviceByUuid = '/device/{deviceUuid}';
static const String deviceFunctions = '/device/{deviceUuid}/functions';
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
static const String deviceFunctionsStatus = '/device/{deviceUuid}/functions/status';
///Device Permission Module
//POST
static const String addDevicePermission = '$baseUrl/device-permission/add';
static const String addDevicePermission = '/device-permission/add';
//GET
static const String devicePermissionList = '$baseUrl/device-permission/list';
static const String devicePermissionList = '/device-permission/list';
//PUT
static const String editDevicePermission = '$baseUrl/device-permission/edit/{userId}';
static const String editDevicePermission = '/device-permission/edit/{userId}';
static const String assignDeviceToRoom = '$baseUrl/device/room';
static const String assignDeviceToRoom = '/device/room';
/// Scene API ////////////////////
/// POST
static const String createScene = '$baseUrl/scene/tap-to-run';
static const String triggerScene = '$baseUrl/scene/tap-to-run/trigger/{sceneId}';
static const String createScene = '/scene/tap-to-run';
static const String triggerScene = '/scene/tap-to-run/trigger/{sceneId}';
/// GET
static const String getUnitScenes = '$baseUrl/scene/tap-to-run/{unitUuid}';
static const String getUnitScenes = '/scene/tap-to-run/{unitUuid}';
static const String getScene = '$baseUrl/scene/tap-to-run/details/{sceneId}';
static const String getScene = '/scene/tap-to-run/details/{sceneId}';
/// PUT
static const String updateScene = '$baseUrl/scene/tap-to-run/{sceneId}';
static const String updateScene = '/scene/tap-to-run/{sceneId}';
/// DELETE
static const String deleteScene = '$baseUrl/scene/tap-to-run/{unitUuid}/{sceneId}';
static const String deleteScene = '/scene/tap-to-run/{unitUuid}/{sceneId}';
//////////////////////Door Lock //////////////////////
//online
static const String addTemporaryPassword =
'$baseUrl/door-lock/temporary-password/online/{doorLockUuid}';
static const String getTemporaryPassword =
'$baseUrl/door-lock/temporary-password/online/{doorLockUuid}';
static const String addTemporaryPassword = '/door-lock/temporary-password/online/{doorLockUuid}';
static const String getTemporaryPassword = '/door-lock/temporary-password/online/{doorLockUuid}';
//one-time offline
static const String addOneTimeTemporaryPassword =
'$baseUrl/door-lock/temporary-password/offline/one-time/{doorLockUuid}';
'/door-lock/temporary-password/offline/one-time/{doorLockUuid}';
static const String getOneTimeTemporaryPassword =
'$baseUrl/door-lock/temporary-password/offline/one-time/{doorLockUuid}';
'/door-lock/temporary-password/offline/one-time/{doorLockUuid}';
//multiple-time offline
static const String addMultipleTimeTemporaryPassword =
'$baseUrl/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
'/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
static const String getMultipleTimeTemporaryPassword =
'$baseUrl/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
'/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
//multiple-time offline
static const String deleteTemporaryPassword =
'$baseUrl/door-lock/temporary-password/{doorLockUuid}/{passwordId}';
'/door-lock/temporary-password/{doorLockUuid}/{passwordId}';
//user
static const String getUser = '$baseUrl/user/{userUuid}';
static const String saveRegion = '$baseUrl/user/region/{userUuid}';
static const String saveTimeZone = '$baseUrl/user/timezone/{userUuid}';
static const String saveName = '$baseUrl/user/name/{userUuid}';
static const String sendPicture = '$baseUrl/user/profile-picture/{userUuid}';
static const String getRegion = '$baseUrl/region';
static const String getTimezone = '$baseUrl/timezone';
static const String getUser = '/user/{userUuid}';
static const String saveRegion = '/user/region/{userUuid}';
static const String saveTimeZone = '/user/timezone/{userUuid}';
static const String saveName = '/user/name/{userUuid}';
static const String sendPicture = '/user/profile-picture/{userUuid}';
static const String getRegion = '/region';
static const String getTimezone = '/timezone';
}

View File

@ -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.1+11
version: 1.0.1+12
environment:
sdk: ">=3.0.6 <4.0.0"
@ -76,6 +76,11 @@ flutter:
- assets/icons/MenuIcons/SecurityAndPrivacyIcons/
- assets/icons/curtainsIcon/
- assets/icons/functions_icons/
- .env.development
- .env.staging
- .env.production
fonts:
- family: Aftika
fonts: