mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 04:21:44 +00:00
Compare commits
14 Commits
power_clam
...
password_c
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d32fc1213 | |||
| bfd9c557ce | |||
| ef232e9cd5 | |||
| a1b8c79ce4 | |||
| 70d8bae19d | |||
| 021f40b8b3 | |||
| 13f244ff19 | |||
| bcc31d53a1 | |||
| 3adb84125a | |||
| 3d56f33ec3 | |||
| 20fdfdde87 | |||
| 7fed2f17af | |||
| 769be41855 | |||
| d4d7ced585 |
23
assets/icons/automation_ic.svg
Normal file
23
assets/icons/automation_ic.svg
Normal file
@ -0,0 +1,23 @@
|
||||
<svg width="35" height="36" viewBox="0 0 35 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5.66933 30.6933C5.53419 30.6933 5.39898 30.6418 5.29581 30.5386C5.08955 30.3323 5.08955 29.9979 5.29581 29.7917L13.1989 21.8886C13.4052 21.6823 13.7396 21.6823 13.9459 21.8886C14.1521 22.0949 14.1521 22.4293 13.9459 22.6355L6.04286 30.5386C5.93969 30.6418 5.80448 30.6933 5.66933 30.6933Z" fill="#E9EDF1"/>
|
||||
<path d="M20.7589 15.6035C20.6238 15.6035 20.4886 15.552 20.3854 15.4488C20.1791 15.2425 20.1791 14.9081 20.3854 14.7019L28.9575 6.1298C29.1639 5.92353 29.4982 5.92353 29.7045 6.1298C29.9108 6.33607 29.9108 6.6705 29.7045 6.8767L21.1325 15.4488C21.0293 15.5519 20.8941 15.6035 20.7589 15.6035Z" fill="#E9EDF1"/>
|
||||
<path d="M29.3309 30.6232C29.1958 30.6232 29.0605 30.5716 28.9574 30.4684L23.4486 24.9597C23.2424 24.7534 23.2424 24.419 23.4486 24.2128C23.655 24.0065 23.9894 24.0065 24.1956 24.2128L29.7043 29.7215C29.9106 29.9278 29.9106 30.2622 29.7043 30.4684C29.6013 30.5716 29.466 30.6232 29.3309 30.6232Z" fill="#E9EDF1"/>
|
||||
<path d="M11.2132 12.5055C11.0781 12.5055 10.9429 12.4539 10.8397 12.3508L5.33097 6.84203C5.1247 6.63576 5.1247 6.30133 5.33097 6.09513C5.53731 5.88886 5.87167 5.88886 6.07794 6.09513L11.5867 11.6039C11.7929 11.8101 11.7929 12.1446 11.5867 12.3508C11.4835 12.4539 11.3484 12.5055 11.2132 12.5055Z" fill="#E9EDF1"/>
|
||||
<path d="M29.1335 15.7045H27.1526C27.0645 15.7045 26.9878 15.6461 26.9631 15.5616C26.7624 14.8743 26.4885 14.2186 26.1511 13.6024C26.1089 13.525 26.1216 13.4299 26.1835 13.3672L27.585 11.9658C27.6624 11.8891 27.6624 11.7644 27.585 11.6869L24.1462 8.24822C24.0688 8.17075 23.9441 8.17075 23.8673 8.24822L22.4659 9.64962C22.4033 9.71159 22.3082 9.72427 22.2307 9.68202C21.6145 9.34469 20.9589 9.07075 20.2716 8.87005C20.1871 8.8454 20.1286 8.76864 20.1286 8.68061V6.69962C20.1286 6.59047 20.0406 6.50244 19.9314 6.50244H15.0681C14.9589 6.50244 14.8709 6.59047 14.8709 6.69962V8.68061C14.8709 8.76864 14.8124 8.8454 14.7279 8.87005C14.0406 9.07075 13.385 9.34469 12.7688 9.68202C12.6913 9.72427 12.5962 9.71159 12.5335 9.64962L11.1321 8.24822C11.0554 8.17075 10.9307 8.17075 10.8533 8.24822L7.41454 11.6869C7.33707 11.7644 7.33707 11.8891 7.41454 11.9658L8.81595 13.3672C8.87792 13.4299 8.89059 13.525 8.84834 13.6024C8.5258 14.1919 8.26102 14.8165 8.06313 15.4714C8.05397 15.501 8.06454 15.5651 8.05538 15.5954C8.03073 15.6799 7.95397 15.7384 7.86595 15.7384L6.03214 15.8306C5.92299 15.8306 5.83496 15.9186 5.83496 16.0278L5.86524 20.5644C5.86524 20.6736 5.95327 20.7616 6.06243 20.7616L7.93848 20.7679C8.02651 20.7679 8.10327 20.8264 8.12792 20.9109C8.32862 21.5982 8.71242 22.4461 9.04975 23.0623C9.092 23.1398 9.07933 23.2348 9.01735 23.2975L7.62721 24.7038C7.54975 24.7806 7.54975 24.9052 7.62721 24.9827L10.8575 28.0503C10.935 28.1278 11.0596 28.1278 11.1364 28.0503L12.4399 26.8398C12.5026 26.7778 12.5976 26.7651 12.6751 26.8074C13.2913 27.1447 14.2645 27.4503 14.9519 27.651C15.0364 27.6757 15.0948 27.7524 15.0948 27.8405L15.0413 29.7524C15.0413 29.8616 15.1293 29.9496 15.2385 29.9496L19.7159 29.9081C19.8251 29.9081 19.9131 29.82 19.9131 29.7109L19.9645 27.8764C19.9645 27.7883 20.023 27.7116 20.1075 27.6869C20.5575 27.556 21.1371 27.4771 21.5575 27.2855C21.6258 27.2545 21.7814 27.2158 21.7814 27.2158C21.9335 27.1426 22.0835 27.0658 22.2307 26.9848C22.3082 26.9426 22.4033 26.9552 22.4659 27.0172L23.8673 28.4186C23.9441 28.4961 24.0688 28.4961 24.1462 28.4186L27.585 24.9799C27.6624 24.9024 27.6624 24.7778 27.585 24.701L26.1835 23.2996C26.1216 23.2369 26.1089 23.1419 26.1511 23.0644C26.4885 22.4482 26.7624 21.7926 26.9631 21.1052C26.9878 21.0207 27.0645 20.9623 27.1526 20.9623H29.1335C29.2427 20.9623 29.3307 20.8743 29.3307 20.7651V15.9017C29.3307 15.7926 29.2427 15.7045 29.1335 15.7045ZM17.5399 21.2693C15.8962 21.2693 14.5638 19.9369 14.5638 18.2933C14.5638 16.6496 15.8962 15.3172 17.5399 15.3172C19.1835 15.3172 20.5159 16.6496 20.5159 18.2933C20.5159 19.9369 19.1835 21.2693 17.5399 21.2693Z" fill="#C3C1C9"/>
|
||||
<path d="M21.7816 27.2158C21.2992 27.4489 20.7943 27.6439 20.2718 27.7967C20.1872 27.8214 20.1288 27.8982 20.1288 27.9862V29.9672C20.1288 30.0763 20.0408 30.1644 19.9316 30.1644H15.0682C14.9591 30.1644 14.8711 30.0763 14.8711 29.9672V27.9862C14.8711 27.8982 14.8126 27.8214 14.7281 27.7967C14.0408 27.596 13.3851 27.3221 12.7689 26.9848C12.6915 26.9425 12.5964 26.9552 12.5337 27.0172L11.1323 28.4186C11.0556 28.496 10.9309 28.496 10.8534 28.4186L7.41472 24.9798C7.33725 24.9024 7.33725 24.7777 7.41472 24.701L8.81613 23.2996C8.8781 23.2369 8.89078 23.1418 8.84852 23.0644C8.5112 22.4482 8.23725 21.7925 8.03655 21.1052C8.0119 21.0207 7.93514 20.9622 7.84711 20.9622H5.86613C5.75697 20.9622 5.66895 20.8742 5.66895 20.7651V15.9017C5.66895 15.7925 5.75697 15.7045 5.86613 15.7045H7.84711C7.93514 15.7045 8.0119 15.6461 8.03655 15.5615C8.045 15.5313 8.05352 15.5008 8.06338 15.4712C8.12747 22.0367 13.4704 27.3397 20.0513 27.3397C20.6387 27.3397 21.2168 27.2975 21.7816 27.2158Z" fill="#ADACB5"/>
|
||||
<path d="M17.5401 12.272C14.2148 12.272 11.5183 14.9677 11.5183 18.2938C11.5183 21.6192 14.2148 24.3156 17.5401 24.3156C20.8662 24.3156 23.562 21.6192 23.562 18.2938C23.562 14.9677 20.8662 12.272 17.5401 12.272ZM17.5401 20.653C16.2373 20.653 15.181 19.5966 15.181 18.2938C15.181 16.991 16.2373 15.9346 17.5401 15.9346C18.843 15.9346 19.8993 16.991 19.8993 18.2938C19.8993 19.5966 18.843 20.653 17.5401 20.653Z" fill="#ADACB5"/>
|
||||
<path d="M34.9999 4.53117C34.9999 2.48926 33.3446 0.833984 31.3027 0.833984C30.589 0.833984 29.9225 1.03624 29.3574 1.38652C29.3574 1.38652 29.164 1.54589 29.0626 1.62441C28.1892 2.30067 27.7471 3.3411 27.7471 4.53124C27.7471 6.57314 29.2607 8.01637 31.3026 8.01637C32.404 8.01637 33.3538 7.71511 34.0312 6.95102C34.114 6.85757 34.3045 6.68997 34.3045 6.68997C34.7421 6.0825 34.9999 5.33694 34.9999 4.53117Z" fill="#73C2FB"/>
|
||||
<path d="M34.3045 6.69058C33.6334 7.62227 32.5386 8.22903 31.3026 8.22903C29.2611 8.22903 27.6055 6.5734 27.6055 4.53185C27.6055 3.20368 28.306 2.03862 29.3574 1.38721C28.9193 1.99425 28.6618 2.7403 28.6618 3.54594C28.6618 5.58749 30.3174 7.24312 32.359 7.24312C33.0731 7.24312 33.7397 7.04129 34.3045 6.69058Z" fill="#4B9CD3"/>
|
||||
<path d="M31.3028 6.11652C32.1779 6.11652 32.8873 5.40711 32.8873 4.53202C32.8873 3.65692 32.1779 2.94751 31.3028 2.94751C30.4277 2.94751 29.7183 3.65692 29.7183 4.53202C29.7183 5.40711 30.4277 6.11652 31.3028 6.11652Z" fill="#4B9CD3"/>
|
||||
<path d="M7.39434 4.53117C7.39434 2.48926 5.73906 0.833984 3.69716 0.833984C2.98343 0.833984 2.31695 1.03624 1.75188 1.38652C1.75188 1.38652 1.55843 1.54589 1.45709 1.62441C0.583714 2.3006 0.141602 3.3411 0.141602 4.53117C0.141602 6.57307 1.65526 8.0163 3.69716 8.0163C4.79857 8.0163 5.74836 7.71504 6.42568 6.95095C6.50857 6.8575 6.69899 6.6899 6.69899 6.6899C7.1366 6.0825 7.39434 5.33694 7.39434 4.53117Z" fill="#7CB9E8"/>
|
||||
<path d="M6.69901 6.69058C6.02788 7.62227 4.9331 8.22903 3.69718 8.22903C1.65563 8.22903 0 6.5734 0 4.53185C0 3.20368 0.700493 2.03862 1.7519 1.38721C1.31387 1.99425 1.05634 2.7403 1.05634 3.54594C1.05634 5.58749 2.71197 7.24312 4.75352 7.24312C5.4676 7.24312 6.13422 7.04129 6.69901 6.69058Z" fill="#6699CC"/>
|
||||
<path d="M3.69705 6.11652C4.57215 6.11652 5.28156 5.40711 5.28156 4.53202C5.28156 3.65692 4.57215 2.94751 3.69705 2.94751C2.82196 2.94751 2.11255 3.65692 2.11255 4.53202C2.11255 5.40711 2.82196 6.11652 3.69705 6.11652Z" fill="#6699CC"/>
|
||||
<path d="M35.0001 32.1376C35.0001 30.0957 33.3448 28.4404 31.3029 28.4404C30.5892 28.4404 29.9227 28.6427 29.3577 28.993C29.3577 28.993 29.1642 29.1523 29.0629 29.2309C28.1894 29.9071 27.7473 30.9475 27.7473 32.1377C27.7473 34.1796 29.261 35.6228 31.3029 35.6228C32.4043 35.6228 33.3541 35.3216 34.0314 34.5575C34.1143 34.464 34.3047 34.2964 34.3047 34.2964C34.7424 33.6889 35.0001 32.9434 35.0001 32.1376Z" fill="#6086FF"/>
|
||||
<path d="M34.305 34.2956C33.6338 35.2273 32.5391 35.834 31.3031 35.834C29.2616 35.834 27.606 34.1784 27.606 32.1368C27.606 30.8087 28.3065 29.6436 29.3579 28.9922C28.9198 29.5992 28.6623 30.3453 28.6623 31.1509C28.6623 33.1925 30.3179 34.8481 32.3595 34.8481C33.0736 34.8481 33.7402 34.6463 34.305 34.2956Z" fill="#023DFE"/>
|
||||
<path d="M31.3033 33.7217C32.1784 33.7217 32.8878 33.0123 32.8878 32.1372C32.8878 31.2621 32.1784 30.5527 31.3033 30.5527C30.4282 30.5527 29.7188 31.2621 29.7188 32.1372C29.7188 33.0123 30.4282 33.7217 31.3033 33.7217Z" fill="#023DFE"/>
|
||||
<path d="M7.39434 32.1376C7.39434 30.0957 5.73906 28.4404 3.69716 28.4404C2.98343 28.4404 2.31695 28.6427 1.75188 28.993C1.75188 28.993 1.55843 29.1523 1.45709 29.2309C0.583714 29.907 0.141602 30.9475 0.141602 32.1376C0.141602 34.1795 1.65526 35.6228 3.69716 35.6228C4.79857 35.6228 5.74836 35.3215 6.42568 34.5574C6.50857 34.4639 6.69899 34.2963 6.69899 34.2963C7.1366 33.6889 7.39434 32.9434 7.39434 32.1376Z" fill="#76ABDF"/>
|
||||
<path d="M6.69901 34.2956C6.02788 35.2273 4.9331 35.834 3.69718 35.834C1.65563 35.834 0 34.1784 0 32.1368C0 30.8087 0.700493 29.6436 1.7519 28.9922C1.31387 29.5992 1.05634 30.3453 1.05634 31.1509C1.05634 33.1925 2.71197 34.8481 4.75352 34.8481C5.4676 34.8481 6.13422 34.6463 6.69901 34.2956Z" fill="#4682B4"/>
|
||||
<path d="M3.69705 33.7217C4.57215 33.7217 5.28156 33.0123 5.28156 32.1372C5.28156 31.2621 4.57215 30.5527 3.69705 30.5527C2.82196 30.5527 2.11255 31.2621 2.11255 32.1372C2.11255 33.0123 2.82196 33.7217 3.69705 33.7217Z" fill="#4682B4"/>
|
||||
<path d="M11.5185 18.8222C11.6454 18.8222 11.7693 18.7765 11.8664 18.6915L13.8114 16.9891C14.0309 16.797 14.0532 16.4634 13.861 16.2439C13.669 16.0243 13.3352 16.0022 13.1157 16.1943L12.2055 16.9909C12.7957 14.5928 14.9731 12.8005 17.54 12.8005C19.8371 12.8005 21.9109 14.2491 22.7002 16.4051C22.8006 16.6791 23.1037 16.8198 23.3778 16.7195C23.6517 16.6192 23.7925 16.3158 23.6922 16.0419C22.751 13.4713 20.2786 11.7441 17.54 11.7441C15.8053 11.7441 14.1704 12.4155 12.9366 13.6347C12.1095 14.452 11.5277 15.4527 11.2267 16.5455L10.8242 15.7489C10.6926 15.4885 10.3748 15.384 10.1146 15.5156C9.85425 15.6472 9.74974 15.9648 9.88136 16.2252L11.0471 18.5322C11.1207 18.6779 11.2575 18.7814 11.4178 18.8125C11.4513 18.819 11.485 18.8222 11.5185 18.8222Z" fill="#F7F9FA"/>
|
||||
<path d="M25.1992 20.368L24.0335 18.061C23.9598 17.9153 23.823 17.8118 23.6627 17.7807C23.5027 17.7496 23.337 17.7942 23.2142 17.9018L21.2691 19.6042C21.0496 19.7963 21.0273 20.1299 21.2195 20.3494C21.4116 20.5689 21.7452 20.5911 21.9648 20.399L22.8727 19.6044C22.2802 21.999 20.1049 23.7877 17.5399 23.7877C15.2331 23.7877 13.1564 22.3309 12.3722 20.1627C12.273 19.8883 11.9701 19.7463 11.6959 19.8456C11.4215 19.9449 11.2796 20.2476 11.3788 20.522C12.3137 23.1071 14.7897 24.844 17.5399 24.844C19.2753 24.844 20.9105 24.1721 22.1446 22.9522C22.9704 22.1357 23.5515 21.1364 23.8524 20.0451L24.2563 20.8444C24.3492 21.0284 24.5351 21.1345 24.7281 21.1345C24.8082 21.1345 24.8895 21.1162 24.9659 21.0776C25.2263 20.9461 25.3308 20.6284 25.1992 20.368Z" fill="#F7F9FA"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 11 KiB |
@ -370,6 +370,9 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
.add(const SmartSceneClearEvent());
|
||||
BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentState!.context)
|
||||
.add(ResetEffectivePeriod());
|
||||
NavigationService.navigatorKey.currentContext!
|
||||
.read<CreateSceneBloc>()
|
||||
.add(const ClearTabToRunSetting());
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
|
||||
@ -237,26 +237,34 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
}
|
||||
}
|
||||
|
||||
sendOtp() async {
|
||||
sendOtp({bool? isforget}) async {
|
||||
try {
|
||||
emit(AuthLoading());
|
||||
await AuthenticationAPI.sendOtp(
|
||||
body: {'email': email, 'type': 'VERIFICATION'});
|
||||
await AuthenticationAPI.sendOtp(body: {
|
||||
'email': email,
|
||||
'type': isforget == true ? 'PASSWORD' : 'VERIFICATION'
|
||||
});
|
||||
emit(AuthSignUpSuccess());
|
||||
} catch (_) {
|
||||
emit(AuthLoginError(message: 'Something went wrong'));
|
||||
emit(AuthErrorStatusWithoutMsg());
|
||||
|
||||
// emit(AuthLoginError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> reSendOtp() async {
|
||||
Future<bool> reSendOtp({bool? forget}) async {
|
||||
try {
|
||||
emit(AuthLoading());
|
||||
await AuthenticationAPI.sendOtp(
|
||||
body: {'email': email, 'type': 'VERIFICATION'});
|
||||
await AuthenticationAPI.sendOtp(body: {
|
||||
'email': email,
|
||||
'type': forget == true ? 'PASSWORD' : 'VERIFICATION'
|
||||
});
|
||||
emit(ResendOtpSuccess());
|
||||
return true;
|
||||
} catch (_) {
|
||||
emit(AuthLoginError(message: 'Something went wrong'));
|
||||
emit(AuthErrorStatusWithoutMsg());
|
||||
|
||||
// emit(AuthLoginError(message: 'Something went wrong'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -264,8 +272,11 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
verifyOtp(bool isForgotPass) async {
|
||||
emit(AuthLoginLoading());
|
||||
try {
|
||||
final response = await AuthenticationAPI.verifyPassCode(
|
||||
body: {'email': email, 'type': 'VERIFICATION', 'otpCode': otpCode});
|
||||
final response = await AuthenticationAPI.verifyPassCode(body: {
|
||||
'email': email,
|
||||
'type': isForgotPass == true ? 'PASSWORD' : 'VERIFICATION',
|
||||
'otpCode': otpCode
|
||||
});
|
||||
if (response['statusCode'] == 200) {
|
||||
if (!isForgotPass) {
|
||||
emailController.text = email;
|
||||
@ -292,7 +303,9 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
(Route route) => false,
|
||||
);
|
||||
} catch (failure) {
|
||||
emit(AuthLogoutError(message: 'Something went wrong'));
|
||||
emit(AuthErrorStatusWithoutMsg());
|
||||
|
||||
// emit(AuthLogoutError(message: 'Something went wrong'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -333,17 +346,22 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
emit(AuthTokenError(message: "Something went wrong"));
|
||||
}
|
||||
} catch (_) {
|
||||
emit(AuthTokenError(message: "Something went wrong"));
|
||||
emit(AuthErrorStatusWithoutMsg());
|
||||
|
||||
// emit(AuthTokenError(message: "Something went wrong"));
|
||||
}
|
||||
}
|
||||
|
||||
sendToForgetPassword({required String password}) async {
|
||||
try {
|
||||
emit(AuthForgetPassLoading());
|
||||
await AuthenticationAPI.forgetPassword(email: email, password: password);
|
||||
|
||||
await AuthenticationAPI.forgetPassword(
|
||||
email: email, password: password, otpCode: otpCode);
|
||||
emit(AuthForgetPassSuccess());
|
||||
} catch (_) {
|
||||
emit(AuthForgetPassError(message: 'Something went wrong'));
|
||||
emit(AuthErrorStatusWithoutMsg());
|
||||
// emit(AuthForgetPassError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,9 +52,6 @@ class AuthTokenError extends AuthError {
|
||||
AuthTokenError({required super.message, super.code});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//ForgetPassword log states
|
||||
class AuthForgetPassLoading extends AuthLoading {}
|
||||
|
||||
@ -64,3 +61,6 @@ class AuthForgetPassError extends AuthError {
|
||||
AuthForgetPassError({required super.message, super.code});
|
||||
}
|
||||
|
||||
class AuthErrorStatusWithoutMsg extends AuthState {
|
||||
AuthErrorStatusWithoutMsg();
|
||||
}
|
||||
|
||||
@ -15,13 +15,15 @@ import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/styles_manager.dart';
|
||||
|
||||
class checkEmailPage extends StatelessWidget {
|
||||
const checkEmailPage({super.key});
|
||||
bool? forget;
|
||||
checkEmailPage({super.key, this.forget});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final formKey = AuthCubit.get(context).checkEmailFormKey;
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light, statusBarIconBrightness: Brightness.light));
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.light));
|
||||
return BlocConsumer<AuthCubit, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthError) {
|
||||
@ -34,8 +36,8 @@ class checkEmailPage extends StatelessWidget {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const OtpView(
|
||||
isForgetPage: true,
|
||||
builder: (context) => OtpView(
|
||||
isForgetPage: forget!,
|
||||
),
|
||||
));
|
||||
}
|
||||
@ -91,7 +93,9 @@ class checkEmailPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height / 5.5,
|
||||
height:
|
||||
MediaQuery.sizeOf(context).height /
|
||||
5.5,
|
||||
),
|
||||
TitleMedium(
|
||||
text: 'Forgot password?',
|
||||
@ -113,32 +117,39 @@ class checkEmailPage extends StatelessWidget {
|
||||
scrollPadding: EdgeInsets.zero,
|
||||
autocorrect: false,
|
||||
enableSuggestions: false,
|
||||
autofillHints: const [AutofillHints.email],
|
||||
validator: AuthCubit.get(context).emailAddressValidator,
|
||||
autofillHints: const [
|
||||
AutofillHints.email
|
||||
],
|
||||
validator: AuthCubit.get(context)
|
||||
.emailAddressValidator,
|
||||
onTapOutside: (event) {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
onChanged: (value) {
|
||||
AuthCubit.get(context).email = value;
|
||||
},
|
||||
decoration: defaultInputDecoration(context,
|
||||
decoration: defaultInputDecoration(
|
||||
context,
|
||||
hint: "Example@email.com"),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
isDone: state is AuthLoginSuccess,
|
||||
isLoading: state is AuthLoading,
|
||||
customButtonStyle: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all(
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(
|
||||
Colors.black.withOpacity(.25),
|
||||
),
|
||||
foregroundColor: MaterialStateProperty.all(
|
||||
foregroundColor:
|
||||
MaterialStateProperty.all(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
@ -146,11 +157,16 @@ class checkEmailPage extends StatelessWidget {
|
||||
'Send Code',
|
||||
),
|
||||
onPressed: () {
|
||||
AuthCubit.get(context).showValidationMessage = true;
|
||||
if (formKey.currentState!.validate()) {
|
||||
AuthCubit.get(context)
|
||||
.showValidationMessage = true;
|
||||
if (formKey.currentState!
|
||||
.validate()) {
|
||||
if ((state is! AuthLoading)) {
|
||||
AuthCubit.get(context).sendOtp();
|
||||
FocusScope.of(context).unfocus();
|
||||
AuthCubit.get(context)
|
||||
.sendOtp(
|
||||
isforget: forget);
|
||||
FocusScope.of(context)
|
||||
.unfocus();
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -160,14 +176,17 @@ class checkEmailPage extends StatelessWidget {
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: MediaQuery.sizeOf(context).height / 5.5),
|
||||
top: MediaQuery.sizeOf(context)
|
||||
.height /
|
||||
5.5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
BodyLarge(
|
||||
text: "Do you have an account? ",
|
||||
style:
|
||||
context.displaySmall.copyWith(color: Colors.white),
|
||||
style: context.displaySmall
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@ -175,7 +194,8 @@ class checkEmailPage extends StatelessWidget {
|
||||
},
|
||||
child: BodyLarge(
|
||||
text: "Sign in",
|
||||
style: context.displaySmall.copyWith(
|
||||
style:
|
||||
context.displaySmall.copyWith(
|
||||
color: Colors.black,
|
||||
fontWeight: FontsManager.bold,
|
||||
),
|
||||
|
||||
@ -12,6 +12,7 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/styles_manager.dart';
|
||||
|
||||
|
||||
class CreateNewPasswordPage extends StatelessWidget {
|
||||
const CreateNewPasswordPage({super.key,});
|
||||
|
||||
|
||||
@ -374,20 +374,25 @@ class _OtpViewState extends State<OtpView> {
|
||||
return;
|
||||
}
|
||||
if ((state is! AuthLoading)) {
|
||||
bool success = await AuthCubit.get(context)
|
||||
.reSendOtp();
|
||||
bool success =
|
||||
await AuthCubit.get(context)
|
||||
.reSendOtp(
|
||||
forget:
|
||||
widget.isForgetPage);
|
||||
FocusScope.of(context).unfocus();
|
||||
if(success){
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => SuccessDialog(
|
||||
key: ValueKey('SuccessDialog'),
|
||||
message: 'New OTP sent!',));
|
||||
if (success) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) =>const SuccessDialog(
|
||||
key: ValueKey(
|
||||
'SuccessDialog'),
|
||||
message: 'New OTP sent!',
|
||||
));
|
||||
}
|
||||
Future.delayed(Duration(seconds: 2),
|
||||
() {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
// Future.delayed(Duration(seconds: 2),
|
||||
// () {
|
||||
// Navigator.of(context).pop();
|
||||
// });
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@ -10,12 +10,17 @@ class ForgetPassword extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isforget = true;
|
||||
return Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const checkEmailPage(),));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => checkEmailPage(forget: isforget),
|
||||
));
|
||||
},
|
||||
child: BodyMedium(
|
||||
text: "Forgot Password?",
|
||||
|
||||
@ -61,8 +61,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
deviceStatus =
|
||||
AcStatusModel.fromJson(response['productUuid'], statusModelList);
|
||||
deviceStatus = AcStatusModel.fromJson(response['productUuid'], statusModelList);
|
||||
emit(GetAcStatusState(acStatusModel: deviceStatus));
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
// _listenToChanges();
|
||||
@ -75,22 +74,18 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$acId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$acId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) {
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus =
|
||||
AcStatusModel.fromJson(usersMap['productUuid'], statusList);
|
||||
deviceStatus = AcStatusModel.fromJson(usersMap['productUuid'], statusList);
|
||||
add(AcUpdated());
|
||||
});
|
||||
} catch (_) {}
|
||||
@ -107,14 +102,12 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', 'AC');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
deviceStatusList.add(
|
||||
AcStatusModel.fromJson(response['productUuid'], statusModelList));
|
||||
deviceStatusList.add(AcStatusModel.fromJson(response['productUuid'], statusModelList));
|
||||
}
|
||||
_setAllAcsTempsAndSwitches();
|
||||
}
|
||||
@ -136,8 +129,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
emit(AcModifyingState(acStatusModel: deviceStatus));
|
||||
}
|
||||
|
||||
await _runDeBouncerForOneDevice(
|
||||
deviceId: event.deviceId, code: 'switch', value: acSwitchValue);
|
||||
await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'switch', value: acSwitchValue);
|
||||
}
|
||||
|
||||
void _changeAllAcSwitch(ChangeAllSwitch event, Emitter<AcsState> emit) async {
|
||||
@ -198,8 +190,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
deviceStatus.childLock = lockValue;
|
||||
emit(AcModifyingState(acStatusModel: deviceStatus));
|
||||
|
||||
await _runDeBouncerForOneDevice(
|
||||
deviceId: acId, code: 'child_lock', value: lockValue);
|
||||
await _runDeBouncerForOneDevice(deviceId: acId, code: 'child_lock', value: lockValue);
|
||||
}
|
||||
|
||||
void _increaseCoolTo(IncreaseCoolToTemp event, Emitter<AcsState> emit) async {
|
||||
@ -227,8 +218,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
emit(AcModifyingState(acStatusModel: deviceStatus));
|
||||
}
|
||||
|
||||
await _runDeBouncerForOneDevice(
|
||||
deviceId: event.deviceId, code: 'temp_set', value: value);
|
||||
await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'temp_set', value: value);
|
||||
}
|
||||
|
||||
void _decreaseCoolTo(DecreaseCoolToTemp event, Emitter<AcsState> emit) async {
|
||||
@ -256,8 +246,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
emit(AcModifyingState(acStatusModel: deviceStatus));
|
||||
}
|
||||
|
||||
await _runDeBouncerForOneDevice(
|
||||
deviceId: event.deviceId, code: 'temp_set', value: value);
|
||||
await _runDeBouncerForOneDevice(deviceId: event.deviceId, code: 'temp_set', value: value);
|
||||
}
|
||||
|
||||
void _changeAcMode(ChangeAcMode event, Emitter<AcsState> emit) async {
|
||||
@ -279,9 +268,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
}
|
||||
|
||||
await _runDeBouncerForOneDevice(
|
||||
deviceId: event.deviceId,
|
||||
code: 'mode',
|
||||
value: getACModeString(tempMode));
|
||||
deviceId: event.deviceId, code: 'mode', value: getACModeString(tempMode));
|
||||
}
|
||||
|
||||
void _changeFanSpeed(ChangeFanSpeed event, Emitter<AcsState> emit) async {
|
||||
@ -294,23 +281,19 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
for (AcStatusModel ac in deviceStatusList) {
|
||||
if (ac.uuid == event.productId) {
|
||||
ac.fanSpeedsString = getNextFanSpeedKey(fanSpeed);
|
||||
ac.acFanSpeed =
|
||||
AcStatusModel.getFanSpeed(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));
|
||||
deviceStatus.acFanSpeed = AcStatusModel.getFanSpeed(getNextFanSpeedKey(fanSpeed));
|
||||
emit(AcModifyingState(acStatusModel: deviceStatus));
|
||||
}
|
||||
|
||||
await _runDeBouncerForOneDevice(
|
||||
deviceId: event.deviceId,
|
||||
code: 'level',
|
||||
value: getNextFanSpeedKey(fanSpeed));
|
||||
deviceId: event.deviceId, code: 'level', value: getNextFanSpeedKey(fanSpeed));
|
||||
}
|
||||
|
||||
String getACModeString(TempModes value) {
|
||||
@ -355,8 +338,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
for (int i = 0; i < deviceStatusList.length; i++) {
|
||||
try {
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: devicesList[i].uuid, code: code, value: value),
|
||||
DeviceControlModel(deviceId: devicesList[i].uuid, code: code, value: value),
|
||||
devicesList[i].uuid ?? '');
|
||||
} catch (_) {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
@ -378,10 +360,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
_timer = Timer(const Duration(seconds: 1), () async {
|
||||
try {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: allAcsPage ? deviceId : acId,
|
||||
code: code,
|
||||
value: value),
|
||||
DeviceControlModel(deviceId: allAcsPage ? deviceId : acId, code: code, value: value),
|
||||
allAcsPage ? deviceId : acId);
|
||||
|
||||
if (!response['success']) {
|
||||
@ -398,8 +377,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
if (value >= 20 && value <= 30) {
|
||||
return true;
|
||||
} else {
|
||||
emit(const AcsFailedState(
|
||||
errorMessage: 'The temperature must be between 20 and 30'));
|
||||
emit(const AcsFailedState(errorMessage: 'The temperature must be between 20 and 30'));
|
||||
emit(GetAllAcsStatusState(
|
||||
allAcsStatues: deviceStatusList,
|
||||
allAcs: devicesList,
|
||||
|
||||
@ -19,8 +19,7 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
on<CeilingSensorUpdated>(_onCeilingSensorUpdated);
|
||||
}
|
||||
|
||||
void _fetchCeilingSensorStatus(
|
||||
InitialEvent event, Emitter<CeilingSensorState> emit) async {
|
||||
void _fetchCeilingSensorStatus(InitialEvent event, Emitter<CeilingSensorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(deviceId);
|
||||
@ -39,18 +38,15 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) {
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = CeilingSensorModel.fromJson(statusList);
|
||||
@ -59,19 +55,15 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
_onCeilingSensorUpdated(
|
||||
CeilingSensorUpdated event, Emitter<CeilingSensorState> emit) {
|
||||
_onCeilingSensorUpdated(CeilingSensorUpdated event, Emitter<CeilingSensorState> emit) {
|
||||
emit(UpdateState(ceilingSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeValue(
|
||||
ChangeValueEvent event, Emitter<CeilingSensorState> emit) async {
|
||||
void _changeValue(ChangeValueEvent event, Emitter<CeilingSensorState> emit) async {
|
||||
emit(LoadingNewSate(ceilingSensorModel: deviceStatus));
|
||||
try {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: deviceId, code: event.code, value: event.value),
|
||||
deviceId);
|
||||
DeviceControlModel(deviceId: deviceId, code: event.code, value: event.value), deviceId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
deviceStatus.sensitivity = event.value;
|
||||
|
||||
@ -25,11 +25,9 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
bool lowBattery = false;
|
||||
bool closingReminder = false;
|
||||
bool doorAlarm = false;
|
||||
DoorSensorModel deviceStatus =
|
||||
DoorSensorModel(doorContactState: false, batteryPercentage: 0);
|
||||
DoorSensorModel deviceStatus = DoorSensorModel(doorContactState: false, batteryPercentage: 0);
|
||||
|
||||
void _fetchStatus(
|
||||
DoorSensorInitial event, Emitter<DoorSensorState> emit) async {
|
||||
void _fetchStatus(DoorSensorInitial event, Emitter<DoorSensorState> emit) async {
|
||||
emit(DoorSensorLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(DSId);
|
||||
@ -50,8 +48,7 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
}
|
||||
|
||||
// Toggle functions for each switch
|
||||
void _toggleLowBattery(
|
||||
ToggleLowBatteryEvent event, Emitter<DoorSensorState> emit) async {
|
||||
void _toggleLowBattery(ToggleLowBatteryEvent event, Emitter<DoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
lowBattery = event.isLowBatteryEnabled;
|
||||
@ -92,8 +89,7 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleDoorAlarm(
|
||||
ToggleDoorAlarmEvent event, Emitter<DoorSensorState> emit) async {
|
||||
void _toggleDoorAlarm(ToggleDoorAlarmEvent event, Emitter<DoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
doorAlarm = event.isDoorAlarmEnabled;
|
||||
@ -112,11 +108,9 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
DeviceReport recordGroups = DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
Future<void> fetchLogsForLastMonth(
|
||||
ReportLogsInitial event, Emitter<DoorSensorState> emit) async {
|
||||
Future<void> fetchLogsForLastMonth(ReportLogsInitial event, Emitter<DoorSensorState> emit) async {
|
||||
DateTime now = DateTime.now();
|
||||
|
||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||
@ -126,9 +120,8 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
try {
|
||||
emit(DoorSensorLoadingState());
|
||||
var response = await DevicesAPI.getReportLogs(
|
||||
startTime:
|
||||
startTime.toString(),
|
||||
endTime: endTime.toString(),
|
||||
startTime: startTime.toString(),
|
||||
endTime: endTime.toString(),
|
||||
deviceUuid: DSId,
|
||||
code: 'doorcontact_state',
|
||||
);
|
||||
@ -142,16 +135,14 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$DSId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$DSId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
|
||||
@ -65,8 +65,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
batteryPercentage: 0,
|
||||
);
|
||||
|
||||
void _fetchStatus(
|
||||
GarageDoorInitial event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _fetchStatus(GarageDoorInitial event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(GarageDoorLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(GDId);
|
||||
@ -114,8 +113,8 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleClosingReminder(ToggleClosingReminderEvent event,
|
||||
Emitter<GarageDoorSensorState> emit) async {
|
||||
void _toggleClosingReminder(
|
||||
ToggleClosingReminderEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
closingReminder = event.isClosingReminderEnabled;
|
||||
@ -133,8 +132,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleDoorAlarm(
|
||||
ToggleDoorAlarmEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _toggleDoorAlarm(ToggleDoorAlarmEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
doorAlarm = event.isDoorAlarmEnabled;
|
||||
@ -152,8 +150,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
DeviceReport recordGroups = DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
Future<void> fetchLogsForLastMonth(
|
||||
ReportLogsInitial event, Emitter<GarageDoorSensorState> emit) async {
|
||||
@ -172,8 +169,6 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
);
|
||||
recordGroups = response;
|
||||
|
||||
|
||||
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -184,16 +179,14 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$GDId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$GDId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList.add(StatusModel(code: element['code'], value: true));
|
||||
@ -268,8 +261,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
deviceId: GDId,
|
||||
);
|
||||
List<dynamic> jsonData = response;
|
||||
listSchedule =
|
||||
jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -280,13 +272,12 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
|
||||
int? getTimeStampWithoutSeconds(DateTime? dateTime) {
|
||||
if (dateTime == null) return null;
|
||||
DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month,
|
||||
dateTime.day, dateTime.hour, dateTime.minute);
|
||||
DateTime dateTimeWithoutSeconds =
|
||||
DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute);
|
||||
return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
Future toggleChange(
|
||||
ToggleScheduleEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
Future toggleChange(ToggleScheduleEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
try {
|
||||
emit(GarageDoorLoadingState());
|
||||
final response = await DevicesAPI.changeSchedule(
|
||||
@ -304,8 +295,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future deleteSchedule(
|
||||
DeleteScheduleEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
Future deleteSchedule(DeleteScheduleEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
try {
|
||||
emit(GarageDoorLoadingState());
|
||||
final response = await DevicesAPI.deleteSchedule(
|
||||
@ -324,15 +314,13 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void toggleSelectedIndex(
|
||||
ToggleSelectedEvent event, Emitter<GarageDoorSensorState> emit) {
|
||||
void toggleSelectedIndex(ToggleSelectedEvent event, Emitter<GarageDoorSensorState> emit) {
|
||||
emit(GarageDoorLoadingState());
|
||||
selectedTabIndex = event.index;
|
||||
emit(ChangeSlidingSegmentState(value: selectedTabIndex));
|
||||
}
|
||||
|
||||
void toggleCreateSchedule(
|
||||
ToggleCreateScheduleEvent event, Emitter<GarageDoorSensorState> emit) {
|
||||
void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter<GarageDoorSensorState> emit) {
|
||||
emit(GarageDoorLoadingState());
|
||||
createSchedule = !createSchedule;
|
||||
selectedDays.clear();
|
||||
@ -349,16 +337,13 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
|
||||
int secondSelected = 0;
|
||||
bool toggleDoor = false;
|
||||
Future<void> selectSeconds(
|
||||
SelectSecondsEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
Future<void> selectSeconds(SelectSecondsEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
try {
|
||||
emit(GarageDoorLoadingState());
|
||||
secondSelected = event.seconds;
|
||||
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: GDId, code: 'tr_timecon', value: secondSelected),
|
||||
GDId);
|
||||
DeviceControlModel(deviceId: GDId, code: 'tr_timecon', value: secondSelected), GDId);
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -367,15 +352,12 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
openCloseGarageDoor(
|
||||
ToggleDoorEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
openCloseGarageDoor(ToggleDoorEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(GarageDoorLoadingState());
|
||||
try {
|
||||
toggleDoor = !event.toggle;
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: GDId, code: 'switch_1', value: toggleDoor),
|
||||
GDId);
|
||||
DeviceControlModel(deviceId: GDId, code: 'switch_1', value: toggleDoor), GDId);
|
||||
add(const GarageDoorInitial());
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
@ -385,16 +367,13 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _setCounterValue(
|
||||
SetCounterValue event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _setCounterValue(SetCounterValue event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
int seconds = 0;
|
||||
try {
|
||||
seconds = event.duration.inSeconds;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: GDId, code: 'countdown_1', value: seconds),
|
||||
GDId);
|
||||
DeviceControlModel(deviceId: GDId, code: 'countdown_1', value: seconds), GDId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
deviceStatus.countdown1 = seconds;
|
||||
@ -414,8 +393,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _getCounterValue(
|
||||
GetCounterEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _getCounterValue(GetCounterEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(GDId);
|
||||
@ -456,8 +434,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
List<GroupGarageModel> groupList = [];
|
||||
bool allSwitchesOn = true;
|
||||
|
||||
void _fetchWizardStatus(
|
||||
InitialWizardEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _fetchWizardStatus(InitialWizardEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
devicesList = [];
|
||||
@ -467,8 +444,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', 'GD');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
@ -497,8 +473,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _groupAllOn(
|
||||
GroupAllOnEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _groupAllOn(GroupAllOnEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
// Set all switches (firstSwitch and secondSwitch) based on the event value (on/off)
|
||||
@ -510,8 +485,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
emit(UpdateGroupState(garageList: groupList, allSwitches: true));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds =
|
||||
groupList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
@ -531,8 +505,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _groupAllOff(
|
||||
GroupAllOffEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _groupAllOff(GroupAllOffEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
// Set all switches (firstSwitch and secondSwitch) based on the event value (on/off)
|
||||
@ -544,8 +517,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
emit(UpdateGroupState(garageList: groupList, allSwitches: false));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds =
|
||||
groupList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
@ -566,8 +538,8 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||
Emitter<GarageDoorSensorState> emit) async {
|
||||
void _changeFirstWizardSwitch(
|
||||
ChangeFirstWizardSwitchStatusEvent event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
try {
|
||||
bool allSwitchesValue = true;
|
||||
@ -580,8 +552,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
});
|
||||
|
||||
emit(UpdateGroupState(
|
||||
garageList: groupList, allSwitches: allSwitchesValue));
|
||||
emit(UpdateGroupState(garageList: groupList, allSwitches: allSwitchesValue));
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'switch_1',
|
||||
@ -597,16 +568,13 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _setTimeOutAlarm(
|
||||
SetTimeOutValue event, Emitter<GarageDoorSensorState> emit) async {
|
||||
void _setTimeOutAlarm(SetTimeOutValue event, Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
int seconds = 0;
|
||||
try {
|
||||
seconds = event.duration.inSeconds;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: GDId, code: 'countdown_alarm', value: seconds),
|
||||
GDId);
|
||||
DeviceControlModel(deviceId: GDId, code: 'countdown_alarm', value: seconds), GDId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
deviceStatus.countdownAlarm = seconds;
|
||||
|
||||
@ -26,8 +26,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
bool oneGangGroup = false;
|
||||
List<DeviceModel> devicesList = [];
|
||||
|
||||
OneGangBloc({required this.oneGangId, required this.switchCode})
|
||||
: super(InitialState()) {
|
||||
OneGangBloc({required this.oneGangId, required this.switchCode}) : super(InitialState()) {
|
||||
on<InitialEvent>(_fetchOneGangStatus);
|
||||
on<OneGangUpdated>(_oneGangUpdated);
|
||||
on<ChangeFirstSwitchStatusEvent>(_changeFirstSwitch);
|
||||
@ -50,8 +49,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
on<GroupAllOffEvent>(_groupAllOff);
|
||||
}
|
||||
|
||||
void _fetchOneGangStatus(
|
||||
InitialEvent event, Emitter<OneGangState> emit) async {
|
||||
void _fetchOneGangStatus(InitialEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(oneGangId);
|
||||
@ -70,21 +68,18 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$oneGangId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$oneGangId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = OneGangModel.fromJson(statusList);
|
||||
@ -99,8 +94,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
emit(UpdateState(oneGangModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeFirstSwitch(
|
||||
ChangeFirstSwitchStatusEvent event, Emitter<OneGangState> emit) async {
|
||||
void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingNewSate(oneGangModel: deviceStatus));
|
||||
try {
|
||||
deviceStatus.firstSwitch = !event.value;
|
||||
@ -125,20 +119,17 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _changeSliding(
|
||||
ChangeSlidingSegment event, Emitter<OneGangState> emit) async {
|
||||
void _changeSliding(ChangeSlidingSegment event, Emitter<OneGangState> emit) async {
|
||||
emit(ChangeSlidingSegmentState(value: event.value));
|
||||
}
|
||||
|
||||
void _setCounterValue(
|
||||
SetCounterValue event, Emitter<OneGangState> emit) async {
|
||||
void _setCounterValue(SetCounterValue event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingNewSate(oneGangModel: deviceStatus));
|
||||
int seconds = 0;
|
||||
try {
|
||||
seconds = event.duration.inSeconds;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: oneGangId, code: event.deviceCode, value: seconds),
|
||||
DeviceControlModel(deviceId: oneGangId, code: event.deviceCode, value: seconds),
|
||||
oneGangId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
@ -161,8 +152,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _getCounterValue(
|
||||
GetCounterEvent event, Emitter<OneGangState> emit) async {
|
||||
void _getCounterValue(GetCounterEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(oneGangId);
|
||||
@ -251,8 +241,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
deviceId: oneGangId,
|
||||
);
|
||||
List<dynamic> jsonData = response;
|
||||
listSchedule =
|
||||
jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
emit(InitialState());
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -263,13 +252,12 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
|
||||
int? getTimeStampWithoutSeconds(DateTime? dateTime) {
|
||||
if (dateTime == null) return null;
|
||||
DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month,
|
||||
dateTime.day, dateTime.hour, dateTime.minute);
|
||||
DateTime dateTimeWithoutSeconds =
|
||||
DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute);
|
||||
return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
Future toggleChange(
|
||||
ToggleScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
Future toggleChange(ToggleScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
final response = await DevicesAPI.changeSchedule(
|
||||
@ -288,8 +276,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future deleteSchedule(
|
||||
DeleteScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
Future deleteSchedule(DeleteScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
final response = await DevicesAPI.deleteSchedule(
|
||||
@ -309,8 +296,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
void toggleCreateSchedule(
|
||||
ToggleCreateScheduleEvent event, Emitter<OneGangState> emit) {
|
||||
void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter<OneGangState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
createSchedule = !createSchedule;
|
||||
selectedDays.clear();
|
||||
@ -339,8 +325,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
|
||||
int selectedTabIndex = 0;
|
||||
|
||||
void toggleSelectedIndex(
|
||||
ToggleSelectedEvent event, Emitter<OneGangState> emit) {
|
||||
void toggleSelectedIndex(ToggleSelectedEvent event, Emitter<OneGangState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
selectedTabIndex = event.index;
|
||||
emit(ChangeSlidingSegmentState(value: selectedTabIndex));
|
||||
@ -349,8 +334,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
List<GroupOneGangModel> groupOneGangList = [];
|
||||
bool allSwitchesOn = true;
|
||||
|
||||
void _fetchOneGangWizardStatus(
|
||||
InitialWizardEvent event, Emitter<OneGangState> emit) async {
|
||||
void _fetchOneGangWizardStatus(InitialWizardEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
devicesList = [];
|
||||
@ -360,8 +344,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', '1G');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
@ -382,16 +365,15 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
emit(UpdateGroupState(
|
||||
oneGangList: groupOneGangList, allSwitches: allSwitchesOn));
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: allSwitchesOn));
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||
Emitter<OneGangState> emit) async {
|
||||
void _changeFirstWizardSwitch(
|
||||
ChangeFirstWizardSwitchStatusEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingNewSate(oneGangModel: deviceStatus));
|
||||
try {
|
||||
bool allSwitchesValue = true;
|
||||
@ -404,8 +386,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
});
|
||||
|
||||
emit(UpdateGroupState(
|
||||
oneGangList: groupOneGangList, allSwitches: allSwitchesValue));
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: allSwitchesValue));
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'switch_1',
|
||||
@ -433,8 +414,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: true));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds =
|
||||
groupOneGangList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupOneGangList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
@ -466,8 +446,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: false));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds =
|
||||
groupOneGangList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupOneGangList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
|
||||
@ -30,8 +30,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
bool oneTouchGroup = false;
|
||||
List<DeviceModel> devicesList = [];
|
||||
|
||||
OneTouchBloc({required this.oneTouchId, required this.switchCode})
|
||||
: super(InitialState()) {
|
||||
OneTouchBloc({required this.oneTouchId, required this.switchCode}) : super(InitialState()) {
|
||||
on<InitialEvent>(_fetchOneTouchStatus);
|
||||
on<OneTouchUpdated>(_oneTouchUpdated);
|
||||
on<ChangeFirstSwitchStatusEvent>(_changeFirstSwitch);
|
||||
@ -54,8 +53,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
on<ChangeStatusEvent>(_changeStatus);
|
||||
}
|
||||
|
||||
void _fetchOneTouchStatus(
|
||||
InitialEvent event, Emitter<OneTouchState> emit) async {
|
||||
void _fetchOneTouchStatus(InitialEvent event, Emitter<OneTouchState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(oneTouchId);
|
||||
@ -74,21 +72,18 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$oneTouchId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$oneTouchId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = OneTouchModel.fromJson(statusList);
|
||||
@ -103,8 +98,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeFirstSwitch(
|
||||
ChangeFirstSwitchStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
emit(LoadingNewSate(oneTouchModel: deviceStatus));
|
||||
try {
|
||||
deviceStatus.firstSwitch = !event.value;
|
||||
@ -129,20 +123,17 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _changeSliding(
|
||||
ChangeSlidingSegment event, Emitter<OneTouchState> emit) async {
|
||||
void _changeSliding(ChangeSlidingSegment event, Emitter<OneTouchState> emit) async {
|
||||
emit(ChangeSlidingSegmentState(value: event.value));
|
||||
}
|
||||
|
||||
void _setCounterValue(
|
||||
SetCounterValue event, Emitter<OneTouchState> emit) async {
|
||||
void _setCounterValue(SetCounterValue event, Emitter<OneTouchState> emit) async {
|
||||
emit(LoadingNewSate(oneTouchModel: deviceStatus));
|
||||
int seconds = 0;
|
||||
try {
|
||||
seconds = event.duration.inSeconds;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: oneTouchId, code: event.deviceCode, value: seconds),
|
||||
DeviceControlModel(deviceId: oneTouchId, code: event.deviceCode, value: seconds),
|
||||
oneTouchId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
@ -165,8 +156,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _getCounterValue(
|
||||
GetCounterEvent event, Emitter<OneTouchState> emit) async {
|
||||
void _getCounterValue(GetCounterEvent event, Emitter<OneTouchState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(oneTouchId);
|
||||
@ -255,8 +245,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
deviceId: oneTouchId,
|
||||
);
|
||||
List<dynamic> jsonData = response;
|
||||
listSchedule =
|
||||
jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
emit(InitialState());
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -267,13 +256,12 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
|
||||
int? getTimeStampWithoutSeconds(DateTime? dateTime) {
|
||||
if (dateTime == null) return null;
|
||||
DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month,
|
||||
dateTime.day, dateTime.hour, dateTime.minute);
|
||||
DateTime dateTimeWithoutSeconds =
|
||||
DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute);
|
||||
return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
Future toggleChange(
|
||||
ToggleScheduleEvent event, Emitter<OneTouchState> emit) async {
|
||||
Future toggleChange(ToggleScheduleEvent event, Emitter<OneTouchState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
final response = await DevicesAPI.changeSchedule(
|
||||
@ -292,8 +280,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future deleteSchedule(
|
||||
DeleteScheduleEvent event, Emitter<OneTouchState> emit) async {
|
||||
Future deleteSchedule(DeleteScheduleEvent event, Emitter<OneTouchState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
final response = await DevicesAPI.deleteSchedule(
|
||||
@ -313,8 +300,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
}
|
||||
|
||||
void toggleCreateSchedule(
|
||||
ToggleCreateScheduleEvent event, Emitter<OneTouchState> emit) {
|
||||
void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter<OneTouchState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
createSchedule = !createSchedule;
|
||||
selectedDays.clear();
|
||||
@ -343,8 +329,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
|
||||
int selectedTabIndex = 0;
|
||||
|
||||
void toggleSelectedIndex(
|
||||
ToggleSelectedEvent event, Emitter<OneTouchState> emit) {
|
||||
void toggleSelectedIndex(ToggleSelectedEvent event, Emitter<OneTouchState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
selectedTabIndex = event.index;
|
||||
emit(ChangeSlidingSegmentState(value: selectedTabIndex));
|
||||
@ -353,8 +338,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
List<GroupOneTouchModel> groupOneTouchList = [];
|
||||
bool allSwitchesOn = true;
|
||||
|
||||
void _fetchOneTouchWizardStatus(
|
||||
InitialWizardEvent event, Emitter<OneTouchState> emit) async {
|
||||
void _fetchOneTouchWizardStatus(InitialWizardEvent event, Emitter<OneTouchState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
devicesList = [];
|
||||
@ -364,8 +348,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', '1GT');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
@ -386,16 +369,15 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
emit(UpdateGroupState(
|
||||
oneTouchList: groupOneTouchList, allSwitches: allSwitchesOn));
|
||||
emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: allSwitchesOn));
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||
Emitter<OneTouchState> emit) async {
|
||||
void _changeFirstWizardSwitch(
|
||||
ChangeFirstWizardSwitchStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
emit(LoadingNewSate(oneTouchModel: deviceStatus));
|
||||
try {
|
||||
bool allSwitchesValue = true;
|
||||
@ -413,8 +395,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
value: !event.value,
|
||||
);
|
||||
|
||||
emit(UpdateGroupState(
|
||||
oneTouchList: groupOneTouchList, allSwitches: allSwitchesValue));
|
||||
emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: allSwitchesValue));
|
||||
if (response['success']) {
|
||||
add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
}
|
||||
@ -432,12 +413,10 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
|
||||
// Emit the state with updated values
|
||||
emit(
|
||||
UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: true));
|
||||
emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: true));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds =
|
||||
groupOneTouchList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupOneTouchList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response1 = await DevicesAPI.deviceBatchController(
|
||||
@ -466,12 +445,10 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
|
||||
// Emit the state with updated values
|
||||
emit(UpdateGroupState(
|
||||
oneTouchList: groupOneTouchList, allSwitches: false));
|
||||
emit(UpdateGroupState(oneTouchList: groupOneTouchList, allSwitches: false));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds =
|
||||
groupOneTouchList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupOneTouchList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response1 = await DevicesAPI.deviceBatchController(
|
||||
@ -495,8 +472,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
String statusSelected = '';
|
||||
String optionSelected = '';
|
||||
|
||||
Future<void> _changeStatus(
|
||||
ChangeStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
Future<void> _changeStatus(ChangeStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
|
||||
@ -521,10 +497,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
final selectedControl = controlMap[optionSelected]?[statusSelected];
|
||||
if (selectedControl != null) {
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: oneTouchId,
|
||||
code: optionSelected,
|
||||
value: selectedControl),
|
||||
DeviceControlModel(deviceId: oneTouchId, code: optionSelected, value: selectedControl),
|
||||
oneTouchId,
|
||||
);
|
||||
} else {
|
||||
|
||||
@ -22,7 +22,8 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
on<FilterRecordsByDateEvent>(_filterRecordsByDate);
|
||||
}
|
||||
DateTime? dateTime = DateTime.now();
|
||||
String formattedDate = DateFormat('yyyy/MM/dd').format(DateTime.now());
|
||||
|
||||
String formattedDate = DateFormat('dd/MM/yyyy').format(DateTime.now());
|
||||
bool lowBattery = false;
|
||||
bool closingReminder = false;
|
||||
bool doorAlarm = false;
|
||||
@ -305,8 +306,8 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
(newDate) {
|
||||
if (newDate != null) {
|
||||
dateTime = newDate;
|
||||
formattedDate = DateFormat('yyyy/MM/dd').format(dateTime!);
|
||||
|
||||
// formattedDate = DateFormat('yyyy/MM/dd').format(dateTime!);
|
||||
formattedDate = DateFormat('dd/MM/yyyy').format(dateTime!);
|
||||
add(FilterRecordsByDateEvent(
|
||||
selectedDate: dateTime!,
|
||||
viewType: views[currentIndex],
|
||||
@ -319,8 +320,7 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
(newDate) {
|
||||
if (newDate != null) {
|
||||
dateTime = newDate;
|
||||
formattedDate = DateFormat('yyyy-MM').format(dateTime!);
|
||||
|
||||
formattedDate = DateFormat('yyyy/MM').format(dateTime!);
|
||||
add(FilterRecordsByDateEvent(
|
||||
selectedDate: dateTime!,
|
||||
viewType: views[currentIndex],
|
||||
@ -359,7 +359,7 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 300,
|
||||
height: MediaQuery.of(context).size.height * 0.4,
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
@ -463,7 +463,7 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 300,
|
||||
height: MediaQuery.of(context).size.height * 0.4,
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
@ -530,13 +530,13 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
Future<DateTime?> dayMonthYearPicker({
|
||||
required BuildContext context,
|
||||
}) async {
|
||||
DateTime selectedDate = DateTime.now(); // Default selected date
|
||||
DateTime selectedDate = DateTime.now();
|
||||
|
||||
return await showModalBottomSheet<DateTime>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 350, // Increased height to accommodate the buttons
|
||||
height: MediaQuery.of(context).size.height * 0.4,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
@ -546,8 +546,7 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
minimumYear: 1900,
|
||||
maximumYear: DateTime.now().year,
|
||||
onDateTimeChanged: (DateTime newDateTime) {
|
||||
selectedDate =
|
||||
newDateTime; // Update the selected date when changed
|
||||
selectedDate = newDateTime;
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -561,15 +560,13 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(); // Dismiss the modal without returning a value
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(selectedDate); // Return the selected date
|
||||
Navigator.of(context).pop(selectedDate);
|
||||
},
|
||||
),
|
||||
],
|
||||
@ -591,6 +588,8 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
.where((record) => record.eventTime!.year == event.selectedDate.year)
|
||||
.toList();
|
||||
} else if (event.viewType == 'Month') {
|
||||
formattedDate =
|
||||
"${getMonthShortName(event.selectedDate.month)} ${event.selectedDate.year.toString()}";
|
||||
filteredRecords = record
|
||||
.where((record) =>
|
||||
record.eventTime!.year == event.selectedDate.year &&
|
||||
@ -604,10 +603,6 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
record.eventTime!.day == event.selectedDate.day)
|
||||
.toList();
|
||||
}
|
||||
String getMonthShortName(int month) {
|
||||
final date = DateTime(0, month);
|
||||
return DateFormat.MMM().format(date);
|
||||
}
|
||||
|
||||
energyDataList = filteredRecords.map((eventDevice) {
|
||||
return EnergyData(
|
||||
@ -615,18 +610,32 @@ class PowerClampBloc extends Bloc<PowerClampEvent, PowerClampState> {
|
||||
? getMonthShortName(
|
||||
int.tryParse(DateFormat('MM').format(eventDevice.eventTime!))!)
|
||||
: event.viewType == 'Month'
|
||||
? DateFormat('yyyy/MM/dd').format(eventDevice.eventTime!)
|
||||
? DateFormat('dd/MM').format(eventDevice.eventTime!)
|
||||
: DateFormat('HH:mm:ss').format(eventDevice.eventTime!),
|
||||
double.parse(eventDevice.value!),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
selectDateRange();
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
emit(FilterRecordsState(filteredRecords: energyDataList));
|
||||
}
|
||||
|
||||
String getMonthShortName(int month) {
|
||||
final date = DateTime(0, month);
|
||||
return DateFormat.MMM().format(date);
|
||||
}
|
||||
|
||||
String endChartDate = '';
|
||||
|
||||
void selectDateRange() async {
|
||||
DateTime startDate = dateTime!;
|
||||
DateTime endDate = DateTime(startDate.year, startDate.month + 1, 1)
|
||||
.subtract(Duration(days: 1));
|
||||
String formattedEndDate = DateFormat('dd/MM/yyyy').format(endDate);
|
||||
endChartDate = ' - $formattedEndDate';
|
||||
}
|
||||
}
|
||||
|
||||
// Event for filtering records by date
|
||||
|
||||
|
||||
// _listenToChanges() {
|
||||
|
||||
@ -37,8 +37,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
on<SelectTimeEvent>(selectTimeOfLinePassword);
|
||||
on<SelectTimeOnlinePasswordEvent>(selectTimeOnlinePassword);
|
||||
on<DeletePasswordEvent>(deletePassword);
|
||||
on<GenerateAndSavePasswordTimeLimitEvent>(
|
||||
generateAndSavePasswordTimeLimited);
|
||||
on<GenerateAndSavePasswordTimeLimitEvent>(generateAndSavePasswordTimeLimited);
|
||||
on<GenerateAndSavePasswordOneTimeEvent>(generateAndSavePasswordOneTime);
|
||||
on<ToggleDaySelectionEvent>(toggleDaySelection);
|
||||
on<RenamePasswordEvent>(_renamePassword);
|
||||
@ -60,8 +59,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
List<OfflinePasswordModel>? oneTimePasswords = [];
|
||||
List<OfflinePasswordModel>? timeLimitPasswords = [];
|
||||
|
||||
Future generate7DigitNumber(
|
||||
GeneratePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
Future generate7DigitNumber(GeneratePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
passwordController.clear();
|
||||
Random random = Random();
|
||||
@ -73,8 +71,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
|
||||
Future generateAndSavePasswordOneTime(
|
||||
GenerateAndSavePasswordOneTimeEvent event,
|
||||
Emitter<SmartDoorState> emit) async {
|
||||
GenerateAndSavePasswordOneTimeEvent event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
if (isSavingPassword) return;
|
||||
isSavingPassword = true;
|
||||
@ -95,8 +92,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _fetchSmartDoorStatus(
|
||||
InitialEvent event, Emitter<SmartDoorState> emit) async {
|
||||
void _fetchSmartDoorStatus(InitialEvent event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
var response = await DevicesAPI.getDeviceStatus(deviceId);
|
||||
@ -115,18 +111,15 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) {
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = SmartDoorModel.fromJson(statusList);
|
||||
@ -140,14 +133,11 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _renamePassword(
|
||||
RenamePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
void _renamePassword(RenamePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
await DevicesAPI.renamePass(
|
||||
name: passwordNameController.text,
|
||||
doorLockUuid: deviceId,
|
||||
passwordId: passwordId);
|
||||
name: passwordNameController.text, doorLockUuid: deviceId, passwordId: passwordId);
|
||||
add(InitialOneTimePassword());
|
||||
add(InitialTimeLimitPassword());
|
||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||
@ -157,58 +147,46 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
}
|
||||
|
||||
void getTemporaryPasswords(
|
||||
InitialPasswordsPage event, Emitter<SmartDoorState> emit) async {
|
||||
void getTemporaryPasswords(InitialPasswordsPage event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
var response = await DevicesAPI.getTemporaryPasswords(
|
||||
deviceId,
|
||||
);
|
||||
if (response is List) {
|
||||
temporaryPasswords =
|
||||
response.map((item) => TemporaryPassword.fromJson(item)).toList();
|
||||
temporaryPasswords = response.map((item) => TemporaryPassword.fromJson(item)).toList();
|
||||
} else if (response is Map && response.containsKey('data')) {
|
||||
temporaryPasswords = (response['data'] as List)
|
||||
.map((item) => TemporaryPassword.fromJson(item))
|
||||
.toList();
|
||||
temporaryPasswords =
|
||||
(response['data'] as List).map((item) => TemporaryPassword.fromJson(item)).toList();
|
||||
}
|
||||
emit(TemporaryPasswordsLoadedState(
|
||||
temporaryPassword: temporaryPasswords!));
|
||||
emit(TemporaryPasswordsLoadedState(temporaryPassword: temporaryPasswords!));
|
||||
} catch (e) {
|
||||
emit(FailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void getOneTimePasswords(
|
||||
InitialOneTimePassword event, Emitter<SmartDoorState> emit) async {
|
||||
void getOneTimePasswords(InitialOneTimePassword event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
var response = await DevicesAPI.getOneTimePasswords(deviceId);
|
||||
if (response is List) {
|
||||
oneTimePasswords = response
|
||||
.map((item) => OfflinePasswordModel.fromJson(item))
|
||||
.toList();
|
||||
oneTimePasswords = response.map((item) => OfflinePasswordModel.fromJson(item)).toList();
|
||||
}
|
||||
emit(TemporaryPasswordsLoadedState(
|
||||
temporaryPassword: temporaryPasswords!));
|
||||
emit(TemporaryPasswordsLoadedState(temporaryPassword: temporaryPasswords!));
|
||||
} catch (e) {
|
||||
emit(FailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void getTimeLimitPasswords(
|
||||
InitialTimeLimitPassword event, Emitter<SmartDoorState> emit) async {
|
||||
void getTimeLimitPasswords(InitialTimeLimitPassword event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
var response = await DevicesAPI.getTimeLimitPasswords(deviceId);
|
||||
if (response is List) {
|
||||
timeLimitPasswords = response
|
||||
.map((item) => OfflinePasswordModel.fromJson(item))
|
||||
.toList();
|
||||
timeLimitPasswords = response.map((item) => OfflinePasswordModel.fromJson(item)).toList();
|
||||
}
|
||||
|
||||
emit(TemporaryPasswordsLoadedState(
|
||||
temporaryPassword: temporaryPasswords!));
|
||||
emit(TemporaryPasswordsLoadedState(temporaryPassword: temporaryPasswords!));
|
||||
} catch (e) {
|
||||
emit(FailedState(errorMessage: e.toString()));
|
||||
}
|
||||
@ -229,8 +207,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
return repeat;
|
||||
}
|
||||
|
||||
bool setStartEndTime(
|
||||
SetStartEndTimeEvent event, Emitter<SmartDoorState> emit) {
|
||||
bool setStartEndTime(SetStartEndTimeEvent event, Emitter<SmartDoorState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
isStartEndTime = event.val;
|
||||
emit(IsStartEndState(isStartEndTime: isStartEndTime));
|
||||
@ -253,8 +230,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||
}
|
||||
|
||||
Future<void> selectTimeOfLinePassword(
|
||||
SelectTimeEvent event, Emitter<SmartDoorState> emit) async {
|
||||
Future<void> selectTimeOfLinePassword(SelectTimeEvent event, Emitter<SmartDoorState> emit) async {
|
||||
emit(ChangeTimeState());
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: event.context,
|
||||
@ -284,27 +260,20 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000; // Divide by 1000 to remove milliseconds
|
||||
if (event.isEffective) {
|
||||
if (expirationTimeTimeStamp != null &&
|
||||
selectedTimestamp > expirationTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar(
|
||||
'Effective Time cannot be later than Expiration Time.');
|
||||
if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
|
||||
} else {
|
||||
effectiveTime = selectedDateTime
|
||||
.toString()
|
||||
.split('.')
|
||||
.first; // Remove seconds and milliseconds
|
||||
effectiveTime =
|
||||
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
||||
effectiveTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
} else {
|
||||
if (effectiveTimeTimeStamp != null &&
|
||||
selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar(
|
||||
'Expiration Time cannot be earlier than Effective Time.');
|
||||
} else {
|
||||
expirationTime = selectedDateTime
|
||||
.toString()
|
||||
.split('.')
|
||||
.first; // Remove seconds and milliseconds
|
||||
expirationTime =
|
||||
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
||||
expirationTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
}
|
||||
@ -360,27 +329,20 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000; // Divide by 1000 to remove milliseconds
|
||||
if (event.isEffective) {
|
||||
if (expirationTimeTimeStamp != null &&
|
||||
selectedTimestamp > expirationTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar(
|
||||
'Effective Time cannot be later than Expiration Time.');
|
||||
if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
|
||||
} else {
|
||||
effectiveTime = selectedDateTime
|
||||
.toString()
|
||||
.split('.')
|
||||
.first; // Remove seconds and milliseconds
|
||||
effectiveTime =
|
||||
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
||||
effectiveTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
} else {
|
||||
if (effectiveTimeTimeStamp != null &&
|
||||
selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar(
|
||||
'Expiration Time cannot be earlier than Effective Time.');
|
||||
} else {
|
||||
expirationTime = selectedDateTime
|
||||
.toString()
|
||||
.split('.')
|
||||
.first; // Remove seconds and milliseconds
|
||||
expirationTime =
|
||||
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
||||
expirationTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
}
|
||||
@ -389,8 +351,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> savePassword(
|
||||
SavePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
Future<void> savePassword(SavePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
if (_validateInputs() || isSavingPassword) return;
|
||||
try {
|
||||
isSavingPassword = true;
|
||||
@ -420,8 +381,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
|
||||
Future<void> generateAndSavePasswordTimeLimited(
|
||||
GenerateAndSavePasswordTimeLimitEvent event,
|
||||
Emitter<SmartDoorState> emit) async {
|
||||
GenerateAndSavePasswordTimeLimitEvent event, Emitter<SmartDoorState> emit) async {
|
||||
if (timeLimitValidate() || isSavingPassword) return;
|
||||
try {
|
||||
isSavingPassword = true;
|
||||
@ -447,12 +407,10 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deletePassword(
|
||||
DeletePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
Future<void> deletePassword(DeletePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
await DevicesAPI.deletePassword(
|
||||
deviceId: deviceId, passwordId: event.passwordId)
|
||||
await DevicesAPI.deletePassword(deviceId: deviceId, passwordId: event.passwordId)
|
||||
.then((value) async {
|
||||
add(InitialPasswordsPage());
|
||||
});
|
||||
@ -487,8 +445,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
|
||||
if (repeat == true && (endTime == null || startTime == null)) {
|
||||
CustomSnackBar.displaySnackBar(
|
||||
'Start Time and End time and the days required ');
|
||||
CustomSnackBar.displaySnackBar('Start Time and End time and the days required ');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -20,9 +20,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
on<WallSensorUpdatedEvent>(_wallSensorUpdated);
|
||||
}
|
||||
|
||||
void _fetchCeilingSensorStatus(
|
||||
InitialEvent event,
|
||||
Emitter<WallSensorState> emit) async {
|
||||
void _fetchCeilingSensorStatus(InitialEvent event, Emitter<WallSensorState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(deviceId);
|
||||
@ -41,18 +39,15 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) {
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = WallSensorModel.fromJson(statusList);
|
||||
@ -61,19 +56,15 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
_wallSensorUpdated(
|
||||
WallSensorUpdatedEvent event, Emitter<WallSensorState> emit) {
|
||||
_wallSensorUpdated(WallSensorUpdatedEvent event, Emitter<WallSensorState> emit) {
|
||||
emit(UpdateState(wallSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeIndicator(
|
||||
ChangeIndicatorEvent event, Emitter<WallSensorState> emit) async {
|
||||
void _changeIndicator(ChangeIndicatorEvent event, Emitter<WallSensorState> emit) async {
|
||||
emit(LoadingNewSate(wallSensorModel: deviceStatus));
|
||||
try {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: deviceId, code: 'indicator', value: !event.value),
|
||||
deviceId);
|
||||
DeviceControlModel(deviceId: deviceId, code: 'indicator', value: !event.value), deviceId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
deviceStatus.indicator = !event.value;
|
||||
@ -82,14 +73,11 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
emit(UpdateState(wallSensorModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeValue(
|
||||
ChangeValueEvent event, Emitter<WallSensorState> emit) async {
|
||||
void _changeValue(ChangeValueEvent event, Emitter<WallSensorState> emit) async {
|
||||
emit(LoadingNewSate(wallSensorModel: deviceStatus));
|
||||
try {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: deviceId, code: event.code, value: event.value),
|
||||
deviceId);
|
||||
DeviceControlModel(deviceId: deviceId, code: event.code, value: event.value), deviceId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
if (event.code == 'far_detection') {
|
||||
|
||||
@ -35,8 +35,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
List<ScheduleModel> listSchedule = [];
|
||||
DateTime? selectedTime = DateTime.now();
|
||||
|
||||
WaterHeaterBloc({required this.whId, required this.switchCode})
|
||||
: super(WHInitialState()) {
|
||||
WaterHeaterBloc({required this.whId, required this.switchCode}) : super(WHInitialState()) {
|
||||
on<WaterHeaterInitial>(_fetchWaterHeaterStatus);
|
||||
on<WaterHeaterSwitch>(_changeFirstSwitch);
|
||||
on<SetCounterValue>(_setCounterValue);
|
||||
@ -61,8 +60,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
on<WaterHeaterUpdated>(_waterHeaterUpdated);
|
||||
}
|
||||
|
||||
void _fetchWaterHeaterStatus(
|
||||
WaterHeaterInitial event, Emitter<WaterHeaterState> emit) async {
|
||||
void _fetchWaterHeaterStatus(WaterHeaterInitial event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(WHLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(whId);
|
||||
@ -83,21 +81,18 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$whId');
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$whId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = WHModel.fromJson(statusList);
|
||||
@ -108,14 +103,12 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
_waterHeaterUpdated(
|
||||
WaterHeaterUpdated event, Emitter<WaterHeaterState> emit) async {
|
||||
_waterHeaterUpdated(WaterHeaterUpdated event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(WHLoadingState());
|
||||
emit(UpdateState(whModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeFirstSwitch(
|
||||
WaterHeaterSwitch event, Emitter<WaterHeaterState> emit) async {
|
||||
void _changeFirstSwitch(WaterHeaterSwitch event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(LoadingNewSate(whModel: deviceStatus));
|
||||
try {
|
||||
deviceStatus.firstSwitch = !event.whSwitch;
|
||||
@ -125,10 +118,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
}
|
||||
_timer = Timer(const Duration(milliseconds: 500), () async {
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: whId,
|
||||
code: 'switch_1',
|
||||
value: deviceStatus.firstSwitch),
|
||||
DeviceControlModel(deviceId: whId, code: 'switch_1', value: deviceStatus.firstSwitch),
|
||||
whId);
|
||||
|
||||
if (!response['success']) {
|
||||
@ -142,16 +132,13 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
|
||||
//=====================---------- timer ----------------------------------------
|
||||
|
||||
void _setCounterValue(
|
||||
SetCounterValue event, Emitter<WaterHeaterState> emit) async {
|
||||
void _setCounterValue(SetCounterValue event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(LoadingNewSate(whModel: deviceStatus));
|
||||
int seconds = 0;
|
||||
try {
|
||||
seconds = event.duration.inSeconds;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: whId, code: event.deviceCode, value: seconds),
|
||||
whId);
|
||||
DeviceControlModel(deviceId: whId, code: event.deviceCode, value: seconds), whId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
if (event.deviceCode == 'countdown_1') {
|
||||
@ -173,8 +160,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _getCounterValue(
|
||||
GetCounterEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
void _getCounterValue(GetCounterEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(WHLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(whId);
|
||||
@ -264,8 +250,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
deviceId: whId,
|
||||
);
|
||||
List<dynamic> jsonData = response;
|
||||
listSchedule =
|
||||
jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
emit(WHInitialState());
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -276,13 +261,12 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
|
||||
int? getTimeStampWithoutSeconds(DateTime? dateTime) {
|
||||
if (dateTime == null) return null;
|
||||
DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month,
|
||||
dateTime.day, dateTime.hour, dateTime.minute);
|
||||
DateTime dateTimeWithoutSeconds =
|
||||
DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute);
|
||||
return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
Future toggleChange(
|
||||
ToggleScheduleEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
Future toggleChange(ToggleScheduleEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
try {
|
||||
emit(WHLoadingState());
|
||||
final response = await DevicesAPI.changeSchedule(
|
||||
@ -300,8 +284,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future deleteSchedule(
|
||||
DeleteScheduleEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
Future deleteSchedule(DeleteScheduleEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
try {
|
||||
emit(WHLoadingState());
|
||||
final response = await DevicesAPI.deleteSchedule(
|
||||
@ -320,8 +303,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleCreateCirculate(
|
||||
ToggleCreateCirculate event, Emitter<WaterHeaterState> emit) {
|
||||
void _toggleCreateCirculate(ToggleCreateCirculate event, Emitter<WaterHeaterState> emit) {
|
||||
emit(WHLoadingState());
|
||||
createCirculate = !createCirculate;
|
||||
selectedDays.clear();
|
||||
@ -329,15 +311,13 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
emit(UpdateCreateScheduleState(createCirculate));
|
||||
}
|
||||
|
||||
void toggleSelectedIndex(
|
||||
ToggleSelectedEvent event, Emitter<WaterHeaterState> emit) {
|
||||
void toggleSelectedIndex(ToggleSelectedEvent event, Emitter<WaterHeaterState> emit) {
|
||||
emit(WHLoadingState());
|
||||
selectedTabIndex = event.index;
|
||||
emit(ChangeSlidingSegmentState(value: selectedTabIndex));
|
||||
}
|
||||
|
||||
void toggleCreateSchedule(
|
||||
ToggleCreateScheduleEvent event, Emitter<WaterHeaterState> emit) {
|
||||
void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter<WaterHeaterState> emit) {
|
||||
emit(WHLoadingState());
|
||||
createSchedule = !createSchedule;
|
||||
selectedDays.clear();
|
||||
@ -386,8 +366,8 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
List<GroupWHModel> groupWaterHeaterList = [];
|
||||
bool allSwitchesOn = true;
|
||||
|
||||
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||
Emitter<WaterHeaterState> emit) async {
|
||||
void _changeFirstWizardSwitch(
|
||||
ChangeFirstWizardSwitchStatusEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(LoadingNewSate(whModel: deviceStatus));
|
||||
try {
|
||||
bool allSwitchesValue = true;
|
||||
@ -399,8 +379,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
allSwitchesValue = false;
|
||||
}
|
||||
});
|
||||
emit(UpdateGroupState(
|
||||
twoGangList: groupWaterHeaterList, allSwitches: allSwitchesValue));
|
||||
emit(UpdateGroupState(twoGangList: groupWaterHeaterList, allSwitches: allSwitchesValue));
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'switch_1',
|
||||
@ -415,8 +394,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _fetchWHWizardStatus(
|
||||
InitialWizardEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
void _fetchWHWizardStatus(InitialWizardEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(WHLoadingState());
|
||||
try {
|
||||
devicesList = [];
|
||||
@ -426,8 +404,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', 'WH');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
@ -449,27 +426,23 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
emit(UpdateGroupState(
|
||||
twoGangList: groupWaterHeaterList, allSwitches: allSwitchesOn));
|
||||
emit(UpdateGroupState(twoGangList: groupWaterHeaterList, allSwitches: allSwitchesOn));
|
||||
} catch (e) {
|
||||
// emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _groupAllOn(
|
||||
GroupAllOnEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
void _groupAllOn(GroupAllOnEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(LoadingNewSate(whModel: deviceStatus));
|
||||
try {
|
||||
for (int i = 0; i < groupWaterHeaterList.length; i++) {
|
||||
groupWaterHeaterList[i].firstSwitch = true;
|
||||
}
|
||||
|
||||
emit(UpdateGroupState(
|
||||
twoGangList: groupWaterHeaterList, allSwitches: true));
|
||||
emit(UpdateGroupState(twoGangList: groupWaterHeaterList, allSwitches: true));
|
||||
|
||||
List<String> allDeviceIds =
|
||||
groupWaterHeaterList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupWaterHeaterList.map((device) => device.deviceId).toList();
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'switch_1',
|
||||
@ -487,18 +460,15 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _groupAllOff(
|
||||
GroupAllOffEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
void _groupAllOff(GroupAllOffEvent event, Emitter<WaterHeaterState> emit) async {
|
||||
emit(LoadingNewSate(whModel: deviceStatus));
|
||||
try {
|
||||
for (int i = 0; i < groupWaterHeaterList.length; i++) {
|
||||
groupWaterHeaterList[i].firstSwitch = false;
|
||||
}
|
||||
emit(UpdateGroupState(
|
||||
twoGangList: groupWaterHeaterList, allSwitches: false));
|
||||
emit(UpdateGroupState(twoGangList: groupWaterHeaterList, allSwitches: false));
|
||||
|
||||
List<String> allDeviceIds =
|
||||
groupWaterHeaterList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds = groupWaterHeaterList.map((device) => device.deviceId).toList();
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'switch_1',
|
||||
|
||||
@ -22,6 +22,8 @@ class PowerClampCard extends StatelessWidget {
|
||||
final String? totalFactor;
|
||||
final Widget? dateSwitcher;
|
||||
final String? formattedDate;
|
||||
final String? phaseType;
|
||||
|
||||
final String? energyConsumption;
|
||||
final Function()? selectDateEvent;
|
||||
final List<EnergyData>? chartData;
|
||||
@ -37,6 +39,7 @@ class PowerClampCard extends StatelessWidget {
|
||||
this.totalCurrentGeneral,
|
||||
this.totalFrequencyGeneral,
|
||||
this.totalVoltage,
|
||||
this.phaseType,
|
||||
this.totalActive,
|
||||
this.totalFrequency,
|
||||
this.totalFactor,
|
||||
@ -53,8 +56,7 @@ class PowerClampCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
|
||||
padding: const EdgeInsets.only(left: 5, right: 5, top: 10, bottom: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@ -116,7 +118,7 @@ class PowerClampCard extends StatelessWidget {
|
||||
PowerClampInfoCard(
|
||||
iconPath: Assets.voltageIcon,
|
||||
title: 'Voltage',
|
||||
value: totalVoltage!,
|
||||
value: '${double.parse(totalVoltage!) / 10}',
|
||||
unit: ' V',
|
||||
),
|
||||
PowerClampInfoCard(
|
||||
@ -152,13 +154,15 @@ class PowerClampCard extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const BodyMedium(
|
||||
text: 'Total consumption',
|
||||
BodyMedium(
|
||||
text: isGeneral == true
|
||||
? 'Total consumption'
|
||||
: phaseType!,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
Text(
|
||||
dateTimeSelected !,
|
||||
dateTimeSelected!,
|
||||
style: const TextStyle(
|
||||
fontSize: 8, fontWeight: FontWeight.w400),
|
||||
),
|
||||
|
||||
@ -55,7 +55,6 @@ class _PowerClampPageState extends State<PowerClampPage> {
|
||||
child: BlocProvider(
|
||||
create: (context) => PowerClampBloc(PCId: widget.device?.uuid ?? '')
|
||||
..add(const PowerClampInitial()),
|
||||
// ..add(const ReportLogsInitial(code: 'VoltageA')),
|
||||
child: BlocBuilder<PowerClampBloc, PowerClampState>(
|
||||
builder: (context, state) {
|
||||
final blocProvider = context.read<PowerClampBloc>();
|
||||
@ -88,6 +87,7 @@ class _PowerClampPageState extends State<PowerClampPage> {
|
||||
},
|
||||
child: PageView(controller: _pageController, children: [
|
||||
_buildPowerClampCard(
|
||||
phaseType: '',
|
||||
title: 'Total Energy \nConsumption',
|
||||
phase: model.status.general,
|
||||
isGeneral: true,
|
||||
@ -96,18 +96,21 @@ class _PowerClampPageState extends State<PowerClampPage> {
|
||||
),
|
||||
_buildPowerClampCard(
|
||||
title: 'Phase A Energy \nConsumption',
|
||||
phaseType: 'Phase A consumption',
|
||||
phase: model.status.phaseA,
|
||||
chartData: chartData,
|
||||
blocProvider: blocProvider,
|
||||
),
|
||||
_buildPowerClampCard(
|
||||
title: 'Phase B Energy \nConsumption',
|
||||
phaseType: 'Phase B consumption',
|
||||
phase: model.status.phaseB,
|
||||
chartData: chartData,
|
||||
blocProvider: blocProvider,
|
||||
),
|
||||
_buildPowerClampCard(
|
||||
title: 'Phase C Energy \nConsumption',
|
||||
phaseType: 'Phase C consumption',
|
||||
phase: model.status.phaseC,
|
||||
chartData: chartData,
|
||||
blocProvider: blocProvider,
|
||||
@ -154,6 +157,7 @@ class _PowerClampPageState extends State<PowerClampPage> {
|
||||
List<EnergyData> chartData, PowerClampBloc blocProvider) {
|
||||
return [
|
||||
_buildPowerClampCard(
|
||||
phaseType: '',
|
||||
title: 'Total Energy \nConsumption',
|
||||
phase: model.status.general,
|
||||
isGeneral: true,
|
||||
@ -161,18 +165,21 @@ class _PowerClampPageState extends State<PowerClampPage> {
|
||||
blocProvider: blocProvider,
|
||||
),
|
||||
_buildPowerClampCard(
|
||||
phaseType: 'Phase A consumption',
|
||||
title: 'Phase A Energy \nConsumption',
|
||||
phase: model.status.phaseA,
|
||||
chartData: chartData,
|
||||
blocProvider: blocProvider,
|
||||
),
|
||||
_buildPowerClampCard(
|
||||
phaseType: 'Phase B consumption',
|
||||
title: 'Phase B Energy \nConsumption',
|
||||
phase: model.status.phaseB,
|
||||
chartData: chartData,
|
||||
blocProvider: blocProvider,
|
||||
),
|
||||
_buildPowerClampCard(
|
||||
phaseType: 'Phase C consumption',
|
||||
title: 'Phase C Energy \nConsumption',
|
||||
phase: model.status.phaseC,
|
||||
chartData: chartData,
|
||||
@ -183,15 +190,18 @@ class _PowerClampPageState extends State<PowerClampPage> {
|
||||
|
||||
Widget _buildPowerClampCard({
|
||||
required String title,
|
||||
required String phaseType,
|
||||
required Phase phase,
|
||||
bool isGeneral = false,
|
||||
required List<EnergyData> chartData,
|
||||
required PowerClampBloc blocProvider,
|
||||
}) {
|
||||
return PowerClampCard(
|
||||
dateTimeSelected:blocProvider.formattedDate,
|
||||
dateTimeSelected:
|
||||
'${blocProvider.dateTime!.day}/${blocProvider.dateTime!.month}/${blocProvider.dateTime!.year} ${blocProvider.endChartDate}',
|
||||
energyConsumption: _getValueOrNA(phase.dataPoints, isGeneral ? 0 : 5),
|
||||
title: title,
|
||||
phaseType: phaseType,
|
||||
isGeneral: isGeneral,
|
||||
dateSwitcher: blocProvider.dateSwitcher(),
|
||||
formattedDate: blocProvider.formattedDate,
|
||||
|
||||
@ -21,53 +21,50 @@ class PowerClampInfoCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: DefaultContainer(
|
||||
height: 55,
|
||||
color: ColorsManager.grayBox,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SvgPicture.asset(
|
||||
iconPath,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
child: DefaultContainer(
|
||||
height: 55,
|
||||
color: ColorsManager.grayBox,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SvgPicture.asset(
|
||||
iconPath,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 8,
|
||||
text: title,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15,
|
||||
text: value,
|
||||
),
|
||||
BodyMedium(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 8,
|
||||
text: unit,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 8,
|
||||
text: title,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15,
|
||||
text: value,
|
||||
),
|
||||
BodyMedium(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 8,
|
||||
text: unit,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@ -67,21 +67,40 @@ class _RoomPageState extends State<RoomPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: GridView.builder(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
childAspectRatio: 1.5,
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
itemCount: _filteredDevices.length,
|
||||
itemBuilder: (context, index) {
|
||||
return RoomPageSwitch(device: _filteredDevices[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
_filteredDevices.isNotEmpty
|
||||
? Expanded(
|
||||
child: GridView.builder(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
childAspectRatio: 1.5,
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
itemCount: _filteredDevices.length,
|
||||
itemBuilder: (context, index) {
|
||||
return RoomPageSwitch(device: _filteredDevices[index]);
|
||||
},
|
||||
),
|
||||
)
|
||||
: widget.room.devices!.isNotEmpty
|
||||
? const Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
'No Results Found',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ class RoomsSlider extends StatelessWidget {
|
||||
onPageChanged: (index) {
|
||||
HomeCubit.getInstance().roomSliderPageChanged(index);
|
||||
},
|
||||
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
@ -45,15 +44,20 @@ class RoomsSlider extends StatelessWidget {
|
||||
(room) => InkWell(
|
||||
onTap: () {
|
||||
HomeCubit.getInstance().roomSliderPageChanged(
|
||||
HomeCubit.getInstance().selectedSpace!.rooms!.indexOf(room));
|
||||
HomeCubit.getInstance()
|
||||
.selectedSpace!
|
||||
.rooms!
|
||||
.indexOf(room));
|
||||
},
|
||||
child: TitleMedium(
|
||||
text: room.name!,
|
||||
style: context.titleMedium.copyWith(
|
||||
fontSize: 25,
|
||||
color: HomeCubit.getInstance().selectedRoom == room
|
||||
? ColorsManager.textPrimaryColor
|
||||
: ColorsManager.textPrimaryColor.withOpacity(.2),
|
||||
color:
|
||||
HomeCubit.getInstance().selectedRoom == room
|
||||
? ColorsManager.textPrimaryColor
|
||||
: ColorsManager.textPrimaryColor
|
||||
.withOpacity(.2),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@ -40,13 +40,10 @@ class SceneListview extends StatelessWidget {
|
||||
sceneName: scene.name,
|
||||
),
|
||||
);
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneClearEvent());
|
||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||
|
||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||
FetchSceneTasksEvent(
|
||||
sceneId: scene.id, isAutomation: false));
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||
|
||||
/// the state to set the scene type must be after the fetch
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
@ -59,11 +56,13 @@ class SceneListview extends StatelessWidget {
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset(
|
||||
child: Image.memory(
|
||||
height: 32,
|
||||
width: 32,
|
||||
Assets.assetsIconsLogo,
|
||||
scene.iconInBytes,
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) => Image.asset(
|
||||
height: 32, width: 32, fit: BoxFit.fill, Assets.assetsIconsLogo),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
|
||||
@ -35,7 +35,7 @@ class WizardPage extends StatelessWidget {
|
||||
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return ListView(
|
||||
return Column(
|
||||
children: [
|
||||
if (groupsList.isNotEmpty)
|
||||
TextFormField(
|
||||
@ -64,129 +64,170 @@ class WizardPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
GridView.builder(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
childAspectRatio: 1.5,
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: _filteredGroups.length,
|
||||
itemBuilder: (_, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (_filteredGroups[index].name == 'AC') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const ACsView()));
|
||||
}
|
||||
if (_filteredGroups[index].name == '3G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const ThreeGangWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == '2G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const TwoGangWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == '1G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const OneGangWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == 'WH') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const WHWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == '1GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const OneTouchWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == '2GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const TwoTouchWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == '3GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const ThreeTouchWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == 'GD') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const GarageWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == 'CUR') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const CurtainsWizard()));
|
||||
}
|
||||
},
|
||||
child: DefaultContainer(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
_filteredGroups.isNotEmpty
|
||||
? Expanded(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
_filteredGroups[index].icon!,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
],
|
||||
),
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: BodyLarge(
|
||||
text: _filteredGroups[index].name!,
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 0,
|
||||
fontSize: 20,
|
||||
color: Colors.grey,
|
||||
),
|
||||
GridView.builder(
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
childAspectRatio: 1.5,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: _filteredGroups.length,
|
||||
itemBuilder: (_, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (_filteredGroups[index].name == 'AC') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const ACsView()));
|
||||
}
|
||||
if (_filteredGroups[index].name == '3G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const ThreeGangWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == '2G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const TwoGangWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == '1G') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const OneGangWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == 'WH') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const WHWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == '1GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const OneTouchWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == '2GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const TwoTouchWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == '3GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const ThreeTouchWizard()));
|
||||
}
|
||||
|
||||
if (_filteredGroups[index].name == 'GD') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const GarageWizard()));
|
||||
}
|
||||
if (_filteredGroups[index].name == 'CUR') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1,
|
||||
animation2) =>
|
||||
const CurtainsWizard()));
|
||||
}
|
||||
},
|
||||
child: DefaultContainer(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
_filteredGroups[index].icon!,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
],
|
||||
),
|
||||
FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: BodyLarge(
|
||||
text: _filteredGroups[index].name!,
|
||||
style: context.bodyLarge.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 0,
|
||||
fontSize: 20,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: const Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
'No Results Found',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
@ -10,6 +9,7 @@ import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_automation_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/icon_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
@ -36,6 +36,10 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
on<SelectConditionEvent>(_selectConditionRule);
|
||||
on<SceneTypeEvent>(_sceneTypeEvent);
|
||||
on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent);
|
||||
on<SceneIconEvent>(_fetchIconScene);
|
||||
on<IconSelected>(_iconSelected);
|
||||
on<ShowOnDeviceClicked>(_showInDeviceClicked);
|
||||
on<ClearTabToRunSetting>(_clearTabToRunSetting);
|
||||
}
|
||||
|
||||
CreateSceneEnum sceneType = CreateSceneEnum.none;
|
||||
@ -52,6 +56,9 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
final Map<String, String> automationComparatorValues = {};
|
||||
String conditionRule = 'or';
|
||||
EffectiveTime? effectiveTime;
|
||||
List<IconModel> iconModelList = [];
|
||||
String selectedIcon = '';
|
||||
bool showInDeviceScreen = false;
|
||||
|
||||
FutureOr<void> _onAddSceneTask(AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
@ -350,6 +357,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
automationTempTasksList.clear();
|
||||
automationSelectedValues.clear();
|
||||
automationComparatorValues.clear();
|
||||
selectedIcon = '';
|
||||
showInDeviceScreen = false;
|
||||
effectiveTime = EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
sceneType = CreateSceneEnum.none;
|
||||
conditionRule = 'or';
|
||||
@ -380,6 +389,19 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
}
|
||||
|
||||
FutureOr<void> _clearTabToRunSetting(ClearTabToRunSetting event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
selectedIcon = '';
|
||||
showInDeviceScreen = false;
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
automationTasksList: automationTasksList,
|
||||
condition: conditionRule,
|
||||
showInDevice: showInDeviceScreen,
|
||||
selectedIcon: selectedIcon,
|
||||
iconModels: iconModelList));
|
||||
}
|
||||
|
||||
FutureOr<void> _fetchSceneTasks(
|
||||
FetchSceneTasksEvent event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
@ -392,6 +414,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
automationTempTasksList.clear();
|
||||
automationSelectedValues.clear();
|
||||
automationComparatorValues.clear();
|
||||
selectedIcon = '';
|
||||
showInDeviceScreen = false;
|
||||
effectiveTime = EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
sceneType = CreateSceneEnum.none;
|
||||
conditionRule = 'or';
|
||||
@ -425,17 +449,23 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
.add(SetCustomTime(effectiveTime!.start, effectiveTime!.end));
|
||||
|
||||
emit(AddSceneTask(
|
||||
automationTasksList: automationTasksList,
|
||||
tasksList: tasksList,
|
||||
condition: conditionRule,
|
||||
));
|
||||
automationTasksList: automationTasksList,
|
||||
tasksList: tasksList,
|
||||
condition: conditionRule,
|
||||
iconModels: iconModelList,
|
||||
selectedIcon: selectedIcon,
|
||||
showInDevice: showInDeviceScreen));
|
||||
} else {
|
||||
tasksList = List<SceneStaticFunction>.from(
|
||||
getTaskListFunctionsFromApi(actions: response.actions, isAutomation: false));
|
||||
selectedIcon = response.icon!;
|
||||
showInDeviceScreen = response.showInDevice!;
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
condition: conditionRule,
|
||||
));
|
||||
tasksList: tasksList,
|
||||
condition: conditionRule,
|
||||
iconModels: iconModelList,
|
||||
selectedIcon: selectedIcon,
|
||||
showInDevice: showInDeviceScreen));
|
||||
}
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
@ -445,6 +475,57 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _fetchIconScene(SceneIconEvent event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
try {
|
||||
iconModelList = await SceneApi.getIcon();
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
automationTasksList: automationTasksList,
|
||||
condition: conditionRule,
|
||||
showInDevice: showInDeviceScreen,
|
||||
selectedIcon: selectedIcon,
|
||||
iconModels: iconModelList));
|
||||
} catch (e) {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _iconSelected(IconSelected event, Emitter<CreateSceneState> emit) async {
|
||||
try {
|
||||
if (event.confirmSelection) {
|
||||
selectedIcon = event.iconId;
|
||||
}
|
||||
emit(CreateSceneLoading());
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
automationTasksList: automationTasksList,
|
||||
showInDevice: showInDeviceScreen,
|
||||
condition: conditionRule,
|
||||
selectedIcon: event.iconId,
|
||||
iconModels: iconModelList));
|
||||
} catch (e) {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _showInDeviceClicked(
|
||||
ShowOnDeviceClicked event, Emitter<CreateSceneState> emit) async {
|
||||
try {
|
||||
emit(CreateSceneLoading());
|
||||
showInDeviceScreen = event.value;
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
automationTasksList: automationTasksList,
|
||||
condition: conditionRule,
|
||||
selectedIcon: selectedIcon,
|
||||
iconModels: iconModelList,
|
||||
showInDevice: showInDeviceScreen));
|
||||
} catch (e) {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
String _getDayFromIndex(int index) {
|
||||
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
return days[index];
|
||||
|
||||
@ -149,8 +149,7 @@ class FetchSceneTasksEvent extends CreateSceneEvent {
|
||||
final String sceneId;
|
||||
final bool isAutomation;
|
||||
|
||||
const FetchSceneTasksEvent(
|
||||
{this.isAutomation = false, required this.sceneId});
|
||||
const FetchSceneTasksEvent({this.isAutomation = false, required this.sceneId});
|
||||
|
||||
@override
|
||||
List<Object> get props => [sceneId, isAutomation];
|
||||
@ -183,3 +182,33 @@ class EffectiveTimePeriodEvent extends CreateSceneEvent {
|
||||
final EffectiveTime period;
|
||||
const EffectiveTimePeriodEvent(this.period);
|
||||
}
|
||||
|
||||
class SceneIconEvent extends CreateSceneEvent {}
|
||||
|
||||
class IconSelected extends CreateSceneEvent {
|
||||
final String iconId;
|
||||
final bool confirmSelection;
|
||||
|
||||
const IconSelected({required this.iconId, required this.confirmSelection});
|
||||
|
||||
@override
|
||||
List<Object> get props => [iconId];
|
||||
}
|
||||
|
||||
class ShowOnDeviceClicked extends CreateSceneEvent {
|
||||
final bool value;
|
||||
|
||||
const ShowOnDeviceClicked({
|
||||
required this.value,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [value];
|
||||
}
|
||||
|
||||
class ClearTabToRunSetting extends CreateSceneEvent {
|
||||
const ClearTabToRunSetting();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
@ -23,8 +23,16 @@ class AddSceneTask extends CreateSceneState {
|
||||
final List<SceneStaticFunction> tasksList;
|
||||
final List<SceneStaticFunction>? automationTasksList;
|
||||
final String? condition;
|
||||
final String? selectedIcon;
|
||||
final List<IconModel>? iconModels;
|
||||
final bool? showInDevice;
|
||||
const AddSceneTask(
|
||||
{required this.tasksList, this.automationTasksList, this.condition});
|
||||
{required this.tasksList,
|
||||
this.automationTasksList,
|
||||
this.condition,
|
||||
this.iconModels,
|
||||
this.selectedIcon,
|
||||
this.showInDevice});
|
||||
|
||||
@override
|
||||
List<Object> get props => [tasksList];
|
||||
@ -33,8 +41,7 @@ class AddSceneTask extends CreateSceneState {
|
||||
class TempHoldSceneTask extends CreateSceneState {
|
||||
final List<SceneStaticFunction> tempTasksList;
|
||||
final List<SceneStaticFunction>? automationTempTasksList;
|
||||
const TempHoldSceneTask(
|
||||
{required this.tempTasksList, this.automationTempTasksList});
|
||||
const TempHoldSceneTask({required this.tempTasksList, this.automationTempTasksList});
|
||||
|
||||
@override
|
||||
List<Object> get props => [tempTasksList];
|
||||
|
||||
@ -24,7 +24,7 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
||||
|
||||
try {
|
||||
if (event.unitId.isNotEmpty) {
|
||||
scenes = await SceneApi.getScenesByUnitId(event.unitId);
|
||||
scenes = await SceneApi.getScenesByUnitId(event.unitId, showInDevice: event.showInDevice);
|
||||
emit(SceneLoaded(scenes, automationList));
|
||||
} else {
|
||||
emit(const SceneError(message: 'Unit ID is empty'));
|
||||
@ -34,8 +34,7 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadAutomation(
|
||||
LoadAutomation event, Emitter<SceneState> emit) async {
|
||||
Future<void> _onLoadAutomation(LoadAutomation event, Emitter<SceneState> emit) async {
|
||||
emit(SceneLoading());
|
||||
|
||||
try {
|
||||
@ -50,8 +49,7 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSceneTrigger(
|
||||
SceneTrigger event, Emitter<SceneState> emit) async {
|
||||
Future<void> _onSceneTrigger(SceneTrigger event, Emitter<SceneState> emit) async {
|
||||
final currentState = state;
|
||||
if (currentState is SceneLoaded) {
|
||||
emit(SceneLoaded(
|
||||
@ -78,9 +76,8 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
||||
UpdateAutomationStatus event, Emitter<SceneState> emit) async {
|
||||
final currentState = state;
|
||||
if (currentState is SceneLoaded) {
|
||||
final newLoadingStates =
|
||||
Map<String, bool>.from(currentState.loadingStates)
|
||||
..[event.automationId] = true;
|
||||
final newLoadingStates = Map<String, bool>.from(currentState.loadingStates)
|
||||
..[event.automationId] = true;
|
||||
|
||||
emit(SceneLoaded(
|
||||
currentState.scenes,
|
||||
@ -89,11 +86,11 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
||||
));
|
||||
|
||||
try {
|
||||
final success = await SceneApi.updateAutomationStatus(
|
||||
event.automationId, event.automationStatusUpdate);
|
||||
final success =
|
||||
await SceneApi.updateAutomationStatus(event.automationId, event.automationStatusUpdate);
|
||||
if (success) {
|
||||
automationList = await SceneApi.getAutomationByUnitId(
|
||||
event.automationStatusUpdate.unitUuid);
|
||||
automationList =
|
||||
await SceneApi.getAutomationByUnitId(event.automationStatusUpdate.unitUuid);
|
||||
newLoadingStates[event.automationId] = false;
|
||||
emit(SceneLoaded(
|
||||
currentState.scenes,
|
||||
|
||||
@ -10,11 +10,12 @@ abstract class SceneEvent extends Equatable {
|
||||
|
||||
class LoadScenes extends SceneEvent {
|
||||
final String unitId;
|
||||
final bool showInDevice;
|
||||
|
||||
const LoadScenes(this.unitId);
|
||||
const LoadScenes(this.unitId, {this.showInDevice = false});
|
||||
|
||||
@override
|
||||
List<Object> get props => [unitId];
|
||||
List<Object> get props => [unitId, showInDevice];
|
||||
}
|
||||
|
||||
class LoadAutomation extends SceneEvent {
|
||||
@ -41,8 +42,7 @@ class UpdateAutomationStatus extends SceneEvent {
|
||||
final String automationId;
|
||||
final AutomationStatusUpdate automationStatusUpdate;
|
||||
|
||||
const UpdateAutomationStatus(
|
||||
{required this.automationStatusUpdate, required this.automationId});
|
||||
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId});
|
||||
|
||||
@override
|
||||
List<Object> get props => [automationStatusUpdate];
|
||||
|
||||
@ -125,6 +125,8 @@ mixin SceneLogicHelper {
|
||||
} else {
|
||||
final createSceneModel = CreateSceneModel(
|
||||
unitUuid: HomeCubit.getInstance().selectedSpace!.id ?? '',
|
||||
iconId: sceneBloc.selectedIcon,
|
||||
showInDevice: sceneBloc.showInDeviceScreen,
|
||||
sceneName: sceneName.text,
|
||||
decisionExpr: 'and',
|
||||
actions: [
|
||||
@ -171,24 +173,21 @@ mixin SceneLogicHelper {
|
||||
}
|
||||
}
|
||||
|
||||
Widget getTheCorrectDialogBody(
|
||||
SceneStaticFunction taskItem, dynamic functionValue,
|
||||
Widget getTheCorrectDialogBody(SceneStaticFunction taskItem, dynamic functionValue,
|
||||
{required bool isAutomation}) {
|
||||
if (taskItem.operationDialogType == OperationDialogType.temperature) {
|
||||
return AlertDialogTemperatureBody(
|
||||
taskItem: taskItem,
|
||||
functionValue: functionValue ?? taskItem.functionValue,
|
||||
);
|
||||
} else if ((taskItem.operationDialogType ==
|
||||
OperationDialogType.countdown) ||
|
||||
} else if ((taskItem.operationDialogType == OperationDialogType.countdown) ||
|
||||
(taskItem.operationDialogType == OperationDialogType.delay)) {
|
||||
return AlertDialogCountdown(
|
||||
durationValue: taskItem.functionValue ?? 0,
|
||||
functionValue: functionValue ?? taskItem.functionValue,
|
||||
function: taskItem,
|
||||
);
|
||||
} else if (taskItem.operationDialogType ==
|
||||
OperationDialogType.integerSteps) {
|
||||
} else if (taskItem.operationDialogType == OperationDialogType.integerSteps) {
|
||||
return AlertDialogSliderSteps(
|
||||
taskItem: taskItem,
|
||||
functionValue: functionValue ?? taskItem.functionValue,
|
||||
|
||||
@ -4,12 +4,16 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class CreateSceneModel {
|
||||
String unitUuid;
|
||||
String iconId;
|
||||
bool showInDevice;
|
||||
String sceneName;
|
||||
String decisionExpr;
|
||||
List<CreateSceneAction> actions;
|
||||
|
||||
CreateSceneModel({
|
||||
required this.unitUuid,
|
||||
required this.iconId,
|
||||
required this.showInDevice,
|
||||
required this.sceneName,
|
||||
required this.decisionExpr,
|
||||
required this.actions,
|
||||
@ -17,12 +21,16 @@ class CreateSceneModel {
|
||||
|
||||
CreateSceneModel copyWith({
|
||||
String? unitUuid,
|
||||
String? iconId,
|
||||
bool? showInDevice,
|
||||
String? sceneName,
|
||||
String? decisionExpr,
|
||||
List<CreateSceneAction>? actions,
|
||||
}) {
|
||||
return CreateSceneModel(
|
||||
unitUuid: unitUuid ?? this.unitUuid,
|
||||
iconId: iconId ?? this.iconId,
|
||||
showInDevice: showInDevice ?? this.showInDevice,
|
||||
sceneName: sceneName ?? this.sceneName,
|
||||
decisionExpr: decisionExpr ?? this.decisionExpr,
|
||||
actions: actions ?? this.actions,
|
||||
@ -32,6 +40,8 @@ class CreateSceneModel {
|
||||
Map<String, dynamic> toMap([String? sceneId]) {
|
||||
return {
|
||||
if (sceneId == null) 'unitUuid': unitUuid,
|
||||
if (iconId.isNotEmpty) 'iconUuid': iconId,
|
||||
'showInHomePage': showInDevice,
|
||||
'sceneName': sceneName,
|
||||
'decisionExpr': decisionExpr,
|
||||
'actions': actions.map((x) => x.toMap()).toList(),
|
||||
@ -41,17 +51,18 @@ class CreateSceneModel {
|
||||
factory CreateSceneModel.fromMap(Map<String, dynamic> map) {
|
||||
return CreateSceneModel(
|
||||
unitUuid: map['unitUuid'] ?? '',
|
||||
iconId: map['iconUuid'] ?? '',
|
||||
showInDevice: map['showInHomePage'] ?? false,
|
||||
sceneName: map['sceneName'] ?? '',
|
||||
decisionExpr: map['decisionExpr'] ?? '',
|
||||
actions: List<CreateSceneAction>.from(
|
||||
map['actions']?.map((x) => CreateSceneAction.fromMap(x))),
|
||||
actions:
|
||||
List<CreateSceneAction>.from(map['actions']?.map((x) => CreateSceneAction.fromMap(x))),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson([String? sceneId]) => json.encode(toMap(sceneId));
|
||||
|
||||
factory CreateSceneModel.fromJson(String source) =>
|
||||
CreateSceneModel.fromMap(json.decode(source));
|
||||
factory CreateSceneModel.fromJson(String source) => CreateSceneModel.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -64,6 +75,8 @@ class CreateSceneModel {
|
||||
|
||||
return other is CreateSceneModel &&
|
||||
other.unitUuid == unitUuid &&
|
||||
other.iconId == iconId &&
|
||||
other.showInDevice == showInDevice &&
|
||||
other.sceneName == sceneName &&
|
||||
other.decisionExpr == decisionExpr &&
|
||||
listEquals(other.actions, actions);
|
||||
@ -71,10 +84,7 @@ class CreateSceneModel {
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return unitUuid.hashCode ^
|
||||
sceneName.hashCode ^
|
||||
decisionExpr.hashCode ^
|
||||
actions.hashCode;
|
||||
return unitUuid.hashCode ^ sceneName.hashCode ^ decisionExpr.hashCode ^ actions.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,8 +130,7 @@ class CreateSceneAction {
|
||||
return CreateSceneAction(
|
||||
entityId: map['entityId'] ?? '',
|
||||
actionExecutor: map['actionExecutor'] ?? '',
|
||||
executorProperty:
|
||||
CreateSceneExecutorProperty.fromMap(map['executorProperty']),
|
||||
executorProperty: CreateSceneExecutorProperty.fromMap(map['executorProperty']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -145,8 +154,7 @@ class CreateSceneAction {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
entityId.hashCode ^ actionExecutor.hashCode ^ executorProperty.hashCode;
|
||||
int get hashCode => entityId.hashCode ^ actionExecutor.hashCode ^ executorProperty.hashCode;
|
||||
}
|
||||
|
||||
class CreateSceneExecutorProperty {
|
||||
@ -210,6 +218,5 @@ class CreateSceneExecutorProperty {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
functionCode.hashCode ^ functionValue.hashCode ^ delaySeconds.hashCode;
|
||||
int get hashCode => functionCode.hashCode ^ functionValue.hashCode ^ delaySeconds.hashCode;
|
||||
}
|
||||
|
||||
39
lib/features/scene/model/icon_model.dart
Normal file
39
lib/features/scene/model/icon_model.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
class IconModel {
|
||||
final String uuid;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String iconBase64;
|
||||
|
||||
IconModel({
|
||||
required this.uuid,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.iconBase64,
|
||||
});
|
||||
|
||||
// Method to decode the icon from Base64 and return as Uint8List
|
||||
Uint8List get iconBytes => base64Decode(iconBase64);
|
||||
|
||||
// Factory constructor to create an instance from JSON
|
||||
factory IconModel.fromJson(Map<String, dynamic> json) {
|
||||
return IconModel(
|
||||
uuid: json['uuid'] as String,
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||
iconBase64: json['icon'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
// Method to convert an instance back to JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'uuid': uuid,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
'icon': iconBase64,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,8 @@ class SceneDetailsModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String status;
|
||||
final String? icon;
|
||||
final bool? showInDevice;
|
||||
final String type;
|
||||
final List<Action> actions;
|
||||
final List<Condition>? conditions;
|
||||
@ -16,37 +18,35 @@ class SceneDetailsModel {
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.actions,
|
||||
this.icon,
|
||||
this.showInDevice,
|
||||
this.conditions,
|
||||
this.decisionExpr,
|
||||
this.effectiveTime,
|
||||
});
|
||||
|
||||
factory SceneDetailsModel.fromRawJson(String str) =>
|
||||
SceneDetailsModel.fromJson(json.decode(str));
|
||||
factory SceneDetailsModel.fromRawJson(String str) => SceneDetailsModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) =>
|
||||
SceneDetailsModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: json["status"],
|
||||
type: json["type"],
|
||||
actions: (json["actions"] as List)
|
||||
.map((x) => Action.fromJson(x))
|
||||
.where((x) => x != null)
|
||||
.toList()
|
||||
.cast<Action>(),
|
||||
conditions: json["conditions"] != null
|
||||
? (json["conditions"] as List)
|
||||
.map((x) => Condition.fromJson(x))
|
||||
.toList()
|
||||
: null,
|
||||
decisionExpr: json["decisionExpr"],
|
||||
effectiveTime: json["effectiveTime"] != null
|
||||
? EffectiveTime.fromJson(json["effectiveTime"])
|
||||
: null,
|
||||
);
|
||||
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) => SceneDetailsModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: json["status"],
|
||||
type: json["type"],
|
||||
actions: (json["actions"] as List)
|
||||
.map((x) => Action.fromJson(x))
|
||||
.where((x) => x != null)
|
||||
.toList()
|
||||
.cast<Action>(),
|
||||
conditions: json["conditions"] != null
|
||||
? (json["conditions"] as List).map((x) => Condition.fromJson(x)).toList()
|
||||
: null,
|
||||
decisionExpr: json["decisionExpr"],
|
||||
effectiveTime:
|
||||
json["effectiveTime"] != null ? EffectiveTime.fromJson(json["effectiveTime"]) : null,
|
||||
icon: json["iconUuid"] != null ? json["iconUuid"] ?? '' : '',
|
||||
showInDevice: json['showInHome'] != null ? json['showInHome'] ?? false : false);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
@ -54,9 +54,8 @@ class SceneDetailsModel {
|
||||
"status": status,
|
||||
"type": type,
|
||||
"actions": List<dynamic>.from(actions.map((x) => x.toJson())),
|
||||
"conditions": conditions != null
|
||||
? List<dynamic>.from(conditions!.map((x) => x.toJson()))
|
||||
: null,
|
||||
"conditions":
|
||||
conditions != null ? List<dynamic>.from(conditions!.map((x) => x.toJson())) : null,
|
||||
"decisionExpr": decisionExpr,
|
||||
"effectiveTime": effectiveTime?.toJson(),
|
||||
};
|
||||
@ -89,7 +88,7 @@ class Action {
|
||||
);
|
||||
}
|
||||
if (json["executorProperty"] == null) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
return Action(
|
||||
@ -117,8 +116,7 @@ class ExecutorProperty {
|
||||
this.delaySeconds,
|
||||
});
|
||||
|
||||
factory ExecutorProperty.fromJson(Map<String, dynamic> json) =>
|
||||
ExecutorProperty(
|
||||
factory ExecutorProperty.fromJson(Map<String, dynamic> json) => ExecutorProperty(
|
||||
functionCode: json["functionCode"] ?? '',
|
||||
functionValue: json["functionValue"] ?? '',
|
||||
delaySeconds: json["delaySeconds"] ?? 0,
|
||||
@ -144,8 +142,7 @@ class Condition {
|
||||
required this.expr,
|
||||
});
|
||||
|
||||
factory Condition.fromRawJson(String str) =>
|
||||
Condition.fromJson(json.decode(str));
|
||||
factory Condition.fromRawJson(String str) => Condition.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
@ -203,8 +200,7 @@ class EffectiveTime {
|
||||
required this.loops,
|
||||
});
|
||||
|
||||
factory EffectiveTime.fromRawJson(String str) =>
|
||||
EffectiveTime.fromJson(json.decode(str));
|
||||
factory EffectiveTime.fromRawJson(String str) => EffectiveTime.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
|
||||
@ -1,29 +1,31 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
class ScenesModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String status;
|
||||
final String type;
|
||||
final String icon;
|
||||
|
||||
ScenesModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
});
|
||||
ScenesModel(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.icon});
|
||||
|
||||
factory ScenesModel.fromRawJson(String str) =>
|
||||
ScenesModel.fromJson(json.decode(str));
|
||||
factory ScenesModel.fromRawJson(String str) => ScenesModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
Uint8List get iconInBytes => base64Decode(icon);
|
||||
|
||||
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||
id: json["id"],
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
);
|
||||
id: json["id"],
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
icon: json["icon"] ?? '');
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/view/scene_tasks_view.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/icons_dialog.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/delete_routine_b.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.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/color_manager.dart';
|
||||
|
||||
@ -22,72 +25,265 @@ class SceneAutoSettings extends StatelessWidget {
|
||||
final isAutomation = context.read<CreateSceneBloc>().sceneType ==
|
||||
CreateSceneEnum.deviceStatusChanges;
|
||||
final sceneName = sceneSettings['sceneName'] as String? ?? '';
|
||||
|
||||
bool showInDevice = context.read<CreateSceneBloc>().showInDeviceScreen;
|
||||
String selectedIcon = '';
|
||||
return DefaultScaffold(
|
||||
title: 'Settings',
|
||||
padding: EdgeInsets.zero,
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.arrow_back_ios,
|
||||
)),
|
||||
child: SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: DefaultContainer(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
title: 'Settings',
|
||||
padding: EdgeInsets.zero,
|
||||
leading: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.arrow_back_ios,
|
||||
)),
|
||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is AddSceneTask) {
|
||||
showInDevice = state.showInDevice ?? false;
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: Column(
|
||||
children: [
|
||||
if (!isAutomation)
|
||||
DefaultContainer(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10, left: 10, right: 10, bottom: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(SceneIconEvent());
|
||||
return IconsDialog(
|
||||
widgetList: Container(
|
||||
height:
|
||||
MediaQuery.sizeOf(context).height * 0.4,
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: BlocBuilder<CreateSceneBloc,
|
||||
CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is CreateSceneLoading) {
|
||||
return const Center(
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
width: 50,
|
||||
child:
|
||||
CircularProgressIndicator()),
|
||||
);
|
||||
} else if (state is AddSceneTask) {
|
||||
return GridView.builder(
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 5,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
),
|
||||
itemCount:
|
||||
state.iconModels?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final iconModel =
|
||||
state.iconModels![index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
BlocProvider.of<
|
||||
CreateSceneBloc>(
|
||||
context)
|
||||
.add(IconSelected(
|
||||
iconId:
|
||||
iconModel.uuid,
|
||||
confirmSelection:
|
||||
false));
|
||||
selectedIcon = iconModel.uuid;
|
||||
},
|
||||
child: ClipOval(
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.all(1),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: state.selectedIcon ==
|
||||
iconModel.uuid
|
||||
? ColorsManager
|
||||
.primaryColorWithOpacity
|
||||
: Colors
|
||||
.transparent,
|
||||
width: 2,
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.memory(
|
||||
iconModel.iconBytes,
|
||||
width: 35,
|
||||
height: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (state is CreateSceneError) {
|
||||
return Text(state.message);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(IconSelected(
|
||||
iconId: selectedIcon,
|
||||
confirmSelection: true));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
title: 'Icons',
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(text: 'Icons'),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios_outlined,
|
||||
color: ColorsManager.textGray,
|
||||
size: 15,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyMedium(text: 'Show on devices page'),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
height: 30,
|
||||
width: 1,
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: showInDevice,
|
||||
onChanged: (value) {
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(ShowOnDeviceClicked(
|
||||
value: value));
|
||||
},
|
||||
applyTheme: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
//Cloud
|
||||
BodyMedium(text: 'Executed by'),
|
||||
Text('Cloud',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
if (isAutomation)
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Visibility(
|
||||
visible: isAutomation,
|
||||
child: SceneListTile(
|
||||
titleString: "Effective Period",
|
||||
trailingWidget:
|
||||
const Icon(Icons.arrow_forward_ios_rounded),
|
||||
onPressed: () {
|
||||
context.customBottomSheet(
|
||||
child: const EffectPeriodBottomSheetContent(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: sceneName.isNotEmpty && isAutomation,
|
||||
child: SizedBox(
|
||||
width: context.width * 0.9,
|
||||
child: const Divider(
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Visibility(
|
||||
visible: isAutomation,
|
||||
child: SceneListTile(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 8),
|
||||
titleString: "Effective Period",
|
||||
trailingWidget:
|
||||
const Icon(Icons.arrow_forward_ios_rounded),
|
||||
onPressed: () {
|
||||
context.customBottomSheet(
|
||||
child: const EffectPeriodBottomSheetContent(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: sceneName.isNotEmpty && isAutomation,
|
||||
child: SizedBox(
|
||||
width: context.width * 0.9,
|
||||
child: const Divider(
|
||||
color: ColorsManager.greyColor,
|
||||
SizedBox(
|
||||
child: Center(
|
||||
child: Visibility(
|
||||
visible: sceneName.isNotEmpty,
|
||||
child: DeleteRoutineButton(
|
||||
isAutomation: isAutomation,
|
||||
sceneId: sceneId,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: sceneName.isNotEmpty,
|
||||
child: DeleteBottomSheetContent(
|
||||
isAutomation: isAutomation,
|
||||
sceneId: sceneId,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,10 +7,10 @@ import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/delete_routine_dialog.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
||||
@ -117,49 +117,3 @@ class SceneTasksView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteBottomSheetContent extends StatelessWidget {
|
||||
const DeleteBottomSheetContent(
|
||||
{super.key, required this.sceneId, required this.isAutomation});
|
||||
|
||||
final String sceneId;
|
||||
final bool isAutomation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
||||
listener: (context, state) {
|
||||
if (state is DeleteSceneSuccess) {
|
||||
if (state.success) {
|
||||
navigateToRoute(context, Routes.homeRoute);
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return SceneListTile(
|
||||
onPressed: () {
|
||||
context.read<CreateSceneBloc>().add(DeleteSceneEvent(
|
||||
sceneId: sceneId,
|
||||
unitUuid: HomeCubit.getInstance().selectedSpace!.id!,
|
||||
));
|
||||
},
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
titleString: isAutomation
|
||||
? StringsManager.deleteAutomation
|
||||
: StringsManager.deleteScene,
|
||||
leadingWidget: (state is DeleteSceneLoading)
|
||||
? const SizedBox(
|
||||
height: 24, width: 24, child: CircularProgressIndicator())
|
||||
: SvgPicture.asset(
|
||||
Assets.assetsDeleteIcon,
|
||||
color: ColorsManager.red,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,35 +21,32 @@ class SceneView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) => SceneBloc()
|
||||
..add(LoadScenes(HomeCubit.getInstance().selectedSpace?.id ?? ''))
|
||||
..add(LoadScenes(HomeCubit.getInstance().selectedSpace?.id ?? '', showInDevice: pageType))
|
||||
..add(LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '')),
|
||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is DeleteSceneSuccess) {
|
||||
if (state.success) {
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
LoadScenes(HomeCubit.getInstance().selectedSpace!.id!, showInDevice: pageType));
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
}
|
||||
}
|
||||
if (state is CreateSceneWithTasks) {
|
||||
if (state.success == true) {
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
context
|
||||
.read<SmartSceneSelectBloc>()
|
||||
.add(const SmartSceneClearEvent());
|
||||
LoadScenes(HomeCubit.getInstance().selectedSpace!.id!, showInDevice: pageType));
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||
}
|
||||
}
|
||||
return BlocListener<SceneBloc, SceneState>(
|
||||
listener: (context, state) {
|
||||
if (state is SceneTriggerSuccess) {
|
||||
context.showCustomSnackbar(
|
||||
message:
|
||||
'Scene ${state.sceneName} triggered successfully!');
|
||||
message: 'Scene ${state.sceneName} triggered successfully!');
|
||||
}
|
||||
},
|
||||
child: HomeCubit.getInstance().spaces?.isEmpty ?? true
|
||||
@ -86,30 +83,25 @@ class SceneView extends StatelessWidget {
|
||||
child: ListView(
|
||||
children: [
|
||||
Theme(
|
||||
data: ThemeData().copyWith(
|
||||
dividerColor: Colors.transparent),
|
||||
data: ThemeData()
|
||||
.copyWith(dividerColor: Colors.transparent),
|
||||
child: ExpansionTile(
|
||||
tilePadding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 6),
|
||||
tilePadding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
initiallyExpanded: true,
|
||||
iconColor: ColorsManager.grayColor,
|
||||
title: const BodyMedium(
|
||||
text: 'Tap to run routines'),
|
||||
title: const BodyMedium(text: 'Tap to run routines'),
|
||||
children: [
|
||||
scenes.isNotEmpty
|
||||
? SceneGrid(
|
||||
scenes: scenes,
|
||||
loadingSceneId:
|
||||
state.loadingSceneId,
|
||||
loadingSceneId: state.loadingSceneId,
|
||||
disablePlayButton: false,
|
||||
loadingStates: state
|
||||
.loadingStates, // Add this line
|
||||
loadingStates:
|
||||
state.loadingStates, // Add this line
|
||||
)
|
||||
: const Center(
|
||||
child: BodyMedium(
|
||||
text:
|
||||
'No scenes have been added yet',
|
||||
text: 'No scenes have been added yet',
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
@ -119,30 +111,25 @@ class SceneView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Theme(
|
||||
data: ThemeData().copyWith(
|
||||
dividerColor: Colors.transparent),
|
||||
data: ThemeData()
|
||||
.copyWith(dividerColor: Colors.transparent),
|
||||
child: ExpansionTile(
|
||||
initiallyExpanded: true,
|
||||
iconColor: ColorsManager.grayColor,
|
||||
tilePadding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 6),
|
||||
title: const BodyMedium(
|
||||
text: 'Automation'),
|
||||
tilePadding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
title: const BodyMedium(text: 'Automation'),
|
||||
children: [
|
||||
automationList.isNotEmpty
|
||||
? SceneGrid(
|
||||
scenes: automationList,
|
||||
loadingSceneId:
|
||||
state.loadingSceneId,
|
||||
loadingSceneId: state.loadingSceneId,
|
||||
disablePlayButton: true,
|
||||
loadingStates: state
|
||||
.loadingStates, // Add this line
|
||||
loadingStates:
|
||||
state.loadingStates, // Add this line
|
||||
)
|
||||
: const Center(
|
||||
child: BodyMedium(
|
||||
text:
|
||||
'No automations have been added yet',
|
||||
text: 'No automations have been added yet',
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
||||
@ -0,0 +1,114 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class DeleteRoutineDialog extends StatelessWidget {
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
|
||||
const DeleteRoutineDialog({
|
||||
super.key,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const BodyLarge(
|
||||
text: 'Delete Routine',
|
||||
fontWeight: FontWeight.w700,
|
||||
fontColor: ColorsManager.red,
|
||||
fontSize: 16,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Divider(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Center(child: const Text('Are you sure you want to ')),
|
||||
Center(child: const Text('delete the routine?'))
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: SizedBox(
|
||||
child: InkWell(
|
||||
onTap: cancelTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: InkWell(
|
||||
onTap: confirmTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.red,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
111
lib/features/scene/widgets/alert_dialogs/icons_dialog.dart
Normal file
111
lib/features/scene/widgets/alert_dialogs/icons_dialog.dart
Normal file
@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class IconsDialog extends StatelessWidget {
|
||||
final String title;
|
||||
final Widget widgetList;
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
|
||||
const IconsDialog({
|
||||
super.key,
|
||||
required this.widgetList,
|
||||
required this.title,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyLarge(
|
||||
text: title,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontColor: ColorsManager.primaryColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Divider(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
widgetList,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: SizedBox(
|
||||
child: InkWell(
|
||||
onTap: cancelTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: InkWell(
|
||||
onTap: confirmTab!,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
81
lib/features/scene/widgets/delete_routine_b.dart
Normal file
81
lib/features/scene/widgets/delete_routine_b.dart
Normal file
@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/alert_dialogs/delete_routine_dialog.dart';
|
||||
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class DeleteRoutineButton extends StatelessWidget {
|
||||
const DeleteRoutineButton(
|
||||
{super.key, required this.sceneId, required this.isAutomation});
|
||||
|
||||
final String sceneId;
|
||||
final bool isAutomation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<CreateSceneBloc, CreateSceneState>(
|
||||
listener: (context, state) {
|
||||
if (state is DeleteSceneSuccess) {
|
||||
if (state.success) {
|
||||
navigateToRoute(context, Routes.homeRoute);
|
||||
BlocProvider.of<SceneBloc>(context)
|
||||
.add(LoadScenes(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
BlocProvider.of<SceneBloc>(context).add(
|
||||
LoadAutomation(HomeCubit.getInstance().selectedSpace!.id!));
|
||||
}
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return DeleteRoutineDialog(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
context.read<CreateSceneBloc>().add(DeleteSceneEvent(
|
||||
sceneId: sceneId,
|
||||
unitUuid:
|
||||
HomeCubit.getInstance().selectedSpace!.id!,
|
||||
));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Remove Routine',
|
||||
style: TextStyle(color: ColorsManager.red),
|
||||
))
|
||||
// : SceneListTile(
|
||||
// onPressed: () {
|
||||
|
||||
// },
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
// titleString: isAutomation
|
||||
// ? StringsManager.deleteAutomation
|
||||
// : StringsManager.deleteScene,
|
||||
// leadingWidget: (state is DeleteSceneLoading)
|
||||
// ? const SizedBox(
|
||||
// height: 24,
|
||||
// width: 24,
|
||||
// child: CircularProgressIndicator())
|
||||
// : SvgPicture.asset(
|
||||
// Assets.assetsDeleteIcon,
|
||||
// color: ColorsManager.red,
|
||||
// ),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
@ -37,8 +38,8 @@ class SceneItem extends StatelessWidget {
|
||||
onTap: () {
|
||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||
if (disablePlayButton == false) {
|
||||
BlocProvider.of<CreateSceneBloc>(context).add(
|
||||
FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
||||
|
||||
/// the state to set the scene type must be after the fetch
|
||||
BlocProvider.of<CreateSceneBloc>(context)
|
||||
@ -72,19 +73,22 @@ class SceneItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
height: 32,
|
||||
width: 32,
|
||||
Assets.assetsIconsLogo,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
if (!disablePlayButton)
|
||||
Image.memory(
|
||||
height: 32,
|
||||
width: 32,
|
||||
scene.iconInBytes,
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
Image.asset(height: 32, width: 32, fit: BoxFit.fill, Assets.assetsIconsLogo),
|
||||
),
|
||||
if (disablePlayButton)
|
||||
SvgPicture.asset(height: 32, width: 32, fit: BoxFit.fill, Assets.automationIcon),
|
||||
disablePlayButton == false
|
||||
? IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
context
|
||||
.read<SceneBloc>()
|
||||
.add(SceneTrigger(scene.id, scene.name));
|
||||
context.read<SceneBloc>().add(SceneTrigger(scene.id, scene.name));
|
||||
},
|
||||
icon: isLoading
|
||||
? const Center(
|
||||
@ -106,15 +110,11 @@ class SceneItem extends StatelessWidget {
|
||||
activeColor: ColorsManager.primaryColor,
|
||||
value: scene.status == 'enable' ? true : false,
|
||||
onChanged: (value) {
|
||||
context.read<SceneBloc>().add(
|
||||
UpdateAutomationStatus(
|
||||
automationStatusUpdate:
|
||||
AutomationStatusUpdate(
|
||||
isEnable: value,
|
||||
unitUuid: HomeCubit.getInstance()
|
||||
.selectedSpace!
|
||||
.id!),
|
||||
automationId: scene.id));
|
||||
context.read<SceneBloc>().add(UpdateAutomationStatus(
|
||||
automationStatusUpdate: AutomationStatusUpdate(
|
||||
isEnable: value,
|
||||
unitUuid: HomeCubit.getInstance().selectedSpace!.id!),
|
||||
automationId: scene.id));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -3,8 +3,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsFontsAftikaRegular
|
||||
/// assets/fonts/AftikaRegular.ttf
|
||||
static const String assetsFontsAftikaRegular =
|
||||
"assets/fonts/AftikaRegular.ttf";
|
||||
static const String assetsFontsAftikaRegular = "assets/fonts/AftikaRegular.ttf";
|
||||
|
||||
/// Assets for assetsIcons3GangSwitch
|
||||
/// assets/icons/3GangSwitch.svg
|
||||
@ -20,98 +19,82 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsAutomatedClock
|
||||
/// assets/icons/automated_clock.svg
|
||||
static const String assetsIconsAutomatedClock =
|
||||
"assets/icons/automated_clock.svg";
|
||||
static const String assetsIconsAutomatedClock = "assets/icons/automated_clock.svg";
|
||||
static const String acSwitchIcon = "assets/icons/ac_switch_ic.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstChargeddmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstChargeddmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstChargeddmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstChargeddmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstChargeddmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstDefaultdmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstDefaultdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstDefaultdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOfflowOffpmOffstDefaultdmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOfflowOffpmOffstDefaultdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOffpmOnstChargeddmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOfflowOffpmOnstChargeddmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOfflowOffpmOnstChargeddmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOfflowOffpmOnstChargeddmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOfflowOffpmOnstChargeddmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOnpmOffstDefaultdmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOfflowOnpmOffstDefaultdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOfflowOnpmOffstDefaultdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOfflowOnpmOffstDefaultdmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOfflowOnpmOffstDefaultdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOfflowOnpmOnstDefaultdmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOfflowOnpmOnstDefaultdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOfflowOnpmOnstDefaultdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOfflowOnpmOnstDefaultdmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOfflowOnpmOnstDefaultdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOnlowOffpmOffstChargeddmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOnlowOffpmOffstChargeddmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOnlowOffpmOffstChargeddmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOnlowOffpmOffstChargeddmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOnlowOffpmOffstChargeddmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOnlowOnpmOffstlowBatterydmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOnlowOnpmOffstlowBatterydmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOnlowOnpmOffstlowBatterydmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOnlowOnpmOffstlowBatterydmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOnlowOnpmOffstlowBatterydmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOffchargOnlowOnpmOnstlowpmdmOff
|
||||
/// assets/icons/battery/dmOff/perOffchargOnlowOnpmOnstlowpmdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOffchargOnlowOnpmOnstlowpmdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOffchargOnlowOnpmOnstlowpmdmOff =
|
||||
"assets/icons/battery/dmOff/perOffchargOnlowOnpmOnstlowpmdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstChargeddmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstChargeddmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstChargeddmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstChargeddmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstChargeddmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstDefaultdmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstDefaultdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstDefaultdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOfflowOffpmOffstDefaultdmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOfflowOffpmOffstDefaultdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOffpmOnstChargeddmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOfflowOffpmOnstChargeddmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOfflowOffpmOnstChargeddmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOfflowOffpmOnstChargeddmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOfflowOffpmOnstChargeddmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOnpmOffstDefaultdmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOfflowOnpmOffstDefaultdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOfflowOnpmOffstDefaultdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOfflowOnpmOffstDefaultdmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOfflowOnpmOffstDefaultdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOfflowOnpmOnstDefaultdmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOfflowOnpmOnstDefaultdmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOfflowOnpmOnstDefaultdmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOfflowOnpmOnstDefaultdmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOfflowOnpmOnstDefaultdmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOnlowOffpmOffstChargeddmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOnlowOffpmOffstChargeddmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOnlowOffpmOffstChargeddmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOnlowOffpmOffstChargeddmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOnlowOffpmOffstChargeddmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOnlowOnpmOffstlowBatterydmOff
|
||||
/// assets/icons/battery/dmOff/perOnchargOnlowOnpmOffstlowBatterydmOff.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOffPerOnchargOnlowOnpmOffstlowBatterydmOff =
|
||||
static const String assetsIconsBatteryDmOffPerOnchargOnlowOnpmOffstlowBatterydmOff =
|
||||
"assets/icons/battery/dmOff/perOnchargOnlowOnpmOffstlowBatterydmOff.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOffPerOnchargOnlowOnpmOnstlowpmdmOff
|
||||
@ -121,44 +104,37 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstChargeddmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstChargeddmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstChargeddmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstChargeddmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstChargeddmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstDefaultdmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstDefaultdmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstDefaultdmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOfflowOffpmOffstDefaultdmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOfflowOffpmOffstDefaultdmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOffpmOnstChargeddmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOfflowOffpmOnstChargeddmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOfflowOffpmOnstChargeddmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOfflowOffpmOnstChargeddmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOfflowOffpmOnstChargeddmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOnpmOffstDefaultdmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOfflowOnpmOffstDefaultdmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOfflowOnpmOffstDefaultdmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOfflowOnpmOffstDefaultdmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOfflowOnpmOffstDefaultdmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOfflowOnpmOnstDefaultdmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOfflowOnpmOnstDefaultdmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOfflowOnpmOnstDefaultdmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOfflowOnpmOnstDefaultdmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOfflowOnpmOnstDefaultdmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOnlowOffpmOffstChargeddmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOnlowOffpmOffstChargeddmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOnlowOffpmOffstChargeddmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOnlowOffpmOffstChargeddmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOnlowOffpmOffstChargeddmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOnlowOnpmOffstlowBatterydmOn
|
||||
/// assets/icons/battery/dmOn/perOffchargOnlowOnpmOffstlowBatterydmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOffchargOnlowOnpmOffstlowBatterydmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOffchargOnlowOnpmOffstlowBatterydmOn =
|
||||
"assets/icons/battery/dmOn/perOffchargOnlowOnpmOffstlowBatterydmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOffchargOnlowOnpmOnstlowpmdmOn
|
||||
@ -168,44 +144,37 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstChargeddmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstChargeddmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstChargeddmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstDefaultdmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstDefaultdmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstDefaultdmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOfflowOffpmOffstDefaultdmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOfflowOffpmOffstDefaultdmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOffpmOnstChargeddmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOfflowOffpmOnstChargeddmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOfflowOffpmOnstChargeddmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOfflowOffpmOnstChargeddmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOfflowOffpmOnstChargeddmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOnpmOffstDefaultdmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOfflowOnpmOffstDefaultdmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOfflowOnpmOffstDefaultdmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOfflowOnpmOffstDefaultdmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOfflowOnpmOffstDefaultdmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOfflowOnpmOnstDefaultdmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOfflowOnpmOnstDefaultdmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOfflowOnpmOnstDefaultdmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOfflowOnpmOnstDefaultdmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOfflowOnpmOnstDefaultdmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOnlowOffpmOffstChargeddmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOnlowOffpmOffstChargeddmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOnlowOffpmOffstChargeddmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOnlowOffpmOffstChargeddmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOnlowOffpmOffstChargeddmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn
|
||||
/// assets/icons/battery/dmOn/perOnchargOnlowOnpmOffstlowBatterydmOn.svg
|
||||
static const String
|
||||
assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn =
|
||||
static const String assetsIconsBatteryDmOnPerOnchargOnlowOnpmOffstlowBatterydmOn =
|
||||
"assets/icons/battery/dmOn/perOnchargOnlowOnpmOffstlowBatterydmOn.svg";
|
||||
|
||||
/// Assets for assetsIconsBatteryDmOnPerOnchargOnlowOnpmOnstlowpmdmOn
|
||||
@ -249,8 +218,7 @@ class Assets {
|
||||
static const String assetsIconsCurtainsIconVerticalBlade =
|
||||
"assets/icons/curtainsIcon/left_vertical_blade.svg";
|
||||
|
||||
static const String rightVerticalBlade =
|
||||
"assets/icons/curtainsIcon/right_vertical_blade.svg";
|
||||
static const String rightVerticalBlade = "assets/icons/curtainsIcon/right_vertical_blade.svg";
|
||||
|
||||
/// Assets for assetsIconsDashboard
|
||||
/// assets/icons/dashboard.svg
|
||||
@ -260,8 +228,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsDashboardFill
|
||||
/// assets/icons/dashboard-fill.svg
|
||||
static const String assetsIconsDashboardFill =
|
||||
"assets/icons/dashboard-fill.svg";
|
||||
static const String assetsIconsDashboardFill = "assets/icons/dashboard-fill.svg";
|
||||
|
||||
/// Assets for assetsIconsDevices
|
||||
/// assets/icons/Devices.svg
|
||||
@ -277,8 +244,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsDoorLockLinkage
|
||||
/// assets/icons/DoorLockLinkage.svg
|
||||
static const String assetsIconsDoorLockLinkage =
|
||||
"assets/icons/DoorLockLinkage.svg";
|
||||
static const String assetsIconsDoorLockLinkage = "assets/icons/DoorLockLinkage.svg";
|
||||
|
||||
/// Assets for assetsIconsDoorLockLock
|
||||
/// assets/icons/DoorLockLock.svg
|
||||
@ -286,18 +252,15 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsDoorLockMembers
|
||||
/// assets/icons/DoorLockMembers.svg
|
||||
static const String assetsIconsDoorLockMembers =
|
||||
"assets/icons/DoorLockMembers.svg";
|
||||
static const String assetsIconsDoorLockMembers = "assets/icons/DoorLockMembers.svg";
|
||||
|
||||
/// Assets for assetsIconsDoorLockPassword
|
||||
/// assets/icons/DoorLockPassword.svg
|
||||
static const String assetsIconsDoorLockPassword =
|
||||
"assets/icons/DoorLockPassword.svg";
|
||||
static const String assetsIconsDoorLockPassword = "assets/icons/DoorLockPassword.svg";
|
||||
|
||||
/// Assets for assetsIconsDoorLockRecords
|
||||
/// assets/icons/DoorLockRecords.svg
|
||||
static const String assetsIconsDoorLockRecords =
|
||||
"assets/icons/DoorLockRecords.svg";
|
||||
static const String assetsIconsDoorLockRecords = "assets/icons/DoorLockRecords.svg";
|
||||
|
||||
/// Assets for assetsIconsDoorlockAssetsBatteryIndicator
|
||||
/// assets/icons/doorlock-assets/BatteryIndicator.svg
|
||||
@ -318,8 +281,7 @@ class Assets {
|
||||
/// assets/icons/doorlock-assets/lockIcon.svg
|
||||
static const String assetsIconsDoorlockAssetsLockIcon =
|
||||
"assets/icons/doorlock-assets/lockIcon.svg";
|
||||
static const String doorUnlockIcon =
|
||||
"assets/icons/doorlock-assets/door_un_look_ic.svg";
|
||||
static const String doorUnlockIcon = "assets/icons/doorlock-assets/door_un_look_ic.svg";
|
||||
|
||||
/// Assets for assetsIconsDoorlockAssetsMembersManagement
|
||||
/// assets/icons/doorlock-assets/members-management.svg
|
||||
@ -407,13 +369,11 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsLightSwitchOff
|
||||
/// assets/icons/lightSwitchOff.svg
|
||||
static const String assetsIconsLightSwitchOff =
|
||||
"assets/icons/lightSwitchOff.svg";
|
||||
static const String assetsIconsLightSwitchOff = "assets/icons/lightSwitchOff.svg";
|
||||
|
||||
/// Assets for assetsIconsLightSwitchOn
|
||||
/// assets/icons/lightSwitchOn.svg
|
||||
static const String assetsIconsLightSwitchOn =
|
||||
"assets/icons/lightSwitchOn.svg";
|
||||
static const String assetsIconsLightSwitchOn = "assets/icons/lightSwitchOn.svg";
|
||||
|
||||
/// Assets for assetsIconsLinkageIconsDoorLockAlarm
|
||||
/// assets/icons/linkageIcons/doorLockAlarm.svg
|
||||
@ -422,8 +382,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsLinkTimeLimitedPasswordIcon
|
||||
/// assets/icons/timeLimitedPasswordIcon.svg
|
||||
static const String timeLimitedPasswordIcon =
|
||||
"assets/icons/timeLimitedPasswordIcon.svg";
|
||||
static const String timeLimitedPasswordIcon = "assets/icons/timeLimitedPasswordIcon.svg";
|
||||
|
||||
/// Assets for assetsIconsoneTimePassword
|
||||
/// assets/icons/oneTimePassword.svg
|
||||
@ -431,8 +390,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsTimeLimitedPassword
|
||||
/// assets/icons/timeLimitedPassword.svg
|
||||
static const String timeLimitedPassword =
|
||||
"assets/icons/timeLimitedPassword.svg";
|
||||
static const String timeLimitedPassword = "assets/icons/timeLimitedPassword.svg";
|
||||
|
||||
/// Assets for assetsIconsNoValidPasswords
|
||||
/// assets/icons/noValidPasswords.svg
|
||||
@ -601,13 +559,11 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsPresenceSensorAssetsParameterSettings
|
||||
/// assets/icons/presence-sensor-assets/space_type_icon.svg
|
||||
static const String spaceTypeIcon =
|
||||
"assets/icons/presence-sensor-assets/space_type_icon.svg";
|
||||
static const String spaceTypeIcon = "assets/icons/presence-sensor-assets/space_type_icon.svg";
|
||||
|
||||
/// Assets for assetsIconsPresenceSensorAssetsParameterSettings
|
||||
/// assets/icons/presence-sensor-assets/space_type_icon.svg
|
||||
static const String sensitivityIcon =
|
||||
"assets/icons/presence-sensor-assets/Sensitivity.svg";
|
||||
static const String sensitivityIcon = "assets/icons/presence-sensor-assets/Sensitivity.svg";
|
||||
|
||||
/// Assets for assetsIconsPresenceSensorAssetsParameterSettings
|
||||
/// assets/icons/presence-sensor-assets/maximum_distance.svg
|
||||
@ -640,8 +596,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsRoutinesFill
|
||||
/// assets/icons/Routines-fill.svg
|
||||
static const String assetsIconsRoutinesFill =
|
||||
"assets/icons/Routines-fill.svg";
|
||||
static const String assetsIconsRoutinesFill = "assets/icons/Routines-fill.svg";
|
||||
|
||||
/// Assets for assetsIconsScan
|
||||
/// assets/icons/Scan.svg
|
||||
@ -673,8 +628,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsIconsSustainability
|
||||
/// assets/icons/sustainability.svg
|
||||
static const String assetsIconsSustainability =
|
||||
"assets/icons/sustainability.svg";
|
||||
static const String assetsIconsSustainability = "assets/icons/sustainability.svg";
|
||||
|
||||
/// Assets for assetsIconsUnlockingMethodsIconsFace
|
||||
/// assets/icons/unlockingMethodsIcons/face.svg
|
||||
@ -770,8 +724,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsImagesHorizintalBlade
|
||||
/// assets/images/HorizintalBlade.png
|
||||
static const String assetsImagesHorizintalBlade =
|
||||
"assets/images/HorizintalBlade.png";
|
||||
static const String assetsImagesHorizintalBlade = "assets/images/HorizintalBlade.png";
|
||||
|
||||
/// Assets for assetsImagesLogo
|
||||
/// assets/images/Logo.svg
|
||||
@ -779,8 +732,7 @@ class Assets {
|
||||
|
||||
/// Assets for assetsImagesLogoHorizontal
|
||||
/// assets/images/logo_horizontal.png
|
||||
static const String assetsImagesLogoHorizontal =
|
||||
"assets/images/logo_horizontal.png";
|
||||
static const String assetsImagesLogoHorizontal = "assets/images/logo_horizontal.png";
|
||||
|
||||
/// Assets for assetsImagesPause
|
||||
/// assets/images/Pause.png
|
||||
@ -810,8 +762,7 @@ class Assets {
|
||||
/// assets/images/Window.png
|
||||
static const String assetsImagesWindow = "assets/images/window_img.svg";
|
||||
|
||||
static const String assetsSensitivityFunction =
|
||||
"assets/icons/functions_icons/sensitivity.svg";
|
||||
static const String assetsSensitivityFunction = "assets/icons/functions_icons/sensitivity.svg";
|
||||
|
||||
//assets/icons/functions_icons/sesitivity_operation_icon.svg
|
||||
static const String assetsSensitivityOperationIcon =
|
||||
@ -819,73 +770,59 @@ class Assets {
|
||||
|
||||
//assets/icons/functions_icons/ac_power.svg
|
||||
|
||||
static const String assetsAcPower =
|
||||
"assets/icons/functions_icons/ac_power.svg";
|
||||
static const String assetsAcPower = "assets/icons/functions_icons/ac_power.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_power_off.svg
|
||||
|
||||
static const String assetsAcPowerOFF =
|
||||
"assets/icons/functions_icons/ac_power_off.svg";
|
||||
static const String assetsAcPowerOFF = "assets/icons/functions_icons/ac_power_off.svg";
|
||||
|
||||
//assets/icons/functions_icons/child_lock.svg
|
||||
|
||||
static const String assetsChildLock =
|
||||
"assets/icons/functions_icons/child_lock.svg";
|
||||
static const String assetsChildLock = "assets/icons/functions_icons/child_lock.svg";
|
||||
|
||||
//assets/icons/functions_icons/cooling.svg
|
||||
|
||||
static const String assetsFreezing =
|
||||
"assets/icons/functions_icons/freezing.svg";
|
||||
static const String assetsFreezing = "assets/icons/functions_icons/freezing.svg";
|
||||
|
||||
//assets/icons/functions_icons/fan_speed.svg
|
||||
|
||||
static const String assetsFanSpeed =
|
||||
"assets/icons/functions_icons/fan_speed.svg";
|
||||
static const String assetsFanSpeed = "assets/icons/functions_icons/fan_speed.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_cooling.svg
|
||||
|
||||
static const String assetsAcCooling =
|
||||
"assets/icons/functions_icons/ac_cooling.svg";
|
||||
static const String assetsAcCooling = "assets/icons/functions_icons/ac_cooling.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_heating.svg
|
||||
|
||||
static const String assetsAcHeating =
|
||||
"assets/icons/functions_icons/ac_heating.svg";
|
||||
static const String assetsAcHeating = "assets/icons/functions_icons/ac_heating.svg";
|
||||
|
||||
//assets/icons/functions_icons/celsius_degrees.svg
|
||||
|
||||
static const String assetsCelsiusDegrees =
|
||||
"assets/icons/functions_icons/celsius_degrees.svg";
|
||||
static const String assetsCelsiusDegrees = "assets/icons/functions_icons/celsius_degrees.svg";
|
||||
|
||||
//assets/icons/functions_icons/tempreture.svg
|
||||
|
||||
static const String assetsTempreture =
|
||||
"assets/icons/functions_icons/tempreture.svg";
|
||||
static const String assetsTempreture = "assets/icons/functions_icons/tempreture.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_fan_low.svg
|
||||
|
||||
static const String assetsAcFanLow =
|
||||
"assets/icons/functions_icons/ac_fan_low.svg";
|
||||
static const String assetsAcFanLow = "assets/icons/functions_icons/ac_fan_low.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_fan_middle.svg
|
||||
|
||||
static const String assetsAcFanMiddle =
|
||||
"assets/icons/functions_icons/ac_fan_middle.svg";
|
||||
static const String assetsAcFanMiddle = "assets/icons/functions_icons/ac_fan_middle.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_fan_high.svg
|
||||
|
||||
static const String assetsAcFanHigh =
|
||||
"assets/icons/functions_icons/ac_fan_high.svg";
|
||||
static const String assetsAcFanHigh = "assets/icons/functions_icons/ac_fan_high.svg";
|
||||
|
||||
//assets/icons/functions_icons/ac_fan_auto.svg
|
||||
|
||||
static const String assetsAcFanAuto =
|
||||
"assets/icons/functions_icons/ac_fan_auto.svg";
|
||||
static const String assetsAcFanAuto = "assets/icons/functions_icons/ac_fan_auto.svg";
|
||||
|
||||
//assets/icons/functions_icons/scene_child_lock.svg
|
||||
|
||||
static const String assetsSceneChildLock =
|
||||
"assets/icons/functions_icons/scene_child_lock.svg";
|
||||
static const String assetsSceneChildLock = "assets/icons/functions_icons/scene_child_lock.svg";
|
||||
|
||||
//assets/icons/functions_icons/scene_child_unlock.svg
|
||||
|
||||
@ -894,18 +831,15 @@ class Assets {
|
||||
|
||||
//assets/icons/functions_icons/scene_refresh.svg
|
||||
|
||||
static const String assetsSceneRefresh =
|
||||
"assets/icons/functions_icons/scene_refresh.svg";
|
||||
static const String assetsSceneRefresh = "assets/icons/functions_icons/scene_refresh.svg";
|
||||
|
||||
//assets/icons/functions_icons/light_countdown.svg
|
||||
|
||||
static const String assetsLightCountdown =
|
||||
"assets/icons/functions_icons/light_countdown.svg";
|
||||
static const String assetsLightCountdown = "assets/icons/functions_icons/light_countdown.svg";
|
||||
|
||||
//assets/icons/functions_icons/far_detection.svg
|
||||
|
||||
static const String assetsFarDetection =
|
||||
"assets/icons/functions_icons/far_detection.svg";
|
||||
static const String assetsFarDetection = "assets/icons/functions_icons/far_detection.svg";
|
||||
|
||||
//assets/icons/functions_icons/far_detection_function.svg
|
||||
|
||||
@ -914,13 +848,11 @@ class Assets {
|
||||
|
||||
//assets/icons/functions_icons/indicator.svg
|
||||
|
||||
static const String assetsIndicator =
|
||||
"assets/icons/functions_icons/indicator.svg";
|
||||
static const String assetsIndicator = "assets/icons/functions_icons/indicator.svg";
|
||||
|
||||
//assets/icons/functions_icons/motion_detection.svg
|
||||
|
||||
static const String assetsMotionDetection =
|
||||
"assets/icons/functions_icons/motion_detection.svg";
|
||||
static const String assetsMotionDetection = "assets/icons/functions_icons/motion_detection.svg";
|
||||
|
||||
//assets/icons/functions_icons/motionless_detection.svg
|
||||
|
||||
@ -929,18 +861,15 @@ class Assets {
|
||||
|
||||
//assets/icons/functions_icons/nobody_time.svg
|
||||
|
||||
static const String assetsNobodyTime =
|
||||
"assets/icons/functions_icons/nobody_time.svg";
|
||||
static const String assetsNobodyTime = "assets/icons/functions_icons/nobody_time.svg";
|
||||
|
||||
//assets/icons/functions_icons/factory_reset.svg
|
||||
|
||||
static const String assetsFactoryReset =
|
||||
"assets/icons/functions_icons/factory_reset.svg";
|
||||
static const String assetsFactoryReset = "assets/icons/functions_icons/factory_reset.svg";
|
||||
|
||||
//assets/icons/functions_icons/master_state.svg
|
||||
|
||||
static const String assetsMasterState =
|
||||
"assets/icons/functions_icons/master_state.svg";
|
||||
static const String assetsMasterState = "assets/icons/functions_icons/master_state.svg";
|
||||
|
||||
//assets/icons/functions_icons/switch_alarm_sound.svg
|
||||
|
||||
@ -949,8 +878,7 @@ class Assets {
|
||||
|
||||
//assets/icons/functions_icons/reset_off.svg
|
||||
|
||||
static const String assetsResetOff =
|
||||
"assets/icons/functions_icons/reset_off.svg";
|
||||
static const String assetsResetOff = "assets/icons/functions_icons/reset_off.svg";
|
||||
|
||||
//assets/icons/functions_icons/automation_functions/card_unlock.svg
|
||||
|
||||
@ -1024,8 +952,7 @@ class Assets {
|
||||
|
||||
//assets/icons/functions_icons/automation_functions/motion.svg
|
||||
|
||||
static const String assetsMotion =
|
||||
"assets/icons/functions_icons/automation_functions/motion.svg";
|
||||
static const String assetsMotion = "assets/icons/functions_icons/automation_functions/motion.svg";
|
||||
|
||||
//assets/icons/functions_icons/automation_functions/current_temp.svg
|
||||
|
||||
@ -1047,33 +974,27 @@ class Assets {
|
||||
static const String waterHeaterOn = "assets/icons/water_heater_on.svg";
|
||||
static const String waterHeaterOff = "assets/icons/water_heater_off.svg";
|
||||
|
||||
static const String scheduleCelenderIcon =
|
||||
"assets/icons/schedule_celender_icon.svg";
|
||||
static const String scheduleCirculateIcon =
|
||||
"assets/icons/schedule_circulate_icon.svg";
|
||||
static const String scheduleInchingIcon =
|
||||
"assets/icons/schedule_Inching_icon.svg";
|
||||
static const String scheduleCelenderIcon = "assets/icons/schedule_celender_icon.svg";
|
||||
static const String scheduleCirculateIcon = "assets/icons/schedule_circulate_icon.svg";
|
||||
static const String scheduleInchingIcon = "assets/icons/schedule_Inching_icon.svg";
|
||||
static const String scheduleTimeIcon = "assets/icons/schedule_time_icon.svg";
|
||||
static const String waterHeaterIcon = "assets/icons/water_heater_icon.svg";
|
||||
|
||||
static const String doorOpen = "assets/icons/opened_door.svg";
|
||||
static const String doorClose = "assets/icons/closed_door.svg";
|
||||
static const String doorNotificationSetting =
|
||||
"assets/icons/door_notification_setting_icon.svg";
|
||||
static const String doorNotificationSetting = "assets/icons/door_notification_setting_icon.svg";
|
||||
static const String doorRecordsIcon = "assets/icons/door_records_icon.svg";
|
||||
static const String doorSensorIcon = "assets/icons/door_sensor_icon.svg";
|
||||
static const String closedGarageIcon = "assets/icons/closed_garage_door.svg";
|
||||
static const String openGarageIcon = "assets/icons/open_garage_door.svg";
|
||||
static const String garageCountdown = "assets/icons/garage_countdown.svg";
|
||||
static const String garagePreferencesIcon =
|
||||
"assets/icons/garage_preferences_icon.svg";
|
||||
static const String garagePreferencesIcon = "assets/icons/garage_preferences_icon.svg";
|
||||
static const String garageSchedule = "assets/icons/garage_schedule.svg";
|
||||
|
||||
static const String garageIcon = "assets/icons/garageIcon.svg";
|
||||
|
||||
static const String normalWaterLeak = "assets/icons/normal_water_leak.svg";
|
||||
static const String detectedWaterLeak =
|
||||
"assets/icons/detected_water_leak.svg";
|
||||
static const String detectedWaterLeak = "assets/icons/detected_water_leak.svg";
|
||||
|
||||
static const String waterLeakIcon = "assets/icons/waterleak_icon.svg";
|
||||
static const String leakDetectedIcon = "assets/icons/leak_detected.svg";
|
||||
@ -1089,6 +1010,7 @@ class Assets {
|
||||
static const String voltageIcon = "assets/icons/voltage_icon.svg";
|
||||
static const String speedoMeter = "assets/icons/speedo_meter.svg";
|
||||
static const String powerClampIcon = "assets/icons/power_clamp.svg";
|
||||
static const String automationIcon = "assets/icons/automation_ic.svg";
|
||||
|
||||
//powerClampIcon
|
||||
}
|
||||
|
||||
@ -128,6 +128,7 @@ abstract class ApiEndpoints {
|
||||
static const String getUnitScenes = '/scene/tap-to-run/{unitUuid}';
|
||||
|
||||
static const String getScene = '/scene/tap-to-run/details/{sceneId}';
|
||||
static const String getIconScene = '/scene/icon';
|
||||
|
||||
static const String getUnitAutomation = '/automation/{unitUuid}';
|
||||
|
||||
|
||||
@ -5,7 +5,8 @@ import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
class AuthenticationAPI {
|
||||
static Future<Map<String, dynamic>> verifyPassCode({required Map<String, dynamic> body}) async {
|
||||
static Future<Map<String, dynamic>> verifyPassCode(
|
||||
{required Map<String, dynamic> body}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.verifyOtp,
|
||||
body: body,
|
||||
@ -14,7 +15,8 @@ class AuthenticationAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Token> loginWithEmail({required LoginWithEmailModel model}) async {
|
||||
static Future<Token> loginWithEmail(
|
||||
{required LoginWithEmailModel model}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.login,
|
||||
body: model.toJson(),
|
||||
@ -32,17 +34,29 @@ class AuthenticationAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> sendOtp({required Map<String, dynamic> body}) async {
|
||||
static Future<Map<String, dynamic>> sendOtp(
|
||||
{required Map<String, dynamic> body}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOtp,
|
||||
body: body,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json['data']);
|
||||
expectedResponseModel: (json) {
|
||||
print(json['data']);
|
||||
return json['data'];
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> forgetPassword({required String email,required String password ,}) async {
|
||||
Map<String, dynamic> params = {"email": email, "password": password,};
|
||||
static Future<Map<String, dynamic>> forgetPassword({
|
||||
required String otpCode,
|
||||
required String email,
|
||||
required String password,
|
||||
}) async {
|
||||
Map<String, dynamic> params = {
|
||||
"email": email,
|
||||
"password": password,
|
||||
"otpCode": otpCode
|
||||
};
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.forgetPassword,
|
||||
body: params,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'package:syncrow_app/features/scene/model/create_automation_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/icon_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/update_automation.dart';
|
||||
@ -10,8 +11,7 @@ class SceneApi {
|
||||
static final HTTPService _httpService = HTTPService();
|
||||
|
||||
//create scene
|
||||
static Future<Map<String, dynamic>> createScene(
|
||||
CreateSceneModel createSceneModel) async {
|
||||
static Future<Map<String, dynamic>> createScene(CreateSceneModel createSceneModel) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.createScene,
|
||||
@ -47,10 +47,11 @@ class SceneApi {
|
||||
|
||||
//get scene by unit id
|
||||
|
||||
static Future<List<ScenesModel>> getScenesByUnitId(String unitId) async {
|
||||
static Future<List<ScenesModel>> getScenesByUnitId(String unitId, {showInDevice = false}) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUnitScenes.replaceAll('{unitUuid}', unitId),
|
||||
queryParameters: {'showInHomePage': showInDevice},
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<ScenesModel> scenes = [];
|
||||
@ -101,12 +102,10 @@ class SceneApi {
|
||||
}
|
||||
|
||||
//automation details
|
||||
static Future<SceneDetailsModel> getAutomationDetails(
|
||||
String automationId) async {
|
||||
static Future<SceneDetailsModel> getAutomationDetails(String automationId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getAutomationDetails
|
||||
.replaceAll('{automationId}', automationId),
|
||||
path: ApiEndpoints.getAutomationDetails.replaceAll('{automationId}', automationId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
||||
);
|
||||
@ -117,12 +116,11 @@ class SceneApi {
|
||||
}
|
||||
|
||||
//updateAutomationStatus
|
||||
static Future<bool> updateAutomationStatus(String automationId,
|
||||
AutomationStatusUpdate createAutomationEnable) async {
|
||||
static Future<bool> updateAutomationStatus(
|
||||
String automationId, AutomationStatusUpdate createAutomationEnable) async {
|
||||
try {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.updateAutomationStatus
|
||||
.replaceAll('{automationId}', automationId),
|
||||
path: ApiEndpoints.updateAutomationStatus.replaceAll('{automationId}', automationId),
|
||||
body: createAutomationEnable.toMap(),
|
||||
expectedResponseModel: (json) => json['success'],
|
||||
);
|
||||
@ -132,8 +130,6 @@ class SceneApi {
|
||||
}
|
||||
}
|
||||
|
||||
//getScene
|
||||
|
||||
static Future<SceneDetailsModel> getSceneDetails(String sceneId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
@ -147,13 +143,27 @@ class SceneApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<IconModel>> getIcon() async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getIconScene,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<IconModel> iconsList = [];
|
||||
json.forEach((element) {
|
||||
iconsList.add(IconModel.fromJson(element));
|
||||
});
|
||||
return iconsList;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
//update Scene
|
||||
static updateScene(CreateSceneModel createSceneModel, String sceneId) async {
|
||||
try {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.updateScene.replaceAll('{sceneId}', sceneId),
|
||||
body: createSceneModel
|
||||
.toJson(sceneId.isNotEmpty == true ? sceneId : null),
|
||||
body: createSceneModel.toJson(sceneId.isNotEmpty == true ? sceneId : null),
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
@ -165,14 +175,11 @@ class SceneApi {
|
||||
}
|
||||
|
||||
//update automation
|
||||
static updateAutomation(
|
||||
CreateAutomationModel createAutomationModel, String automationId) async {
|
||||
static updateAutomation(CreateAutomationModel createAutomationModel, String automationId) async {
|
||||
try {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.updateAutomation
|
||||
.replaceAll('{automationId}', automationId),
|
||||
body: createAutomationModel
|
||||
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||
path: ApiEndpoints.updateAutomation.replaceAll('{automationId}', automationId),
|
||||
body: createAutomationModel.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
@ -185,8 +192,7 @@ class SceneApi {
|
||||
|
||||
//delete Scene
|
||||
|
||||
static Future<bool> deleteScene(
|
||||
{required String unitUuid, required String sceneId}) async {
|
||||
static Future<bool> deleteScene({required String unitUuid, required String sceneId}) async {
|
||||
try {
|
||||
final response = await _httpService.delete(
|
||||
path: ApiEndpoints.deleteScene
|
||||
|
||||
@ -39,6 +39,6 @@ class StringsManager {
|
||||
'Example: when an unusual activity is detected.';
|
||||
static const String functions = "Functions";
|
||||
static const String firstLaunch = "firstLaunch";
|
||||
static const String deleteScene = 'Delete Scene';
|
||||
static const String deleteScene = 'Remove Routine';
|
||||
static const String deleteAutomation = 'Delete Automation';
|
||||
}
|
||||
|
||||
@ -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.5+31
|
||||
version: 1.0.5+35
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.6 <4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user