mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
Implement Two-Gang & One-Gang
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#E9E9E9"/>
|
||||||
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#D1D1D1"/>
|
||||||
<path opacity="0.6" d="M20.875 19.2411V20.7304C20.875 20.9746 20.7996 21.1767 20.7014 21.3067C20.6035 21.4364 20.5053 21.4715 20.4375 21.4715H16.3125C16.2447 21.4715 16.1465 21.4364 16.0486 21.3067C15.9504 21.1767 15.875 20.9746 15.875 20.7304V19.2411C15.875 18.9969 15.9504 18.7949 16.0486 18.6649C16.1465 18.5352 16.2447 18.5 16.3125 18.5H20.4375C20.5053 18.5 20.6035 18.5352 20.7014 18.6649C20.7996 18.7949 20.875 18.9969 20.875 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
<path opacity="0.6" d="M21.375 31.8319V33.3213C21.375 34.0067 20.9553 34.5624 20.4375 34.5624H16.3125C15.7947 34.5624 15.375 34.0067 15.375 33.3213V31.8319C15.375 31.1465 15.7947 30.5908 16.3125 30.5908H20.4375C20.9553 30.5908 21.375 31.1465 21.375 31.8319Z" fill="#023DFE" fill-opacity="0.5"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 933 B |
7
assets/icons/2gang.svg
Normal file
7
assets/icons/2gang.svg
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#E9E9E9"/>
|
||||||
|
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#D1D1D1"/>
|
||||||
|
<path opacity="0.6" d="M12.0284 31.8319V33.3213C12.0284 34.0067 11.6087 34.5624 11.0909 34.5624H6.96594C6.44816 34.5624 6.02844 34.0067 6.02844 33.3213V31.8319C6.02844 31.1465 6.44816 30.5908 6.96594 30.5908H11.0909C11.6087 30.5908 12.0284 31.1465 12.0284 31.8319Z" fill="#023DFE" fill-opacity="0.5"/>
|
||||||
|
<path opacity="0.6" d="M26.0285 31.8319V33.3213C26.0285 34.0067 26.4482 34.5624 26.966 34.5624H31.091C31.6088 34.5624 32.0285 34.0067 32.0285 33.3213V31.8319C32.0285 31.1465 31.6088 30.5908 31.091 30.5908H26.966C26.4482 30.5908 26.0285 31.1465 26.0285 31.8319Z" fill="#023DFE" fill-opacity="0.5"/>
|
||||||
|
<path d="M19.0691 0H20.9308V40H19.0691V0Z" fill="#D1D1D1"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
@ -69,7 +69,8 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
deviceName: devicesList[i].name ?? '',
|
deviceName: devicesList[i].name ?? '',
|
||||||
firstSwitch: deviceStatus.firstSwitch,
|
firstSwitch: deviceStatus.firstSwitch,
|
||||||
secondSwitch: deviceStatus.secondSwitch,
|
secondSwitch: deviceStatus.secondSwitch,
|
||||||
));
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupTwoGangList.isNotEmpty) {
|
if (groupTwoGangList.isNotEmpty) {
|
||||||
@ -128,22 +129,8 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter<TwoGangState> emit) async {
|
void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter<TwoGangState> emit) async {
|
||||||
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
if (twoGangGroup) {
|
deviceStatus.firstSwitch = !event.value;
|
||||||
bool allSwitchesValue = true;
|
emit(UpdateState(twoGangModel: deviceStatus));
|
||||||
groupTwoGangList.forEach((element) {
|
|
||||||
if (element.deviceId == event.deviceId) {
|
|
||||||
element.firstSwitch = !event.value;
|
|
||||||
}
|
|
||||||
if (!element.firstSwitch || !element.secondSwitch ) {
|
|
||||||
allSwitchesValue = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: allSwitchesValue));
|
|
||||||
} else {
|
|
||||||
deviceStatus.firstSwitch = !event.value;
|
|
||||||
emit(UpdateState(twoGangModel: deviceStatus));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_timer != null) {
|
if (_timer != null) {
|
||||||
_timer!.cancel();
|
_timer!.cancel();
|
||||||
}
|
}
|
||||||
@ -169,22 +156,8 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
ChangeSecondSwitchStatusEvent event, Emitter<TwoGangState> emit) async {
|
ChangeSecondSwitchStatusEvent event, Emitter<TwoGangState> emit) async {
|
||||||
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
if (twoGangGroup) {
|
deviceStatus.secondSwitch = !event.value;
|
||||||
bool allSwitchesValue = true;
|
emit(UpdateState(twoGangModel: deviceStatus));
|
||||||
groupTwoGangList.forEach((element) {
|
|
||||||
if (element.deviceId == event.deviceId) {
|
|
||||||
element.secondSwitch = !event.value;
|
|
||||||
}
|
|
||||||
if (!element.firstSwitch || !element.secondSwitch ) {
|
|
||||||
allSwitchesValue = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
emit(UpdateGroupState(twoGangList: groupTwoGangList, allSwitches: allSwitchesValue));
|
|
||||||
} else {
|
|
||||||
deviceStatus.secondSwitch = !event.value;
|
|
||||||
emit(UpdateState(twoGangModel: deviceStatus));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_timer != null) {
|
if (_timer != null) {
|
||||||
_timer!.cancel();
|
_timer!.cancel();
|
||||||
}
|
}
|
||||||
@ -238,24 +211,23 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
|
|
||||||
void _allOn(AllOnEvent event, Emitter<TwoGangState> emit) async {
|
void _allOn(AllOnEvent event, Emitter<TwoGangState> emit) async {
|
||||||
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
emit(LoadingNewSate(twoGangModel: deviceStatus));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deviceStatus.firstSwitch = true;
|
deviceStatus.firstSwitch = true;
|
||||||
deviceStatus.secondSwitch = true;
|
deviceStatus.secondSwitch = true;
|
||||||
emit(UpdateState(twoGangModel: deviceStatus));
|
emit(UpdateState(twoGangModel: deviceStatus));
|
||||||
|
|
||||||
final response = await Future.wait([
|
final response = await Future.wait([
|
||||||
DevicesAPI.controlDevice(
|
DevicesAPI.controlDevice(
|
||||||
DeviceControlModel(
|
DeviceControlModel(
|
||||||
deviceId: twoGangId, code: 'switch_1', value: deviceStatus.firstSwitch),
|
deviceId: twoGangId, code: 'switch_1',
|
||||||
|
value: deviceStatus.firstSwitch),
|
||||||
twoGangId),
|
twoGangId),
|
||||||
DevicesAPI.controlDevice(
|
DevicesAPI.controlDevice(
|
||||||
DeviceControlModel(
|
DeviceControlModel(
|
||||||
deviceId: twoGangId, code: 'switch_2', value: deviceStatus.secondSwitch),
|
deviceId: twoGangId,
|
||||||
twoGangId),
|
code: 'switch_2',
|
||||||
|
value: deviceStatus.secondSwitch),
|
||||||
|
twoGangId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (response.every((element) => !element['success'])) {
|
if (response.every((element) => !element['success'])) {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
add(const InitialEvent(groupScreen: false));
|
add(const InitialEvent(groupScreen: false));
|
||||||
|
@ -58,6 +58,10 @@ class DeviceModel {
|
|||||||
tempIcon = Assets.assetsIcons3GangSwitch;
|
tempIcon = Assets.assetsIcons3GangSwitch;
|
||||||
} else if (type == DeviceType.Gateway) {
|
} else if (type == DeviceType.Gateway) {
|
||||||
tempIcon = Assets.assetsIconsGateway;
|
tempIcon = Assets.assetsIconsGateway;
|
||||||
|
} else if (type == DeviceType.OneGang) {
|
||||||
|
tempIcon = Assets.oneGang;
|
||||||
|
} else if (type == DeviceType.TwoGang) {
|
||||||
|
tempIcon = Assets.twoGang;
|
||||||
} else {
|
} else {
|
||||||
tempIcon = Assets.assetsIconsLogo;
|
tempIcon = Assets.assetsIconsLogo;
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,7 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
if (HomeCubit.getInstance().selectedSpace != null)
|
if (HomeCubit.getInstance().selectedSpace != null)
|
||||||
if (HomeCubit.getInstance().selectedSpace!.rooms != null)
|
if (HomeCubit.getInstance().selectedSpace!.rooms != null)
|
||||||
...HomeCubit.getInstance().selectedSpace!.rooms!.map(
|
...HomeCubit.getInstance().selectedSpace!.rooms!.map((room) {
|
||||||
(room) {
|
|
||||||
return RoomPage(
|
return RoomPage(
|
||||||
room: room,
|
room: room,
|
||||||
);
|
);
|
||||||
|
@ -22,6 +22,7 @@ class RoomsSlider extends StatelessWidget {
|
|||||||
onPageChanged: (index) {
|
onPageChanged: (index) {
|
||||||
HomeCubit.getInstance().roomSliderPageChanged(index);
|
HomeCubit.getInstance().roomSliderPageChanged(index);
|
||||||
},
|
},
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
@ -1030,9 +1030,9 @@ class Assets {
|
|||||||
static const String assetsPresenceState =
|
static const String assetsPresenceState =
|
||||||
"assets/icons/functions_icons/automation_functions/presence_state.svg";
|
"assets/icons/functions_icons/automation_functions/presence_state.svg";
|
||||||
|
|
||||||
|
|
||||||
//assets/icons/functions_icons/automation_functions/presence_state.svg
|
//assets/icons/functions_icons/automation_functions/presence_state.svg
|
||||||
|
|
||||||
static const String oneGang =
|
static const String oneGang = "assets/icons/1gang.svg";
|
||||||
"assets/icons/1gang.svg";
|
|
||||||
|
static const String twoGang = "assets/icons/2gang.svg";
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ void main() {
|
|||||||
//to catch all the errors in the app and send them to firebase
|
//to catch all the errors in the app and send them to firebase
|
||||||
runZonedGuarded(() async {
|
runZonedGuarded(() async {
|
||||||
//to load the environment variables
|
//to load the environment variables
|
||||||
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production');
|
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
|
||||||
await dotenv.load(fileName: '.env.$environment');
|
await dotenv.load(fileName: '.env.$environment');
|
||||||
|
|
||||||
// //this is to make the app work with the self-signed certificate
|
// //this is to make the app work with the self-signed certificate
|
||||||
|
Reference in New Issue
Block a user