5
assets/icons/1gang_touch.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
||||
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
||||
<path opacity="0.6" d="M20.875 19.2411V20.7304C20.875 20.9746 20.7996 21.1767 20.7014 21.3067C20.6035 21.4364 20.5053 21.4715 20.4375 21.4715H16.3125C16.2447 21.4715 16.1465 21.4364 16.0486 21.3067C15.9504 21.1767 15.875 20.9746 15.875 20.7304V19.2411C15.875 18.9969 15.9504 18.7949 16.0486 18.6649C16.1465 18.5352 16.2447 18.5 16.3125 18.5H20.4375C20.5053 18.5 20.6035 18.5352 20.7014 18.6649C20.7996 18.7949 20.875 18.9969 20.875 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
6
assets/icons/2gang_touch.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
||||
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
||||
<path opacity="0.6" d="M16.5 19.2411V20.7304C16.5 20.9746 16.4246 21.1767 16.3264 21.3067C16.2285 21.4364 16.1303 21.4715 16.0625 21.4715H11.9375C11.8697 21.4715 11.7715 21.4364 11.6736 21.3067C11.5754 21.1767 11.5 20.9746 11.5 20.7304V19.2411C11.5 18.9969 11.5754 18.7949 11.6736 18.6649C11.7715 18.5352 11.8697 18.5 11.9375 18.5H16.0625C16.1303 18.5 16.2285 18.5352 16.3264 18.6649C16.4246 18.7949 16.5 18.9969 16.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||
<path opacity="0.6" d="M26.5 19.2411V20.7304C26.5 20.9746 26.4246 21.1767 26.3264 21.3067C26.2285 21.4364 26.1303 21.4715 26.0625 21.4715H21.9375C21.8697 21.4715 21.7715 21.4364 21.6736 21.3067C21.5754 21.1767 21.5 20.9746 21.5 20.7304V19.2411C21.5 18.9969 21.5754 18.7949 21.6736 18.6649C21.7715 18.5352 21.8697 18.5 21.9375 18.5H26.0625C26.1303 18.5 26.2285 18.5352 26.3264 18.6649C26.4246 18.7949 26.5 18.9969 26.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
7
assets/icons/3gang_touch.svg
Normal file
@ -0,0 +1,7 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M38.0142 39.2553L35.3682 40H20.9308H19.9999H19.0691H1.24111C0.555643 40 0 39.4444 0 38.7589V1.24111C0 0.555643 0.555643 0 1.24111 0H19.0682H20.1226H20.9543H35.4255L38.2625 1.24111C38.9479 1.24111 39.5036 1.79675 39.5036 2.48221L39.2553 38.0142C39.2553 38.6997 38.6997 39.2553 38.0142 39.2553Z" fill="#D1D1D1"/>
|
||||
<path d="M38.7589 0H35.0356C35.721 0 36.2767 0.555643 36.2767 1.24111V38.7589C36.2767 39.4444 35.721 40 35.0356 40H38.7589C39.4444 40 40 39.4444 40 38.7589V1.24111C40 0.555643 39.4444 0 38.7589 0Z" fill="#A0A0A0"/>
|
||||
<path opacity="0.6" d="M10.5 19.2411V20.7304C10.5 20.9746 10.4246 21.1767 10.3264 21.3067C10.2285 21.4364 10.1303 21.4715 10.0625 21.4715H5.9375C5.86973 21.4715 5.77153 21.4364 5.67355 21.3067C5.57536 21.1767 5.5 20.9746 5.5 20.7304V19.2411C5.5 18.9969 5.57536 18.7949 5.67355 18.6649C5.77153 18.5352 5.86973 18.5 5.9375 18.5H10.0625C10.1303 18.5 10.2285 18.5352 10.3264 18.6649C10.4246 18.7949 10.5 18.9969 10.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||
<path opacity="0.6" d="M20.5 19.2411V20.7304C20.5 20.9746 20.4246 21.1767 20.3264 21.3067C20.2285 21.4364 20.1303 21.4715 20.0625 21.4715H15.9375C15.8697 21.4715 15.7715 21.4364 15.6736 21.3067C15.5754 21.1767 15.5 20.9746 15.5 20.7304V19.2411C15.5 18.9969 15.5754 18.7949 15.6736 18.6649C15.7715 18.5352 15.8697 18.5 15.9375 18.5H20.0625C20.1303 18.5 20.2285 18.5352 20.3264 18.6649C20.4246 18.7949 20.5 18.9969 20.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||
<path opacity="0.6" d="M30.5 19.2411V20.7304C30.5 20.9746 30.4246 21.1767 30.3264 21.3067C30.2285 21.4364 30.1303 21.4715 30.0625 21.4715H25.9375C25.8697 21.4715 25.7715 21.4364 25.6736 21.3067C25.5754 21.1767 25.5 20.9746 25.5 20.7304V19.2411C25.5 18.9969 25.5754 18.7949 25.6736 18.6649C25.7715 18.5352 25.8697 18.5 25.9375 18.5H30.0625C30.1303 18.5 30.2285 18.5352 30.3264 18.6649C30.4246 18.7949 30.5 18.9969 30.5 19.2411Z" stroke="#023DFE" stroke-opacity="0.6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
32
assets/icons/detected_water_leak.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
3
assets/icons/leak_detected.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="5" stroke="#FF4756" stroke-width="5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 171 B |
3
assets/icons/leak_normal_icon.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="7.5" cy="7.5" r="5" stroke="#023DFE" stroke-opacity="0.6" stroke-width="5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 192 B |
27
assets/icons/normal_water_leak.svg
Normal file
@ -0,0 +1,27 @@
|
||||
<svg width="290" height="290" viewBox="0 0 290 290" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_4096_940)">
|
||||
<rect x="20" y="20" width="250" height="250" rx="100" fill="#EDEDED"/>
|
||||
<path d="M188.067 144.007C188.067 169.96 167.01 191 141.034 191C115.058 191 94 169.96 94 144.007C94 121.065 130.751 80.7942 139.281 71.7567C140.233 70.7478 141.835 70.7478 142.787 71.7567C151.317 80.7945 188.067 121.065 188.067 144.007Z" fill="#B3DAFE"/>
|
||||
<path d="M142.787 71.7567C141.835 70.7478 140.233 70.7478 139.281 71.7567C138.759 72.3096 138.13 72.9809 137.412 73.7562C148.433 85.6575 180.824 122.468 180.824 144.006C180.824 168.743 161.696 189.015 137.412 190.862C138.607 190.953 139.815 191 141.034 191C167.01 191 188.068 169.96 188.068 144.006C188.068 121.065 151.317 80.7945 142.787 71.7567Z" fill="#8AC9FE"/>
|
||||
<path d="M187.944 147.412C174.836 141.859 160.63 142.943 123.956 150.612C115.699 152.338 106.251 154.41 95.7856 156.876C101.386 176.573 119.524 191 141.034 191C165.864 191 186.197 171.776 187.944 147.412Z" fill="#60B7FF"/>
|
||||
<path d="M171.214 128.586C184.882 128.586 195.962 117.506 195.962 103.837C195.962 90.1692 184.882 79.0889 171.214 79.0889C157.545 79.0889 146.465 90.1692 146.465 103.837C146.465 117.506 157.545 128.586 171.214 128.586Z" fill="#97D729"/>
|
||||
<path d="M171.312 79.057C170.081 79.057 168.872 79.1482 167.69 79.3219C179.626 81.0743 188.79 91.356 188.79 103.779C188.79 116.202 179.626 126.484 167.69 128.236C168.872 128.41 170.081 128.501 171.312 128.501C184.965 128.501 196.034 117.433 196.034 103.779C196.034 90.1253 184.965 79.057 171.312 79.057Z" fill="#8BC727"/>
|
||||
<path d="M168.515 114.479C167.115 114.479 165.798 113.933 164.808 112.943L157.249 105.383C155.713 103.848 155.713 101.359 157.249 99.8238C158.784 98.2886 161.273 98.2881 162.808 99.8238L168.515 105.531L179.816 94.2307C181.351 92.6955 183.84 92.6955 185.375 94.2307C186.911 95.7658 186.911 98.2551 185.375 99.79L172.222 112.943C171.232 113.934 169.915 114.479 168.515 114.479Z" fill="#F9F7F8"/>
|
||||
<path d="M187.944 147.39C185.707 146.442 183.227 145.694 180.811 145.145C180.706 149.723 179.999 154.036 178.64 158.186L184.447 162.112C185.371 159.949 186.219 157.298 186.921 154.209C187.492 151.698 187.795 149.396 187.944 147.39Z" fill="#26A6FE"/>
|
||||
<path d="M158.594 154.258C134.004 150.208 121.183 134.478 95.1665 136.178C94.4172 138.944 94 141.573 94 144.007C94 169.96 115.058 191 141.034 191C163.857 191 182.881 174.757 187.163 153.21C175.527 155.808 166.006 155.478 158.594 154.258Z" fill="#0593FC"/>
|
||||
<path d="M179.633 154.541C175.105 174.288 158.13 189.291 137.395 190.861C138.596 190.953 139.809 191 141.034 191C163.857 191 182.881 174.757 187.163 153.21C184.546 153.794 182.036 154.229 179.633 154.541Z" fill="#0182FC"/>
|
||||
<path d="M119.354 205.825H122.193V219H119.495L113.571 210.809V219H110.732V205.825H113.431L119.354 214.034V205.825ZM133.602 217.646C132.57 218.684 131.27 219.202 129.699 219.202C128.129 219.202 126.828 218.684 125.797 217.646C124.766 216.604 124.25 215.347 124.25 213.876C124.25 212.405 124.766 211.154 125.797 210.123C126.822 209.098 128.123 208.585 129.699 208.585C131.275 208.585 132.576 209.098 133.602 210.123C134.633 211.154 135.148 212.405 135.148 213.876C135.148 215.347 134.633 216.604 133.602 217.646ZM129.69 211.046V211.055C128.876 211.055 128.223 211.321 127.73 211.854C127.238 212.388 126.992 213.067 126.992 213.894C126.992 214.708 127.238 215.388 127.73 215.933C128.223 216.478 128.876 216.75 129.69 216.75C130.517 216.75 131.176 216.48 131.668 215.941C132.16 215.402 132.406 214.72 132.406 213.894C132.406 213.067 132.16 212.385 131.668 211.846C131.176 211.312 130.517 211.046 129.69 211.046ZM139.815 210.844V210.835C140.694 209.394 141.948 208.673 143.577 208.673V211.573H143.252C142.262 211.573 141.441 211.846 140.791 212.391C140.141 212.936 139.815 213.832 139.815 215.08V219H137.073V208.796H139.815V210.844ZM158.141 208.611H158.149C159.251 208.611 160.136 208.995 160.804 209.763C161.472 210.524 161.806 211.559 161.806 212.865V219H159.072V213.226C159.072 212.563 158.888 212.039 158.519 211.652C158.149 211.266 157.66 211.072 157.051 211.072C156.465 211.072 155.964 211.292 155.548 211.731C155.138 212.165 154.933 212.728 154.933 213.419V219H152.199V213.261C152.199 212.581 152.015 212.048 151.646 211.661C151.276 211.274 150.799 211.081 150.213 211.081C149.604 211.081 149.094 211.327 148.684 211.819C148.273 212.306 148.068 212.851 148.068 213.454V219H145.326V208.796H148.068V210.237C149.053 209.159 150.131 208.614 151.303 208.603C151.994 208.603 152.609 208.77 153.148 209.104C153.688 209.438 154.115 209.903 154.432 210.501C155.539 209.241 156.775 208.611 158.141 208.611ZM170.621 219L170.604 217.84C169.959 218.742 168.913 219.19 167.466 219.185C166.294 219.185 165.359 218.909 164.662 218.358C163.959 217.802 163.607 217.017 163.607 216.003C163.607 214.972 164.023 214.166 164.855 213.586C165.688 213.006 166.663 212.716 167.782 212.716C168.702 212.716 169.616 212.848 170.524 213.111C170.56 211.635 169.798 210.896 168.239 210.896C167.618 210.896 166.982 210.976 166.332 211.134C165.682 211.292 165.172 211.459 164.803 211.635L164.135 209.64C165.594 208.942 167.094 208.594 168.635 208.594C170.217 208.594 171.386 208.98 172.142 209.754C172.897 210.527 173.275 211.702 173.275 213.278V219H170.621ZM168.248 217.225L168.239 217.233C168.884 217.233 169.429 217.078 169.874 216.768C170.313 216.463 170.533 216.018 170.533 215.432V214.755C169.889 214.526 169.203 214.412 168.477 214.412C167.867 214.412 167.357 214.535 166.947 214.781C166.537 215.027 166.332 215.37 166.332 215.81C166.332 216.243 166.514 216.589 166.877 216.847C167.234 217.099 167.691 217.225 168.248 217.225ZM175.657 219V205.034H178.399V219H175.657Z" fill="#0593FC"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_4096_940" x="0" y="0" width="290" height="290" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="10"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4096_940"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_4096_940" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.2 KiB |
8
assets/icons/waterleak_icon.svg
Normal file
@ -0,0 +1,8 @@
|
||||
<svg width="32" height="40" viewBox="0 0 32 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M31.3558 24.3356C31.3558 32.9868 24.3366 40 15.6779 40C7.01928 40 0 32.9868 0 24.3356C0 16.6883 12.2504 3.26474 15.0936 0.252246C15.411 -0.0840819 15.945 -0.0840819 16.2623 0.252246C19.1055 3.26482 31.3558 16.6883 31.3558 24.3356Z" fill="#B3DAFE"/>
|
||||
<path d="M16.2623 0.252246C15.9449 -0.0840819 15.4109 -0.0840819 15.0936 0.252246C14.9197 0.436542 14.7101 0.660292 14.4707 0.918729C18.1444 4.88583 28.9414 17.156 28.9414 24.3355C28.9414 32.5809 22.5653 39.3383 14.4707 39.9541C14.8691 39.9845 15.2717 39.9999 15.678 39.9999C24.3366 39.9999 31.3559 32.9867 31.3559 24.3355C31.3559 16.6883 19.1055 3.26482 16.2623 0.252246Z" fill="#8AC9FE"/>
|
||||
<path d="M31.3146 25.4707C26.9452 23.6196 22.2099 23.9811 9.98543 26.5371C7.23286 27.1127 4.08365 27.8032 0.595215 28.6251C2.46216 35.191 8.50794 39.9999 15.678 39.9999C23.9546 39.9999 30.7324 33.5919 31.3146 25.4707Z" fill="#60B7FF"/>
|
||||
<path d="M31.3146 25.4633C30.5689 25.1473 29.7422 24.8981 28.9369 24.7148C28.902 26.2409 28.6664 27.6787 28.2134 29.0619L30.1492 30.3706C30.4571 29.6496 30.7395 28.766 30.9738 27.7362C31.164 26.8995 31.2649 26.132 31.3146 25.4633Z" fill="#26A6FE"/>
|
||||
<path d="M21.5314 27.7526C13.3347 26.4026 9.06084 21.1593 0.388828 21.7261C0.139062 22.6479 0 23.5245 0 24.3356C0 32.9868 7.01921 40 15.6779 40C23.2857 40 29.6271 34.5856 31.0545 27.4032C27.1755 28.2694 24.002 28.1595 21.5314 27.7526Z" fill="#0593FC"/>
|
||||
<path d="M28.5442 27.8469C27.0352 34.4294 21.3767 39.4302 14.465 39.9537C14.8653 39.9844 15.2698 40 15.6779 40C23.2857 40 29.627 34.5855 31.0545 27.4032C30.182 27.598 29.3454 27.7431 28.5442 27.8469Z" fill="#0182FC"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@ -61,10 +61,11 @@ 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();
|
||||
// _listenToChanges();
|
||||
}
|
||||
} catch (e) {
|
||||
emit(AcsFailedState(errorMessage: e.toString()));
|
||||
@ -74,18 +75,22 @@ 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 (_) {}
|
||||
@ -102,12 +107,14 @@ 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();
|
||||
}
|
||||
@ -129,7 +136,8 @@ 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 {
|
||||
@ -190,7 +198,8 @@ 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 {
|
||||
@ -218,7 +227,8 @@ 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 {
|
||||
@ -246,7 +256,8 @@ 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 {
|
||||
@ -268,7 +279,9 @@ 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 {
|
||||
@ -281,19 +294,23 @@ 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) {
|
||||
@ -338,7 +355,8 @@ 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));
|
||||
@ -360,7 +378,10 @@ 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']) {
|
||||
@ -377,7 +398,8 @@ 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,7 +19,8 @@ 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);
|
||||
@ -29,7 +30,7 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
}
|
||||
deviceStatus = CeilingSensorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(ceilingSensorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
@ -38,15 +39,18 @@ 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);
|
||||
@ -55,15 +59,19 @@ 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;
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
@ -22,9 +26,14 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
on<OpenCurtain>(_onOpenCurtain);
|
||||
on<CloseCurtain>(_onCloseCurtain);
|
||||
on<PauseCurtain>(_onPauseCurtain);
|
||||
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
||||
on<InitialWizardEvent>(_fetchWizardStatus);
|
||||
on<GroupAllOffEvent>(_groupAllOff);
|
||||
on<GroupAllOnEvent>(_groupAllOn);
|
||||
}
|
||||
|
||||
Future<void> _onOpenCurtain(OpenCurtain event, Emitter<CurtainState> emit) async {
|
||||
Future<void> _onOpenCurtain(
|
||||
OpenCurtain event, Emitter<CurtainState> emit) async {
|
||||
isMoving = true;
|
||||
while (openPercentage < 100.0) {
|
||||
if (state is CurtainsClosing) {
|
||||
@ -71,7 +80,8 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onCloseCurtain(CloseCurtain event, Emitter<CurtainState> emit) async {
|
||||
Future<void> _onCloseCurtain(
|
||||
CloseCurtain event, Emitter<CurtainState> emit) async {
|
||||
isMoving = true;
|
||||
while (openPercentage > 0.0) {
|
||||
if (state is CurtainsOpening) {
|
||||
@ -118,7 +128,8 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onPauseCurtain(PauseCurtain event, Emitter<CurtainState> emit) async {
|
||||
Future<void> _onPauseCurtain(
|
||||
PauseCurtain event, Emitter<CurtainState> emit) async {
|
||||
_pauseCurtain(emit);
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
@ -150,15 +161,12 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
void _fetchStatus(InitCurtain event, Emitter<CurtainState> emit) async {
|
||||
try {
|
||||
emit(CurtainLoadingState());
|
||||
// Fetch the status from the API
|
||||
var response = await DevicesAPI.getDeviceStatus(curtainId);
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
// Get the open percentage from the response
|
||||
openPercentage = double.tryParse(statusModelList[1].value.toString())!;
|
||||
// Calculate curtain width and blind height based on the open percentage
|
||||
curtainWidth = 270 - (openPercentage / 100) * curtainOpeningSpace;
|
||||
blindHeight = 310 - (openPercentage / 100) * blindOpeningSpace;
|
||||
|
||||
@ -172,4 +180,139 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<GroupCurtainModel> groupList = [];
|
||||
bool allSwitchesOn = true;
|
||||
List<DeviceModel> devicesList = [];
|
||||
CurtainModel deviceStatus = CurtainModel(control: 'stop', percent: 0);
|
||||
void _fetchWizardStatus(
|
||||
InitialWizardEvent event, Emitter<CurtainState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
|
||||
try {
|
||||
devicesList = [];
|
||||
groupList = [];
|
||||
allSwitchesOn = true;
|
||||
devicesList = await DevicesAPI.getDeviceByGroupName(
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', 'CUR');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
deviceStatus = CurtainModel.fromJson(statusModelList);
|
||||
groupList.add(GroupCurtainModel(
|
||||
deviceId: devicesList[i].uuid ?? '',
|
||||
deviceName: devicesList[i].name ?? '',
|
||||
firstSwitch: deviceStatus.control,
|
||||
percentControl: deviceStatus.percent));
|
||||
}
|
||||
|
||||
if (groupList.isNotEmpty) {
|
||||
groupList.firstWhere((element) {
|
||||
if (element.percentControl > 1) {
|
||||
allSwitchesOn = true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
emit(
|
||||
UpdateGroupState(curtainList: groupList, allSwitches: allSwitchesOn));
|
||||
} catch (e) {
|
||||
emit(FailedState());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||
Emitter<CurtainState> emit) async {
|
||||
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||
try {
|
||||
bool allSwitchesValue = true;
|
||||
|
||||
// Update the firstSwitch value in the groupList based on the deviceId
|
||||
groupList.forEach((element) {
|
||||
if (element.deviceId == event.deviceId) {
|
||||
element.percentControl =
|
||||
event.value; // Set the new value from the event
|
||||
}
|
||||
if (element.percentControl > 1) {
|
||||
allSwitchesValue = true; // Check if any switch is not 'open'
|
||||
}
|
||||
});
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'percent_control',
|
||||
devicesUuid: [event.deviceId],
|
||||
value: event.value, // Use the value from the event
|
||||
);
|
||||
|
||||
emit(UpdateGroupState(
|
||||
curtainList: groupList, allSwitches: allSwitchesValue));
|
||||
|
||||
if (response['success']) {
|
||||
// Optionally add an initial event if needed.
|
||||
}
|
||||
} catch (_) {
|
||||
// Handle the error if needed.
|
||||
}
|
||||
}
|
||||
|
||||
void _groupAllOn(GroupAllOnEvent event, Emitter<CurtainState> emit) async {
|
||||
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||
try {
|
||||
for (int i = 0; i < groupList.length; i++) {
|
||||
groupList[i].percentControl = 100;
|
||||
}
|
||||
|
||||
emit(UpdateGroupState(curtainList: groupList, allSwitches: true));
|
||||
|
||||
List<String> allDeviceIds =
|
||||
groupList.map((device) => device.deviceId).toList();
|
||||
|
||||
final response2 = await DevicesAPI.deviceBatchController(
|
||||
code: 'percent_control',
|
||||
devicesUuid: allDeviceIds,
|
||||
value: 100,
|
||||
);
|
||||
|
||||
if (response2['failedResults'].toString() != '[]') {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
} catch (_) {
|
||||
emit(FailedState());
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
// Optionally add an initial event if needed.
|
||||
}
|
||||
}
|
||||
|
||||
void _groupAllOff(GroupAllOffEvent event, Emitter<CurtainState> emit) async {
|
||||
emit(LoadingNewSate(curtainModel: deviceStatus));
|
||||
try {
|
||||
for (int i = 0; i < groupList.length; i++) {
|
||||
groupList[i].percentControl = 0;
|
||||
}
|
||||
|
||||
emit(UpdateGroupState(curtainList: groupList, allSwitches: false));
|
||||
|
||||
List<String> allDeviceIds =
|
||||
groupList.map((device) => device.deviceId).toList();
|
||||
|
||||
final response2 = await DevicesAPI.deviceBatchController(
|
||||
code: 'percent_control',
|
||||
devicesUuid: allDeviceIds,
|
||||
value: 0,
|
||||
);
|
||||
|
||||
if (response2['failedResults'].toString() != '[]') {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
} catch (_) {
|
||||
emit(FailedState());
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,4 +31,21 @@ class CloseCurtain extends CurtainEvent {
|
||||
|
||||
class InitCurtain extends CurtainEvent {}
|
||||
class PauseCurtain extends CurtainEvent {}
|
||||
class useCurtainEvent extends CurtainEvent {}
|
||||
class useCurtainEvent extends CurtainEvent {}
|
||||
class InitialWizardEvent extends CurtainEvent {}
|
||||
|
||||
|
||||
class ChangeFirstWizardSwitchStatusEvent extends CurtainEvent {
|
||||
final int value;
|
||||
final String deviceId;
|
||||
const ChangeFirstWizardSwitchStatusEvent(
|
||||
{required this.value, this.deviceId = ''});
|
||||
@override
|
||||
List<Object> get props => [value, deviceId];
|
||||
}
|
||||
|
||||
|
||||
|
||||
class GroupAllOnEvent extends CurtainEvent {}
|
||||
|
||||
class GroupAllOffEvent extends CurtainEvent {}
|
||||
@ -1,5 +1,7 @@
|
||||
// curtain_state.dart
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||
|
||||
abstract class CurtainState extends Equatable {
|
||||
const CurtainState();
|
||||
@ -10,8 +12,9 @@ abstract class CurtainState extends Equatable {
|
||||
|
||||
class CurtainInitial extends CurtainState {}
|
||||
|
||||
class UpdateCurtain extends CurtainState {
|
||||
class LoadingInitialState extends CurtainState {}
|
||||
|
||||
class UpdateCurtain extends CurtainState {
|
||||
final double curtainWidth;
|
||||
final double blindHeight;
|
||||
final double openPercentage;
|
||||
@ -73,4 +76,23 @@ class CurtainsPaused extends CurtainState {
|
||||
|
||||
@override
|
||||
List<Object?> get props => [curtainWidth, blindHeight, openPercentage];
|
||||
}
|
||||
}
|
||||
|
||||
class UpdateGroupState extends CurtainState {
|
||||
final List<GroupCurtainModel> curtainList;
|
||||
final bool allSwitches;
|
||||
|
||||
const UpdateGroupState(
|
||||
{required this.curtainList, required this.allSwitches});
|
||||
|
||||
@override
|
||||
List<Object> get props => [curtainList, allSwitches];
|
||||
}
|
||||
|
||||
class LoadingNewSate extends CurtainState {
|
||||
final CurtainModel curtainModel;
|
||||
const LoadingNewSate({required this.curtainModel});
|
||||
|
||||
@override
|
||||
List<Object> get props => [curtainModel];
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
);
|
||||
emit(UpdateState(doorSensor: deviceStatus));
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(DoorSensorFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
@ -100,7 +100,6 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
doorAlarm = event.isDoorAlarmEnabled;
|
||||
emit(UpdateState(doorSensor: deviceStatus));
|
||||
|
||||
// API call to update the state, if necessary
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: DSId,
|
||||
@ -119,33 +118,26 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
|
||||
Future<void> fetchLogsForLastMonth(
|
||||
ReportLogsInitial event, Emitter<DoorSensorState> emit) async {
|
||||
// Get the current date and time
|
||||
DateTime now = DateTime.now();
|
||||
|
||||
// Calculate the date one month ago
|
||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||
|
||||
// Convert the date to milliseconds since epoch (Unix timestamp in milliseconds)
|
||||
int startTime = lastMonth.millisecondsSinceEpoch;
|
||||
int endTime = now.millisecondsSinceEpoch;
|
||||
try {
|
||||
emit(DoorSensorLoadingState());
|
||||
var response = await DevicesAPI.getReportLogs(
|
||||
startTime:
|
||||
startTime.toString(), // Convert to String if the API expects it
|
||||
endTime: endTime.toString(), // Convert to String if the API expects it
|
||||
startTime.toString(),
|
||||
endTime: endTime.toString(),
|
||||
deviceUuid: DSId,
|
||||
code: 'doorcontact_state',
|
||||
);
|
||||
print('response======${response}');
|
||||
recordGroups = response;
|
||||
// Process response here
|
||||
emit(UpdateState(doorSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
// Handle error
|
||||
print('Error fetching logs: ${errorMessage}');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,11 +34,15 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
on<ToggleDoorEvent>(openCloseGarageDoor);
|
||||
on<GetCounterEvent>(_getCounterValue);
|
||||
on<SetCounterValue>(_setCounterValue);
|
||||
on<SetTimeOutValue>(_setTimeOutAlarm);
|
||||
on<TickTimer>(_onTickTimer);
|
||||
on<InitialWizardEvent>(_fetchWizardStatus);
|
||||
on<GroupAllOnEvent>(_groupAllOn);
|
||||
on<GroupAllOffEvent>(_groupAllOff);
|
||||
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
||||
on<ToggleAlarmEvent>(_toggleAlarmEvent);
|
||||
on<DeleteScheduleEvent>(deleteSchedule);
|
||||
//_toggleAlarmEvent
|
||||
}
|
||||
void _onClose(OnClose event, Emitter<GarageDoorSensorState> emit) {
|
||||
_timer?.cancel();
|
||||
@ -77,13 +81,39 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
toggleDoor = deviceStatus.switch1;
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(GarageDoorFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleAlarmEvent(
|
||||
ToggleAlarmEvent event,
|
||||
Emitter<GarageDoorSensorState> emit,
|
||||
) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
|
||||
try {
|
||||
deviceStatus.doorState1 = event.isEnabled;
|
||||
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: GDId,
|
||||
code: 'door_state_1',
|
||||
value: event.isEnabled,
|
||||
),
|
||||
GDId,
|
||||
);
|
||||
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(GarageDoorFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleClosingReminder(ToggleClosingReminderEvent event,
|
||||
Emitter<GarageDoorSensorState> emit) async {
|
||||
emit(LoadingNewSate(doorSensor: deviceStatus));
|
||||
@ -138,7 +168,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
startTime: startTime.toString(),
|
||||
endTime: endTime.toString(),
|
||||
deviceUuid: GDId,
|
||||
code: 'doorcontact_state',
|
||||
code: 'switch_1',
|
||||
);
|
||||
recordGroups = response;
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
@ -215,6 +245,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
days: selectedDays);
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
add(GetScheduleEvent());
|
||||
add(const ToggleCreateScheduleEvent(index: 1));
|
||||
} else {
|
||||
CustomSnackBar.displaySnackBar('Please select days');
|
||||
}
|
||||
@ -236,6 +267,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
List<dynamic> jsonData = response;
|
||||
listSchedule =
|
||||
jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
@ -561,4 +593,29 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
add(InitialEvent(groupScreen: oneGangGroup));
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
deviceStatus.countdownAlarm = seconds;
|
||||
CustomSnackBar.displaySnackBar('Save Successfully');
|
||||
add(GetScheduleEvent());
|
||||
} else {
|
||||
emit(const GarageDoorFailedState(errorMessage: 'Something went wrong'));
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
emit(GarageDoorFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,13 +39,13 @@ class GetCounterEvent extends GarageDoorEvent {
|
||||
List<Object> get props => [deviceCode];
|
||||
}
|
||||
|
||||
class ToggleLowBatteryEvent extends GarageDoorEvent {
|
||||
final bool isLowBatteryEnabled;
|
||||
class ToggleAlarmEvent extends GarageDoorEvent {
|
||||
final String isEnabled;
|
||||
|
||||
const ToggleLowBatteryEvent(this.isLowBatteryEnabled);
|
||||
const ToggleAlarmEvent(this.isEnabled);
|
||||
|
||||
@override
|
||||
List<Object> get props => [isLowBatteryEnabled];
|
||||
List<Object> get props => [isEnabled];
|
||||
}
|
||||
|
||||
class ToggleClosingReminderEvent extends GarageDoorEvent {
|
||||
@ -74,6 +74,14 @@ class SetCounterValue extends GarageDoorEvent {
|
||||
List<Object> get props => [duration, deviceCode];
|
||||
}
|
||||
|
||||
class SetTimeOutValue extends GarageDoorEvent {
|
||||
final Duration duration;
|
||||
final String deviceCode;
|
||||
const SetTimeOutValue({required this.duration, required this.deviceCode});
|
||||
@override
|
||||
List<Object> get props => [duration, deviceCode];
|
||||
}
|
||||
|
||||
class StartTimer extends GarageDoorEvent {
|
||||
final int duration;
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
deviceStatus = OneGangModel.fromJson(statusModelList);
|
||||
emit(UpdateState(oneGangModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:firebase_database/firebase_database.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_state.dart';
|
||||
@ -64,7 +65,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
deviceStatus = OneTouchModel.fromJson(statusModelList);
|
||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
@ -527,7 +528,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
oneTouchId,
|
||||
);
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
debugPrint('Invalid statusSelected or optionSelected');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
|
||||
@ -37,7 +37,8 @@ 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);
|
||||
@ -59,7 +60,8 @@ 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();
|
||||
@ -71,7 +73,8 @@ 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;
|
||||
@ -92,7 +95,8 @@ 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);
|
||||
@ -102,7 +106,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
deviceStatus = SmartDoorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
@ -111,15 +115,18 @@ 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);
|
||||
@ -133,11 +140,14 @@ 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));
|
||||
@ -147,46 +157,58 @@ 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();
|
||||
} else if (response is Map && response.containsKey('data')) {
|
||||
temporaryPasswords =
|
||||
(response['data'] as List).map((item) => TemporaryPassword.fromJson(item)).toList();
|
||||
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();
|
||||
}
|
||||
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()));
|
||||
}
|
||||
@ -207,7 +229,8 @@ 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));
|
||||
@ -230,7 +253,8 @@ 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,
|
||||
@ -260,20 +284,27 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -329,20 +360,27 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -351,7 +389,8 @@ 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;
|
||||
@ -381,7 +420,8 @@ 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;
|
||||
@ -407,10 +447,12 @@ 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());
|
||||
});
|
||||
@ -445,7 +487,8 @@ 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;
|
||||
|
||||
@ -724,7 +724,8 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
||||
threeTouchId,
|
||||
);
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
emit(const FailedState(
|
||||
error: 'Invalid statusSelected or optionSelected'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
|
||||
@ -93,7 +93,7 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
||||
}
|
||||
deviceStatus = TwoGangModel.fromJson(statusModelList);
|
||||
emit(UpdateState(twoGangModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
||||
@ -99,7 +99,7 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
||||
}
|
||||
deviceStatus = TwoTouchModel.fromJson(statusModelList);
|
||||
emit(UpdateState(twoTouchModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
@ -670,7 +670,7 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
||||
twoTouchId,
|
||||
);
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
emit( const FailedState(error: 'Invalid statusSelected or optionSelected'));
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
|
||||
@ -20,7 +20,9 @@ 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);
|
||||
@ -30,7 +32,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
}
|
||||
deviceStatus = WallSensorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(wallSensorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
@ -39,15 +41,18 @@ 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);
|
||||
@ -56,15 +61,19 @@ 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;
|
||||
@ -73,11 +82,14 @@ 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') {
|
||||
|
||||
@ -74,7 +74,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
statusModelList,
|
||||
);
|
||||
emit(UpdateState(whModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(WHFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
|
||||
165
lib/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart
Normal file
@ -0,0 +1,165 @@
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:firebase_database/firebase_database.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/water_leak_model.dart';
|
||||
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||
|
||||
class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
||||
final String WLId;
|
||||
WaterLeakBloc({
|
||||
required this.WLId,
|
||||
}) : super(const WaterLeakState()) {
|
||||
on<WaterLeakInitial>(_fetchStatus);
|
||||
on<ReportLogsInitial>(fetchLogsForLastMonth);
|
||||
on<ToggleLowBatteryEvent>(_toggleLowBattery);
|
||||
on<ToggleClosingReminderEvent>(_toggleClosingReminder);
|
||||
on<ToggleWaterLeakAlarmEvent>(_toggleWaterLeakAlarm);
|
||||
}
|
||||
Timer? _timer;
|
||||
bool lowBattery = false;
|
||||
bool closingReminder = false;
|
||||
bool waterAlarm = false;
|
||||
WaterLeakModel deviceStatus =
|
||||
WaterLeakModel(waterContactState: 'normal', batteryPercentage: 0);
|
||||
|
||||
void _fetchStatus(
|
||||
WaterLeakInitial event, Emitter<WaterLeakState> emit) async {
|
||||
emit(WaterLeakLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(WLId);
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
deviceStatus = WaterLeakModel.fromJson(
|
||||
statusModelList,
|
||||
);
|
||||
emit(UpdateState(waterSensor: deviceStatus));
|
||||
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(WaterLeakFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleLowBattery(
|
||||
ToggleLowBatteryEvent event, Emitter<WaterLeakState> emit) async {
|
||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||
try {
|
||||
lowBattery = event.isLowBatteryEnabled;
|
||||
emit(UpdateState(waterSensor: deviceStatus));
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: WLId,
|
||||
code: 'low_battery',
|
||||
value: lowBattery,
|
||||
),
|
||||
WLId,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(WaterLeakFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleClosingReminder(
|
||||
ToggleClosingReminderEvent event, Emitter<WaterLeakState> emit) async {
|
||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||
try {
|
||||
closingReminder = event.isClosingReminderEnabled;
|
||||
emit(UpdateState(waterSensor: deviceStatus));
|
||||
|
||||
// API call to update the state, if necessary
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: WLId,
|
||||
code: 'closing_reminder',
|
||||
value: closingReminder,
|
||||
),
|
||||
WLId,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(WaterLeakFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleWaterLeakAlarm(
|
||||
ToggleWaterLeakAlarmEvent event, Emitter<WaterLeakState> emit) async {
|
||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||
try {
|
||||
waterAlarm = event.isWaterLeakAlarmEnabled;
|
||||
emit(UpdateState(waterSensor: deviceStatus));
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: WLId,
|
||||
code: 'water_alarm',
|
||||
value: waterAlarm,
|
||||
),
|
||||
WLId,
|
||||
);
|
||||
} catch (e) {
|
||||
emit(WaterLeakFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
Future<void> fetchLogsForLastMonth(
|
||||
ReportLogsInitial event, Emitter<WaterLeakState> emit) async {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||
int startTime = lastMonth.millisecondsSinceEpoch;
|
||||
int endTime = now.millisecondsSinceEpoch;
|
||||
try {
|
||||
emit(WaterLeakLoadingState());
|
||||
var response = await DevicesAPI.getReportLogs(
|
||||
startTime: startTime.toString(),
|
||||
endTime: endTime.toString(),
|
||||
deviceUuid: WLId,
|
||||
code: 'watersensor_state',
|
||||
);
|
||||
recordGroups = response;
|
||||
emit(UpdateState(waterSensor: deviceStatus));
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
emit(WaterLeakFailedState(errorMessage: errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$WLId');
|
||||
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>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList.add(StatusModel(code: element['code'], value: true));
|
||||
});
|
||||
|
||||
deviceStatus = WaterLeakModel.fromJson(statusList);
|
||||
if (!isClosed) {
|
||||
add(
|
||||
WaterLeakSwitch(switchD: deviceStatus.waterContactState),
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
102
lib/features/devices/bloc/water_leak_bloc/water_leak_event.dart
Normal file
@ -0,0 +1,102 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class WaterLeakEvent extends Equatable {
|
||||
const WaterLeakEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class WaterLeakLoading extends WaterLeakEvent {}
|
||||
|
||||
class WaterLeakSwitch extends WaterLeakEvent {
|
||||
final String switchD;
|
||||
final String deviceId;
|
||||
final String productId;
|
||||
const WaterLeakSwitch({required this.switchD, this.deviceId = '', this.productId = ''});
|
||||
|
||||
@override
|
||||
List<Object> get props => [switchD, deviceId, productId];
|
||||
}
|
||||
|
||||
class WaterLeakUpdated extends WaterLeakEvent {}
|
||||
|
||||
class WaterLeakInitial extends WaterLeakEvent {
|
||||
const WaterLeakInitial();
|
||||
}
|
||||
|
||||
class ReportLogsInitial extends WaterLeakEvent {
|
||||
const ReportLogsInitial();
|
||||
}
|
||||
|
||||
|
||||
class WaterLeakChangeStatus extends WaterLeakEvent {}
|
||||
|
||||
|
||||
class GetCounterEvent extends WaterLeakEvent {
|
||||
final String deviceCode;
|
||||
const GetCounterEvent({required this.deviceCode});
|
||||
@override
|
||||
List<Object> get props => [deviceCode];
|
||||
}
|
||||
|
||||
|
||||
|
||||
class ToggleLowBatteryEvent extends WaterLeakEvent {
|
||||
final bool isLowBatteryEnabled;
|
||||
|
||||
const ToggleLowBatteryEvent(this.isLowBatteryEnabled);
|
||||
|
||||
@override
|
||||
List<Object> get props => [isLowBatteryEnabled];
|
||||
}
|
||||
|
||||
class ToggleClosingReminderEvent extends WaterLeakEvent {
|
||||
final bool isClosingReminderEnabled;
|
||||
|
||||
const ToggleClosingReminderEvent(this.isClosingReminderEnabled);
|
||||
|
||||
@override
|
||||
List<Object> get props => [isClosingReminderEnabled];
|
||||
}
|
||||
|
||||
class ToggleWaterLeakAlarmEvent extends WaterLeakEvent {
|
||||
final bool isWaterLeakAlarmEnabled;
|
||||
|
||||
const ToggleWaterLeakAlarmEvent(this.isWaterLeakAlarmEnabled);
|
||||
|
||||
@override
|
||||
List<Object> get props => [isWaterLeakAlarmEnabled];
|
||||
}
|
||||
|
||||
|
||||
|
||||
class SetCounterValue extends WaterLeakEvent {
|
||||
final Duration duration;
|
||||
final String deviceCode;
|
||||
const SetCounterValue({required this.duration, required this.deviceCode});
|
||||
@override
|
||||
List<Object> get props => [duration, deviceCode];
|
||||
}
|
||||
|
||||
class StartTimer extends WaterLeakEvent {
|
||||
final int duration;
|
||||
|
||||
const StartTimer(this.duration);
|
||||
|
||||
@override
|
||||
List<Object> get props => [duration];
|
||||
}
|
||||
|
||||
class TickTimer extends WaterLeakEvent {
|
||||
final int remainingTime;
|
||||
|
||||
const TickTimer(this.remainingTime);
|
||||
|
||||
@override
|
||||
List<Object> get props => [remainingTime];
|
||||
}
|
||||
|
||||
class StopTimer extends WaterLeakEvent {}
|
||||
|
||||
class OnClose extends WaterLeakEvent {}
|
||||
@ -0,0 +1,39 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/water_leak_model.dart';
|
||||
|
||||
class WaterLeakState extends Equatable {
|
||||
const WaterLeakState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class WaterLeakInitialState extends WaterLeakState {}
|
||||
|
||||
class WaterLeakLoadingState extends WaterLeakState {}
|
||||
|
||||
class WaterLeakFailedState extends WaterLeakState {
|
||||
final String errorMessage;
|
||||
|
||||
const WaterLeakFailedState({required this.errorMessage});
|
||||
|
||||
@override
|
||||
List<Object> get props => [errorMessage];
|
||||
}
|
||||
|
||||
class UpdateState extends WaterLeakState {
|
||||
final WaterLeakModel waterSensor;
|
||||
const UpdateState({required this.waterSensor});
|
||||
|
||||
@override
|
||||
List<Object> get props => [waterSensor];
|
||||
}
|
||||
|
||||
|
||||
class LoadingNewSate extends WaterLeakState {
|
||||
final WaterLeakModel waterSensor;
|
||||
const LoadingNewSate({required this.waterSensor});
|
||||
|
||||
@override
|
||||
List<Object> get props => [waterSensor];
|
||||
}
|
||||
29
lib/features/devices/model/curtain_model.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class CurtainModel {
|
||||
String control;
|
||||
int percent;
|
||||
|
||||
CurtainModel({
|
||||
required this.control,
|
||||
required this.percent,
|
||||
});
|
||||
|
||||
factory CurtainModel.fromJson(List<StatusModel> jsonList) {
|
||||
late String _control;
|
||||
late int _percent;
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'control') {
|
||||
_control = jsonList[i].value ?? false;
|
||||
}
|
||||
if (jsonList[i].code == 'percent_control') {
|
||||
_percent = jsonList[i].value ?? 0;
|
||||
}
|
||||
}
|
||||
//percent_control
|
||||
return CurtainModel(
|
||||
control: _control,
|
||||
percent: _percent,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,9 @@ class DevicesCategoryModel {
|
||||
: name = json['groupName'],
|
||||
// id = json['groupId'],
|
||||
type = devicesTypesMap[json['groupName']] ?? DeviceType.Other,
|
||||
icon = deviceTypeIconMap[devicesTypesMap[json['groupName']] ?? DeviceType.Other] ?? '',
|
||||
icon = deviceTypeIconMap[
|
||||
devicesTypesMap[json['groupName']] ?? DeviceType.Other] ??
|
||||
'',
|
||||
devices = [],
|
||||
isSelected = false;
|
||||
|
||||
@ -65,8 +67,8 @@ Map<DeviceType, String> deviceTypeIconMap = {
|
||||
DeviceType.WH: Assets.waterHeaterIcon,
|
||||
DeviceType.DS: Assets.doorSensorIcon,
|
||||
DeviceType.Other: Assets.assetsIconsAC,
|
||||
DeviceType.OneTouch: Assets.oneGang,
|
||||
DeviceType.TowTouch: Assets.twoGang,
|
||||
DeviceType.ThreeTouch: Assets.assetsIconsGang,
|
||||
DeviceType.OneTouch: Assets.gang1touch,
|
||||
DeviceType.TowTouch: Assets.gang2touch,
|
||||
DeviceType.ThreeTouch: Assets.gang3touch,
|
||||
DeviceType.GarageDoor: Assets.garageIcon
|
||||
};
|
||||
|
||||
@ -67,15 +67,16 @@ class DeviceModel {
|
||||
} else if (type == DeviceType.DS) {
|
||||
tempIcon = Assets.doorSensorIcon;
|
||||
} else if (type == DeviceType.OneTouch) {
|
||||
tempIcon = Assets.oneGang;
|
||||
tempIcon = Assets.gang1touch;
|
||||
} else if (type == DeviceType.TowTouch) {
|
||||
tempIcon = Assets.twoGang;
|
||||
tempIcon = Assets.gang2touch;
|
||||
} else if (type == DeviceType.GarageDoor) {
|
||||
tempIcon = Assets.garageIcon;
|
||||
} else if (type == DeviceType.ThreeTouch) {
|
||||
tempIcon = Assets.assetsIcons3GangSwitch;
|
||||
}
|
||||
else {
|
||||
tempIcon = Assets.gang3touch;
|
||||
} else if (type == DeviceType.WaterLeak) {
|
||||
tempIcon = Assets.waterLeakIcon;
|
||||
} else {
|
||||
tempIcon = Assets.assetsIconsLogo;
|
||||
}
|
||||
|
||||
|
||||
13
lib/features/devices/model/group_curtain_model.dart
Normal file
@ -0,0 +1,13 @@
|
||||
class GroupCurtainModel {
|
||||
final String deviceId;
|
||||
final String deviceName;
|
||||
String firstSwitch;
|
||||
int percentControl;
|
||||
|
||||
GroupCurtainModel({
|
||||
required this.deviceId,
|
||||
required this.deviceName,
|
||||
required this.firstSwitch,
|
||||
required this.percentControl,
|
||||
});
|
||||
}
|
||||
28
lib/features/devices/model/water_leak_model.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
class WaterLeakModel {
|
||||
String waterContactState;
|
||||
int batteryPercentage;
|
||||
|
||||
WaterLeakModel({
|
||||
required this.waterContactState,
|
||||
required this.batteryPercentage,
|
||||
});
|
||||
|
||||
factory WaterLeakModel.fromJson(List<StatusModel> jsonList) {
|
||||
late String _waterContactState;
|
||||
late int _batteryPercentage;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'watersensor_state') {
|
||||
_waterContactState = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'battery_percentage') {
|
||||
_batteryPercentage = jsonList[i].value ?? 0;
|
||||
}
|
||||
}
|
||||
return WaterLeakModel(
|
||||
waterContactState: _waterContactState,
|
||||
batteryPercentage: _batteryPercentage,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -86,6 +86,8 @@ class ACsList extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: devicesStatuesList[index].acSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ACsBloc>(context).add(AcSwitch(
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
||||
|
||||
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||
|
||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class CurtainsList extends StatelessWidget {
|
||||
const CurtainsList(
|
||||
{super.key, required this.curtainsList, required this.allSwitches});
|
||||
|
||||
final List<GroupCurtainModel> curtainsList;
|
||||
final bool allSwitches;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CurtainBloc, CurtainState>(
|
||||
builder: (context, state) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const BodySmall(text: 'All Curtains'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'Close',
|
||||
on: 'Open',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<CurtainBloc>(context).add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<CurtainBloc>(context).add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: curtainsList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: curtainsList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'close',
|
||||
on: 'open',
|
||||
switchValue: curtainsList[index].percentControl > 1,
|
||||
action: () {
|
||||
// Toggle between 'open' and 'close' based on current value
|
||||
final newValue =
|
||||
curtainsList[index].percentControl > 1 ? 0 : 100;
|
||||
BlocProvider.of<CurtainBloc>(context).add(
|
||||
ChangeFirstWizardSwitchStatusEvent(
|
||||
value: newValue,
|
||||
deviceId: curtainsList[index].deviceId,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/curtain_bloc/curtain_state.dart';
|
||||
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_curtain_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtains_list.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
|
||||
class CurtainsWizard extends StatelessWidget {
|
||||
const CurtainsWizard({super.key, this.device});
|
||||
|
||||
final DeviceModel? device;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<GroupCurtainModel> groupOneTouchModel = [];
|
||||
|
||||
return DefaultScaffold(
|
||||
title: 'Curtain',
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
CurtainBloc(device?.uuid ?? '')..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<CurtainBloc, CurtainState>(
|
||||
builder: (context, state) {
|
||||
bool allSwitchesOn = false;
|
||||
if (state is UpdateGroupState) {
|
||||
groupOneTouchModel = state.curtainList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: CurtainsList(
|
||||
curtainsList: groupOneTouchModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -24,32 +24,17 @@ class GarageDoorScreen extends StatelessWidget {
|
||||
return DefaultScaffold(
|
||||
title: 'Garage Door Opener',
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
GarageDoorBloc(GDId: device?.uuid ?? '')..add(const GarageDoorInitial()),
|
||||
create: (context) => GarageDoorBloc(GDId: device?.uuid ?? '')
|
||||
..add(const GarageDoorInitial()),
|
||||
child: BlocBuilder<GarageDoorBloc, GarageDoorSensorState>(
|
||||
builder: (context, state) {
|
||||
final garageBloc = BlocProvider.of<GarageDoorBloc>(context);
|
||||
// GarageDoorModel model = GarageDoorModel(
|
||||
// tr_timecon: 0,
|
||||
// countdown1: 0,
|
||||
// countdownAlarm: 0,
|
||||
// doorContactState: false,
|
||||
// doorControl1: '',
|
||||
// doorState1: '',
|
||||
// switch1: false,
|
||||
// voiceControl1: false,
|
||||
// batteryPercentage: 0,
|
||||
// );
|
||||
|
||||
// if (state is LoadingNewSate) {
|
||||
// model = state.doorSensor;
|
||||
// } else if (state is UpdateState) {
|
||||
// model = state.garageSensor;
|
||||
// }
|
||||
return state is GarageDoorLoadingState
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
@ -62,32 +47,38 @@ class GarageDoorScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
flex: 5,
|
||||
child: InkWell(
|
||||
overlayColor: WidgetStateProperty.all(Colors.transparent),
|
||||
overlayColor: WidgetStateProperty.all(
|
||||
Colors.transparent),
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(890),
|
||||
borderRadius:
|
||||
BorderRadius.circular(890),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
color: Colors.white
|
||||
.withOpacity(0.1),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(-5, -5),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.11),
|
||||
color: Colors.black
|
||||
.withOpacity(0.11),
|
||||
blurRadius: 25,
|
||||
offset: const Offset(5, 5),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.13),
|
||||
color: Colors.black
|
||||
.withOpacity(0.13),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(5, 5),
|
||||
blurStyle: BlurStyle.inner,
|
||||
@ -96,177 +87,226 @@ class GarageDoorScreen extends StatelessWidget {
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
garageBloc.add(
|
||||
ToggleDoorEvent(toggle: garageBloc.toggleDoor));
|
||||
garageBloc.add(ToggleDoorEvent(
|
||||
toggle:
|
||||
garageBloc.toggleDoor));
|
||||
},
|
||||
child: GradientWidget(
|
||||
doorStatus: garageBloc.toggleDoor,
|
||||
seconds: garageBloc.secondSelected,
|
||||
seconds:
|
||||
garageBloc.secondSelected,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TimerScheduleScreen(
|
||||
device: device!,
|
||||
switchCode: 'switch_1',
|
||||
deviceCode: 'countdown_1',
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
TimerScheduleScreen(
|
||||
device: device!,
|
||||
switchCode:
|
||||
'switch_1',
|
||||
deviceCode:
|
||||
'countdown_1',
|
||||
)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(
|
||||
maxHeight: 46,
|
||||
maxWidth: 50),
|
||||
child: SvgPicture.asset(
|
||||
Assets
|
||||
.garageSchedule),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
height: 15,
|
||||
)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(maxHeight: 46, maxWidth: 50),
|
||||
child: SvgPicture.asset(Assets.garageSchedule),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Schedule',
|
||||
textAlign: TextAlign.center,
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Schedule',
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TimerPage(
|
||||
device: device!,
|
||||
switchCode: 'switch_1',
|
||||
deviceCode: 'countdown_1',
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
TimerPage(
|
||||
device: device!,
|
||||
switchCode:
|
||||
'switch_1',
|
||||
deviceCode:
|
||||
'countdown_1',
|
||||
)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(
|
||||
maxHeight: 46,
|
||||
maxWidth: 50),
|
||||
child: SvgPicture.asset(
|
||||
Assets
|
||||
.garageCountdown),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
height: 15,
|
||||
)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(maxHeight: 46, maxWidth: 50),
|
||||
child: SvgPicture.asset(Assets.garageCountdown),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Countdown',
|
||||
textAlign: TextAlign.center,
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Countdown',
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Flexible(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
GarageRecordsScreen(GDId: device!.uuid!)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Flexible(
|
||||
child: Row(
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(maxHeight: 46, maxWidth: 50),
|
||||
child: SvgPicture.asset(Assets.doorRecordsIcon),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
GarageRecordsScreen(
|
||||
GDId: device!
|
||||
.uuid!)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(
|
||||
maxHeight: 46,
|
||||
maxWidth: 50),
|
||||
child: SvgPicture.asset(
|
||||
Assets
|
||||
.doorRecordsIcon),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
height: 15,
|
||||
)),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Records',
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
width: 10,
|
||||
),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Records',
|
||||
textAlign: TextAlign.center,
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
PreferencesPage(
|
||||
GDId: device!
|
||||
.uuid!)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(
|
||||
maxHeight: 46,
|
||||
maxWidth: 50),
|
||||
child: SvgPicture.asset(Assets
|
||||
.garagePreferencesIcon),
|
||||
),
|
||||
const Flexible(
|
||||
child: SizedBox(
|
||||
height: 15,
|
||||
)),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Preferences',
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
PreferencesPage(GDId: device!.uuid!)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints:
|
||||
const BoxConstraints(maxHeight: 46, maxWidth: 50),
|
||||
child: SvgPicture.asset(Assets.garagePreferencesIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Preferences',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -289,7 +329,8 @@ class GradientWidget extends StatefulWidget {
|
||||
State<GradientWidget> createState() => _GradientWidgetState();
|
||||
}
|
||||
|
||||
class _GradientWidgetState extends State<GradientWidget> with SingleTickerProviderStateMixin {
|
||||
class _GradientWidgetState extends State<GradientWidget>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late ScrollController _scrollController;
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> _itemExtentAnimation;
|
||||
@ -302,15 +343,16 @@ class _GradientWidgetState extends State<GradientWidget> with SingleTickerProvid
|
||||
vsync: this,
|
||||
duration: Duration(seconds: widget.seconds),
|
||||
);
|
||||
_itemExtentAnimation =
|
||||
Tween<double>(begin: widget.doorStatus ? 0 : 15, end: widget.doorStatus ? 15 : 0).animate(
|
||||
_itemExtentAnimation = Tween<double>(
|
||||
begin: widget.doorStatus ? 0 : 15, end: widget.doorStatus ? 15 : 0)
|
||||
.animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Curves.easeInOut,
|
||||
),
|
||||
)..addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.doorStatus) {
|
||||
|
||||
@ -26,6 +26,8 @@ class GarageList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<GarageDoorBloc>(context)
|
||||
@ -49,6 +51,8 @@ class GarageList extends StatelessWidget {
|
||||
BodySmall(text: garageList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: garageList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<GarageDoorBloc>(context).add(
|
||||
|
||||
@ -18,7 +18,8 @@ class PreferencesPage extends StatelessWidget {
|
||||
return DefaultScaffold(
|
||||
title: 'Preferences',
|
||||
child: BlocProvider(
|
||||
create: (context) => GarageDoorBloc(GDId: GDId)..add(const GarageDoorInitial()),
|
||||
create: (context) =>
|
||||
GarageDoorBloc(GDId: GDId)..add(const GarageDoorInitial()),
|
||||
child: BlocBuilder<GarageDoorBloc, GarageDoorSensorState>(
|
||||
builder: (context, state) {
|
||||
final garageDoorBloc = BlocProvider.of<GarageDoorBloc>(context);
|
||||
@ -26,7 +27,9 @@ class PreferencesPage extends StatelessWidget {
|
||||
return state is GarageDoorLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
@ -49,14 +52,42 @@ class PreferencesPage extends StatelessWidget {
|
||||
height: 50,
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
text: 'Alarm when door is open',
|
||||
fontWeight: FontWeight.normal,
|
||||
leading: InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return TimeoutDialog(
|
||||
duration: Duration(
|
||||
seconds: garageDoorBloc
|
||||
.deviceStatus
|
||||
.countdownAlarm),
|
||||
title: 'Timeout Alarm',
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: (selectedSecond) {
|
||||
garageDoorBloc.add(
|
||||
SetTimeOutValue(
|
||||
deviceCode:
|
||||
'countdown_alarm',
|
||||
duration:
|
||||
selectedSecond));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const BodyMedium(
|
||||
text: 'Alarm when door is open',
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
trailing: Container(
|
||||
width: 100,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
height: 30,
|
||||
@ -64,18 +95,25 @@ class PreferencesPage extends StatelessWidget {
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: garageDoorBloc.lowBattery,
|
||||
onChanged: (value) {
|
||||
// context
|
||||
// .read<GarageDoorBloc>()
|
||||
// .add(
|
||||
// ToggleLowBatteryEvent(
|
||||
// value));
|
||||
},
|
||||
applyTheme: true,
|
||||
)),
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: garageDoorBloc.deviceStatus
|
||||
.doorState1 !=
|
||||
'unclosed_time',
|
||||
onChanged: (value) {
|
||||
context
|
||||
.read<GarageDoorBloc>()
|
||||
.add(
|
||||
ToggleAlarmEvent(
|
||||
value
|
||||
? 'unclosed_time'
|
||||
: 'close_time_alarm',
|
||||
),
|
||||
);
|
||||
},
|
||||
applyTheme: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
@ -103,12 +141,15 @@ class PreferencesPage extends StatelessWidget {
|
||||
builder: (context) {
|
||||
return SecondDialog(
|
||||
label2: 'Close',
|
||||
initialSelectedLabel: garageDoorBloc.secondSelected.toString(),
|
||||
initialSelectedLabel: garageDoorBloc
|
||||
.secondSelected
|
||||
.toString(),
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: (v) {
|
||||
garageDoorBloc.add(SelectSecondsEvent(seconds: v));
|
||||
garageDoorBloc
|
||||
.add(SelectSecondsEvent(seconds: v));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
title: 'Control',
|
||||
@ -118,34 +159,37 @@ class PreferencesPage extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(top: 12, bottom: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyMedium(
|
||||
text: 'Opening and Closing Time',
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
trailing: Container(
|
||||
height: 90,
|
||||
width: 120,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontColor: ColorsManager.textGray,
|
||||
text:
|
||||
'${garageDoorBloc.secondSelected.toString()} Seconds',
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 15,
|
||||
color: ColorsManager.textGray,
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontColor: ColorsManager.textGray,
|
||||
text:
|
||||
'${garageDoorBloc.secondSelected.toString()} Seconds',
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 13,
|
||||
),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 15,
|
||||
color: ColorsManager.textGray,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -156,6 +200,7 @@ class PreferencesPage extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
}
|
||||
//Timeout
|
||||
|
||||
class SecondDialog extends StatefulWidget {
|
||||
final String label1;
|
||||
@ -183,15 +228,12 @@ class SecondDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SecondDialogState extends State<SecondDialog> {
|
||||
// late String _selectedOption;
|
||||
late int selectedSecond;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Parse the initialSelectedLabel as an integer. Default to 10 if invalid or not provided.
|
||||
selectedSecond = int.tryParse(widget.initialSelectedLabel ?? '10') ?? 10;
|
||||
// _selectedOption = widget.initialSelectedLabel ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -229,7 +271,6 @@ class _SecondDialogState extends State<SecondDialog> {
|
||||
child: CupertinoPicker(
|
||||
itemExtent: 40.0,
|
||||
scrollController: FixedExtentScrollController(
|
||||
// Set the initial position based on selectedSecond
|
||||
initialItem: selectedSecond - 10,
|
||||
),
|
||||
onSelectedItemChanged: (int index) {
|
||||
@ -242,7 +283,9 @@ class _SecondDialogState extends State<SecondDialog> {
|
||||
child: BodyLarge(
|
||||
text: (index + 10).toString().padLeft(2, '0'),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w400, fontSize: 30, color: Colors.blue),
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 30,
|
||||
color: Colors.blue),
|
||||
),
|
||||
);
|
||||
}),
|
||||
@ -326,3 +369,153 @@ class _SecondDialogState extends State<SecondDialog> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TimeoutDialog extends StatefulWidget {
|
||||
final String title;
|
||||
final Function(String)? onTapLabel1;
|
||||
final Function()? cancelTab;
|
||||
final Function(Duration timeSelected)? confirmTab;
|
||||
final Duration? duration;
|
||||
|
||||
TimeoutDialog({
|
||||
required this.title,
|
||||
this.onTapLabel1,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
this.duration,
|
||||
});
|
||||
|
||||
@override
|
||||
_TimeoutDialogState createState() => _TimeoutDialogState();
|
||||
}
|
||||
|
||||
class _TimeoutDialogState extends State<TimeoutDialog> {
|
||||
late int selectedSecond;
|
||||
Duration duration = Duration.zero;
|
||||
int countNum = 0;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
duration = widget.duration!;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyLarge(
|
||||
text: widget.title,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontColor: ColorsManager.primaryColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Divider(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15, bottom: 10),
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
height: 150,
|
||||
width: MediaQuery.of(context).size.width * 1,
|
||||
child: CupertinoTimerPicker(
|
||||
initialTimerDuration: duration,
|
||||
mode: CupertinoTimerPickerMode.hm,
|
||||
onTimerDurationChanged: (Duration newDuration) {
|
||||
duration = newDuration;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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: widget.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: () {
|
||||
widget.confirmTab?.call(duration);
|
||||
},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatDuration(int seconds) {
|
||||
final hours = (seconds ~/ 3600).toString().padLeft(2, '0');
|
||||
final minutes = ((seconds % 3600) ~/ 60).toString().padLeft(2, '0');
|
||||
final secs = (seconds % 60).toString().padLeft(2, '0');
|
||||
return '$hours:$minutes:$secs';
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,10 @@ class TimerScheduleScreen extends StatelessWidget {
|
||||
final String deviceCode;
|
||||
final String switchCode;
|
||||
const TimerScheduleScreen(
|
||||
{required this.device, required this.deviceCode, required this.switchCode, super.key});
|
||||
{required this.device,
|
||||
required this.deviceCode,
|
||||
required this.switchCode,
|
||||
super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -28,21 +31,11 @@ class TimerScheduleScreen extends StatelessWidget {
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: BlocProvider(
|
||||
create: (context) => GarageDoorBloc(GDId: device.uuid ?? '')..add(GetScheduleEvent()),
|
||||
create: (context) =>
|
||||
GarageDoorBloc(GDId: device.uuid ?? '')..add(GetScheduleEvent()),
|
||||
child: BlocBuilder<GarageDoorBloc, GarageDoorSensorState>(
|
||||
builder: (context, state) {
|
||||
final garageBloc = BlocProvider.of<GarageDoorBloc>(context);
|
||||
// Duration duration = Duration.zero;
|
||||
// int countNum = 0;
|
||||
// if (state is UpdateTimerState) {
|
||||
// countNum = state.seconds;
|
||||
// } else if (state is TimerRunInProgress) {
|
||||
// countNum = state.remainingTime;
|
||||
// } else if (state is TimerRunComplete) {
|
||||
// countNum = 0;
|
||||
// } else if (state is LoadingNewSate) {
|
||||
// countNum = 0;
|
||||
// }
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) {
|
||||
@ -71,13 +64,15 @@ class TimerScheduleScreen extends StatelessWidget {
|
||||
child: const Text('Save'))
|
||||
: IconButton(
|
||||
onPressed: () {
|
||||
garageBloc.add(const ToggleCreateScheduleEvent(index: 1));
|
||||
garageBloc.add(
|
||||
const ToggleCreateScheduleEvent(
|
||||
index: 1));
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: state is GarageDoorLoading
|
||||
child: state is GarageDoorLoadingState
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Column(
|
||||
children: [
|
||||
@ -86,7 +81,8 @@ class TimerScheduleScreen extends StatelessWidget {
|
||||
decoration: const ShapeDecoration(
|
||||
color: ColorsManager.onPrimaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(30)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -97,25 +93,37 @@ class TimerScheduleScreen extends StatelessWidget {
|
||||
onToggleChanged: (bool value) {
|
||||
garageBloc.toggleSchedule = value;
|
||||
},
|
||||
onDateTimeChanged: (DateTime dateTime) {
|
||||
garageBloc.selectedTime = dateTime;
|
||||
onDateTimeChanged:
|
||||
(DateTime dateTime) {
|
||||
garageBloc.selectedTime =
|
||||
dateTime;
|
||||
},
|
||||
days: garageBloc.days,
|
||||
selectDays: (List<String> selectedDays) {
|
||||
garageBloc.selectedDays = selectedDays;
|
||||
selectDays:
|
||||
(List<String> selectedDays) {
|
||||
garageBloc.selectedDays =
|
||||
selectedDays;
|
||||
},
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 10),
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10),
|
||||
child: ScheduleListView(
|
||||
listSchedule: garageBloc.listSchedule,
|
||||
listSchedule:
|
||||
garageBloc.listSchedule,
|
||||
onDismissed: (scheduleId) {
|
||||
garageBloc.listSchedule.removeWhere((schedule) =>
|
||||
schedule.scheduleId == scheduleId);
|
||||
garageBloc.add(DeleteScheduleEvent(id: scheduleId));
|
||||
garageBloc.listSchedule
|
||||
.removeWhere((schedule) =>
|
||||
schedule.scheduleId ==
|
||||
scheduleId);
|
||||
garageBloc.add(
|
||||
DeleteScheduleEvent(
|
||||
id: scheduleId));
|
||||
},
|
||||
onToggleSchedule: (scheduleId, isEnabled) {
|
||||
garageBloc.add(ToggleScheduleEvent(
|
||||
onToggleSchedule:
|
||||
(scheduleId, isEnabled) {
|
||||
garageBloc
|
||||
.add(ToggleScheduleEvent(
|
||||
id: scheduleId,
|
||||
toggle: isEnabled,
|
||||
));
|
||||
|
||||
@ -48,6 +48,8 @@ class LightsList extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: false,
|
||||
action: () {},
|
||||
),
|
||||
|
||||
@ -26,6 +26,8 @@ class OneGangList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<OneGangBloc>(context).add(GroupAllOnEvent());
|
||||
@ -47,6 +49,8 @@ class OneGangList extends StatelessWidget {
|
||||
BodySmall(text: oneGangList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: oneGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<OneGangBloc>(context).add(
|
||||
|
||||
@ -27,12 +27,15 @@ class OneTouchList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOffEvent());
|
||||
BlocProvider.of<OneTouchBloc>(context)
|
||||
.add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
@ -48,6 +51,8 @@ class OneTouchList extends StatelessWidget {
|
||||
BodySmall(text: oneTouchList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: oneTouchList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<OneTouchBloc>(context).add(
|
||||
|
||||
@ -23,6 +23,7 @@ import 'package:syncrow_app/features/devices/view/widgets/ceiling_sensor/ceiling
|
||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_heater/water_heater_page.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_leak/water_leak_screen.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
|
||||
@ -196,6 +197,13 @@ void showDeviceInterface(DeviceModel device, BuildContext context) {
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
GarageDoorScreen(device: device)));
|
||||
|
||||
case DeviceType.WaterLeak:
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
WaterLeakScreen(device: device)));
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
@ -8,7 +8,8 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class ThreeGangList extends StatelessWidget {
|
||||
const ThreeGangList({super.key, required this.threeGangList, required this.allSwitches});
|
||||
const ThreeGangList(
|
||||
{super.key, required this.threeGangList, required this.allSwitches});
|
||||
|
||||
final List<GroupThreeGangModel> threeGangList;
|
||||
final bool allSwitches;
|
||||
@ -25,12 +26,16 @@ class ThreeGangList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOnEvent());
|
||||
BlocProvider.of<ThreeGangBloc>(context)
|
||||
.add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(GroupAllOffEvent());
|
||||
BlocProvider.of<ThreeGangBloc>(context)
|
||||
.add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
@ -43,36 +48,50 @@ class ThreeGangList extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} beside light'),
|
||||
BodySmall(
|
||||
text:
|
||||
'${threeGangList[index].deviceName} beside light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: threeGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
||||
value: threeGangList[index].firstSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: threeGangList[index].firstSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} ceiling light'),
|
||||
BodySmall(
|
||||
text:
|
||||
'${threeGangList[index].deviceName} ceiling light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: threeGangList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeSecondSwitchStatusEvent(
|
||||
value: threeGangList[index].secondSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeSecondSwitchStatusEvent(
|
||||
value: threeGangList[index].secondSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeGangList[index].deviceName} spotlight'),
|
||||
BodySmall(
|
||||
text: '${threeGangList[index].deviceName} spotlight'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: threeGangList[index].thirdSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(ChangeThirdSwitchStatusEvent(
|
||||
value: threeGangList[index].thirdSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
BlocProvider.of<ThreeGangBloc>(context).add(
|
||||
ChangeThirdSwitchStatusEvent(
|
||||
value: threeGangList[index].thirdSwitch,
|
||||
deviceId: threeGangList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -8,7 +8,8 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class ThreeTouchList extends StatelessWidget {
|
||||
const ThreeTouchList({super.key, required this.threeTouchList, required this.allSwitches});
|
||||
const ThreeTouchList(
|
||||
{super.key, required this.threeTouchList, required this.allSwitches});
|
||||
|
||||
final List<GroupThreeTouchModel> threeTouchList;
|
||||
final bool allSwitches;
|
||||
@ -25,12 +26,16 @@ class ThreeTouchList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(GroupAllOnEvent());
|
||||
BlocProvider.of<ThreeTouchBloc>(context)
|
||||
.add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(GroupAllOffEvent());
|
||||
BlocProvider.of<ThreeTouchBloc>(context)
|
||||
.add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
@ -43,36 +48,51 @@ class ThreeTouchList extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeTouchList[index].deviceName} beside light'),
|
||||
BodySmall(
|
||||
text:
|
||||
'${threeTouchList[index].deviceName} beside light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: threeTouchList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(ChangeFirstSwitchStatusEvent(
|
||||
value: threeTouchList[index].firstSwitch,
|
||||
deviceId: threeTouchList[index].deviceId));
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(
|
||||
ChangeFirstSwitchStatusEvent(
|
||||
value: threeTouchList[index].firstSwitch,
|
||||
deviceId: threeTouchList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeTouchList[index].deviceName} ceiling light'),
|
||||
BodySmall(
|
||||
text:
|
||||
'${threeTouchList[index].deviceName} ceiling light'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: threeTouchList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(ChangeSecondSwitchStatusEvent(
|
||||
value: threeTouchList[index].secondSwitch,
|
||||
deviceId: threeTouchList[index].deviceId));
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(
|
||||
ChangeSecondSwitchStatusEvent(
|
||||
value: threeTouchList[index].secondSwitch,
|
||||
deviceId: threeTouchList[index].deviceId));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: '${threeTouchList[index].deviceName} spotlight'),
|
||||
BodySmall(
|
||||
text:
|
||||
'${threeTouchList[index].deviceName} spotlight'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: threeTouchList[index].thirdSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(ChangeThirdSwitchStatusEvent(
|
||||
value: threeTouchList[index].thirdSwitch,
|
||||
deviceId: threeTouchList[index].deviceId));
|
||||
BlocProvider.of<ThreeTouchBloc>(context).add(
|
||||
ChangeThirdSwitchStatusEvent(
|
||||
value: threeTouchList[index].thirdSwitch,
|
||||
deviceId: threeTouchList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@ -26,6 +26,8 @@ class TwoGangList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(GroupAllOnEvent());
|
||||
@ -47,6 +49,8 @@ class TwoGangList extends StatelessWidget {
|
||||
BodySmall(text: twoGangList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: twoGangList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
@ -59,6 +63,8 @@ class TwoGangList extends StatelessWidget {
|
||||
BodySmall(text: twoGangList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: twoGangList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoGangBloc>(context).add(
|
||||
|
||||
@ -26,12 +26,15 @@ class TwoTouchList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<TwoTouchBloc>(context).add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<TwoTouchBloc>(context).add(GroupAllOffEvent());
|
||||
BlocProvider.of<TwoTouchBloc>(context)
|
||||
.add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
@ -47,6 +50,8 @@ class TwoTouchList extends StatelessWidget {
|
||||
BodySmall(text: twoTouchList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: twoTouchList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoTouchBloc>(context).add(
|
||||
@ -59,6 +64,8 @@ class TwoTouchList extends StatelessWidget {
|
||||
BodySmall(text: twoTouchList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: twoTouchList[index].secondSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<TwoTouchBloc>(context).add(
|
||||
|
||||
@ -25,6 +25,8 @@ class WHList extends StatelessWidget {
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<WaterHeaterBloc>(context)
|
||||
@ -48,6 +50,8 @@ class WHList extends StatelessWidget {
|
||||
BodySmall(text: whList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
off: 'OFF',
|
||||
on: 'ON',
|
||||
switchValue: whList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<WaterHeaterBloc>(context).add(
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_state.dart';
|
||||
|
||||
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_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class NotificationSettingsPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: 'Notification Settings',
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
WaterLeakBloc(WLId: '')..add(const WaterLeakInitial()),
|
||||
child: BlocBuilder<WaterLeakBloc, WaterLeakState>(
|
||||
builder: (context, state) {
|
||||
final waterLeakBloc = BlocProvider.of<WaterLeakBloc>(context);
|
||||
|
||||
return state is WaterLeakLoading
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
DefaultContainer(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
text: 'Low Battery Alarm',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 15,
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: waterLeakBloc.lowBattery,
|
||||
onChanged: (value) {
|
||||
context.read<WaterLeakBloc>().add(
|
||||
ToggleLowBatteryEvent(value));
|
||||
},
|
||||
applyTheme: true,
|
||||
)),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyLarge(
|
||||
text: 'Water Leakage Alarm',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 15,
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: waterLeakBloc.closingReminder,
|
||||
onChanged: (value) {
|
||||
context.read<WaterLeakBloc>().add(
|
||||
ToggleClosingReminderEvent(
|
||||
value));
|
||||
},
|
||||
applyTheme: true,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,224 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_report_model.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_small.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class WaterLeakRecordsScreen extends StatefulWidget {
|
||||
final String WLId;
|
||||
const WaterLeakRecordsScreen({super.key, required this.WLId});
|
||||
|
||||
@override
|
||||
State<WaterLeakRecordsScreen> createState() => _WaterLeakRecordsScreenState();
|
||||
}
|
||||
|
||||
class _WaterLeakRecordsScreenState extends State<WaterLeakRecordsScreen> {
|
||||
int _selectedIndex = 0;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: 'Records',
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
WaterLeakBloc(WLId: widget.WLId)..add(const ReportLogsInitial()),
|
||||
child: BlocBuilder<WaterLeakBloc, WaterLeakState>(
|
||||
builder: (context, state) {
|
||||
final waterSensorBloc = BlocProvider.of<WaterLeakBloc>(context);
|
||||
final Map<String, List<DeviceEvent>> groupedRecords = {};
|
||||
|
||||
if (state is WaterLeakLoadingState) {
|
||||
return const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
);
|
||||
} else if (state is UpdateState) {
|
||||
for (var record in waterSensorBloc.recordGroups.data!) {
|
||||
final DateTime eventDateTime =
|
||||
DateTime.fromMillisecondsSinceEpoch(record.eventTime!);
|
||||
final String formattedDate =
|
||||
DateFormat('EEEE, dd/MM/yyyy').format(eventDateTime);
|
||||
|
||||
if (groupedRecords.containsKey(formattedDate)) {
|
||||
groupedRecords[formattedDate]!.add(record);
|
||||
} else {
|
||||
groupedRecords[formattedDate] = [record];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultTabController(
|
||||
length: 2,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: const ShapeDecoration(
|
||||
color: ColorsManager.onPrimaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
),
|
||||
),
|
||||
child: TabBar(
|
||||
onTap: (value) {
|
||||
setState(() {
|
||||
_selectedIndex = value;
|
||||
});
|
||||
},
|
||||
indicatorColor: Colors.white,
|
||||
dividerHeight: 0,
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
indicator: const ShapeDecoration(
|
||||
color: ColorsManager.slidingBlueColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
),
|
||||
tabs: [
|
||||
Tab(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: BodySmall(
|
||||
text: 'Record',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: _selectedIndex == 0
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Tab(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Text(
|
||||
'Automation Record',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: _selectedIndex == 1
|
||||
? Colors.white
|
||||
: ColorsManager.blackColor,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
groupedRecords.isEmpty
|
||||
? const Center(child: Text('No data available.'))
|
||||
: ListView.builder(
|
||||
itemCount: groupedRecords.length,
|
||||
itemBuilder: (context, index) {
|
||||
final String date =
|
||||
groupedRecords.keys.elementAt(index);
|
||||
final List<DeviceEvent> recordsForDate =
|
||||
groupedRecords[date]!;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
DefaultContainer(
|
||||
child: Column(
|
||||
children: [
|
||||
...recordsForDate
|
||||
.asMap()
|
||||
.entries
|
||||
.map((entry) {
|
||||
final int idx = entry.key;
|
||||
final DeviceEvent record =
|
||||
entry.value;
|
||||
final DateTime eventDateTime =
|
||||
DateTime
|
||||
.fromMillisecondsSinceEpoch(
|
||||
record.eventTime!);
|
||||
final String formattedTime =
|
||||
DateFormat('HH:mm:ss')
|
||||
.format(eventDateTime);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
record.value == 'true'
|
||||
? Assets
|
||||
.leakDetectedIcon
|
||||
: Assets
|
||||
.leakNormalIcon,
|
||||
height: 25,
|
||||
width: 25,
|
||||
),
|
||||
title: Text(
|
||||
record.value == 'true'
|
||||
? "Leak Detected"
|
||||
: "Normal",
|
||||
style: const TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
subtitle:
|
||||
Text('$formattedTime'),
|
||||
),
|
||||
if (idx !=
|
||||
recordsForDate.length - 1)
|
||||
const Divider(
|
||||
color: ColorsManager
|
||||
.graysColor,
|
||||
),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
Container(
|
||||
height: 10,
|
||||
width: 20,
|
||||
child:
|
||||
const Center(child: Text('No data available.')),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,202 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/water_leak_bloc/water_leak_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/water_leak_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_leak/water_leak_notification_settings.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_leak/water_leak_records_screen.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/battery_bar.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_small.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
|
||||
class WaterLeakScreen extends StatelessWidget {
|
||||
final DeviceModel? device;
|
||||
|
||||
const WaterLeakScreen({super.key, this.device});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: 'Water Leak Sensor',
|
||||
child: BlocProvider(
|
||||
create: (context) => WaterLeakBloc(WLId: device?.uuid ?? '')
|
||||
..add(const WaterLeakInitial()),
|
||||
child: BlocBuilder<WaterLeakBloc, WaterLeakState>(
|
||||
builder: (context, state) {
|
||||
final waterLeakBloc = BlocProvider.of<WaterLeakBloc>(context);
|
||||
WaterLeakModel model = WaterLeakModel(
|
||||
batteryPercentage: 0, waterContactState: 'normal');
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.waterSensor;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.waterSensor;
|
||||
}
|
||||
return state is WaterLeakLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
waterLeakBloc.add(const WaterLeakInitial());
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height * 0.8,
|
||||
child: Column(
|
||||
children: [
|
||||
BatteryBar(
|
||||
batteryPercentage: model.batteryPercentage,
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: InkWell(
|
||||
overlayColor: WidgetStateProperty.all(
|
||||
Colors.transparent),
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(890),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color:
|
||||
Colors.white.withOpacity(0.1),
|
||||
blurRadius: 24,
|
||||
offset: const Offset(-5, -5),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black
|
||||
.withOpacity(0.11),
|
||||
blurRadius: 25,
|
||||
offset: const Offset(5, 5),
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black
|
||||
.withOpacity(0.13),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(5, 5),
|
||||
blurStyle: BlurStyle.inner,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
model.waterContactState == 'normal'
|
||||
? Assets.normalWaterLeak
|
||||
: Assets.detectedWaterLeak,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
WaterLeakRecordsScreen(
|
||||
WLId: device!.uuid!)),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
child: SvgPicture.asset(
|
||||
Assets.doorRecordsIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Records',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
NotificationSettingsPage()),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
child: SvgPicture.asset(Assets
|
||||
.doorNotificationSetting),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
text: 'Notification Settings',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtains_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/garage_door/garage_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_touch/one_touch_wizard.dart';
|
||||
@ -100,6 +101,13 @@ class WizardPage extends StatelessWidget {
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const GarageWizard()));
|
||||
}
|
||||
if (groupsList[index].name == 'CUR') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const CurtainsWizard()));
|
||||
}
|
||||
},
|
||||
child: DefaultContainer(
|
||||
padding: const EdgeInsets.all(15),
|
||||
|
||||
@ -7,9 +7,13 @@ class DevicesDefaultSwitch extends StatelessWidget {
|
||||
{super.key,
|
||||
required this.switchValue,
|
||||
required this.action,
|
||||
required this.on,
|
||||
required this.off,
|
||||
this.secondAction});
|
||||
|
||||
final bool switchValue;
|
||||
final String on;
|
||||
final String off;
|
||||
final Function action;
|
||||
final Function? secondAction;
|
||||
|
||||
@ -36,7 +40,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
fontSize: 14,
|
||||
text: "ON",
|
||||
text: on,
|
||||
fontColor: switchValue ? Colors.white : null,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@ -67,7 +71,7 @@ class DevicesDefaultSwitch extends StatelessWidget {
|
||||
child: Center(
|
||||
child: BodyMedium(
|
||||
fontSize: 14,
|
||||
text: "OFF",
|
||||
text: off,
|
||||
fontColor: switchValue ? null : Colors.white,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
|
||||
@ -3,7 +3,8 @@ 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
|
||||
@ -19,82 +20,98 @@ 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
|
||||
@ -104,37 +121,44 @@ 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
|
||||
@ -144,37 +168,44 @@ 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
|
||||
@ -218,7 +249,8 @@ 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
|
||||
@ -228,7 +260,8 @@ 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
|
||||
@ -244,7 +277,8 @@ 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
|
||||
@ -252,15 +286,18 @@ 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
|
||||
@ -281,7 +318,8 @@ 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
|
||||
@ -369,11 +407,13 @@ 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
|
||||
@ -382,7 +422,8 @@ 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
|
||||
@ -390,7 +431,8 @@ 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
|
||||
@ -559,11 +601,13 @@ 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
|
||||
@ -596,7 +640,8 @@ 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
|
||||
@ -628,7 +673,8 @@ 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
|
||||
@ -724,7 +770,8 @@ 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
|
||||
@ -732,7 +779,8 @@ 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
|
||||
@ -762,7 +810,8 @@ 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 =
|
||||
@ -770,59 +819,73 @@ 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
|
||||
|
||||
@ -831,15 +894,18 @@ 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
|
||||
|
||||
@ -848,11 +914,13 @@ 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
|
||||
|
||||
@ -861,15 +929,18 @@ 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
|
||||
|
||||
@ -878,7 +949,8 @@ 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
|
||||
|
||||
@ -952,7 +1024,8 @@ 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
|
||||
|
||||
@ -974,22 +1047,39 @@ 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 waterLeakIcon = "assets/icons/waterleak_icon.svg";
|
||||
static const String leakDetectedIcon = "assets/icons/leak_detected.svg";
|
||||
static const String leakNormalIcon = "assets/icons/leak_normal_icon.svg";
|
||||
static const String gang1touch = "assets/icons/1gang_touch.svg";
|
||||
static const String gang2touch = "assets/icons/2gang_touch.svg";
|
||||
static const String gang3touch = "assets/icons/3gang_touch.svg";
|
||||
//leakNormalIcon
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ abstract class ApiEndpoints {
|
||||
static const String communityChild = '/community/child/{communityUuid}';
|
||||
static const String communityUser = '/community/user/{userUuid}';
|
||||
//PUT
|
||||
static const String renameCommunity = '/community/rename/{communityUuid}';
|
||||
static const String renameCommunity = '/community/{communityUuid}';
|
||||
|
||||
///Building Module
|
||||
//POST
|
||||
@ -35,7 +35,7 @@ abstract class ApiEndpoints {
|
||||
static const String buildingParent = '/building/parent/{buildingUuid}';
|
||||
static const String buildingUser = '/building/user/{userUuid}';
|
||||
//PUT
|
||||
static const String renameBuilding = '/building/rename/{buildingUuid}';
|
||||
static const String renameBuilding = '/building/{buildingUuid}';
|
||||
|
||||
///Floor Module
|
||||
//POST
|
||||
@ -47,7 +47,7 @@ abstract class ApiEndpoints {
|
||||
static const String floorParent = '/floor/parent/{floorUuid}';
|
||||
static const String floorUser = '/floor/user/{userUuid}';
|
||||
//PUT
|
||||
static const String renameFloor = '/floor/rename/{floorUuid}';
|
||||
static const String renameFloor = '/floor/{floorUuid}';
|
||||
|
||||
///Unit Module
|
||||
//POST
|
||||
@ -62,7 +62,7 @@ abstract class ApiEndpoints {
|
||||
static const String verifyInvitationCode = '/unit/user/verify-code';
|
||||
|
||||
//PUT
|
||||
static const String renameUnit = '/unit/rename/{unitUuid}';
|
||||
static const String renameUnit = '/unit/{unitUuid}';
|
||||
|
||||
///Room Module
|
||||
//POST
|
||||
@ -73,7 +73,7 @@ abstract class ApiEndpoints {
|
||||
static const String roomParent = '/room/parent/{roomUuid}';
|
||||
static const String roomUser = '/room/user/{userUuid}';
|
||||
//PUT
|
||||
static const String renameRoom = '/room/rename/{roomUuid}';
|
||||
static const String renameRoom = '/room/{roomUuid}';
|
||||
|
||||
///Group Module
|
||||
//POST
|
||||
@ -81,7 +81,8 @@ abstract class ApiEndpoints {
|
||||
static const String controlGroup = '/group/control';
|
||||
//GET
|
||||
static const String groupBySpace = '/group/{unitUuid}';
|
||||
static const String devicesByGroupName = '/group/{unitUuid}/devices/{groupName}';
|
||||
static const String devicesByGroupName =
|
||||
'/group/{unitUuid}/devices/{groupName}';
|
||||
|
||||
static const String groupByUuid = '/group/{groupUuid}';
|
||||
//DELETE
|
||||
@ -93,7 +94,8 @@ abstract class ApiEndpoints {
|
||||
static const String addDeviceToRoom = '/device/room';
|
||||
static const String addDeviceToGroup = '/device/group';
|
||||
static const String controlDevice = '/device/{deviceUuid}/control';
|
||||
static const String firmwareDevice = '/device/{deviceUuid}/firmware/{firmwareVersion}';
|
||||
static const String firmwareDevice =
|
||||
'/device/{deviceUuid}/firmware/{firmwareVersion}';
|
||||
static const String getDevicesByUserId = '/device/user/{userId}';
|
||||
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||
@ -103,7 +105,8 @@ abstract class ApiEndpoints {
|
||||
static const String deviceByUuid = '/device/{deviceUuid}';
|
||||
static const String deviceFunctions = '/device/{deviceUuid}/functions';
|
||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
||||
static const String deviceFunctionsStatus = '/device/{deviceUuid}/functions/status';
|
||||
static const String deviceFunctionsStatus =
|
||||
'/device/{deviceUuid}/functions/status';
|
||||
|
||||
///Device Permission Module
|
||||
//POST
|
||||
@ -128,24 +131,29 @@ abstract class ApiEndpoints {
|
||||
|
||||
static const String getUnitAutomation = '/automation/{unitUuid}';
|
||||
|
||||
static const String getAutomationDetails = '/automation/details/{automationId}';
|
||||
static const String getAutomationDetails =
|
||||
'/automation/details/{automationId}';
|
||||
|
||||
/// PUT
|
||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
||||
|
||||
static const String updateAutomation = '/automation/{automationId}';
|
||||
|
||||
static const String updateAutomationStatus = '/automation/status/{automationId}';
|
||||
static const String updateAutomationStatus =
|
||||
'/automation/status/{automationId}';
|
||||
|
||||
/// DELETE
|
||||
static const String deleteScene = '/scene/tap-to-run/{unitUuid}/{sceneId}';
|
||||
|
||||
static const String deleteAutomation = '/automation/{unitUuid}/{automationId}';
|
||||
static const String deleteAutomation =
|
||||
'/automation/{unitUuid}/{automationId}';
|
||||
|
||||
//////////////////////Door Lock //////////////////////
|
||||
//online
|
||||
static const String addTemporaryPassword = '/door-lock/temporary-password/online/{doorLockUuid}';
|
||||
static const String getTemporaryPassword = '/door-lock/temporary-password/online/{doorLockUuid}';
|
||||
static const String addTemporaryPassword =
|
||||
'/door-lock/temporary-password/online/{doorLockUuid}';
|
||||
static const String getTemporaryPassword =
|
||||
'/door-lock/temporary-password/online/{doorLockUuid}';
|
||||
|
||||
//one-time offline
|
||||
static const String addOneTimeTemporaryPassword =
|
||||
@ -177,7 +185,8 @@ abstract class ApiEndpoints {
|
||||
'/door-lock/temporary-password/online/{doorLockUuid}/{passwordId}';
|
||||
|
||||
static const String saveSchedule = '/schedule/{deviceUuid}';
|
||||
static const String getSchedule = '/schedule/{deviceUuid}?category={category}';
|
||||
static const String getSchedule =
|
||||
'/schedule/{deviceUuid}?category={category}';
|
||||
static const String changeSchedule = '/schedule/enable/{deviceUuid}';
|
||||
static const String deleteSchedule = '/schedule/{deviceUuid}/{scheduleId}';
|
||||
static const String reportLogs =
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
@ -33,7 +34,6 @@ class DevicesAPI {
|
||||
static Future<Map<String, dynamic>> controlDevice(
|
||||
DeviceControlModel controlModel, String deviceId) async {
|
||||
try {
|
||||
print(controlModel.toJson());
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.controlDevice.replaceAll('{deviceUuid}', deviceId),
|
||||
body: controlModel.toJson(),
|
||||
@ -60,11 +60,8 @@ class DevicesAPI {
|
||||
}
|
||||
|
||||
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
|
||||
// Map<String, dynamic> params = {"homeId": spaceId, "pageSize": 100, "pageNo": 1};
|
||||
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.groupBySpace.replaceAll('{unitUuid}', spaceId),
|
||||
// queryParameters: params,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json),
|
||||
);
|
||||
@ -123,6 +120,7 @@ class DevicesAPI {
|
||||
return <DeviceModel>[];
|
||||
}
|
||||
List<DeviceModel> devices = [];
|
||||
|
||||
for (var device in json) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
@ -383,15 +381,13 @@ class DevicesAPI {
|
||||
static Future deviceBatchController({
|
||||
List<String>? devicesUuid,
|
||||
String? code,
|
||||
bool? value,
|
||||
var value,
|
||||
}) async {
|
||||
print({"devicesUuid": devicesUuid, "code": code, "value": value});
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.controlBatch,
|
||||
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('json===$json');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
|
||||
@ -54,6 +54,7 @@ enum DeviceType {
|
||||
TowTouch,
|
||||
ThreeTouch,
|
||||
GarageDoor,
|
||||
WaterLeak,
|
||||
|
||||
Other,
|
||||
}
|
||||
@ -85,6 +86,7 @@ Map<String, DeviceType> devicesTypesMap = {
|
||||
"2GT": DeviceType.TowTouch,
|
||||
"3GT": DeviceType.ThreeTouch,
|
||||
"GD": DeviceType.GarageDoor,
|
||||
"WL": DeviceType.WaterLeak,
|
||||
};
|
||||
Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
||||
DeviceType.AC: [
|
||||
@ -468,6 +470,7 @@ Map<DeviceType, List<FunctionModel>> devicesFunctionsMap = {
|
||||
"range": ["unclosed_time", "close_time_alarm", "none"]
|
||||
})),
|
||||
],
|
||||
DeviceType.WaterLeak: [],
|
||||
};
|
||||
|
||||
enum TempModes { hot, cold, wind }
|
||||
@ -812,7 +815,7 @@ extension lightStatusExtension on lightStatus {
|
||||
case lightStatus.switchPosition:
|
||||
return "On/Off Status";
|
||||
case lightStatus.on_off:
|
||||
return "Restart Memory";
|
||||
return "Switch Position";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ description: This is the mobile application project, developed with Flutter for
|
||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
version: 1.0.3+25
|
||||
version: 1.0.5+29
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.6 <4.0.0"
|
||||
|
||||