Compare commits
67 Commits
link_space
...
SP-1279
Author | SHA1 | Date | |
---|---|---|---|
49c743befb | |||
4fc259491e | |||
b77dc860cb | |||
6045158432 | |||
7e06dd76cf | |||
7e1c2ba712 | |||
80c43b8046 | |||
2d3345c1d9 | |||
c0d53fdf5c | |||
5e05b20f68 | |||
95730cc2ba | |||
a5a37f3841 | |||
e0486deecb | |||
bc64efa557 | |||
2a065efc0e | |||
7ae3e4a933 | |||
2a0f6a4596 | |||
5b2822f973 | |||
70d31f5351 | |||
c39c693755 | |||
8ed6980264 | |||
16df75eb49 | |||
80c294f09c | |||
c806b5f59d | |||
dd01a7fddb | |||
b563cc378e | |||
2140b7eee3 | |||
7de9e25ed5 | |||
123949aa86 | |||
6d554c5953 | |||
5ed87a5794 | |||
168c997240 | |||
de65f79ccf | |||
eb0490fb16 | |||
a73fc04712 | |||
dee07ebb06 | |||
5237f3ae5b | |||
e017633b9b | |||
e8e5e9bcb7 | |||
a1d15c9cea | |||
16c006e7a9 | |||
24280549ec | |||
8359642a1a | |||
ada19a5992 | |||
c6702d4d5f | |||
f78e2e2d36 | |||
83b9555920 | |||
8af24e575c | |||
4301d7f62f | |||
788d36541b | |||
44cf1cec69 | |||
acb7ed5192 | |||
1b8a87e942 | |||
fa39182386 | |||
efccac4d19 | |||
096317fce8 | |||
d624dd767b | |||
9795517a3f | |||
fecab17cbe | |||
d2ff909bf2 | |||
5cea8eddb3 | |||
213ec329c0 | |||
c9427b35be | |||
a7995bb2b8 | |||
20474835dd | |||
5233c1b38e | |||
d88ae9ea15 |
18
assets/icons/Illuminance_icon.svg
Normal file
@ -0,0 +1,18 @@
|
||||
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10.8326 16.8575C7.55614 16.8575 4.89062 14.192 4.89062 10.9156C4.89062 7.63915 7.55614 4.97363 10.8326 4.97363C14.1091 4.97363 16.7746 7.63915 16.7746 10.9156C16.7746 14.192 14.1091 16.8575 10.8326 16.8575Z" fill="#FFE645"/>
|
||||
<path d="M10.8333 4.97363C10.8332 4.97363 10.833 4.97363 10.833 4.97363V16.8575H10.8333C14.1098 16.8575 16.7753 14.192 16.7753 10.9156C16.7753 7.63915 14.1098 4.97363 10.8333 4.97363Z" fill="#FFF1B9"/>
|
||||
<path d="M10.833 21.8334C10.4824 21.8334 10.1982 21.5493 10.1982 21.1986V18.8289C10.1982 18.4784 10.4824 18.1941 10.833 18.1941C11.1836 18.1941 11.4678 18.4784 11.4678 18.8289V21.1986C11.4678 21.5493 11.1836 21.8334 10.833 21.8334Z" fill="#FFE645"/>
|
||||
<path d="M21.0317 11.6348H18.7461C18.3955 11.6348 18.1113 11.3506 18.1113 11C18.1113 10.6496 18.3955 10.3652 18.7461 10.3652H21.0317C21.3824 10.3652 21.6665 10.6496 21.6665 11C21.6665 11.3506 21.3824 11.6348 21.0317 11.6348Z" fill="#FFCF2C"/>
|
||||
<path d="M2.92042 11.6348H0.634766C0.284157 11.6348 0 11.3506 0 11C0 10.6496 0.284157 10.3652 0.634766 10.3652H2.92042C3.27103 10.3652 3.55518 10.6496 3.55518 11C3.55518 11.3506 3.27103 11.6348 2.92042 11.6348Z" fill="#FFE645"/>
|
||||
<path d="M17.7243 7.65695C17.5049 7.65695 17.2915 7.54306 17.174 7.33941C16.9988 7.03591 17.1027 6.64761 17.4064 6.47239L19.3481 5.3513C19.6517 5.17591 20.04 5.28005 20.2152 5.58372C20.3905 5.88721 20.2865 6.27551 19.9828 6.45073L18.0412 7.57182C17.9412 7.62951 17.8321 7.65695 17.7243 7.65695Z" fill="#FFCF2C"/>
|
||||
<path d="M2.03686 16.7139C1.8175 16.7139 1.60409 16.6 1.48656 16.3963C1.31117 16.0928 1.41531 15.7045 1.71881 15.5293L3.69865 14.3862C4.00231 14.2108 4.39045 14.315 4.56567 14.6186C4.74106 14.9221 4.63708 15.3104 4.33342 15.4856L2.35358 16.6287C2.25373 16.6864 2.14447 16.7139 2.03686 16.7139Z" fill="#FFE645"/>
|
||||
<path d="M5.76902 20.4051C5.6614 20.4051 5.5523 20.3778 5.4523 20.32C5.14863 20.1448 5.04466 19.7565 5.21988 19.453L6.36279 17.4735C6.53801 17.17 6.92631 17.0658 7.22981 17.2412C7.53347 17.4164 7.63744 17.8047 7.46222 18.1082L6.31931 20.0877C6.20178 20.2914 5.98838 20.4051 5.76902 20.4051Z" fill="#FFE645"/>
|
||||
<path d="M3.94197 7.65681C3.83419 7.65681 3.72509 7.62937 3.62524 7.57168L1.64557 6.42877C1.34207 6.25355 1.23793 5.86525 1.41332 5.56158C1.58854 5.25809 1.97667 5.15395 2.28033 5.32933L4.26001 6.47224C4.56351 6.64746 4.66748 7.03576 4.49226 7.33926C4.37473 7.54291 4.16132 7.65681 3.94197 7.65681Z" fill="#FFE645"/>
|
||||
<path d="M19.6649 16.7342C19.5572 16.7342 19.4481 16.7067 19.348 16.6491L17.333 15.4857C17.0295 15.3103 16.9255 14.9221 17.1007 14.6185C17.276 14.315 17.6643 14.2108 17.9678 14.3862L19.9828 15.5496C20.2865 15.7248 20.3905 16.1131 20.2152 16.4166C20.0977 16.6203 19.8843 16.7342 19.6649 16.7342Z" fill="#FFCF2C"/>
|
||||
<path d="M15.8973 20.4051C15.6778 20.4051 15.4645 20.2913 15.347 20.0877L14.2043 18.1085C14.029 17.8048 14.133 17.4167 14.4367 17.2415C14.7402 17.0661 15.1285 17.1701 15.3037 17.4737L16.4464 19.4529C16.6217 19.7566 16.5177 20.1447 16.214 20.3199C16.114 20.3778 16.0049 20.4051 15.8973 20.4051Z" fill="#FFCF2C"/>
|
||||
<path d="M10.833 3.72144C10.4824 3.72144 10.1982 3.43728 10.1982 3.08667V0.801514C10.1982 0.450905 10.4824 0.166748 10.833 0.166748C11.1836 0.166748 11.4678 0.450905 11.4678 0.801514V3.08667C11.4678 3.43728 11.1836 3.72144 10.833 3.72144Z" fill="#FFE645"/>
|
||||
<path d="M14.7534 4.75952C14.6458 4.75952 14.5365 4.73208 14.4367 4.67422C14.133 4.499 14.029 4.11086 14.2043 3.8072L15.3472 1.82786C15.5224 1.5242 15.9105 1.42005 16.2142 1.59544C16.5178 1.77066 16.6218 2.15896 16.4466 2.46262L15.3037 4.44197C15.1862 4.64562 14.9728 4.75952 14.7534 4.75952Z" fill="#FFCF2C"/>
|
||||
<path d="M6.91292 4.75919C6.69356 4.75919 6.48015 4.64529 6.36262 4.44164L5.21988 2.46262C5.04466 2.15896 5.14863 1.77066 5.4523 1.59544C5.75579 1.42005 6.14409 1.5242 6.31931 1.82786L7.46206 3.80687C7.63728 4.11053 7.5333 4.49867 7.22964 4.67405C7.1298 4.73175 7.02053 4.75919 6.91292 4.75919Z" fill="#FFE645"/>
|
||||
<path d="M10.8333 18.1941C10.8332 18.1941 10.833 18.1941 10.833 18.1941V21.8334H10.8333C11.1839 21.8334 11.4681 21.5493 11.4681 21.1986V18.8289C11.4681 18.4784 11.1839 18.1941 10.8333 18.1941Z" fill="#FFCF2C"/>
|
||||
<path d="M10.8333 0.166748C10.8332 0.166748 10.833 0.166748 10.833 0.166748V3.72144H10.8333C11.1839 3.72144 11.4681 3.43728 11.4681 3.08667V0.801514C11.4681 0.450905 11.1839 0.166748 10.8333 0.166748Z" fill="#FFCF2C"/>
|
||||
</svg>
|
After Width: | Height: | Size: 4.3 KiB |
12
assets/icons/Indicator_icon.svg
Normal file
@ -0,0 +1,12 @@
|
||||
<svg width="16" height="22" viewBox="0 0 16 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15.3977 14.7672V18.2386C15.3977 19.0611 14.7285 19.7299 13.906 19.7299H1.49132C0.668788 19.7299 0 19.0611 0 18.2386V14.7672C0 10.522 3.45363 7.06836 7.69885 7.06836H7.73063C11.9615 7.08575 15.3977 10.5326 15.3977 14.7672Z" fill="#FF5B5B"/>
|
||||
<path d="M15.3975 14.7672V18.2386C15.3975 19.0611 14.7283 19.7299 13.9058 19.7299H7.73047V7.06836C11.9613 7.08575 15.3975 10.5326 15.3975 14.7672Z" fill="#FF193D"/>
|
||||
<path d="M15.3977 15.5405V18.239C15.3977 19.0615 14.7285 19.7303 13.906 19.7303H1.49132C0.668788 19.7303 0 19.0615 0 18.239V15.5405H15.3977Z" fill="#7C8287"/>
|
||||
<path d="M15.3977 21.1981C15.3977 21.5492 15.1131 21.8334 14.7624 21.8334H0.635315C0.284205 21.8334 0 21.5492 0 21.1981C0 20.8474 0.284205 20.5627 0.635315 20.5627H14.7623C15.1131 20.5627 15.3977 20.8473 15.3977 21.1981Z" fill="#DCE6EB"/>
|
||||
<path d="M8.36829 0.802063V4.67286C8.36829 5.02355 8.08366 5.30817 7.73297 5.30817C7.38228 5.30817 7.09766 5.02355 7.09766 4.67286V0.802063C7.09761 0.451377 7.38224 0.166748 7.73297 0.166748C8.0837 0.166748 8.36829 0.451377 8.36829 0.802063Z" fill="#FFB64C"/>
|
||||
<path d="M2.87856 6.65271C2.67031 6.65271 2.4663 6.55047 2.34472 6.36262L0.357991 3.29471C0.167266 3.00023 0.251393 2.60684 0.545924 2.41612C0.840412 2.22535 1.23376 2.30952 1.42452 2.60405L3.41125 5.67195C3.60198 5.96644 3.51785 6.35983 3.22332 6.55055C3.11659 6.61966 2.99688 6.65271 2.87856 6.65271Z" fill="#FFB64C"/>
|
||||
<path d="M12.3087 6.6527C12.1903 6.6527 12.0706 6.61965 11.9639 6.55054C11.6694 6.35982 11.5852 5.96643 11.7759 5.67194L13.7627 2.60404C13.9534 2.30947 14.3467 2.22538 14.6413 2.41611C14.9358 2.60683 15.0199 3.00022 14.8292 3.29471L12.8425 6.36261C12.7209 6.55042 12.5169 6.6527 12.3087 6.6527Z" fill="#FF9F00"/>
|
||||
<path d="M15.3975 21.1981C15.3975 21.5492 15.1129 21.8334 14.7622 21.8334H7.73047V20.5627H14.7622C15.1129 20.5627 15.3975 20.8473 15.3975 21.1981Z" fill="#C8D2DC"/>
|
||||
<path d="M15.3975 15.5405V18.239C15.3975 19.0615 14.7283 19.7303 13.9058 19.7303H7.73047V15.5405H15.3975Z" fill="#596C76"/>
|
||||
<path d="M8.36774 0.802063V4.67286C8.36774 5.02355 8.08311 5.30817 7.73242 5.30817V0.166748C8.08311 0.166748 8.36774 0.451377 8.36774 0.802063Z" fill="#FF9F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
17
assets/icons/current_distance_icon.svg
Normal file
@ -0,0 +1,17 @@
|
||||
<svg width="22" height="14" viewBox="0 0 22 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M21.6663 11.1257L7.02441 8.58667L10.833 13.6648H21.6663V11.1257Z" fill="#FFB54C"/>
|
||||
<path d="M0 11.1257V13.6648H10.8333V8.58667L0 11.1257Z" fill="#FFCC4A"/>
|
||||
<path d="M21.6663 11.1257V5.41284H20.0688L19.4341 6.04761L18.7993 5.41284H17.2018L16.5671 6.04761L15.9323 5.41284H14.3348L13.7 6.04761L13.0653 5.41284H11.4678L8.29395 8.26929L10.833 11.1257H21.6663Z" fill="#FFCC4A"/>
|
||||
<path d="M10.8333 5.41284H10.1986H8.60107L7.96631 6.04761L7.33154 5.41284H5.73405L5.09928 6.04761L4.46452 5.41284H2.86702L2.23226 6.04761L1.59749 5.41284H0V11.1257H10.8333V5.41284Z" fill="#FFE278"/>
|
||||
<path d="M21.0316 1.60449H10.833L10.1982 2.23926L10.833 2.87402H21.0316V1.60449Z" fill="#ABD5ED"/>
|
||||
<path d="M10.8333 1.60449H1.26953V0.334961H0V4.14355H1.26953V2.87402H10.8333V1.60449Z" fill="#BFEBFF"/>
|
||||
<path d="M20.3965 0.334961H21.666V4.14355H20.3965V0.334961Z" fill="#ABD5ED"/>
|
||||
<path d="M1.59766 5.41284H2.86719V8.58667H1.59766V5.41284Z" fill="#587AA1"/>
|
||||
<path d="M4.46484 5.41284H5.73438V7.31714H4.46484V5.41284Z" fill="#587AA1"/>
|
||||
<path d="M7.33203 5.41284H8.60156V8.58667H7.33203V5.41284Z" fill="#587AA1"/>
|
||||
<path d="M11.4678 7.31714H10.833L10.5156 6.99976V5.73022L10.833 5.41284H11.4678V7.31714Z" fill="#455F80"/>
|
||||
<path d="M10.1982 5.41284H10.833V7.31714H10.1982V5.41284Z" fill="#587AA1"/>
|
||||
<path d="M13.0654 5.41284H14.335V8.58667H13.0654V5.41284Z" fill="#455F80"/>
|
||||
<path d="M15.9326 5.41284H17.2021V7.31714H15.9326V5.41284Z" fill="#455F80"/>
|
||||
<path d="M18.7998 5.41284H20.0693V8.58667H18.7998V5.41284Z" fill="#455F80"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.6 KiB |
16
assets/icons/far_detection_icon.svg
Normal file
@ -0,0 +1,16 @@
|
||||
<svg width="22" height="16" viewBox="0 0 22 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12.9326 7.99996C12.9326 8.4282 12.8042 8.82647 12.5838 9.15837C12.2083 9.72412 11.5654 9.84106 10.8355 9.84106C9.67727 9.84106 9.05078 9.15816 9.05078 7.99996C9.05078 7.26923 9.11211 6.62577 9.67883 6.25036C10.0104 6.03074 10.408 5.90283 10.8354 5.90283C11.9937 5.90287 12.9326 6.84175 12.9326 7.99996Z" fill="#E5646E"/>
|
||||
<path d="M11.4252 9.50734C10.267 9.50734 9.32807 8.56846 9.32807 7.41026C9.32807 6.98202 9.45843 6.5824 9.67877 6.25049C9.11302 6.62607 8.73828 7.27012 8.73828 8.00009C8.73828 9.15829 9.67716 10.0972 10.8354 10.0972C11.5653 10.0972 12.2082 9.72425 12.5837 9.15851C12.2519 9.3788 11.8534 9.50734 11.4252 9.50734Z" fill="#DB4655"/>
|
||||
<path d="M3.66787 0.133789C3.84673 0.133789 4.02559 0.202058 4.16209 0.338597C4.16848 0.344987 4.1747 0.351463 4.18079 0.358023L3.79505 1.32708C2.01269 3.10948 1.03102 5.47931 1.03102 7.99997C1.03102 10.5206 2.01269 12.8905 3.79505 14.6729L4.18101 15.6417C4.17483 15.6483 4.16852 15.6549 4.16209 15.6613C3.88935 15.9344 3.44668 15.9344 3.1736 15.6613C1.12705 13.6149 0 10.8941 0 7.99997C0 5.10588 1.12705 2.38502 3.17364 0.338597C3.31001 0.202058 3.489 0.133789 3.66787 0.133789Z" fill="#FFE6E7"/>
|
||||
<path d="M7.6231 4.08813C7.80196 4.08813 7.98099 4.1564 8.11732 4.29294C8.1312 4.30682 8.14437 4.32109 8.15681 4.33582L7.68282 5.28138C6.18391 6.78047 6.18391 9.21957 7.68282 10.7187L8.15774 11.6633C8.145 11.6783 8.13154 11.693 8.11732 11.7072C7.84458 11.9803 7.40157 11.9803 7.12884 11.7072C5.08466 9.66318 5.08466 6.33695 7.12884 4.29294C7.26521 4.15636 7.44424 4.08813 7.6231 4.08813Z" fill="#FF9A9F"/>
|
||||
<path d="M5.64357 2.11108C5.82243 2.11108 6.0013 2.17935 6.13779 2.31589C6.14575 2.32385 6.15345 2.33189 6.16094 2.34014L5.56438 3.30433C2.97545 5.89361 2.97545 10.1066 5.56438 12.6959L6.16145 13.6596C6.15383 13.668 6.14596 13.6762 6.13783 13.6843C5.86476 13.9574 5.42243 13.9574 5.14935 13.6843C2.01532 10.5501 2.01532 5.45005 5.14935 2.31581C5.28585 2.17935 5.46471 2.11108 5.64357 2.11108Z" fill="#FFCCCF"/>
|
||||
<path d="M6.29102 7.99972C6.29102 9.50473 7.0294 10.836 8.1565 11.6629C8.38886 11.3884 8.37511 10.9772 8.11608 10.7184C6.61717 9.21929 6.61717 6.78019 8.11608 5.28106C8.37511 5.0222 8.38793 4.61001 8.15557 4.33545C7.02852 5.1623 6.29102 6.49471 6.29102 7.99972Z" fill="#FF8086"/>
|
||||
<path d="M3.49609 7.99983C3.49609 10.2771 4.53592 12.313 6.16362 13.6593C6.413 13.385 6.405 12.9604 6.14001 12.6956C3.55107 10.1064 3.55107 5.89335 6.14001 3.30408C6.405 3.03925 6.41249 2.61411 6.16316 2.33984C4.53541 3.68609 3.49609 5.72253 3.49609 7.99983Z" fill="#FF9A9F"/>
|
||||
<path d="M0.699219 7.99986C0.699219 11.0495 2.05 13.7834 4.18124 15.6416C4.43535 15.3675 4.42896 14.9393 4.16232 14.6728C2.37992 12.8903 1.39825 10.5205 1.39825 7.99986C1.39825 5.47919 2.37992 3.10937 4.16232 1.32697C4.42896 1.06049 4.43514 0.632002 4.18103 0.35791C2.04979 2.21607 0.699219 4.95022 0.699219 7.99986Z" fill="#FFCCCF"/>
|
||||
<path d="M18.0014 15.8662C17.8226 15.8662 17.6437 15.7979 17.5072 15.6613C17.5008 15.655 17.4946 15.6485 17.4885 15.6419L17.8742 14.6729C19.6566 12.8905 20.6383 10.5206 20.6383 7.99997C20.6383 5.4793 19.6566 3.10948 17.8742 1.32708L17.4883 0.358277C17.4945 0.351632 17.5008 0.345072 17.5072 0.338596C17.7799 0.06552 18.2226 0.06552 18.4957 0.338596C20.5422 2.38502 21.6693 5.10588 21.6693 7.99997C21.6693 10.8941 20.5422 13.6149 18.4956 15.6613C18.3593 15.7979 18.1803 15.8662 18.0014 15.8662Z" fill="#FFE6E7"/>
|
||||
<path d="M14.0464 11.912C13.8675 11.912 13.6885 11.8438 13.5521 11.7072C13.5383 11.6933 13.5251 11.6791 13.5127 11.6644L13.9866 10.7187C15.4856 9.21966 15.4856 6.78055 13.9866 5.28143L13.5117 4.33687C13.5245 4.32181 13.5379 4.30716 13.5521 4.29294C13.8249 4.01987 14.2679 4.01987 14.5406 4.29294C16.5848 6.33695 16.5848 9.66318 14.5406 11.7072C14.4043 11.8438 14.2252 11.912 14.0464 11.912Z" fill="#FF9A9F"/>
|
||||
<path d="M16.0257 13.8892C15.8468 13.8892 15.668 13.8209 15.5315 13.6844C15.5235 13.6764 15.5158 13.6684 15.5083 13.6601L16.1049 12.6959C18.6938 10.1066 18.6938 5.89361 16.1049 3.30433L15.5078 2.34065C15.5154 2.33223 15.5233 2.32398 15.5314 2.31589C15.8045 2.04281 16.2468 2.04281 16.5199 2.31589C19.6539 5.45009 19.6539 10.5502 16.5199 13.6844C16.3834 13.8209 16.2046 13.8892 16.0257 13.8892Z" fill="#FFCCCF"/>
|
||||
<path d="M15.3797 8.00012C15.3797 6.49511 14.6413 5.16376 13.5142 4.33691C13.2819 4.61147 13.2956 5.02261 13.5546 5.28147C15.0536 6.78055 15.0536 9.21966 13.5546 10.7188C13.2956 10.9776 13.2828 11.3898 13.5152 11.6644C14.6422 10.8375 15.3797 9.50513 15.3797 8.00012Z" fill="#FF8086"/>
|
||||
<path d="M18.175 8.00005C18.175 5.72275 17.1351 3.68687 15.5074 2.34058C15.2581 2.61484 15.2661 3.03944 15.531 3.30426C18.12 5.89353 18.12 10.1065 15.531 12.6958C15.2661 12.9606 15.2586 13.3858 15.5079 13.66C17.1356 12.3138 18.175 10.2774 18.175 8.00005Z" fill="#FF9A9F"/>
|
||||
<path d="M20.9707 7.99989C20.9707 4.95025 19.6199 2.21636 17.4887 0.358154C17.2346 0.632246 17.241 1.06048 17.5076 1.32696C19.29 3.10936 20.2716 5.47918 20.2716 7.99985C20.2716 10.5205 19.29 12.8903 17.5076 14.6727C17.241 14.9392 17.2348 15.3677 17.4889 15.6418C19.6201 13.7837 20.9707 11.0495 20.9707 7.99989Z" fill="#FFCCCF"/>
|
||||
</svg>
|
After Width: | Height: | Size: 5.1 KiB |
21
assets/icons/motion_detection_sensitivity_icon.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.91415 8.48211C6.17473 8.04425 4.3403 8.07332 2.60916 8.56611C1.74635 8.81143 0.920517 9.16778 0.154693 9.62511C0.00421161 9.71499 -0.0449192 9.90978 0.0449212 10.0603C0.130234 10.2033 0.336744 10.2556 0.480159 10.1701C1.19846 9.74106 1.97317 9.40684 2.78283 9.17663C4.40699 8.71422 6.12775 8.68689 7.75919 9.09766C7.92922 9.14032 8.10166 9.03732 8.14445 8.86737C8.18723 8.69742 8.0841 8.52489 7.91415 8.48211Z" fill="#6BBEF6"/>
|
||||
<path d="M7.37225 10.4417C5.99155 10.1036 4.53693 10.1313 3.16562 10.5219C2.47009 10.7197 1.80528 11.0068 1.1896 11.3753C1.0392 11.4653 0.990237 11.6602 1.08025 11.8106C1.1397 11.91 1.24495 11.9651 1.3529 11.9651C1.40838 11.9651 1.46453 11.9505 1.51557 11.92C2.0836 11.58 2.69716 11.3151 3.33942 11.1324C4.60502 10.7719 5.94733 10.7463 7.22126 11.0583C7.39138 11.0999 7.56332 10.9958 7.60504 10.8255C7.64677 10.6553 7.54254 10.4835 7.37225 10.4417Z" fill="#6BBEF6"/>
|
||||
<path d="M6.83178 12.4028C5.81116 12.1632 4.73634 12.1888 3.72363 12.4772C3.19665 12.627 2.6929 12.8452 2.22626 13.1255C2.07599 13.2158 2.02737 13.4108 2.11763 13.561C2.20697 13.7097 2.4048 13.7587 2.55312 13.6696C2.97186 13.4181 3.42406 13.2223 3.89735 13.0877C4.80646 12.8289 5.77096 12.8057 6.68663 13.0208C6.85739 13.0605 7.02809 12.9549 7.06817 12.7844C7.10824 12.6138 7.00241 12.4429 6.83178 12.4028Z" fill="#6BBEF6"/>
|
||||
<path d="M14.4727 19.6416L13.6738 21.4527C13.5717 21.6842 13.3426 21.8336 13.0896 21.8336H8.12563C7.79678 21.8336 7.57643 21.4956 7.70914 21.1947L9.38433 17.397L13.3135 19.1303L14.4727 19.6416Z" fill="#FFDDCE"/>
|
||||
<path d="M14.475 19.6415L13.6761 21.4526C13.574 21.6841 13.3448 21.8335 13.0918 21.8335H12.123L13.3158 19.1301L14.475 19.6415Z" fill="#FFCBBE"/>
|
||||
<path d="M14.1855 13.4249L16.3003 14.3579L19.2365 7.70213C19.4938 7.119 19.229 6.43743 18.645 6.1798C18.061 5.92217 17.3791 6.18606 17.1218 6.7692L14.1855 13.4249Z" fill="#FFDDCE"/>
|
||||
<path d="M18.6453 6.17967C18.4607 6.09821 18.2662 6.06906 18.0786 6.08543C18.326 6.40921 18.3944 6.85397 18.2185 7.25273L15.8676 12.5814C15.6524 13.0693 15.8731 13.6392 16.3607 13.8543L16.4962 13.9141L19.2368 7.70201C19.4941 7.11887 19.2292 6.43726 18.6453 6.17967Z" fill="#FFCBBE"/>
|
||||
<path d="M12.0723 12.492L14.187 13.425L16.7716 7.56632C17.0291 6.98276 16.7647 6.30102 16.1812 6.04356L16.1797 6.04289C15.5961 5.78542 14.9144 6.04983 14.6569 6.63334L12.0723 12.492Z" fill="#FFDDCE"/>
|
||||
<path d="M16.1808 6.04379L16.1789 6.04295C15.9946 5.96165 15.8006 5.93254 15.6132 5.949C15.8606 6.27286 15.9288 6.71808 15.7526 7.11744L13.757 11.6407C13.5398 12.1331 13.7626 12.7082 14.2546 12.9252L14.3821 12.9814L16.7708 7.56693C17.0284 6.98312 16.7642 6.30121 16.1808 6.04379Z" fill="#FFCBBE"/>
|
||||
<path d="M8.56284 14.6994C7.94352 16.1032 8.58154 17.7448 9.98852 18.3655L13.7612 20.0298C14.9419 20.5507 16.3209 20.0175 16.8407 18.8391L21.1141 9.15261C21.2426 8.86126 21.2407 8.54557 21.1335 8.26982C21.0262 7.99412 20.8142 7.75968 20.5222 7.63091C19.9384 7.37337 19.2564 7.63705 18.9994 8.21972L16.4886 13.9111L12.2593 12.0453C12.2942 11.9675 14.112 7.84707 14.112 7.84707C14.2405 7.55571 14.2384 7.23939 14.1314 6.96428C14.0246 6.68875 13.8121 6.45414 13.5201 6.32537C12.9363 6.06782 12.2545 6.33104 11.9973 6.91418L8.56284 14.6994Z" fill="#FFDDCE"/>
|
||||
<path d="M13.1203 6.51804C13.2273 6.79311 13.2294 7.10947 13.1008 7.40083C13.1008 7.40083 12.0882 9.6961 11.5601 10.8928C11.3879 11.2831 11.5646 11.7387 11.9547 11.9108L12.2666 12.0484C12.3015 11.9705 14.1192 7.85012 14.1192 7.85012C14.2478 7.55876 14.2456 7.24244 14.1387 6.96733C14.0319 6.6918 13.8194 6.45719 13.5275 6.32842C13.3429 6.247 13.1485 6.21776 12.9608 6.23409C13.0274 6.32105 13.0811 6.41673 13.1203 6.51804Z" fill="#FFCBBE"/>
|
||||
<path d="M21.1416 8.27269C21.0344 7.99699 20.8223 7.76255 20.5303 7.63377C20.3457 7.55235 20.1513 7.52316 19.9636 7.53953C20.0301 7.62649 20.0837 7.72213 20.1231 7.8234C20.2304 8.0991 20.2322 8.41483 20.1037 8.70619L17.2515 15.1713C17.102 15.5102 16.7231 15.686 16.3689 15.5776C15.1754 15.2122 13.3924 15.1243 12.5647 17.0007C11.6818 19.0018 13.3307 19.8367 13.3307 19.8367L13.7693 20.0326C14.9499 20.5535 16.3289 20.0203 16.8488 18.842L21.1221 9.15548C21.2507 8.86412 21.2488 8.54839 21.1416 8.27269Z" fill="#FFCBBE"/>
|
||||
<path d="M14.0754 16.7326C14.8301 16.2038 15.3009 16.203 16.2573 16.2547C16.5879 16.2725 17.1315 16.1379 17.3359 15.8777L19.3641 12.8099C19.8043 12.2496 20.616 12.1527 21.1758 12.5935C21.7348 13.0337 21.8308 13.8434 21.3901 14.402L18.8737 18.2526C18.8737 18.2526 17.9272 19.6558 16.9484 20.0884C15.5668 20.6991 13.919 20.3242 13.0262 19.5722C13.0262 19.5722 12.8878 19.3576 13.0925 18.2919C13.2237 17.6089 14.0754 16.7326 14.0754 16.7326Z" fill="#FFDDCE"/>
|
||||
<path d="M21.1759 12.5933C20.874 12.3556 20.4991 12.2745 20.1486 12.3378C20.5354 12.7953 20.5607 13.4764 20.1751 13.9651L17.6587 17.8158C17.6587 17.8158 16.7122 19.2189 15.7334 19.6515C15.0065 19.9729 14.206 20.0211 13.4805 19.8853C14.4122 20.4147 15.7761 20.6063 16.9485 20.0881C17.9273 19.6555 18.8737 18.2523 18.8737 18.2523L21.3902 14.4017C21.8308 13.8432 21.7349 13.0335 21.1759 12.5933Z" fill="#FFCBBE"/>
|
||||
<path d="M14.2333 4.09028H7.43247C6.34901 4.09028 5.4707 3.21197 5.4707 2.12851C5.4707 1.04505 6.34901 0.166748 7.43247 0.166748H14.2333C15.3167 0.166748 16.195 1.04505 16.195 2.12851C16.195 3.21197 15.3167 4.09028 14.2333 4.09028Z" fill="#5C90B9"/>
|
||||
<path d="M14.2336 0.166748H12.9258C14.0092 0.166748 14.8875 1.04505 14.8875 2.12851C14.8875 3.21197 14.0092 4.09028 12.9258 4.09028H14.2336C15.3171 4.09028 16.1954 3.21197 16.1954 2.12851C16.1954 1.04505 15.3171 0.166748 14.2336 0.166748Z" fill="#4A80AA"/>
|
||||
<path d="M10.8338 4.09028C11.92 4.09028 12.8004 3.21197 12.8004 2.12851C12.8004 1.04506 11.92 0.166748 10.8338 0.166748C9.74768 0.166748 8.86719 1.04506 8.86719 2.12851C8.86719 3.21197 9.74768 4.09028 10.8338 4.09028Z" fill="#FFD064"/>
|
||||
<path d="M10.8329 4.09028C11.9163 4.09028 12.7946 3.21197 12.7946 2.12851C12.7946 1.04506 11.9163 0.166748 10.8329 0.166748C9.74941 0.166748 8.87109 1.04506 8.87109 2.12851C8.87109 3.21197 9.74941 4.09028 10.8329 4.09028Z" fill="#FFD064"/>
|
||||
<path d="M10.834 2.78329C11.1954 2.78329 11.4884 2.49033 11.4884 2.12895C11.4884 1.76757 11.1954 1.47461 10.834 1.47461C10.4726 1.47461 10.1797 1.76757 10.1797 2.12895C10.1797 2.49033 10.4726 2.78329 10.834 2.78329Z" fill="#5C90B9"/>
|
||||
</svg>
|
After Width: | Height: | Size: 6.2 KiB |
5
assets/icons/motion_detection_sensitivity_value_icon.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg width="17" height="21" viewBox="0 0 17 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M16.629 7.72751C16.7022 7.47106 16.444 7.24286 16.1963 7.34188L15.166 7.75403C16.1394 3.617 13.6255 1.13192 12.3309 0.160156L11.9303 0.68629C12.295 4.20985 10.8697 6.77552 10.8697 6.77552L9.6861 6.06286C7.63047 8.86439 7.26813 11.637 7.26813 11.637L6.22457 10.9497L5.84278 15.599L4.19531 17.1113C4.19531 17.1113 9.12215 19.2668 13.862 14.8542C14.0281 14.6996 13.9924 14.4272 13.7895 14.3258L12.2619 13.562C13.7729 12.6635 15.8697 10.3879 16.629 7.72751Z" fill="#1479FF"/>
|
||||
<path d="M6.94955 12.0658C7.20748 12.3235 7.64893 12.1695 7.69061 11.8073L7.74029 11.3759C7.74315 11.3515 8.03272 8.98838 9.75631 6.48396L10.3884 7.11599C10.5932 7.32076 10.9371 7.27255 11.0777 7.01939L11.2124 6.77685C11.2795 6.65646 12.7674 3.91306 12.3306 0.160279C12.2926 0.131763 12.2554 0.104185 12.2196 0.0782866C11.9917 -0.0867917 11.68 0.0943414 11.709 0.374303C12.0737 3.89786 10.6483 6.46353 10.6483 6.46353L9.94327 5.75849C9.80448 5.6197 9.57174 5.63474 9.45561 5.79298C7.40002 8.59451 7.099 11.3035 7.099 11.3035L6.50061 10.7051C6.32693 10.5315 6.03064 10.6084 5.96029 10.8437C5.23283 13.2767 5.71564 15.7659 5.71564 15.7659L5.71514 15.7664L6.34936 15.6438C6.34525 15.6222 5.97377 13.6265 6.44041 11.5575L6.94955 12.0658Z" fill="#D5EAFF"/>
|
||||
<path d="M13.2564 6.00624C13.3141 5.83764 13.224 5.65428 13.0554 5.59659C12.8865 5.5394 12.7031 5.62905 12.6457 5.7976C11.8359 8.16772 10.4981 10.2792 8.9927 12.0909C8.98586 10.3632 9.52113 9.3046 9.5316 9.28437C9.61414 9.12683 9.55367 8.93194 9.39641 8.8489C9.23793 8.76601 9.04348 8.82636 8.96031 8.98394C8.92824 9.04499 8.19051 10.4827 8.37992 12.7999C4.65574 16.9746 0.236005 19.3733 0.170849 19.408C0.0136223 19.492 -0.0459481 19.6873 0.0381926 19.8446C0.0961615 19.9534 0.207724 20.0154 0.323037 20.0154C0.374404 20.0154 0.426084 20.0032 0.474599 19.9774C0.530303 19.9477 3.69996 18.2289 6.9675 15.1631C7.06207 15.1709 7.47437 15.2031 7.91512 15.2031C8.76023 15.2031 10.083 15.1232 11.1436 14.6989C11.3091 14.6326 11.3897 14.4449 11.3236 14.2793C11.2574 14.1139 11.068 14.034 10.9041 14.0996C9.80613 14.5389 8.34164 14.5695 7.6 14.552C9.86817 12.3043 12.09 9.41976 13.2564 6.00624Z" fill="#B8DDFF"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
6
assets/icons/motionless_detection_sensitivity_icon.svg
Normal file
@ -0,0 +1,6 @@
|
||||
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10.8334 21.8334C7.93969 21.8334 5.21921 20.7065 3.17302 18.6604C1.12688 16.6143 0 13.8938 0 11.0001C0 8.10644 1.12688 5.38596 3.17298 3.33977C5.21921 1.29363 7.93961 0.166748 10.8334 0.166748C13.727 0.166748 16.4475 1.29363 18.4936 3.33977C20.5398 5.38596 21.6667 8.1064 21.6667 11.0001C21.6667 13.8939 20.5397 16.6143 18.4936 18.6605C16.4475 20.7067 13.727 21.8334 10.8334 21.8334ZM10.8334 3.12052C6.48853 3.12052 2.95378 6.65528 2.95378 11.0001C2.95378 15.345 6.48853 18.8797 10.8334 18.8797C15.1782 18.8797 18.713 15.3449 18.713 11.0001C18.713 6.65532 15.1781 3.12052 10.8334 3.12052Z" fill="#7DD2F0"/>
|
||||
<g opacity="0.1">
|
||||
<path d="M5.14215 18.6604C3.09605 16.6143 1.96917 13.8938 1.96917 11.0001C1.96917 8.1064 3.09605 5.38592 5.14215 3.33981C6.95445 1.52752 9.29585 0.437158 11.8179 0.211393C11.4924 0.182194 11.1641 0.166748 10.8334 0.166748C7.93969 0.166748 5.21921 1.29363 3.17302 3.33977C1.12688 5.38588 0 8.1064 0 11C0 13.8937 1.12688 16.6142 3.17298 18.6603C5.21913 20.7065 7.93961 21.8334 10.8333 21.8334C11.164 21.8334 11.4924 21.818 11.8179 21.7888C9.29585 21.563 6.95449 20.4726 5.14215 18.6604Z" fill="black"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
18
assets/icons/presence_state.svg
Normal file
@ -0,0 +1,18 @@
|
||||
<svg width="22" height="20" viewBox="0 0 22 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10.8333 1.71851L0.472669 15.9196C-0.702346 17.5301 0.447998 19.7934 2.44166 19.7934H19.225C21.2187 19.7934 22.369 17.5301 21.194 15.9196L10.8333 1.71851Z" fill="#F1FAFF"/>
|
||||
<path d="M21.1931 15.9183L10.8333 1.71851L9.06055 4.14839L17.6475 15.9183C18.8229 17.5294 17.6722 19.7933 15.6779 19.7933H19.2235C21.2178 19.7934 22.3685 17.5294 21.1931 15.9183Z" fill="#C7EEFB"/>
|
||||
<path d="M12.9102 6.05994H8.76926C7.63838 6.05994 6.72168 5.14319 6.72168 4.01236V2.12199C6.72168 2.00515 6.81643 1.9104 6.93327 1.9104H14.7463C14.8631 1.9104 14.9579 2.00515 14.9579 2.12199V4.01236C14.9579 5.14319 14.0411 6.05994 12.9102 6.05994Z" fill="#E0DDE2"/>
|
||||
<path d="M14.748 1.9104H13.5893V2.63688C13.5893 3.77034 12.6704 4.6892 11.537 4.6892H7.40546C7.19886 4.6892 6.99959 4.65835 6.81152 4.6016C7.06628 5.44539 7.84934 6.05998 8.77624 6.05998H12.9078C14.0412 6.05998 14.9601 5.14112 14.9601 4.00766V2.12246C14.9601 2.00536 14.8651 1.9104 14.748 1.9104Z" fill="#C8C1C9"/>
|
||||
<path d="M16.3024 2.66033H5.37858C5.26174 2.66033 5.16699 2.56558 5.16699 2.44874V0.41838C5.16699 0.301538 5.26174 0.206787 5.37858 0.206787H16.3024C16.4192 0.206787 16.514 0.301538 16.514 0.41838V2.44874C16.514 2.56562 16.4193 2.66033 16.3024 2.66033Z" fill="#E0DDE2"/>
|
||||
<path d="M16.3019 0.206787H15.0629V0.997127C15.0629 1.11426 14.9679 1.20923 14.8508 1.20923H5.16699V2.44827C5.16699 2.56541 5.26195 2.66037 5.37909 2.66037H16.3019C16.4191 2.66037 16.514 2.56541 16.514 2.44827V0.418887C16.514 0.30175 16.4191 0.206787 16.3019 0.206787Z" fill="#C8C1C9"/>
|
||||
<path d="M10.841 4.82612C11.141 4.82612 11.3842 4.58293 11.3842 4.28294C11.3842 3.98294 11.141 3.73975 10.841 3.73975C10.541 3.73975 10.2979 3.98294 10.2979 4.28294C10.2979 4.58293 10.541 4.82612 10.841 4.82612Z" fill="#FA2A3B"/>
|
||||
<path d="M10.7136 10.264C11.2545 10.264 11.6929 9.82553 11.6929 9.28469C11.6929 8.74385 11.2545 8.30542 10.7136 8.30542C10.1728 8.30542 9.73438 8.74385 9.73438 9.28469C9.73438 9.82553 10.1728 10.264 10.7136 10.264Z" fill="#62D8F9"/>
|
||||
<path d="M10.7138 8.30566C10.6442 8.30566 10.5762 8.31307 10.5107 8.32686C10.9541 8.42039 11.2869 8.81373 11.2869 9.28494C11.2869 9.75614 10.9541 10.1495 10.5107 10.243C10.5763 10.2568 10.6442 10.2642 10.7138 10.2642C11.2546 10.2642 11.6931 9.82576 11.6931 9.28494C11.6931 8.74412 11.2547 8.30566 10.7138 8.30566Z" fill="#00BEF7"/>
|
||||
<path d="M14.1217 13.3881L12.4086 13.1096L11.4778 11.3116C11.3944 11.1236 11.2634 10.8661 10.9741 10.78L9.88702 10.4538C9.76776 10.4247 9.65308 10.4141 9.4497 10.446L7.13145 10.9844C6.99264 11.0167 6.86865 11.0946 6.7794 11.2057L5.54163 12.7463C5.32157 13.0202 5.3652 13.4207 5.63913 13.6408C5.75661 13.7352 5.89736 13.7811 6.03718 13.7811C6.22338 13.7811 6.40789 13.6997 6.53357 13.5433L7.6336 12.1741L8.72165 11.9215L8.08273 14.0507C8.07045 14.0866 8.06652 14.1328 8.04896 14.234L7.68849 16.7928L6.00734 18.2515C5.74192 18.4818 5.71344 18.8836 5.94374 19.149C6.06959 19.294 6.24657 19.3683 6.4246 19.3683C6.57238 19.3683 6.72087 19.3171 6.84127 19.2126L8.70227 17.598C8.81826 17.4973 8.89393 17.3582 8.91534 17.2062L9.21009 15.114L9.24932 15.1257L10.8419 16.9844L11.7847 19.0313C11.892 19.2643 12.1223 19.4016 12.363 19.4016C12.452 19.4016 12.5425 19.3828 12.6287 19.343C12.9479 19.196 13.0874 18.8181 12.9405 18.499L11.9606 16.3716C11.936 16.3182 11.9042 16.2685 11.8659 16.2238L10.5325 14.6676L10.9911 13.1393L11.4257 13.9789C11.5183 14.1577 11.69 14.282 11.8886 14.3143L13.9174 14.6441C13.952 14.6497 13.9864 14.6524 14.0203 14.6524C14.3267 14.6524 14.5968 14.4304 14.6475 14.1182C14.7039 13.7713 14.4685 13.4445 14.1217 13.3881Z" fill="#62D8F9"/>
|
||||
<path d="M8.99707 10.5511C9.20045 10.5192 9.31454 10.5321 9.4338 10.5611L10.5209 10.8873C10.8102 10.9735 10.9411 11.231 11.0245 11.419L12.0585 13.4273C12.085 13.4787 12.1345 13.5144 12.1917 13.5232L14.645 13.9017C14.5979 13.6445 14.3947 13.4324 14.1218 13.3881L12.4088 13.1096L11.4779 11.3116C11.3945 11.1236 11.2635 10.8661 10.9742 10.78L9.88716 10.4538C9.7679 10.4247 9.65322 10.4141 9.44984 10.446L8.99707 10.5511Z" fill="#00BEF7"/>
|
||||
<path d="M11.9615 16.3715C11.9369 16.3181 11.905 16.2684 11.8667 16.2237L10.5333 14.6676L10.9919 13.1396L10.9337 13.0271C10.8579 12.8807 10.6424 12.9008 10.595 13.0587L10.1416 14.5696C10.1032 14.6976 10.1325 14.8363 10.2194 14.9377L11.4134 16.3311C11.4516 16.3758 11.4835 16.4256 11.5081 16.4789L12.4879 18.6063C12.6191 18.8912 12.5216 19.2223 12.2723 19.3948C12.3025 19.3992 12.3331 19.4015 12.3638 19.4015C12.4528 19.4015 12.5433 19.3827 12.6295 19.343C12.9487 19.196 13.0882 18.8181 12.9413 18.499L11.9615 16.3715Z" fill="#00BEF7"/>
|
||||
<path d="M3.47827 18.4406C3.31064 18.4406 3.17032 18.3095 3.16092 18.1401C3.08839 16.833 4.09282 15.7105 5.39991 15.6379C5.57574 15.6288 5.72551 15.7624 5.7352 15.9379C5.74493 16.1133 5.61065 16.2634 5.4352 16.2732C4.47834 16.3263 3.74305 17.148 3.79616 18.1048C3.8059 18.2802 3.67162 18.4304 3.49617 18.4401C3.4902 18.4404 3.48419 18.4406 3.47827 18.4406Z" fill="#00BEF7"/>
|
||||
<path d="M4.76838 18.4539C4.60076 18.4539 4.46044 18.3228 4.45104 18.1534C4.41524 17.5085 4.91082 16.9547 5.5557 16.9189C5.73081 16.9093 5.88121 17.0435 5.89094 17.219C5.90068 17.3944 5.76636 17.5445 5.59091 17.5542C5.29634 17.5706 5.06994 17.8236 5.08627 18.1182C5.09601 18.2936 4.96169 18.4437 4.78624 18.4535C4.78032 18.4537 4.77431 18.4539 4.76838 18.4539Z" fill="#00BEF7"/>
|
||||
<path d="M17.0106 13.6226C17.0076 13.6226 17.0046 13.6226 17.0016 13.6225C16.826 13.6176 16.6876 13.4712 16.6925 13.2956C16.7191 12.3377 15.9615 11.5366 15.0036 11.5099C14.828 11.505 14.6896 11.3587 14.6945 11.183C14.6994 11.0074 14.8466 10.8691 15.0213 10.8739C16.3299 10.9103 17.365 12.0047 17.3285 13.3134C17.3237 13.4859 17.1822 13.6226 17.0106 13.6226Z" fill="#00BEF7"/>
|
||||
<path d="M15.7216 13.6714C15.7186 13.6714 15.7156 13.6713 15.7126 13.6712C15.537 13.6663 15.3986 13.52 15.4035 13.3444C15.4075 13.2015 15.3555 13.0656 15.2574 12.9618C15.1591 12.8579 15.0263 12.7985 14.8835 12.7946C14.7079 12.7897 14.5695 12.6433 14.5743 12.4677C14.5793 12.2921 14.724 12.1534 14.9012 12.1586C15.214 12.1673 15.5046 12.2973 15.7196 12.5246C15.9346 12.752 16.0482 13.0494 16.0395 13.3621C16.0346 13.5347 15.8932 13.6714 15.7216 13.6714Z" fill="#00BEF7"/>
|
||||
</svg>
|
After Width: | Height: | Size: 6.1 KiB |
29
assets/icons/presence_time_icon.svg
Normal file
@ -0,0 +1,29 @@
|
||||
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5.18147 12.617H0.352631C0.157897 12.617 0 12.4719 0 12.2928C0 12.1137 0.157897 11.9685 0.352631 11.9685H5.18147C5.37624 11.9685 5.5341 12.1137 5.5341 12.2928C5.5341 12.4719 5.37624 12.617 5.18147 12.617Z" fill="#C5D3DD"/>
|
||||
<path d="M5.37006 14.6529H1.70029C1.50555 14.6529 1.34766 14.5077 1.34766 14.3287C1.34766 14.1496 1.50555 14.0044 1.70029 14.0044H5.3701C5.56483 14.0044 5.72273 14.1496 5.72273 14.3287C5.72269 14.5077 5.56483 14.6529 5.37006 14.6529Z" fill="#C5D3DD"/>
|
||||
<path d="M6.10302 16.3546H3.87607C3.68133 16.3546 3.52344 16.2094 3.52344 16.0303C3.52344 15.8512 3.68133 15.7061 3.87607 15.7061H6.10302C6.29775 15.7061 6.45565 15.8512 6.45565 16.0303C6.45565 16.2094 6.29779 16.3546 6.10302 16.3546Z" fill="#C5D3DD"/>
|
||||
<path d="M5.70018 10.5809H2.03037C1.83563 10.5809 1.67773 10.4357 1.67773 10.2566C1.67773 10.0776 1.83563 9.93237 2.03037 9.93237H5.70018C5.89495 9.93237 6.05281 10.0776 6.05281 10.2566C6.05281 10.4358 5.89491 10.5809 5.70018 10.5809Z" fill="#C5D3DD"/>
|
||||
<path d="M6.43505 8.87901H4.2081C4.01332 8.87901 3.85547 8.73382 3.85547 8.55474C3.85547 8.37565 4.01337 8.23047 4.2081 8.23047H6.43505C6.62978 8.23047 6.78768 8.37565 6.78768 8.55474C6.78768 8.73382 6.62978 8.87901 6.43505 8.87901Z" fill="#C5D3DD"/>
|
||||
<path d="M9.54009 6.56555L7.89129 4.64779C7.77455 4.51203 7.56983 4.4965 7.43398 4.61333L6.40778 5.4956C6.34258 5.55167 6.30233 5.63136 6.29584 5.71709C6.28936 5.80283 6.31725 5.88766 6.37332 5.9529L8.02212 7.87067C8.08624 7.94525 8.17695 7.98351 8.26813 7.98351C8.34297 7.98351 8.4182 7.95775 8.47938 7.90513L9.50559 7.02286C9.57078 6.96678 9.61104 6.8871 9.61752 6.80136C9.62405 6.71558 9.59616 6.63075 9.54009 6.56555Z" fill="#FEDF30"/>
|
||||
<path d="M8.57688 4.05987L7.88066 3.25006C7.76388 3.1143 7.5592 3.09882 7.42335 3.2156L5.02887 5.27423C4.96367 5.33031 4.92341 5.40999 4.91693 5.49573C4.91049 5.58147 4.93833 5.6663 4.99441 5.73154L5.69063 6.54135C5.75475 6.61593 5.84542 6.65419 5.93664 6.65419C6.01149 6.65419 6.08672 6.62842 6.1479 6.5758L8.54238 4.51718C8.60758 4.4611 8.64783 4.38142 8.65432 4.29568C8.6608 4.2099 8.63292 4.12507 8.57688 4.05987Z" fill="#D7AA02"/>
|
||||
<path d="M20.2699 5.71709C20.2634 5.63135 20.2231 5.55167 20.1579 5.49559L19.1317 4.61332C18.9959 4.49654 18.7912 4.51198 18.6744 4.64778L17.0256 6.56555C16.9696 6.63075 16.9417 6.71558 16.9482 6.80136C16.9547 6.8871 16.9949 6.96678 17.0601 7.02286L18.0863 7.90513C18.1476 7.95774 18.2227 7.98351 18.2976 7.98351C18.3888 7.98351 18.4795 7.94525 18.5436 7.87067L20.1924 5.9529C20.2485 5.88766 20.2763 5.80287 20.2699 5.71709Z" fill="#FEDF30"/>
|
||||
<path d="M21.5385 5.27382L19.144 3.21519C19.0788 3.15912 18.994 3.13093 18.9082 3.13771C18.8225 3.14416 18.7428 3.18445 18.6867 3.24965L17.9905 4.05946C17.8737 4.19526 17.8892 4.39998 18.025 4.51672L20.4195 6.57535C20.4785 6.62611 20.5536 6.65374 20.6309 6.65374C20.6391 6.65374 20.6472 6.65343 20.6553 6.65283C20.7411 6.64634 20.8207 6.60609 20.8768 6.54085L21.573 5.73104C21.6898 5.59532 21.6743 5.39056 21.5385 5.27382Z" fill="#D7AA02"/>
|
||||
<path d="M12.3359 2.71826H14.3258V5.56015H12.3359V2.71826Z" fill="#0055A3"/>
|
||||
<path d="M14.5486 0.899902H10.8925C10.5495 0.899902 10.2715 1.17795 10.2715 1.52094V2.27541C10.2715 2.6184 10.5495 2.89645 10.8925 2.89645H14.529L15.412 2.65843V1.153L14.5486 0.899902Z" fill="#0473CE"/>
|
||||
<path d="M15.7658 0.899902H14.4688C14.8117 0.899902 15.0898 1.17795 15.0898 1.52094V2.27541C15.0898 2.6184 14.8117 2.89645 14.4688 2.89645H15.7658C16.1088 2.89645 16.3869 2.6184 16.3869 2.27541V1.52094C16.3869 1.17795 16.1088 0.899902 15.7658 0.899902Z" fill="#0055A3"/>
|
||||
<path d="M11.1894 20.8213C6.73857 19.6401 4.08809 15.0744 5.26933 10.6236C6.22178 7.03487 9.37457 4.61661 12.8933 4.43364C13.7386 4.38971 21.1366 5.74662 21.1366 12.5075C21.1366 17.4616 16.6175 21.3883 12.6796 21.0765C12.1846 21.0373 11.6863 20.9532 11.1894 20.8213Z" fill="#26A6FE"/>
|
||||
<path d="M13.3282 4.42456C13.11 4.42456 12.8937 4.43303 12.6797 4.44951C16.9815 4.78048 20.369 8.37579 20.369 12.7625C20.369 17.1491 16.9814 20.7444 12.6797 21.0754C12.8937 21.0919 13.11 21.1003 13.3282 21.1003C17.9331 21.1003 21.6661 17.3674 21.6661 12.7625C21.6661 8.15754 17.9331 4.42456 13.3282 4.42456Z" fill="#0593FC"/>
|
||||
<path d="M13.3291 19.2553C16.9152 19.2553 19.8222 16.3483 19.8222 12.7622C19.8222 9.17613 16.9152 6.26904 13.3291 6.26904C9.74302 6.26904 6.83594 9.17613 6.83594 12.7622C6.83594 16.3483 9.74302 19.2553 13.3291 19.2553Z" fill="#FFF3EF"/>
|
||||
<path d="M14.167 6.32385C13.6602 6.25778 13.1594 6.25229 12.6719 6.30141C12.7378 6.30798 12.8038 6.31524 12.8699 6.32385C16.426 6.78721 18.933 10.0456 18.4696 13.6016C18.0723 16.6508 15.6199 18.9285 12.687 19.2238C16.1652 19.5707 19.3119 17.0915 19.7667 13.6016C20.2301 10.0456 17.723 6.78721 14.167 6.32385Z" fill="#F1F0F0"/>
|
||||
<path d="M13.3291 8.12532C13.1625 8.12532 13.0273 7.99021 13.0273 7.82353V6.98977C13.0273 6.8231 13.1625 6.68799 13.3291 6.68799C13.4958 6.68799 13.6309 6.8231 13.6309 6.98977V7.82353C13.6309 7.99021 13.4958 8.12532 13.3291 8.12532Z" fill="#B6C4CF"/>
|
||||
<path d="M16.8487 9.56667C16.7714 9.56667 16.6942 9.53722 16.6353 9.47829C16.5174 9.36043 16.5174 9.16937 16.6353 9.05151L17.2249 8.46195C17.3427 8.34404 17.5337 8.34409 17.6517 8.46195C17.7695 8.57981 17.7695 8.77087 17.6516 8.88873L17.062 9.47829C17.0031 9.53718 16.9259 9.56667 16.8487 9.56667Z" fill="#B6C4CF"/>
|
||||
<path d="M19.1512 13.0738H18.3174C18.1507 13.0738 18.0156 12.9387 18.0156 12.772C18.0156 12.6053 18.1507 12.4702 18.3174 12.4702H19.1512C19.3178 12.4702 19.453 12.6053 19.453 12.772C19.453 12.9387 19.3178 13.0738 19.1512 13.0738Z" fill="#B6C4CF"/>
|
||||
<path d="M17.4656 17.1814C17.3884 17.1814 17.3111 17.1519 17.2522 17.093L16.6626 16.5035C16.5448 16.3856 16.5448 16.1945 16.6626 16.0767C16.7805 15.9588 16.9715 15.9588 17.0894 16.0767L17.679 16.6662C17.7969 16.7841 17.7969 16.9752 17.679 17.093C17.6201 17.152 17.5428 17.1814 17.4656 17.1814Z" fill="#B6C4CF"/>
|
||||
<path d="M13.3682 18.8934C13.2015 18.8934 13.0664 18.7583 13.0664 18.5916V17.7578C13.0664 17.5912 13.2015 17.4561 13.3682 17.4561C13.5349 17.4561 13.67 17.5912 13.67 17.7578V18.5916C13.67 18.7583 13.5349 18.8934 13.3682 18.8934Z" fill="#B6C4CF"/>
|
||||
<path d="M9.26075 17.2073C9.18353 17.2073 9.10627 17.1779 9.04738 17.1189C8.92952 17.001 8.92952 16.81 9.04738 16.6921L9.63694 16.1026C9.7548 15.9847 9.94586 15.9847 10.0637 16.1026C10.1816 16.2204 10.1816 16.4115 10.0637 16.5293L9.47416 17.1189C9.41523 17.1778 9.33797 17.2073 9.26075 17.2073Z" fill="#B6C4CF"/>
|
||||
<path d="M8.38164 13.1114H7.54788C7.38121 13.1114 7.24609 12.9763 7.24609 12.8096C7.24609 12.6429 7.38121 12.5078 7.54788 12.5078H8.38164C8.54831 12.5078 8.68342 12.6429 8.68342 12.8096C8.68342 12.9763 8.54831 13.1114 8.38164 13.1114Z" fill="#B6C4CF"/>
|
||||
<path d="M9.82297 9.59328C9.74575 9.59328 9.66849 9.56383 9.6096 9.5049L9.02004 8.91534C8.90218 8.79748 8.90218 8.60642 9.02004 8.48856C9.1379 8.3707 9.32896 8.37065 9.44682 8.48856L10.0364 9.07812C10.1542 9.19598 10.1542 9.38704 10.0364 9.5049C9.97745 9.56383 9.90019 9.59328 9.82297 9.59328Z" fill="#B6C4CF"/>
|
||||
<path d="M13.3282 12.6168C13.149 12.6168 13.0039 12.4717 13.0039 12.2926V10.1121C13.0039 9.93303 13.149 9.78784 13.3282 9.78784C13.5073 9.78784 13.6524 9.93303 13.6524 10.1121V12.2926C13.6524 12.4717 13.5073 12.6168 13.3282 12.6168Z" fill="#678D98"/>
|
||||
<path d="M16.0561 15.7395C15.9731 15.7395 15.8901 15.7078 15.8268 15.6445L13.4661 13.2838C13.3394 13.1571 13.3394 12.9518 13.4661 12.8252C13.5928 12.6986 13.7981 12.6986 13.9247 12.8252L16.2854 15.1859C16.412 15.3126 16.412 15.5179 16.2854 15.6445C16.2221 15.7078 16.1391 15.7395 16.0561 15.7395Z" fill="#678D98"/>
|
||||
<path d="M13.3724 13.3816C13.0131 13.3816 12.7207 13.0893 12.7207 12.73C12.7207 12.3707 13.013 12.0784 13.3724 12.0784C13.7316 12.0784 14.024 12.3707 14.024 12.73C14.024 13.0893 13.7316 13.3816 13.3724 13.3816Z" fill="#3E5959"/>
|
||||
</svg>
|
After Width: | Height: | Size: 7.7 KiB |
17
assets/icons/scenesPlayIcon.svg
Normal file
@ -0,0 +1,17 @@
|
||||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_6675_32326)">
|
||||
<path d="M18 3C9.71584 3 3 9.71572 3 18C3 26.2843 9.71584 33 18 33C26.2842 33 33 26.2843 33 18C33 9.71572 26.2842 3 18 3ZM23.1844 18.7951L15.6844 23.4826C15.5326 23.5774 15.3601 23.625 15.1875 23.625C15.0312 23.625 14.8746 23.5861 14.7329 23.5073C14.4349 23.3421 14.25 23.0285 14.25 22.6875V13.3125C14.25 12.9715 14.4349 12.6579 14.7329 12.4927C15.0309 12.3265 15.3953 12.3366 15.6844 12.5174L23.1844 17.2049C23.4584 17.3766 23.625 17.6769 23.625 18C23.625 18.3231 23.4584 18.6235 23.1844 18.7951Z" fill="#F4F4F4"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_6675_32326" x="0" y="0" width="36" height="36" 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="1.5"/>
|
||||
<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.5 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6675_32326"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6675_32326" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
30
assets/icons/scenesPlayIconCheck.svg
Normal file
@ -0,0 +1,30 @@
|
||||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_7280_5211)">
|
||||
<circle cx="18" cy="18" r="15" fill="#F4F4F4"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_i_7280_5211)">
|
||||
<path d="M25.1663 13.187C24.8231 12.8439 24.2666 12.8439 23.9234 13.1871L16.1621 20.9484L12.0766 16.8628C11.7334 16.5196 11.1768 16.5196 10.8336 16.8628C10.4904 17.206 10.4904 17.7625 10.8336 18.1057L15.5406 22.8127C15.7122 22.9844 15.9372 23.0701 16.1621 23.0701C16.3869 23.0701 16.6119 22.9843 16.7835 22.8127L25.1663 14.43C25.5095 14.0868 25.5095 13.5303 25.1663 13.187Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_7280_5211" x="0" y="0" width="36" height="36" 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="1.5"/>
|
||||
<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.5 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_7280_5211"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_7280_5211" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter1_i_7280_5211" x="10.5762" y="12.9297" width="14.8475" height="10.1406" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<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="1.5"/>
|
||||
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0"/>
|
||||
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_7280_5211"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
4
assets/icons/spaseLocationIcon.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.13597 13.8173C7.21711 13.9314 7.35373 14 7.5 14C7.64627 14 7.78289 13.9315 7.86403 13.8173C8.89942 12.3614 10.4245 10.5632 11.4872 8.73444C12.3369 7.27221 12.75 6.02509 12.75 4.92188C12.75 2.20795 10.3948 0 7.5 0C4.60515 0 2.25 2.20795 2.25 4.92188C2.25 6.02509 2.66309 7.27221 3.51283 8.73444C4.57476 10.5618 6.10271 12.3644 7.13597 13.8173ZM7.5 0.820312C9.91237 0.820312 11.875 2.66027 11.875 4.92188C11.875 5.88448 11.4968 7.00323 10.7188 8.342C9.80277 9.91834 8.49557 11.5174 7.5 12.8617C6.50457 11.5176 5.19729 9.91843 4.2812 8.342C3.5032 7.00323 3.125 5.88448 3.125 4.92188C3.125 2.66027 5.08763 0.820312 7.5 0.820312Z" fill="#999999"/>
|
||||
<path d="M7.5 7.38281C8.94742 7.38281 10.125 6.27884 10.125 4.92188C10.125 3.56491 8.94742 2.46094 7.5 2.46094C6.05257 2.46094 4.875 3.56491 4.875 4.92188C4.875 6.27884 6.05257 7.38281 7.5 7.38281ZM7.5 3.28125C8.46495 3.28125 9.25 4.01723 9.25 4.92188C9.25 5.82652 8.46495 6.5625 7.5 6.5625C6.53505 6.5625 5.75 5.82652 5.75 4.92188C5.75 4.01723 6.53505 3.28125 7.5 3.28125Z" fill="#999999"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
21
assets/images/delete_space_link_icon.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_6702_36698)">
|
||||
<circle cx="20" cy="20" r="15" fill="#F4F4F4"/>
|
||||
<path d="M26.4 13.1094H23.7333V12.582C23.7333 11.7097 23.0156 11 22.1333 11H17.8667C16.9844 11 16.2667 11.7097 16.2667 12.582V13.1094H13.6C12.7178 13.1094 12 13.8191 12 14.6914C12 15.392 12.4631 15.9873 13.1024 16.1947L14.0537 27.5493C14.1222 28.3628 14.8226 29 15.6481 29H24.3519C25.1775 29 25.8778 28.3628 25.9464 27.5491L26.8976 16.1947C27.5369 15.9873 28 15.392 28 14.6914C28 13.8191 27.2822 13.1094 26.4 13.1094ZM17.3333 12.582C17.3333 12.2913 17.5726 12.0547 17.8667 12.0547H22.1333C22.4274 12.0547 22.6667 12.2913 22.6667 12.582V13.1094H17.3333V12.582ZM24.8833 27.4618C24.8605 27.7329 24.6271 27.9453 24.3519 27.9453H15.6481C15.373 27.9453 15.1395 27.7329 15.1167 27.462L14.1793 16.2734H25.8207L24.8833 27.4618ZM26.4 15.2188H13.6C13.3059 15.2188 13.0667 14.9822 13.0667 14.6914C13.0667 14.4006 13.3059 14.1641 13.6 14.1641H26.4C26.6941 14.1641 26.9333 14.4006 26.9333 14.6914C26.9333 14.9822 26.6941 15.2188 26.4 15.2188Z" fill="#999999"/>
|
||||
<path d="M17.8656 26.3307L17.3323 17.8229C17.314 17.5322 17.0596 17.3111 16.767 17.3292C16.473 17.3472 16.2494 17.5974 16.2676 17.8881L16.801 26.396C16.8185 26.6756 17.0533 26.8907 17.3328 26.8907C17.6416 26.8907 17.8846 26.6335 17.8656 26.3307Z" fill="#999999"/>
|
||||
<path d="M20.0001 17.3281C19.7056 17.3281 19.4668 17.5642 19.4668 17.8555V26.3633C19.4668 26.6545 19.7056 26.8906 20.0001 26.8906C20.2947 26.8906 20.5335 26.6545 20.5335 26.3633V17.8555C20.5335 17.5642 20.2947 17.3281 20.0001 17.3281Z" fill="#999999"/>
|
||||
<path d="M23.233 17.3292C22.9396 17.3111 22.6859 17.5321 22.6677 17.8229L22.1343 26.3307C22.1162 26.6213 22.3397 26.8716 22.6337 26.8896C22.9278 26.9076 23.1808 26.6865 23.199 26.3959L23.7323 17.8881C23.7505 17.5974 23.527 17.3472 23.233 17.3292Z" fill="#999999"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_6702_36698" x="0" y="0" width="40" height="40" 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="2.5"/>
|
||||
<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.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6702_36698"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6702_36698" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
25
assets/images/space_link_icon.svg
Normal file
@ -0,0 +1,25 @@
|
||||
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_6702_36714)">
|
||||
<circle cx="20" cy="20" r="15" fill="#F4F4F4"/>
|
||||
<path d="M21.1979 12.3395L18.26 15.2772C17.7228 15.8146 17.3477 16.4536 17.1345 17.1328C16.437 17.3525 15.798 17.7393 15.2772 18.26L12.3395 21.1979C10.5536 22.9837 10.5534 25.8744 12.3395 27.6605C14.1253 29.4464 17.0161 29.4466 18.8022 27.6605L21.7399 24.7227C22.2773 24.1855 22.6522 23.5465 22.8655 22.8671C23.5631 22.6475 24.202 22.2607 24.7227 21.7399L27.6605 18.8022C29.4464 17.0162 29.4467 14.1256 27.6605 12.3395C25.8746 10.5536 22.984 10.5534 21.1979 12.3395ZM17.266 20.2484C17.4886 20.7914 17.8199 21.2998 18.26 21.7399C18.6877 22.1674 19.1965 22.5054 19.7513 22.7343L16.8137 25.6721C16.1284 26.3572 15.0133 26.3574 14.328 25.6721C13.6427 24.9867 13.6427 23.8717 14.328 23.1864L17.2657 20.2485C17.2659 20.2485 17.2659 20.2485 17.266 20.2484ZM21.2428 24.2256L18.3049 27.1633C16.7939 28.6745 14.3479 28.6747 12.8366 27.1633C11.3254 25.6523 11.3253 23.2062 12.8366 21.695L15.7744 18.7571C16.1166 18.4149 16.5191 18.1412 16.9579 17.9488C16.8924 18.4845 16.9223 19.014 17.0364 19.5199C16.9419 19.5905 16.8524 19.6676 16.7686 19.7514L13.8309 22.6892C12.8715 23.6487 12.8715 25.2097 13.8309 26.1691C14.7903 27.1285 16.3513 27.1285 17.3108 26.1691L20.2485 23.2313C21.2089 22.2709 21.209 20.7119 20.2485 19.7514C19.7355 19.2383 19.6105 18.4924 19.8554 17.8663C20.3734 18.059 20.8488 18.3631 21.2428 18.7571C22.7504 20.2647 22.7505 22.7179 21.2428 24.2256ZM27.1633 18.3049L24.2256 21.2428C23.8834 21.585 23.4809 21.8587 23.0421 22.0511C23.1076 21.5154 23.0777 20.986 22.9637 20.4801C23.058 20.4095 23.1477 20.3323 23.2313 20.2485L26.1692 17.3108C27.1286 16.3514 27.1286 14.7903 26.1692 13.8309C25.3077 12.9695 23.9604 12.8807 22.9987 13.5684C22.8408 13.6813 22.8044 13.9009 22.9173 14.0588C23.0301 14.2168 23.2497 14.2533 23.4077 14.1403C24.1093 13.6386 25.0615 13.7174 25.6721 14.328C26.3574 15.0133 26.3574 16.1283 25.6721 16.8137L22.7342 19.7514C22.7342 19.7514 22.7342 19.7514 22.7341 19.7515C22.5113 19.2085 22.1801 18.7002 21.7399 18.26C21.3124 17.8325 20.8035 17.4945 20.2487 17.2656L21.4465 16.0678C21.5837 15.9306 21.5837 15.708 21.4465 15.5707C21.3091 15.4335 21.0867 15.4335 20.9493 15.5707L19.7514 16.7686C18.7911 17.729 18.7909 19.2879 19.7514 20.2485C20.2645 20.7615 20.3894 21.5076 20.1446 22.1337C19.6266 21.941 19.1511 21.6368 18.7571 21.2427C17.2497 19.7352 17.2495 17.282 18.7571 15.7744L21.695 12.8366C23.2061 11.3254 25.6522 11.3252 27.1633 12.8366C28.6745 14.3476 28.6747 16.7937 27.1633 18.3049Z" fill="#999999"/>
|
||||
<path d="M22.5443 14.8262C22.5443 15.0204 22.3869 15.1777 22.1929 15.1777C21.9987 15.1777 21.8413 15.0204 21.8413 14.8262C21.8413 14.632 21.9987 14.4746 22.1929 14.4746C22.3869 14.4746 22.5443 14.632 22.5443 14.8262Z" fill="#999999"/>
|
||||
<path d="M15.7755 15.774C15.9128 15.6368 15.9128 15.4142 15.7755 15.2769L14.2841 13.7855C14.1468 13.6483 13.9243 13.6483 13.787 13.7855C13.6498 13.9228 13.6498 14.1455 13.787 14.2828L15.2784 15.7742C15.4158 15.9114 15.6383 15.9114 15.7755 15.774Z" fill="#999999"/>
|
||||
<path d="M12.3378 16.9062C12.1437 16.9062 11.9863 17.0636 11.9863 17.2577C11.9863 17.4519 12.1437 17.6092 12.3378 17.6092H14.447C14.641 17.6092 14.7984 17.4519 14.7984 17.2577C14.7984 17.0636 14.641 16.9062 14.447 16.9062H12.3378Z" fill="#999999"/>
|
||||
<path d="M16.9062 12.2314V14.3405C16.9062 14.5346 17.0636 14.6921 17.2577 14.6921C17.4519 14.6921 17.6092 14.5346 17.6092 14.3405V12.2314C17.6092 12.0373 17.4519 11.8799 17.2577 11.8799C17.0636 11.8799 16.9062 12.0373 16.9062 12.2314Z" fill="#999999"/>
|
||||
<path d="M24.227 24.2259C24.0897 24.3631 24.0897 24.5857 24.227 24.7231L25.7184 26.2145C25.7871 26.2831 25.877 26.3175 25.967 26.3175C26.2772 26.3175 26.4377 25.9397 26.2155 25.7173L24.7242 24.2259C24.5868 24.0887 24.3643 24.0887 24.227 24.2259Z" fill="#999999"/>
|
||||
<path d="M23.0605 27.7673V25.6581C23.0605 25.464 22.903 25.3066 22.709 25.3066C22.5148 25.3066 22.3574 25.464 22.3574 25.6581V27.7673C22.3574 27.9614 22.5148 28.1187 22.709 28.1187C22.903 28.1187 23.0605 27.9614 23.0605 27.7673Z" fill="#999999"/>
|
||||
<path d="M27.7693 23.0586C27.9633 23.0586 28.1207 22.9011 28.1207 22.707C28.1207 22.5128 27.9633 22.3555 27.7693 22.3555H25.66C25.466 22.3555 25.3086 22.5128 25.3086 22.707C25.3086 22.9011 25.466 23.0586 25.66 23.0586H27.7693Z" fill="#999999"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_6702_36714" x="0" y="0" width="40" height="40" 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="2.5"/>
|
||||
<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.25 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6702_36714"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6702_36714" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 5.0 KiB |
3
assets/images/success_icon.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M43.2614 20.4808C44.1769 21.3963 44.1769 22.8804 43.2614 23.7955L27.5381 39.5192C26.6226 40.4343 25.139 40.4343 24.2235 39.5192L16.7386 32.0338C15.8231 31.1188 15.8231 29.6347 16.7386 28.7196C17.6537 27.8041 19.1377 27.8041 20.0528 28.7196L25.8806 34.5474L39.9467 20.4808C40.8623 19.5657 42.3463 19.5657 43.2614 20.4808ZM60 30C60 46.5825 46.5802 60 30 60C13.4175 60 0 46.5802 0 30C0 13.4175 13.4198 0 30 0C46.5825 0 60 13.4198 60 30ZM55.3125 30C55.3125 16.0085 43.9897 4.6875 30 4.6875C16.0085 4.6875 4.6875 16.0103 4.6875 30C4.6875 43.9915 16.0103 55.3125 30 55.3125C43.9915 55.3125 55.3125 43.9897 55.3125 30Z" fill="#023DFE" fill-opacity="0.7"/>
|
||||
</svg>
|
After Width: | Height: | Size: 761 B |
@ -1,35 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class DialogTextfieldDropdown extends StatefulWidget {
|
||||
final List<String> items;
|
||||
final ValueChanged<String> onSelected;
|
||||
final String? initialValue;
|
||||
class TagDialogTextfieldDropdown extends StatefulWidget {
|
||||
final List<Tag> items;
|
||||
final ValueChanged<Tag> onSelected;
|
||||
final Tag? initialValue;
|
||||
final String product;
|
||||
|
||||
const DialogTextfieldDropdown({
|
||||
const TagDialogTextfieldDropdown({
|
||||
Key? key,
|
||||
required this.items,
|
||||
required this.onSelected,
|
||||
this.initialValue,
|
||||
required this.product,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DialogTextfieldDropdownState createState() =>
|
||||
_DialogTextfieldDropdownState();
|
||||
_DialogTextfieldDropdownState createState() => _DialogTextfieldDropdownState();
|
||||
}
|
||||
|
||||
class _DialogTextfieldDropdownState extends State<DialogTextfieldDropdown> {
|
||||
class _DialogTextfieldDropdownState extends State<TagDialogTextfieldDropdown> {
|
||||
bool _isOpen = false;
|
||||
OverlayEntry? _overlayEntry;
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
List<String> _filteredItems = [];
|
||||
List<Tag> _filteredItems = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller.text = widget.initialValue ?? '';
|
||||
_filteredItems = List.from(widget.items);
|
||||
_controller.text = widget.initialValue?.tag ?? '';
|
||||
|
||||
_filterItems();
|
||||
|
||||
_focusNode.addListener(() {
|
||||
if (!_focusNode.hasFocus) {
|
||||
@ -38,6 +41,12 @@ class _DialogTextfieldDropdownState extends State<DialogTextfieldDropdown> {
|
||||
});
|
||||
}
|
||||
|
||||
void _filterItems() {
|
||||
setState(() {
|
||||
_filteredItems = widget.items.where((tag) => tag.product?.uuid == widget.product).toList();
|
||||
});
|
||||
}
|
||||
|
||||
void _toggleDropdown() {
|
||||
if (_isOpen) {
|
||||
_closeDropdown();
|
||||
@ -87,7 +96,7 @@ class _DialogTextfieldDropdownState extends State<DialogTextfieldDropdown> {
|
||||
shrinkWrap: true,
|
||||
itemCount: _filteredItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _filteredItems[index];
|
||||
final tag = _filteredItems[index];
|
||||
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
@ -99,19 +108,16 @@ class _DialogTextfieldDropdownState extends State<DialogTextfieldDropdown> {
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Text(item,
|
||||
title: Text(tag.tag ?? '',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: ColorsManager
|
||||
.textPrimaryColor)),
|
||||
?.copyWith(color: ColorsManager.textPrimaryColor)),
|
||||
onTap: () {
|
||||
_controller.text = item;
|
||||
widget.onSelected(item);
|
||||
_controller.text = tag.tag ?? '';
|
||||
widget.onSelected(tag);
|
||||
setState(() {
|
||||
_filteredItems
|
||||
.remove(item); // Remove selected item
|
||||
_filteredItems.remove(tag);
|
||||
});
|
||||
_closeDropdown();
|
||||
},
|
||||
@ -150,11 +156,14 @@ class _DialogTextfieldDropdownState extends State<DialogTextfieldDropdown> {
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
onFieldSubmitted: (value) {
|
||||
widget.onSelected(value);
|
||||
final selectedTag = _filteredItems.firstWhere((tag) => tag.tag == value,
|
||||
orElse: () => Tag(tag: value));
|
||||
widget.onSelected(selectedTag);
|
||||
_closeDropdown();
|
||||
},
|
||||
onTapOutside: (event) {
|
||||
widget.onSelected(_controller.text);
|
||||
widget.onSelected(_filteredItems.firstWhere((tag) => tag.tag == _controller.text,
|
||||
orElse: () => Tag(tag: _controller.text)));
|
||||
_closeDropdown();
|
||||
},
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
@ -101,7 +101,7 @@ class CustomExpansionTileState extends State<CustomExpansionTile> {
|
||||
widget.children != null &&
|
||||
widget.children!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48.0), // Indented children
|
||||
padding: const EdgeInsets.only(left: 24.0), // Indented children
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: widget.children!,
|
||||
|
@ -4,11 +4,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:syncrow_web/firebase_options_dev.dart';
|
||||
import 'package:syncrow_web/firebase_options_prod.dart';
|
||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
@ -34,7 +34,6 @@ Future<void> main() async {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
MyApp({super.key});
|
||||
|
||||
final GoRouter _router = GoRouter(
|
||||
@ -56,6 +55,9 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<CreateRoutineBloc>(
|
||||
create: (context) => CreateRoutineBloc(),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||
BlocProvider<VisitorPasswordBloc>(
|
||||
|
@ -8,6 +8,7 @@ import 'package:syncrow_web/firebase_options_dev.dart';
|
||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
@ -55,6 +56,9 @@ class MyApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<CreateRoutineBloc>(
|
||||
create: (context) => CreateRoutineBloc(),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => HomeBloc()..add(const FetchUserInfo())),
|
||||
BlocProvider<VisitorPasswordBloc>(
|
||||
|
@ -3,7 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_bloc.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_event.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/search_reset_buttons.dart';
|
||||
import 'package:syncrow_web/pages/common/custom_table.dart';
|
||||
|
@ -15,7 +15,6 @@ import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
import 'package:syncrow_web/services/auth_api.dart';
|
||||
import 'package:syncrow_web/utils/constants/strings_manager.dart';
|
||||
import 'package:syncrow_web/utils/helpers/shared_preferences_helper.dart';
|
||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||
|
||||
class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
|
@ -5,9 +5,6 @@ import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||
import 'package:syncrow_web/utils/constants/strings_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||
import 'package:syncrow_web/utils/helpers/shared_preferences_helper.dart';
|
||||
|
||||
part 'device_managment_event.dart';
|
||||
part 'device_managment_state.dart';
|
||||
@ -46,8 +43,7 @@ class DeviceManagementBloc
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
if (spaceBloc.state.selectedCommunities.isEmpty) {
|
||||
devices = await DevicesManagementApi()
|
||||
.fetchDevices('', '', projectUuid );
|
||||
devices = await DevicesManagementApi().fetchDevices('', '', projectUuid);
|
||||
} else {
|
||||
for (var community in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
|
@ -8,6 +8,7 @@ import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/three_gang_switch/three_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/two_gang_switch/two_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_functions.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/enum/device_types.dart';
|
||||
|
||||
@ -148,7 +149,9 @@ class AllDevicesModel {
|
||||
|
||||
productName = json['productName']?.toString();
|
||||
if (json['spaces'] != null && json['spaces'] is List) {
|
||||
spaces = (json['spaces'] as List).map((space) => DeviceSpaceModel.fromJson(space)).toList();
|
||||
spaces = (json['spaces'] as List)
|
||||
.map((space) => DeviceSpaceModel.fromJson(space))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +199,8 @@ SOS
|
||||
String tempIcon = '';
|
||||
if (type == DeviceType.LightBulb) {
|
||||
tempIcon = Assets.lightBulb;
|
||||
} else if (type == DeviceType.CeilingSensor || type == DeviceType.WallSensor) {
|
||||
} else if (type == DeviceType.CeilingSensor ||
|
||||
type == DeviceType.WallSensor) {
|
||||
tempIcon = Assets.sensors;
|
||||
} else if (type == DeviceType.AC) {
|
||||
tempIcon = Assets.ac;
|
||||
@ -226,6 +230,8 @@ SOS
|
||||
// tempIcon = Assets.gang3touch;
|
||||
} else if (type == DeviceType.WaterLeak) {
|
||||
tempIcon = Assets.waterLeakNormal;
|
||||
} else if (type == DeviceType.WaterLeak) {
|
||||
tempIcon = Assets.waterLeakNormal;
|
||||
} else {
|
||||
tempIcon = Assets.logoHorizontal;
|
||||
}
|
||||
@ -244,6 +250,7 @@ SOS
|
||||
SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
];
|
||||
@ -251,27 +258,62 @@ SOS
|
||||
case '1G':
|
||||
return [
|
||||
OneGangSwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
OneGangCountdownFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
OneGangCountdownFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
];
|
||||
|
||||
case '2G':
|
||||
return [
|
||||
TwoGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TwoGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TwoGangCountdown1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TwoGangCountdown2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TwoGangCountdown1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TwoGangCountdown2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
];
|
||||
|
||||
case '3G':
|
||||
return [
|
||||
ThreeGangSwitch1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangSwitch2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangSwitch3Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangCountdown1Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangCountdown2Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangCountdown3Function(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangSwitch1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangSwitch2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangSwitch3Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangCountdown1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangCountdown2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ThreeGangCountdown3Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
];
|
||||
case 'WPS':
|
||||
return [
|
||||
//IF Functions
|
||||
PresenceStateFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
CurrentDistanceFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
IlluminanceValueFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
PresenceTimeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
|
||||
//THEN Functions
|
||||
FarDetectionFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
MotionSensitivityFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
MotionLessSensitivityFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
IndicatorFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
NoOneTimeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
|
||||
// FarDetectionSliderFunction(
|
||||
// deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN')
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_mgmt_bloc/device_managment_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/widgets/device_managment_body.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
||||
import 'package:syncrow_web/pages/routines/view/routines_view.dart';
|
||||
@ -40,10 +41,15 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
backgroundColor: null,
|
||||
),
|
||||
onPressed: () {
|
||||
BlocProvider.of<CreateRoutineBloc>(context)
|
||||
.add(const ResetSelectedEvent());
|
||||
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(const TriggerSwitchTabsEvent(isRoutineTab: false));
|
||||
context.read<DeviceManagementBloc>().add(FetchDevices(context));
|
||||
context
|
||||
.read<DeviceManagementBloc>()
|
||||
.add(FetchDevices(context));
|
||||
},
|
||||
child: Text(
|
||||
'Devices',
|
||||
@ -61,6 +67,9 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
||||
backgroundColor: null,
|
||||
),
|
||||
onPressed: () {
|
||||
BlocProvider.of<CreateRoutineBloc>(context)
|
||||
.add(const ResetSelectedEvent());
|
||||
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(const TriggerSwitchTabsEvent(isRoutineTab: true));
|
||||
|
@ -29,7 +29,7 @@ class TwoGangSwitchBloc extends Bloc<TwoGangSwitchEvent, TwoGangSwitchState> {
|
||||
final status =
|
||||
await DevicesManagementApi().getDeviceStatus(event.deviceId);
|
||||
deviceStatus = TwoGangStatusModel.fromJson(event.deviceId, status.status);
|
||||
_listenToChanges(emit);
|
||||
_listenToChanges(event.deviceId);
|
||||
emit(TwoGangSwitchStatusLoaded(deviceStatus));
|
||||
} catch (e) {
|
||||
emit(TwoGangSwitchError(e.toString()));
|
||||
|
@ -30,7 +30,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
var response = await DevicesManagementApi().getDeviceStatus(deviceId);
|
||||
deviceStatus = WallSensorModel.fromJson(response.status);
|
||||
emit(WallSensorUpdateState(wallSensorModel: deviceStatus));
|
||||
_listenToChanges(emit);
|
||||
_listenToChanges(emit, deviceId);
|
||||
} catch (e) {
|
||||
emit(WallSensorFailedState(error: e.toString()));
|
||||
return;
|
||||
@ -52,7 +52,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
}
|
||||
}
|
||||
|
||||
_listenToChanges(Emitter<WallSensorState> emit) {
|
||||
_listenToChanges(Emitter<WallSensorState> emit, deviceId) {
|
||||
try {
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$deviceId');
|
||||
|
@ -95,6 +95,77 @@ class CountdownInchingView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Row _hourMinutesSecondWheel(
|
||||
BuildContext context, WaterHeaterDeviceStatusLoaded state) {
|
||||
final isCountDown =
|
||||
state.scheduleMode?.name == ScheduleModes.countdown.name;
|
||||
late bool isActive;
|
||||
if (isCountDown &&
|
||||
state.countdownRemaining != null &&
|
||||
state.isCountdownActive == true) {
|
||||
isActive = true;
|
||||
} else if (!isCountDown &&
|
||||
state.countdownRemaining != null &&
|
||||
state.isInchingActive == true) {
|
||||
isActive = true;
|
||||
} else {
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
_buildPickerColumn(
|
||||
context,
|
||||
'h',
|
||||
isCountDown
|
||||
? (state.countdownHours ?? 0)
|
||||
: (state.inchingHours ?? 0),
|
||||
24, (value) {
|
||||
context.read<WaterHeaterBloc>().add(UpdateScheduleEvent(
|
||||
scheduleMode: state.scheduleMode ?? ScheduleModes.countdown,
|
||||
hours: value,
|
||||
minutes: isCountDown
|
||||
? (state.countdownMinutes ?? 0)
|
||||
: (state.inchingMinutes ?? 0),
|
||||
));
|
||||
}, isActive: isActive),
|
||||
const SizedBox(width: 10),
|
||||
_buildPickerColumn(
|
||||
context,
|
||||
'm',
|
||||
isCountDown
|
||||
? (state.countdownMinutes ?? 0)
|
||||
: (state.inchingMinutes ?? 0),
|
||||
60, (value) {
|
||||
context.read<WaterHeaterBloc>().add(UpdateScheduleEvent(
|
||||
scheduleMode: state.scheduleMode ?? ScheduleModes.countdown,
|
||||
hours: isCountDown
|
||||
? (state.countdownHours ?? 0)
|
||||
: (state.inchingHours ?? 0),
|
||||
minutes: value,
|
||||
));
|
||||
}, isActive: isActive),
|
||||
const SizedBox(width: 10),
|
||||
_buildPickerColumn(
|
||||
context,
|
||||
'S',
|
||||
isCountDown
|
||||
? (state.countdownMinutes ?? 0)
|
||||
: (state.inchingMinutes ?? 0),
|
||||
60, (value) {
|
||||
context.read<WaterHeaterBloc>().add(UpdateScheduleEvent(
|
||||
scheduleMode: state.scheduleMode ?? ScheduleModes.countdown,
|
||||
hours: isCountDown
|
||||
? (state.countdownHours ?? 0)
|
||||
: (state.inchingHours ?? 0),
|
||||
minutes: value,
|
||||
));
|
||||
}, isActive: isActive),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPickerColumn(
|
||||
BuildContext context,
|
||||
String label,
|
||||
|
@ -0,0 +1,39 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class AutomationStatusUpdate {
|
||||
final String spaceUuid;
|
||||
final bool isEnable;
|
||||
|
||||
AutomationStatusUpdate({
|
||||
required this.spaceUuid,
|
||||
required this.isEnable,
|
||||
});
|
||||
|
||||
factory AutomationStatusUpdate.fromRawJson(String str) =>
|
||||
AutomationStatusUpdate.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory AutomationStatusUpdate.fromJson(Map<String, dynamic> json) =>
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: json["spaceUuid"],
|
||||
isEnable: json["isEnable"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"spaceUuid": spaceUuid,
|
||||
"isEnable": isEnable,
|
||||
};
|
||||
|
||||
factory AutomationStatusUpdate.fromMap(Map<String, dynamic> map) =>
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: map["spaceUuid"],
|
||||
isEnable: map["isEnable"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"spaceUuid": spaceUuid,
|
||||
"isEnable": isEnable,
|
||||
};
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
|
||||
class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
||||
CreateRoutineBloc() : super(const CreateRoutineInitial()) {
|
||||
on<SpaceOnlyWithDevicesEvent>(_fetchSpaceOnlyWithDevices);
|
||||
on<SaveCommunityIdAndSpaceIdEvent>(saveSpaceIdCommunityId);
|
||||
on<ResetSelectedEvent>(resetSelected);
|
||||
}
|
||||
|
||||
String selectedSpaceId = '';
|
||||
String selectedCommunityId = '';
|
||||
|
||||
List<SpaceModel> spacesOnlyWithDevices = [];
|
||||
|
||||
Future<void> _fetchSpaceOnlyWithDevices(
|
||||
SpaceOnlyWithDevicesEvent event, Emitter<CreateRoutineState> emit) async {
|
||||
emit(const SpaceWithDeviceLoadingState());
|
||||
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
spacesOnlyWithDevices = await CommunitySpaceManagementApi()
|
||||
.getSpaceOnlyWithDevices(
|
||||
communityId: event.communityID, projectId: projectUuid);
|
||||
|
||||
emit(SpaceWithDeviceLoadedState(spacesOnlyWithDevices));
|
||||
} catch (e) {
|
||||
emit(SpaceTreeErrorState('Error loading communities and spaces: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
saveSpaceIdCommunityId(
|
||||
SaveCommunityIdAndSpaceIdEvent event, Emitter<CreateRoutineState> emit) {
|
||||
emit(const SpaceWithDeviceLoadingState());
|
||||
selectedSpaceId = event.spaceID!;
|
||||
selectedCommunityId = event.communityID!;
|
||||
emit(const SelectedState());
|
||||
}
|
||||
|
||||
resetSelected(ResetSelectedEvent event, Emitter<CreateRoutineState> emit) {
|
||||
emit(const SpaceWithDeviceLoadingState());
|
||||
selectedSpaceId = '';
|
||||
selectedCommunityId = '';
|
||||
emit(const ResetSelectedState());
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
abstract class CreateRoutineEvent extends Equatable {
|
||||
const CreateRoutineEvent();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class AddToIfContainer extends CreateRoutineEvent {
|
||||
final SpaceModel spaceModel;
|
||||
|
||||
const AddToIfContainer(this.spaceModel);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [spaceModel];
|
||||
}
|
||||
|
||||
class SpaceOnlyWithDevicesEvent extends CreateRoutineEvent {
|
||||
final String communityID;
|
||||
const SpaceOnlyWithDevicesEvent(this.communityID);
|
||||
|
||||
@override
|
||||
List<Object> get props => [communityID];
|
||||
}
|
||||
|
||||
class SaveCommunityIdAndSpaceIdEvent extends CreateRoutineEvent {
|
||||
final String? communityID;
|
||||
final String? spaceID;
|
||||
|
||||
const SaveCommunityIdAndSpaceIdEvent({this.communityID, this.spaceID});
|
||||
|
||||
@override
|
||||
List<Object> get props => [communityID!, spaceID!];
|
||||
}
|
||||
|
||||
class ResetSelectedEvent extends CreateRoutineEvent {
|
||||
const ResetSelectedEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
abstract class CreateRoutineState extends Equatable {
|
||||
const CreateRoutineState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class CreateRoutineInitial extends CreateRoutineState {
|
||||
const CreateRoutineInitial();
|
||||
}
|
||||
|
||||
class SpaceWithDeviceLoadingState extends CreateRoutineState {
|
||||
const SpaceWithDeviceLoadingState();
|
||||
}
|
||||
|
||||
class SpaceWithDeviceLoadedState extends CreateRoutineState {
|
||||
final List<SpaceModel> spaces;
|
||||
|
||||
const SpaceWithDeviceLoadedState(this.spaces);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [spaces];
|
||||
}
|
||||
|
||||
class SpaceTreeErrorState extends CreateRoutineState {
|
||||
final String errorMessage;
|
||||
|
||||
const SpaceTreeErrorState(this.errorMessage);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [errorMessage];
|
||||
}
|
||||
|
||||
class SelectedState extends CreateRoutineState {
|
||||
const SelectedState();
|
||||
}
|
||||
|
||||
|
||||
class ResetSelectedState extends CreateRoutineState {
|
||||
const ResetSelectedState();
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/automation_scene_trigger_bloc/automation_status_update.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_scene_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/delay/delay_fucntions.dart';
|
||||
@ -16,9 +18,6 @@ import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||
import 'package:syncrow_web/services/routines_api.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/constants/strings_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||
import 'package:syncrow_web/utils/helpers/shared_preferences_helper.dart';
|
||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@ -55,7 +54,11 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
on<TriggerSwitchTabsEvent>(_triggerSwitchTabsEvent);
|
||||
on<CreateNewRoutineViewEvent>(_createNewRoutineViewEvent);
|
||||
on<ResetErrorMessage>(_resetErrorMessage);
|
||||
on<SceneTrigger>(_onSceneTrigger);
|
||||
on<UpdateAutomationStatus>(_onUpdateAutomationStatus);
|
||||
}
|
||||
String selectedSpaceId = '';
|
||||
String selectedCommunityId = '';
|
||||
|
||||
FutureOr<void> _triggerSwitchTabsEvent(
|
||||
TriggerSwitchTabsEvent event,
|
||||
@ -174,17 +177,25 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||
List<ScenesModel> scenes = [];
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
scenes.addAll(
|
||||
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||
createRoutineBloc.selectedCommunityId == '') {
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
scenes.addAll(
|
||||
await SceneApi.getScenes(spaceId, communityId, projectUuid));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
scenes.addAll(await SceneApi.getScenes(
|
||||
createRoutineBloc.selectedSpaceId,
|
||||
createRoutineBloc.selectedCommunityId,
|
||||
projectUuid));
|
||||
}
|
||||
|
||||
emit(state.copyWith(
|
||||
@ -205,16 +216,28 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||
List<ScenesModel> automations = [];
|
||||
final projectId = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
try {
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
automations.addAll(await SceneApi.getAutomation(spaceId));
|
||||
|
||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||
createRoutineBloc.selectedCommunityId == '') {
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
automations.addAll(
|
||||
await SceneApi.getAutomation(spaceId, communityId, projectId));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
automations.addAll(await SceneApi.getAutomation(
|
||||
createRoutineBloc.selectedSpaceId,
|
||||
createRoutineBloc.selectedCommunityId,
|
||||
projectId));
|
||||
}
|
||||
emit(state.copyWith(
|
||||
automations: automations,
|
||||
@ -314,10 +337,10 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
}).toList();
|
||||
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
|
||||
final createSceneModel = CreateSceneModel(
|
||||
spaceUuid: spaceBloc.state.selectedSpaces[0],
|
||||
spaceUuid: createRoutineBloc.selectedSpaceId,
|
||||
iconId: state.selectedIcon ?? '',
|
||||
showInDevice: true,
|
||||
sceneName: state.routineName ?? '',
|
||||
@ -347,6 +370,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
Future<void> _onCreateAutomation(
|
||||
CreateAutomationEvent event, Emitter<RoutineState> emit) async {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||
emit(state.copyWith(
|
||||
errorMessage: 'Automation name is required',
|
||||
@ -443,10 +467,10 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
});
|
||||
}).toList();
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
|
||||
final createAutomationModel = CreateAutomationModel(
|
||||
spaceUuid: spaceBloc.state.selectedSpaces[0],
|
||||
spaceUuid: createRoutineBloc.selectedSpaceId,
|
||||
automationName: state.routineName ?? '',
|
||||
decisionExpr: state.selectedAutomationOperator,
|
||||
effectiveTime: EffectiveTime(
|
||||
@ -458,7 +482,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
actions: actions,
|
||||
);
|
||||
|
||||
final result = await SceneApi.createAutomation(createAutomationModel);
|
||||
final result =
|
||||
await SceneApi.createAutomation(createAutomationModel, projectUuid);
|
||||
if (result['success']) {
|
||||
add(ResetRoutineState());
|
||||
add(const LoadAutomation());
|
||||
@ -836,22 +861,33 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
isUpdate: false,
|
||||
createRoutineView: false));
|
||||
}
|
||||
|
||||
FutureOr<void> _deleteScene(
|
||||
DeleteScene event, Emitter<RoutineState> emit) async {
|
||||
FutureOr<void> _deleteScene(DeleteScene event, Emitter<RoutineState> emit) async {
|
||||
try {
|
||||
final projectId = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
emit(state.copyWith(isLoading: true));
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
if (state.isTabToRun) {
|
||||
await SceneApi.deleteScene(
|
||||
unitUuid: spaceBloc.state.selectedSpaces[0],
|
||||
sceneId: state.sceneId ?? '');
|
||||
unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? '');
|
||||
} else {
|
||||
await SceneApi.deleteAutomation(
|
||||
unitUuid: spaceBloc.state.selectedSpaces[0],
|
||||
automationId: state.automationId ?? '');
|
||||
automationId: state.automationId ?? '',
|
||||
projectId: projectId);
|
||||
}
|
||||
// var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
// if (state.isTabToRun) {
|
||||
// await SceneApi.deleteScene(
|
||||
// unitUuid: createRoutineBloc.selectedSpaceId,
|
||||
// sceneId: state.sceneId ?? '');
|
||||
// } else {
|
||||
// await SceneApi.deleteAutomation(
|
||||
// projectId: projectId,
|
||||
// unitUuid: createRoutineBloc.selectedSpaceId,
|
||||
// automationId: state.automationId ?? '');
|
||||
// }
|
||||
|
||||
add(const LoadScenes());
|
||||
add(const LoadAutomation());
|
||||
@ -864,7 +900,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FutureOr<void> _deleteAutomation(DeleteAutomation event, Emitter<RoutineState> emit) {
|
||||
// try {
|
||||
// emit(state.copyWith(isLoading: true));
|
||||
@ -884,18 +920,26 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
List<AllDevicesModel> devices = [];
|
||||
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var createRoutineBloc = context.read<CreateRoutineBloc>();
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
devices.addAll(await DevicesManagementApi()
|
||||
.fetchDevices(communityId, spaceId, projectUuid));
|
||||
|
||||
if (createRoutineBloc.selectedSpaceId == '' &&
|
||||
createRoutineBloc.selectedCommunityId == '') {
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
for (var spaceId in spacesList) {
|
||||
devices.addAll(await DevicesManagementApi()
|
||||
.fetchDevices(communityId, spaceId, projectUuid));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
devices.addAll(await DevicesManagementApi().fetchDevices(
|
||||
createRoutineBloc.selectedCommunityId,
|
||||
createRoutineBloc.selectedSpaceId,
|
||||
projectUuid));
|
||||
}
|
||||
|
||||
emit(state.copyWith(isLoading: false, devices: devices));
|
||||
@ -1090,10 +1134,10 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
}).toList();
|
||||
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
var spaceBloc = context.read<CreateRoutineBloc>();
|
||||
|
||||
final createAutomationModel = CreateAutomationModel(
|
||||
spaceUuid: spaceBloc.state.selectedSpaces[0],
|
||||
spaceUuid: spaceBloc.selectedSpaceId,
|
||||
automationName: state.routineName ?? '',
|
||||
decisionExpr: state.selectedAutomationOperator,
|
||||
effectiveTime: EffectiveTime(
|
||||
@ -1104,9 +1148,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
conditions: conditions,
|
||||
actions: actions,
|
||||
);
|
||||
|
||||
final projectId = await ProjectManager.getProjectUUID() ?? '';
|
||||
final result = await SceneApi.updateAutomation(
|
||||
createAutomationModel, state.automationId ?? '');
|
||||
createAutomationModel, state.automationId ?? '', projectId);
|
||||
|
||||
if (result['success']) {
|
||||
add(ResetRoutineState());
|
||||
@ -1129,6 +1173,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
Future<void> _onGetAutomationDetails(
|
||||
GetAutomationDetails event, Emitter<RoutineState> emit) async {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
emit(state.copyWith(
|
||||
isLoading: true,
|
||||
isUpdate: true,
|
||||
@ -1140,7 +1185,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
));
|
||||
|
||||
final automationDetails =
|
||||
await SceneApi.getAutomationDetails(event.automationId);
|
||||
await SceneApi.getAutomationDetails(event.automationId, projectUuid);
|
||||
|
||||
final Map<String, Map<String, dynamic>> deviceIfCards = {};
|
||||
final Map<String, Map<String, dynamic>> deviceThenCards = {};
|
||||
@ -1318,4 +1363,77 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSceneTrigger(
|
||||
SceneTrigger event, Emitter<RoutineState> emit) async {
|
||||
emit(state.copyWith(loadingSceneId: event.sceneId));
|
||||
|
||||
try {
|
||||
final success = await SceneApi.triggerScene(event.sceneId!);
|
||||
|
||||
if (success) {
|
||||
emit(state.copyWith(
|
||||
loadingSceneId: null,
|
||||
// Add success state if needed
|
||||
));
|
||||
// Optional: Add delay to show success feedback
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
} else {
|
||||
emit(state.copyWith(
|
||||
loadingSceneId: null,
|
||||
errorMessage: 'Trigger failed',
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(state.copyWith(
|
||||
loadingSceneId: null,
|
||||
errorMessage: 'Trigger error: ${e.toString()}',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onUpdateAutomationStatus(
|
||||
UpdateAutomationStatus event, Emitter<RoutineState> emit) async {
|
||||
// Create a new set safely
|
||||
final currentLoadingIds = state.loadingAutomationIds;
|
||||
final newLoadingIds = {...currentLoadingIds!}..add(event.automationId);
|
||||
|
||||
emit(state.copyWith(loadingAutomationIds: newLoadingIds));
|
||||
|
||||
try {
|
||||
final projectId = await ProjectManager.getProjectUUID() ?? '';
|
||||
final success = await SceneApi.updateAutomationStatus(
|
||||
event.automationId, event.automationStatusUpdate, projectId);
|
||||
|
||||
if (success) {
|
||||
final updatedAutomations = await SceneApi.getAutomationByUnitId(
|
||||
event.automationStatusUpdate.spaceUuid,
|
||||
event.communityId,
|
||||
projectId);
|
||||
|
||||
// Remove from loading set safely
|
||||
final updatedLoadingIds = {...state.loadingAutomationIds!}
|
||||
..remove(event.automationId);
|
||||
|
||||
emit(state.copyWith(
|
||||
automations: updatedAutomations,
|
||||
loadingAutomationIds: updatedLoadingIds,
|
||||
));
|
||||
} else {
|
||||
final updatedLoadingIds = {...state.loadingAutomationIds!}
|
||||
..remove(event.automationId);
|
||||
emit(state.copyWith(
|
||||
loadingAutomationIds: updatedLoadingIds,
|
||||
errorMessage: 'Update failed',
|
||||
));
|
||||
}
|
||||
} catch (e) {
|
||||
final updatedLoadingIds = {...state.loadingAutomationIds!}
|
||||
..remove(event.automationId);
|
||||
emit(state.copyWith(
|
||||
loadingAutomationIds: updatedLoadingIds,
|
||||
errorMessage: 'Update error: ${e.toString()}',
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,3 +210,28 @@ class ResetRoutineState extends RoutineEvent {}
|
||||
class ClearFunctions extends RoutineEvent {}
|
||||
|
||||
class ResetErrorMessage extends RoutineEvent {}
|
||||
|
||||
|
||||
|
||||
|
||||
class SceneTrigger extends RoutineEvent {
|
||||
final String? sceneId;
|
||||
final String? name;
|
||||
|
||||
const SceneTrigger({this.sceneId, this.name});
|
||||
|
||||
@override
|
||||
List<Object> get props => [sceneId!,name!];
|
||||
}
|
||||
|
||||
//updateAutomationStatus
|
||||
class UpdateAutomationStatus extends RoutineEvent {
|
||||
final String automationId;
|
||||
final AutomationStatusUpdate automationStatusUpdate;
|
||||
final String communityId;
|
||||
|
||||
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId, required this.communityId});
|
||||
|
||||
@override
|
||||
List<Object> get props => [automationStatusUpdate];
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
part of 'routine_bloc.dart';
|
||||
|
||||
class RoutineState extends Equatable {
|
||||
final String? loadingSceneId;
|
||||
final List<Map<String, dynamic>> ifItems;
|
||||
final List<Map<String, dynamic>> thenItems;
|
||||
final List<Map<String, String>> availableCards;
|
||||
@ -25,6 +26,7 @@ class RoutineState extends Equatable {
|
||||
// final String? automationActionExecutor;
|
||||
final bool routineTab;
|
||||
final bool createRoutineView;
|
||||
final Set<String>? loadingAutomationIds; // Track loading automations
|
||||
|
||||
const RoutineState(
|
||||
{this.ifItems = const [],
|
||||
@ -47,12 +49,16 @@ class RoutineState extends Equatable {
|
||||
this.sceneId,
|
||||
this.automationId,
|
||||
this.isUpdate,
|
||||
this.loadingAutomationIds = const <String>{}, // Initialize with empty set
|
||||
this.loadingSceneId,
|
||||
this.devices = const [],
|
||||
// this.automationActionExecutor,
|
||||
this.routineTab = false,
|
||||
this.createRoutineView = false});
|
||||
|
||||
RoutineState copyWith({
|
||||
String? loadingSceneId,
|
||||
Set<String>? loadingAutomationIds,
|
||||
List<Map<String, dynamic>>? ifItems,
|
||||
List<Map<String, dynamic>>? thenItems,
|
||||
List<ScenesModel>? scenes,
|
||||
@ -79,6 +85,8 @@ class RoutineState extends Equatable {
|
||||
bool? createRoutineView,
|
||||
}) {
|
||||
return RoutineState(
|
||||
loadingSceneId: loadingSceneId,
|
||||
loadingAutomationIds: loadingAutomationIds ?? this.loadingAutomationIds,
|
||||
ifItems: ifItems ?? this.ifItems,
|
||||
thenItems: thenItems ?? this.thenItems,
|
||||
scenes: scenes ?? this.scenes,
|
||||
@ -109,6 +117,7 @@ class RoutineState extends Equatable {
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
loadingAutomationIds,
|
||||
ifItems,
|
||||
thenItems,
|
||||
scenes,
|
||||
@ -134,3 +143,38 @@ class RoutineState extends Equatable {
|
||||
createRoutineView
|
||||
];
|
||||
}
|
||||
|
||||
class SceneInitial extends RoutineState {}
|
||||
|
||||
class SceneLoading extends RoutineState {}
|
||||
|
||||
class SceneLoaded extends RoutineState {
|
||||
final List<ScenesModel>? scenesOrAutomation;
|
||||
const SceneLoaded({this.scenesOrAutomation});
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
scenesOrAutomation,
|
||||
];
|
||||
}
|
||||
|
||||
class SceneError extends RoutineState {
|
||||
final String message;
|
||||
|
||||
const SceneError({required this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
|
||||
class SceneTriggerSuccess extends RoutineState {
|
||||
final String sceneName;
|
||||
|
||||
const SceneTriggerSuccess(this.sceneName);
|
||||
|
||||
@override
|
||||
List<Object> get props => [sceneName];
|
||||
}
|
||||
|
||||
class UpdateAutomationStatusLoading extends RoutineState {
|
||||
const UpdateAutomationStatusLoading();
|
||||
}
|
||||
|
96
lib/pages/routines/create_new_routines/commu_dropdown.dart
Normal file
@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class CommunityDropdown extends StatelessWidget {
|
||||
final String? selectedValue;
|
||||
final Function(String?) onChanged;
|
||||
|
||||
const CommunityDropdown({
|
||||
Key? key,
|
||||
required this.selectedValue,
|
||||
required this.onChanged,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Community",
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 13,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
||||
builder: (context, state) {
|
||||
List<CommunityModel> communities = state.isSearching
|
||||
? state.filteredCommunity
|
||||
: state.communityList;
|
||||
|
||||
return SizedBox(
|
||||
child: DropdownButtonFormField<String>(
|
||||
dropdownColor: ColorsManager.whiteColors,
|
||||
value: selectedValue,
|
||||
items: communities.map((community) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: community.uuid,
|
||||
child: Text(' ${community.name}'),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: onChanged,
|
||||
icon: const SizedBox.shrink(),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
hint: Padding(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
"Please Select",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
decoration: inputTextFormDeco().copyWith(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
suffixIcon: Container(
|
||||
padding: EdgeInsets.zero,
|
||||
width: 70,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomRight: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
148
lib/pages/routines/create_new_routines/create_new_routines.dart
Normal file
@ -0,0 +1,148 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_state.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/create_new_routines/commu_dropdown.dart';
|
||||
import 'package:syncrow_web/pages/routines/create_new_routines/space_dropdown.dart';
|
||||
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class CreateNewRoutinesDialog extends StatefulWidget {
|
||||
const CreateNewRoutinesDialog({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<CreateNewRoutinesDialog> createState() =>
|
||||
_CreateNewRoutinesDialogState();
|
||||
}
|
||||
|
||||
class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
String? _selectedCommunity;
|
||||
String? _selectedSpace;
|
||||
void _fetchSpaces(String communityId) {
|
||||
context
|
||||
.read<CreateRoutineBloc>()
|
||||
.add(SpaceOnlyWithDevicesEvent(communityId));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CreateRoutineBloc, CreateRoutineState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
||||
final spaces = _bloc.spacesOnlyWithDevices;
|
||||
final isLoading = state is SpaceWithDeviceLoadingState;
|
||||
|
||||
String spaceHint = 'Select a community first';
|
||||
|
||||
if (_selectedCommunity != null) {
|
||||
if (isLoading) {
|
||||
spaceHint = 'Loading spaces...';
|
||||
} else if (spaces.isEmpty) {
|
||||
spaceHint = 'No spaces available';
|
||||
} else {
|
||||
spaceHint = 'Select Space';
|
||||
}
|
||||
}
|
||||
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: Text(
|
||||
'Create New Routines',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
color: ColorsManager.primaryColor,
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Divider(),
|
||||
CommunityDropdown(
|
||||
selectedValue: _selectedCommunity,
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
_selectedCommunity = newValue;
|
||||
_selectedSpace = null;
|
||||
});
|
||||
if (newValue != null) {
|
||||
_fetchSpaces(newValue);
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SpaceDropdown(
|
||||
hintMessage: spaceHint,
|
||||
spaces: spaces,
|
||||
selectedValue: _selectedSpace,
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
_selectedSpace = newValue;
|
||||
});
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 20,
|
||||
right: 20,
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 20,
|
||||
right: 20,
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed:
|
||||
_selectedCommunity != null && _selectedSpace != null
|
||||
? () {
|
||||
Navigator.of(context).pop({
|
||||
'community': _selectedCommunity,
|
||||
'space': _selectedSpace,
|
||||
});
|
||||
}
|
||||
: null,
|
||||
child: Text(
|
||||
'Next',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
color: _selectedCommunity != null &&
|
||||
_selectedSpace != null
|
||||
? ColorsManager.blueColor
|
||||
: Colors.blue.shade100,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
100
lib/pages/routines/create_new_routines/space_dropdown.dart
Normal file
@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class SpaceDropdown extends StatelessWidget {
|
||||
final List<SpaceModel> spaces;
|
||||
final String? selectedValue;
|
||||
final Function(String?)? onChanged;
|
||||
final String hintMessage;
|
||||
|
||||
const SpaceDropdown({
|
||||
Key? key,
|
||||
required this.spaces,
|
||||
required this.selectedValue,
|
||||
required this.onChanged,
|
||||
required this.hintMessage,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Space",
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 13,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonFormField<String>(
|
||||
value: selectedValue,
|
||||
items: spaces.map((space) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: space.uuid,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
' ${space.name}',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' ${space.lastThreeParents}',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}).toList(),
|
||||
onChanged: onChanged,
|
||||
icon: const SizedBox.shrink(),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
hint: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
hintMessage,
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
decoration: inputTextFormDeco().copyWith(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
suffixIcon: Container(
|
||||
width: 70,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomRight: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -6,21 +6,24 @@ import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_swit
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
||||
|
||||
class DeviceDialogHelper {
|
||||
static Future<Map<String, dynamic>?> showDeviceDialog(
|
||||
BuildContext context,
|
||||
Map<String, dynamic> data, {
|
||||
static Future<Map<String, dynamic>?> showDeviceDialog({
|
||||
required BuildContext context,
|
||||
required String dialogType,
|
||||
required Map<String, dynamic> data,
|
||||
required bool removeComparetors,
|
||||
}) async {
|
||||
final functions = data['functions'] as List<DeviceFunction>;
|
||||
|
||||
try {
|
||||
final result = await _getDialogForDeviceType(
|
||||
context,
|
||||
data['productType'],
|
||||
data,
|
||||
functions,
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
productType: data['productType'],
|
||||
data: data,
|
||||
functions: functions,
|
||||
removeComparetors: removeComparetors,
|
||||
);
|
||||
|
||||
@ -34,27 +37,66 @@ class DeviceDialogHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>?> _getDialogForDeviceType(BuildContext context,
|
||||
String productType, Map<String, dynamic> data, List<DeviceFunction> functions,
|
||||
{required bool removeComparetors}) async {
|
||||
static Future<Map<String, dynamic>?> _getDialogForDeviceType({
|
||||
required String dialogType,
|
||||
required BuildContext context,
|
||||
required String productType,
|
||||
required Map<String, dynamic> data,
|
||||
required List<DeviceFunction> functions,
|
||||
required bool removeComparetors,
|
||||
}) async {
|
||||
final routineBloc = context.read<RoutineBloc>();
|
||||
final deviceSelectedFunctions =
|
||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||
|
||||
if (removeComparetors && data['productType'] != 'WPS') {
|
||||
//remove the current temp function in the 'if container'
|
||||
functions.removeAt(3);
|
||||
}
|
||||
|
||||
switch (productType) {
|
||||
case 'AC':
|
||||
return ACHelper.showACFunctionsDialog(context, functions, data['device'],
|
||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
||||
return ACHelper.showACFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
|
||||
case '1G':
|
||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(context, functions, data['device'],
|
||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
case '2G':
|
||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(context, functions, data['device'],
|
||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
case '3G':
|
||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(context, functions, data['device'],
|
||||
deviceSelectedFunctions, data['uniqueCustomId'], removeComparetors);
|
||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
case 'WPS':
|
||||
return WallPresenceSensor.showWPSFunctionsDialog(
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -151,3 +151,32 @@ class ChildLockFunction extends ACFunction {
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
class CurrentTempFunction extends ACFunction {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
CurrentTempFunction({required super.deviceId, required super.deviceName})
|
||||
: min = -100,
|
||||
max = 990,
|
||||
step = 1,
|
||||
super(
|
||||
code: 'temp_current',
|
||||
operationName: 'Current Temperature',
|
||||
icon: Assets.currentTemp,
|
||||
);
|
||||
|
||||
@override
|
||||
List<ACOperationalValue> getOperationalValues() {
|
||||
List<ACOperationalValue> values = [];
|
||||
for (int temp = min; temp <= max; temp += step) {
|
||||
values.add(ACOperationalValue(
|
||||
icon: Assets.currentTemp,
|
||||
description: "${temp / 10}°C",
|
||||
value: temp,
|
||||
));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ class ScenesModel {
|
||||
final String status;
|
||||
final String type;
|
||||
final String? icon;
|
||||
final String spaceName;
|
||||
final String spaceId;
|
||||
final String communityId;
|
||||
|
||||
ScenesModel({
|
||||
required this.id,
|
||||
@ -16,6 +19,9 @@ class ScenesModel {
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.spaceName,
|
||||
required this.spaceId,
|
||||
required this.communityId,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
@ -41,6 +47,9 @@ class ScenesModel {
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
spaceName: json["spaceName"] ?? '',
|
||||
spaceId: json["spaceId"] ?? '',
|
||||
communityId: json["communityId"] ?? '',
|
||||
icon:
|
||||
isAutomation == true ? Assets.automation : (json["icon"] as String?),
|
||||
);
|
||||
@ -52,5 +61,8 @@ class ScenesModel {
|
||||
"name": name,
|
||||
"status": status,
|
||||
"type": type,
|
||||
"spaceName": spaceName,
|
||||
"spaceId": spaceId,
|
||||
"communityId": communityId,
|
||||
};
|
||||
}
|
||||
|
290
lib/pages/routines/models/wps/wps_functions.dart
Normal file
@ -0,0 +1,290 @@
|
||||
|
||||
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/model/wall_sensor_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_operational_value.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
abstract class WpsFunctions extends DeviceFunction<WallSensorModel> {
|
||||
final String type;
|
||||
|
||||
WpsFunctions({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.code,
|
||||
required super.operationName,
|
||||
required super.icon,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
List<WpsOperationalValue> getOperationalValues();
|
||||
}
|
||||
|
||||
// For far_detection (75-600cm in 75cm steps)
|
||||
class FarDetectionFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
final String unit;
|
||||
|
||||
FarDetectionFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 75,
|
||||
max = 600,
|
||||
step = 75,
|
||||
unit = 'cm',
|
||||
super(
|
||||
type: type,
|
||||
code: 'far_detection',
|
||||
operationName: 'Far Detection',
|
||||
icon: Assets.farDetectionIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
final values = <WpsOperationalValue>[];
|
||||
for (var value = min; value <= max; value += step) {
|
||||
values.add(WpsOperationalValue(
|
||||
icon: Assets.currentDistanceIcon,
|
||||
description: '$value $unit',
|
||||
value: value,
|
||||
));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
// For presence_time (0-65535 minutes)
|
||||
class PresenceTimeFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
final String unit;
|
||||
|
||||
PresenceTimeFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 0,
|
||||
max = 65535,
|
||||
step = 1,
|
||||
unit = 'Min',
|
||||
super(
|
||||
type: type,
|
||||
code: 'presence_time',
|
||||
operationName: 'Presence Time',
|
||||
icon: Assets.presenceTimeIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
return [
|
||||
WpsOperationalValue(
|
||||
icon: icon,
|
||||
description: 'Custom $unit',
|
||||
value: null,
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// For motion_sensitivity_value (1-5 levels)
|
||||
class MotionSensitivityFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
MotionSensitivityFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 1,
|
||||
max = 5,
|
||||
step = 1,
|
||||
super(
|
||||
type: type,
|
||||
code: 'motion_sensitivity_value',
|
||||
operationName: 'Motion Detection Sensitivity',
|
||||
icon: Assets.motionDetectionSensitivityIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => WpsOperationalValue(
|
||||
icon: Assets.motionDetectionSensitivityValueIcon,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MotionLessSensitivityFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
MotionLessSensitivityFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 1,
|
||||
max = 5,
|
||||
step = 1,
|
||||
super(
|
||||
type: type,
|
||||
code: 'motionless_sensitivity',
|
||||
operationName: 'Motionless Detection Sensitivity',
|
||||
icon: Assets.motionlessDetectionSensitivityIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
return List.generate(
|
||||
(max - min) ~/ step + 1,
|
||||
(index) => WpsOperationalValue(
|
||||
icon: Assets.currentDistanceIcon,
|
||||
description: '${min + (index * step)}',
|
||||
value: min + (index * step),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IndicatorFunction extends WpsFunctions {
|
||||
IndicatorFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
type: type,
|
||||
code: 'indicator',
|
||||
operationName: 'Indicator',
|
||||
icon: Assets.IndicatorIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() => [
|
||||
WpsOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "ON",
|
||||
value: true,
|
||||
),
|
||||
WpsOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
class NoOneTimeFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final String unit;
|
||||
|
||||
NoOneTimeFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 10,
|
||||
max = 10000,
|
||||
unit = '秒',
|
||||
super(
|
||||
type: type,
|
||||
code: 'no_one_time',
|
||||
operationName: 'Nobody Time',
|
||||
icon: Assets.nobodyTime,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
return [
|
||||
WpsOperationalValue(
|
||||
icon: icon,
|
||||
description: 'Custom $unit',
|
||||
value: null,
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class PresenceStateFunction extends WpsFunctions {
|
||||
PresenceStateFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
type: type,
|
||||
code: 'presence_state',
|
||||
operationName: 'Presence State',
|
||||
icon: Assets.presenceStateIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() => [
|
||||
WpsOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "None",
|
||||
value: true,
|
||||
),
|
||||
WpsOperationalValue(
|
||||
icon: Assets.presenceStateIcon,
|
||||
description: "Presence",
|
||||
value: false,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
class CurrentDistanceFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
CurrentDistanceFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 1,
|
||||
max = 600,
|
||||
step = 1,
|
||||
super(
|
||||
type: type,
|
||||
code: 'current_distance',
|
||||
operationName: 'Current Distance',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
List<WpsOperationalValue> values = [];
|
||||
for (int temp = min; temp <= max; temp += step) {
|
||||
values.add(WpsOperationalValue(
|
||||
icon: Assets.assetsTempreture,
|
||||
description: "${temp}CM",
|
||||
value: temp,
|
||||
));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
||||
class IlluminanceValueFunction extends WpsFunctions {
|
||||
final int min;
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
IlluminanceValueFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : min = 0,
|
||||
max = 10000,
|
||||
step = 10,
|
||||
super(
|
||||
code: 'illuminance_value',
|
||||
operationName: 'Illuminance Value',
|
||||
icon: Assets.IlluminanceIcon,
|
||||
);
|
||||
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
List<WpsOperationalValue> values = [];
|
||||
for (int lux = min; lux <= max; lux += step) {
|
||||
values.add(WpsOperationalValue(
|
||||
icon: Assets.IlluminanceIcon,
|
||||
description: "$lux Lux",
|
||||
value: lux,
|
||||
));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
}
|
11
lib/pages/routines/models/wps/wps_operational_value.dart
Normal file
@ -0,0 +1,11 @@
|
||||
class WpsOperationalValue {
|
||||
final String icon;
|
||||
final String description;
|
||||
final dynamic value;
|
||||
|
||||
WpsOperationalValue({
|
||||
required this.icon,
|
||||
required this.description,
|
||||
required this.value,
|
||||
});
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/create_new_routines/create_new_routines.dart';
|
||||
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/fetch_routine_scenes_automation.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
@ -16,10 +18,23 @@ class RoutinesView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RoutinesViewState extends State<RoutinesView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
||||
void _handleRoutineCreation(BuildContext context) async {
|
||||
final result = await showDialog<Map<String, dynamic>>(
|
||||
context: context,
|
||||
builder: (context) => const CreateNewRoutinesDialog(),
|
||||
);
|
||||
|
||||
if (result == null) return;
|
||||
final communityId = result['community'];
|
||||
final spaceId = result['space'];
|
||||
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
||||
final routineBloc = context.read<RoutineBloc>();
|
||||
_bloc.add(SaveCommunityIdAndSpaceIdEvent(
|
||||
communityID: communityId, spaceID: spaceId));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
||||
await Future.delayed(const Duration(milliseconds:500));
|
||||
_bloc.add(const ResetSelectedEvent());
|
||||
}
|
||||
|
||||
@override
|
||||
@ -29,73 +44,57 @@ class _RoutinesViewState extends State<RoutinesView> {
|
||||
if (state.createRoutineView) {
|
||||
return const CreateNewRoutineView();
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(child: SpaceTreeView(
|
||||
onSelect: () {
|
||||
context.read<RoutineBloc>()
|
||||
Expanded(
|
||||
child: SpaceTreeView(
|
||||
onSelect: () => context.read<RoutineBloc>()
|
||||
..add(const LoadScenes())
|
||||
..add(const LoadAutomation());
|
||||
},
|
||||
)),
|
||||
..add(const LoadAutomation()),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: ListView(children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Create New Routines",
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
RoutineViewCard(
|
||||
onTap: () {
|
||||
if (context.read<SpaceTreeBloc>().state.selectedCommunities.length == 1 &&
|
||||
context.read<SpaceTreeBloc>().state.selectedSpaces.length == 1) {
|
||||
context.read<RoutineBloc>().add(
|
||||
(ResetRoutineState()),
|
||||
);
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(createRoutineView: true),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
context.read<SpaceTreeBloc>().state.selectedSpaces.isEmpty
|
||||
? 'Please select a space'
|
||||
: 'Please select only one space to proceed'),
|
||||
),
|
||||
);
|
||||
// CustomSnackBar.redSnackBar(
|
||||
// context.read<SpaceTreeBloc>().state.selectedSpaces.isEmpty
|
||||
// ? 'Please select a space'
|
||||
// : 'Please select only one space to proceed');
|
||||
}
|
||||
},
|
||||
icon: Icons.add,
|
||||
textString: '',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const Expanded(child: FetchRoutineScenesAutomation()),
|
||||
],
|
||||
child: ListView(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Create New Routines",
|
||||
style:
|
||||
Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
RoutineViewCard(
|
||||
isLoading: false,
|
||||
onChanged: (v) {},
|
||||
status: '',
|
||||
spaceId: '',
|
||||
automationId: '',
|
||||
communityId: '',
|
||||
sceneId: '',
|
||||
cardType: '',
|
||||
spaceName: '',
|
||||
onTap: () => _handleRoutineCreation(context),
|
||||
icon: Icons.add,
|
||||
textString: '',
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Expanded(child: FetchRoutineScenesAutomation()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
|
@ -26,7 +26,9 @@ class IfContainer extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text('IF', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const Text('IF',
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
if (state.isAutomation && state.ifItems.isNotEmpty)
|
||||
AutomationOperatorSelector(
|
||||
selectedOperator: state.selectedAutomationOperator),
|
||||
@ -53,34 +55,47 @@ class IfContainer extends StatelessWidget {
|
||||
(index) => GestureDetector(
|
||||
onTap: () async {
|
||||
if (!state.isTabToRun) {
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||
context, state.ifItems[index],
|
||||
removeComparetors: false);
|
||||
final result = await DeviceDialogHelper
|
||||
.showDeviceDialog(
|
||||
context: context,
|
||||
data: state.ifItems[index],
|
||||
removeComparetors: false,
|
||||
dialogType: "IF");
|
||||
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(state.ifItems[index], false));
|
||||
} else if (!['AC', '1G', '2G', '3G']
|
||||
.contains(state.ifItems[index]['productType'])) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(state.ifItems[index], false));
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToIfContainer(
|
||||
state.ifItems[index], false));
|
||||
} else if (![
|
||||
'AC',
|
||||
'1G',
|
||||
'2G',
|
||||
'3G',
|
||||
'WPS'
|
||||
].contains(
|
||||
state.ifItems[index]['productType'])) {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToIfContainer(
|
||||
state.ifItems[index], false));
|
||||
}
|
||||
}
|
||||
},
|
||||
child: DraggableCard(
|
||||
imagePath: state.ifItems[index]['imagePath'] ?? '',
|
||||
imagePath:
|
||||
state.ifItems[index]['imagePath'] ?? '',
|
||||
title: state.ifItems[index]['title'] ?? '',
|
||||
deviceData: state.ifItems[index],
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4, vertical: 8),
|
||||
isFromThen: false,
|
||||
isFromIf: true,
|
||||
onRemove: () {
|
||||
context.read<RoutineBloc>().add(RemoveDragCard(
|
||||
index: index,
|
||||
isFromThen: false,
|
||||
key: state.ifItems[index]['uniqueCustomId']));
|
||||
context.read<RoutineBloc>().add(
|
||||
RemoveDragCard(
|
||||
index: index,
|
||||
isFromThen: false,
|
||||
key: state.ifItems[index]
|
||||
['uniqueCustomId']));
|
||||
},
|
||||
),
|
||||
)),
|
||||
@ -90,6 +105,7 @@ class IfContainer extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
onAcceptWithDetails: (data) async {
|
||||
print('data.data=${data.data}');
|
||||
final uniqueCustomId = const Uuid().v4();
|
||||
|
||||
final mutableData = Map<String, dynamic>.from(data.data);
|
||||
@ -101,15 +117,25 @@ class IfContainer extends StatelessWidget {
|
||||
|
||||
if (!state.isTabToRun) {
|
||||
if (mutableData['deviceId'] == 'tab_to_run') {
|
||||
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, true));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(mutableData, true));
|
||||
} else {
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData,
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||
dialogType: 'IF',
|
||||
context: context,
|
||||
data: mutableData,
|
||||
removeComparetors: false);
|
||||
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
||||
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {
|
||||
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(mutableData, false));
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
||||
.contains(mutableData['productType'])) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(mutableData, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -155,7 +181,9 @@ class AutomationOperatorSelector extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'or'));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(const ChangeAutomationOperator(operator: 'or'));
|
||||
},
|
||||
),
|
||||
Container(
|
||||
@ -181,7 +209,9 @@ class AutomationOperatorSelector extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'and'));
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(const ChangeAutomationOperator(operator: 'and'));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/automation_scene_trigger_bloc/automation_status_update.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
@ -12,7 +12,8 @@ class FetchRoutineScenesAutomation extends StatefulWidget {
|
||||
const FetchRoutineScenesAutomation({super.key});
|
||||
|
||||
@override
|
||||
State<FetchRoutineScenesAutomation> createState() => _FetchRoutineScenesState();
|
||||
State<FetchRoutineScenesAutomation> createState() =>
|
||||
_FetchRoutineScenesState();
|
||||
}
|
||||
|
||||
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
@ -45,46 +46,70 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (state.scenes.isEmpty)
|
||||
Text(
|
||||
"No scenes found",
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
Expanded(
|
||||
child: Text(
|
||||
"No scenes found",
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.scenes.isNotEmpty)
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
||||
maxWidth: MediaQuery.sizeOf(context).width * 0.7),
|
||||
maxHeight: isSmallScreenSize(context) ? 190 : 200,
|
||||
maxWidth: MediaQuery.sizeOf(context).width * 0.8),
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.scenes.length,
|
||||
itemBuilder: (context, index) => Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(createRoutineView: true),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetSceneDetails(
|
||||
sceneId: state.scenes[index].id,
|
||||
isTabToRun: true,
|
||||
isUpdate: true,
|
||||
),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.scenes.length,
|
||||
itemBuilder: (context, index) {
|
||||
final scene = state.scenes[index];
|
||||
final isLoading =
|
||||
state.loadingSceneId == scene.id;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
isLoading: isLoading,
|
||||
sceneOnTap: () {
|
||||
context.read<RoutineBloc>().add(
|
||||
SceneTrigger(
|
||||
sceneId: scene.id,
|
||||
name: scene.name));
|
||||
},
|
||||
status: state.scenes[index].status,
|
||||
communityId:
|
||||
state.scenes[index].communityId ?? '',
|
||||
spaceId: state.scenes[index].spaceId,
|
||||
sceneId: state.scenes[index].sceneTuyaId!,
|
||||
automationId: state.scenes[index].id,
|
||||
cardType: 'scenes',
|
||||
spaceName: state.scenes[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true),
|
||||
);
|
||||
},
|
||||
textString: state.scenes[index].name,
|
||||
icon: state.scenes[index].icon ?? Assets.logoHorizontal,
|
||||
isFromScenes: true,
|
||||
iconInBytes: state.scenes[index].iconInBytes,
|
||||
),
|
||||
),
|
||||
),
|
||||
context.read<RoutineBloc>().add(
|
||||
GetSceneDetails(
|
||||
sceneId: state.scenes[index].id,
|
||||
isTabToRun: true,
|
||||
isUpdate: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
textString: state.scenes[index].name,
|
||||
icon: state.scenes[index].icon ??
|
||||
Assets.logoHorizontal,
|
||||
isFromScenes: true,
|
||||
iconInBytes: state.scenes[index].iconInBytes,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Automations",
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
@ -92,43 +117,77 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const SizedBox(height: 5),
|
||||
if (state.automations.isEmpty)
|
||||
Text(
|
||||
"No automations found",
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
Expanded(
|
||||
child: Text(
|
||||
"No automations found",
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.automations.isNotEmpty)
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: isSmallScreenSize(context) ? 160 : 170,
|
||||
maxHeight: isSmallScreenSize(context) ? 185 : 192,
|
||||
maxWidth: MediaQuery.sizeOf(context).width * 0.7),
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.automations.length,
|
||||
itemBuilder: (context, index) => Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(createRoutineView: true),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetAutomationDetails(
|
||||
automationId: state.automations[index].id,
|
||||
isAutomation: true,
|
||||
isUpdate: true),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.automations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final isLoading = state.automations!
|
||||
.contains(state.automations[index].id);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
isLoading: isLoading,
|
||||
onChanged: (v) {
|
||||
// BlocProvider.of<RoutineBloc>(context)
|
||||
context.read<RoutineBloc>().add(
|
||||
UpdateAutomationStatus(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
automationStatusUpdate:
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: state
|
||||
.automations[index]
|
||||
.spaceId,
|
||||
isEnable: v),
|
||||
communityId: state
|
||||
.automations[index].communityId,
|
||||
),
|
||||
);
|
||||
},
|
||||
status: state.automations[index].status,
|
||||
communityId: '',
|
||||
spaceId: state.automations[index].spaceId,
|
||||
sceneId: '',
|
||||
automationId: state.automations[index].id,
|
||||
cardType: 'automations',
|
||||
spaceName: state.scenes[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true),
|
||||
);
|
||||
},
|
||||
textString: state.automations[index].name,
|
||||
icon: state.automations[index].icon ?? Assets.automation,
|
||||
),
|
||||
),
|
||||
),
|
||||
context.read<RoutineBloc>().add(
|
||||
GetAutomationDetails(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
isAutomation: true,
|
||||
isUpdate: true),
|
||||
);
|
||||
},
|
||||
textString: state.automations[index].name,
|
||||
icon: state.automations[index].icon ??
|
||||
Assets.automation,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
@ -6,37 +8,78 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
|
||||
class RoutineViewCard extends StatelessWidget with HelperResponsiveLayout {
|
||||
class RoutineViewCard extends StatefulWidget with HelperResponsiveLayout {
|
||||
const RoutineViewCard({
|
||||
super.key,
|
||||
required this.onTap,
|
||||
this.sceneOnTap,
|
||||
required this.icon,
|
||||
required this.textString,
|
||||
required this.spaceName,
|
||||
required this.cardType,
|
||||
this.isFromScenes,
|
||||
this.iconInBytes,
|
||||
required this.sceneId,
|
||||
required this.communityId,
|
||||
required this.spaceId,
|
||||
required this.automationId,
|
||||
required this.status,
|
||||
this.onChanged,
|
||||
required this.isLoading,
|
||||
});
|
||||
|
||||
final Function() onTap;
|
||||
final Function()? sceneOnTap;
|
||||
|
||||
final dynamic icon;
|
||||
final String textString;
|
||||
final String spaceName;
|
||||
final String cardType;
|
||||
final String sceneId;
|
||||
final String spaceId;
|
||||
final String status;
|
||||
final bool isLoading;
|
||||
|
||||
final void Function(bool)? onChanged;
|
||||
final String automationId;
|
||||
final String communityId;
|
||||
|
||||
final bool? isFromScenes;
|
||||
final Uint8List? iconInBytes;
|
||||
|
||||
@override
|
||||
State<RoutineViewCard> createState() => _RoutineViewCardState();
|
||||
}
|
||||
|
||||
class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
bool _showTemporaryCheck = false;
|
||||
|
||||
void _handleSceneTap() {
|
||||
if (!_showTemporaryCheck) {
|
||||
setState(() => _showTemporaryCheck = true);
|
||||
widget.sceneOnTap?.call();
|
||||
Timer(const Duration(seconds: 3), () {
|
||||
if (mounted) setState(() => _showTemporaryCheck = false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double cardWidth = isSmallScreenSize(context)
|
||||
// Use widget.<mixinMethod> instead of just <mixinMethod>
|
||||
final double cardWidth = widget.isSmallScreenSize(context)
|
||||
? 120
|
||||
: isMediumScreenSize(context)
|
||||
: widget.isMediumScreenSize(context)
|
||||
? 135
|
||||
: 150;
|
||||
|
||||
final double cardHeight = isSmallScreenSize(context) ? 160 : 170;
|
||||
final double cardHeight = widget.isSmallScreenSize(context) ? 190 : 200;
|
||||
|
||||
final double iconSize = isSmallScreenSize(context)
|
||||
? 50
|
||||
: isMediumScreenSize(context)
|
||||
? 60
|
||||
: 70;
|
||||
final double iconSize = widget.isSmallScreenSize(context)
|
||||
? 70
|
||||
: widget.isMediumScreenSize(context)
|
||||
? 80
|
||||
: 90;
|
||||
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
@ -50,69 +93,147 @@ class RoutineViewCard extends StatelessWidget with HelperResponsiveLayout {
|
||||
),
|
||||
color: ColorsManager.whiteColors,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(120),
|
||||
border: Border.all(
|
||||
color: ColorsManager.greyColor,
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
child: (isFromScenes ?? false)
|
||||
? (iconInBytes != null && iconInBytes?.isNotEmpty == true)
|
||||
? Image.memory(
|
||||
iconInBytes!,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
widget.cardType != ''
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (widget.isFromScenes ?? false)
|
||||
InkWell(
|
||||
onTap: _handleSceneTap,
|
||||
child: SvgPicture.asset(
|
||||
_showTemporaryCheck
|
||||
? Assets.scenesPlayIconCheck
|
||||
: Assets.scenesPlayIcon,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder: (context, error, stackTrace) => Image.asset(
|
||||
Assets.logo,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
)
|
||||
: Image.asset(
|
||||
Assets.logo,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
)
|
||||
: (icon is String && icon.endsWith('.svg'))
|
||||
? SvgPicture.asset(
|
||||
icon,
|
||||
fit: BoxFit.contain,
|
||||
)
|
||||
: Icon(
|
||||
icon,
|
||||
color: ColorsManager.dialogBlueTitle,
|
||||
size: isSmallScreenSize(context) ? 30 : 40,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Text(
|
||||
textString,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: isSmallScreenSize(context) ? 10 : 12,
|
||||
),
|
||||
)
|
||||
else if (widget.isLoading)
|
||||
const SizedBox(
|
||||
width: 49,
|
||||
height: 20,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child:
|
||||
CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
CupertinoSwitch(
|
||||
activeColor: ColorsManager.primaryColor,
|
||||
value: widget.status == 'enable',
|
||||
onChanged: widget.onChanged,
|
||||
)
|
||||
],
|
||||
)
|
||||
: const SizedBox(),
|
||||
InkWell(
|
||||
onTap: widget.onTap,
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.graysColor,
|
||||
borderRadius: BorderRadius.circular(120),
|
||||
border: Border.all(
|
||||
color: ColorsManager.greyColor,
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
child: (widget.isFromScenes ?? false)
|
||||
? (widget.iconInBytes != null &&
|
||||
widget.iconInBytes?.isNotEmpty == true)
|
||||
? Image.memory(
|
||||
widget.iconInBytes!,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder:
|
||||
(context, error, stackTrace) =>
|
||||
Image.asset(
|
||||
Assets.logo,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
)
|
||||
: Image.asset(
|
||||
Assets.logo,
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
fit: BoxFit.contain,
|
||||
)
|
||||
: (widget.icon is String &&
|
||||
widget.icon.endsWith('.svg'))
|
||||
? SvgPicture.asset(
|
||||
widget.icon,
|
||||
fit: BoxFit.contain,
|
||||
)
|
||||
: Icon(
|
||||
widget.icon,
|
||||
color: ColorsManager.dialogBlueTitle,
|
||||
size: widget.isSmallScreenSize(context)
|
||||
? 30
|
||||
: 40,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
widget.textString,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize:
|
||||
widget.isSmallScreenSize(context) ? 10 : 12,
|
||||
),
|
||||
),
|
||||
if (widget.spaceName != '')
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.spaceLocationIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
Text(
|
||||
widget.spaceName,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style:
|
||||
context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize:
|
||||
widget.isSmallScreenSize(context)
|
||||
? 10
|
||||
: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -37,7 +37,8 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
||||
device.productType == 'AC' ||
|
||||
device.productType == '1G' ||
|
||||
device.productType == '2G' ||
|
||||
device.productType == '3G')
|
||||
device.productType == '3G' ||
|
||||
device.productType == 'WPS')
|
||||
.toList();
|
||||
|
||||
return Wrap(
|
||||
@ -46,7 +47,9 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
||||
children: deviceList.asMap().entries.map((entry) {
|
||||
final device = entry.value;
|
||||
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
||||
return device.name!.toLowerCase().contains(state.searchText!.toLowerCase())
|
||||
return device.name!
|
||||
.toLowerCase()
|
||||
.contains(state.searchText!.toLowerCase())
|
||||
? DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
|
@ -329,8 +329,8 @@ class ACHelper {
|
||||
) {
|
||||
return Slider(
|
||||
value: initialValue is int ? initialValue.toDouble() : 200.0,
|
||||
min: 200,
|
||||
max: 300,
|
||||
min: selectCode == 'temp_current' ? -100 : 200,
|
||||
max: selectCode == 'temp_current' ? 900 : 300,
|
||||
divisions: 10,
|
||||
label: '${((initialValue ?? 160) / 10).toInt()}°C',
|
||||
onChanged: (value) {
|
||||
|
@ -22,21 +22,23 @@ class ThreeGangSwitchHelper {
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||
List<BaseSwitchFunction> switchFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -83,9 +85,12 @@ class ThreeGangSwitchHelper {
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
operationName:
|
||||
function.operationName,
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -177,7 +182,8 @@ class ThreeGangSwitchHelper {
|
||||
);
|
||||
}
|
||||
|
||||
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final selectedFn =
|
||||
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -214,11 +220,11 @@ class ThreeGangSwitchHelper {
|
||||
selectedFunctionData,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownDisplay(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownSlider(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -259,7 +265,8 @@ class ThreeGangSwitchHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -307,7 +314,8 @@ class ThreeGangSwitchHelper {
|
||||
value: (initialValue ?? 0).toDouble(),
|
||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||
divisions: (((operationalValues.maxValue ?? 0) -
|
||||
(operationalValues.minValue ?? 0)) /
|
||||
(operationalValues.stepValue ?? 1))
|
||||
.round(),
|
||||
onChanged: (value) {
|
||||
@ -359,9 +367,13 @@ class ThreeGangSwitchHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -373,7 +385,8 @@ class ThreeGangSwitchHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -0,0 +1,150 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class TimeWheelPicker extends StatefulWidget {
|
||||
final int initialHours;
|
||||
final int initialMinutes;
|
||||
final int initialSeconds;
|
||||
final Function(int, int, int) onTimeChanged;
|
||||
|
||||
const TimeWheelPicker({
|
||||
super.key,
|
||||
required this.initialHours,
|
||||
required this.initialMinutes,
|
||||
required this.initialSeconds,
|
||||
required this.onTimeChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TimeWheelPicker> createState() => _TimeWheelPickerState();
|
||||
}
|
||||
|
||||
class _TimeWheelPickerState extends State<TimeWheelPicker> {
|
||||
late FixedExtentScrollController _hoursController;
|
||||
late FixedExtentScrollController _minutesController;
|
||||
late FixedExtentScrollController _secondsController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_hoursController = FixedExtentScrollController(initialItem: widget.initialHours);
|
||||
_minutesController = FixedExtentScrollController(initialItem: widget.initialMinutes);
|
||||
_secondsController = FixedExtentScrollController(initialItem: widget.initialSeconds);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(TimeWheelPicker oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.initialHours != widget.initialHours) {
|
||||
_hoursController.jumpToItem(widget.initialHours);
|
||||
}
|
||||
if (oldWidget.initialMinutes != widget.initialMinutes) {
|
||||
_minutesController.jumpToItem(widget.initialMinutes);
|
||||
}
|
||||
if (oldWidget.initialSeconds != widget.initialSeconds) {
|
||||
_secondsController.jumpToItem(widget.initialSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_hoursController.dispose();
|
||||
_minutesController.dispose();
|
||||
_secondsController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildPickerColumn(
|
||||
label: 'h',
|
||||
controller: _hoursController,
|
||||
itemCount: 24,
|
||||
onChanged: (value) => _handleTimeChange(
|
||||
value,
|
||||
_minutesController.selectedItem,
|
||||
_secondsController.selectedItem,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
_buildPickerColumn(
|
||||
label: 'm',
|
||||
controller: _minutesController,
|
||||
itemCount: 60,
|
||||
onChanged: (value) => _handleTimeChange(
|
||||
_hoursController.selectedItem,
|
||||
value,
|
||||
_secondsController.selectedItem,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
_buildPickerColumn(
|
||||
label: 's',
|
||||
controller: _secondsController,
|
||||
itemCount: 60,
|
||||
onChanged: (value) => _handleTimeChange(
|
||||
_hoursController.selectedItem,
|
||||
_minutesController.selectedItem,
|
||||
value,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _handleTimeChange(int hours, int minutes, int seconds) {
|
||||
widget.onTimeChanged(hours, minutes, seconds);
|
||||
}
|
||||
|
||||
Widget _buildPickerColumn({
|
||||
required String label,
|
||||
required FixedExtentScrollController controller,
|
||||
required int itemCount,
|
||||
required Function(int) onChanged,
|
||||
}) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
height: 40,
|
||||
width: 40,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: ListWheelScrollView.useDelegate(
|
||||
controller: controller,
|
||||
itemExtent: 40.0,
|
||||
physics: const FixedExtentScrollPhysics(),
|
||||
onSelectedItemChanged: onChanged,
|
||||
childDelegate: ListWheelChildBuilderDelegate(
|
||||
builder: (context, index) => Center(
|
||||
child: Text(
|
||||
index.toString().padLeft(2),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
color: ColorsManager.blue1,
|
||||
),
|
||||
),
|
||||
),
|
||||
childCount: itemCount,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
color: ColorsManager.blackColor,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,553 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_operational_value.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/time_wheel.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
|
||||
|
||||
class WallPresenceSensor extends StatefulWidget {
|
||||
final List<DeviceFunction> functions;
|
||||
final AllDevicesModel? device;
|
||||
final List<DeviceFunctionData>? deviceSelectedFunctions;
|
||||
final String? uniqueCustomId;
|
||||
final String? dialogType;
|
||||
final bool removeComparetors;
|
||||
|
||||
const WallPresenceSensor({
|
||||
super.key,
|
||||
required this.functions,
|
||||
this.device,
|
||||
this.deviceSelectedFunctions,
|
||||
this.uniqueCustomId,
|
||||
this.dialogType,
|
||||
this.removeComparetors = false,
|
||||
});
|
||||
|
||||
static Future<Map<String, dynamic>?> showWPSFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String? uniqueCustomId,
|
||||
String? dialogType,
|
||||
bool removeComparetors = false,
|
||||
}) async {
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (context) => WallPresenceSensor(
|
||||
functions: functions,
|
||||
device: device,
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: uniqueCustomId,
|
||||
removeComparetors: removeComparetors,
|
||||
dialogType: dialogType,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
State<WallPresenceSensor> createState() => _WallPresenceSensorState();
|
||||
}
|
||||
|
||||
class _WallPresenceSensorState extends State<WallPresenceSensor> {
|
||||
late final List<WpsFunctions> _wpsFunctions;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_wpsFunctions =
|
||||
widget.functions.whereType<WpsFunctions>().where((function) {
|
||||
if (widget.dialogType == 'THEN') {
|
||||
return function.type == 'THEN' || function.type == 'BOTH';
|
||||
}
|
||||
return function.type == 'IF' || function.type == 'BOTH';
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(widget.deviceSelectedFunctions ?? [])),
|
||||
child: _buildDialogContent(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
return Container(
|
||||
width: selectedFunction != null ? 600 : 360,
|
||||
height: 450,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const DialogHeader('Presence Sensor Condition'),
|
||||
Expanded(child: _buildMainContent(context, state)),
|
||||
_buildDialogFooter(context, state),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainContent(BuildContext context, FunctionBlocState state) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_buildFunctionList(context),
|
||||
if (state.selectedFunction != null) _buildValueSelector(context, state),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFunctionList(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 360,
|
||||
child: ListView.separated(
|
||||
shrinkWrap: false,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: _wpsFunctions.length,
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: Divider(color: ColorsManager.dividerColor),
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final function = _wpsFunctions[index];
|
||||
return ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
function.icon,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (context) => const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
function.operationName,
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () => context.read<FunctionBloc>().add(
|
||||
SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueSelector(BuildContext context, FunctionBlocState state) {
|
||||
final selectedFunction = state.selectedFunction!;
|
||||
final functionData = state.addedFunctions.firstWhere(
|
||||
(f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: '',
|
||||
value: null,
|
||||
),
|
||||
);
|
||||
|
||||
return Expanded(
|
||||
child: _ValueSelector(
|
||||
selectedFunction: selectedFunction,
|
||||
functionData: functionData,
|
||||
acFunctions: _wpsFunctions,
|
||||
device: widget.device,
|
||||
dialogType: widget.dialogType!,
|
||||
removeComparators: widget.removeComparetors,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogFooter(BuildContext context, FunctionBlocState state) {
|
||||
return DialogFooter(
|
||||
onCancel: () => Navigator.pop(context),
|
||||
onConfirm: state.addedFunctions.isNotEmpty
|
||||
? () {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddFunctionToRoutine(
|
||||
state.addedFunctions,
|
||||
widget.uniqueCustomId!,
|
||||
),
|
||||
);
|
||||
Navigator.pop(
|
||||
context,
|
||||
{'deviceId': widget.functions.first.deviceId},
|
||||
);
|
||||
}
|
||||
: null,
|
||||
isConfirmEnabled: state.selectedFunction != null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ValueSelector extends StatelessWidget {
|
||||
final String selectedFunction;
|
||||
final DeviceFunctionData functionData;
|
||||
final List<WpsFunctions> acFunctions;
|
||||
final AllDevicesModel? device;
|
||||
final String dialogType;
|
||||
final bool removeComparators;
|
||||
|
||||
const _ValueSelector({
|
||||
required this.selectedFunction,
|
||||
required this.functionData,
|
||||
required this.acFunctions,
|
||||
required this.device,
|
||||
required this.dialogType,
|
||||
required this.removeComparators,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selectedFn =
|
||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
if (_isSliderFunction(selectedFunction)) {
|
||||
return _SliderValueSelector(
|
||||
selectedFunction: selectedFunction,
|
||||
functionData: functionData,
|
||||
device: device,
|
||||
dialogType: dialogType,
|
||||
);
|
||||
}
|
||||
|
||||
return _OperationalValuesList(
|
||||
values: values,
|
||||
selectedValue: functionData.value,
|
||||
device: device,
|
||||
operationName: selectedFn.operationName,
|
||||
selectCode: selectedFunction,
|
||||
);
|
||||
}
|
||||
|
||||
bool _isSliderFunction(String function) => [
|
||||
'current_distance',
|
||||
'presence_time',
|
||||
'illuminance_value'
|
||||
].contains(function);
|
||||
}
|
||||
|
||||
class _SliderValueSelector extends StatelessWidget {
|
||||
final String selectedFunction;
|
||||
final DeviceFunctionData functionData;
|
||||
final AllDevicesModel? device;
|
||||
final String dialogType;
|
||||
|
||||
const _SliderValueSelector({
|
||||
required this.selectedFunction,
|
||||
required this.functionData,
|
||||
required this.device,
|
||||
required this.dialogType,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final initialValue = functionData.value ?? 250;
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
_ConditionToggle(
|
||||
currentCondition: functionData.condition,
|
||||
selectCode: selectedFunction,
|
||||
device: device,
|
||||
operationName: functionData.operationName,
|
||||
selectedValue: functionData.value,
|
||||
),
|
||||
_ValueDisplay(
|
||||
value: initialValue,
|
||||
functionCode: selectedFunction,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_FunctionSlider(
|
||||
initialValue: initialValue,
|
||||
functionCode: selectedFunction,
|
||||
functionData: functionData,
|
||||
device: device,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ConditionToggle extends StatelessWidget {
|
||||
final String? currentCondition;
|
||||
final String selectCode;
|
||||
final AllDevicesModel? device;
|
||||
final String operationName;
|
||||
final dynamic selectedValue;
|
||||
|
||||
const _ConditionToggle({
|
||||
this.currentCondition,
|
||||
required this.selectCode,
|
||||
this.device,
|
||||
required this.operationName,
|
||||
this.selectedValue,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const conditions = ["<", "==", ">"];
|
||||
return ToggleButtons(
|
||||
onPressed: (index) => _updateCondition(context, conditions[index]),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
||||
selectedColor: Colors.white,
|
||||
fillColor: ColorsManager.primaryColorWithOpacity,
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateCondition(BuildContext context, String condition) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectCode,
|
||||
operationName: operationName,
|
||||
condition: condition,
|
||||
value: selectedValue,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ValueDisplay extends StatelessWidget {
|
||||
final dynamic value;
|
||||
final String functionCode;
|
||||
|
||||
const _ValueDisplay({
|
||||
required this.value,
|
||||
required this.functionCode,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.primaryColorWithOpacity.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
_getDisplayText(),
|
||||
style: context.textTheme.headlineMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getDisplayText() {
|
||||
final intValue = (value as num?)?.toInt() ?? 0;
|
||||
switch (functionCode) {
|
||||
case 'presence_time':
|
||||
return '$intValue Min';
|
||||
case 'current_distance':
|
||||
return '$intValue CM';
|
||||
case 'illuminance_value':
|
||||
return '$intValue Lux';
|
||||
default:
|
||||
return '$intValue';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _FunctionSlider extends StatelessWidget {
|
||||
final dynamic initialValue;
|
||||
final String functionCode;
|
||||
final DeviceFunctionData functionData;
|
||||
final AllDevicesModel? device;
|
||||
|
||||
const _FunctionSlider({
|
||||
required this.initialValue,
|
||||
required this.functionCode,
|
||||
required this.functionData,
|
||||
required this.device,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final (min, max) = _getSliderRange();
|
||||
return Slider(
|
||||
value: initialValue is int ? initialValue.toDouble() : min,
|
||||
min: min,
|
||||
max: max,
|
||||
divisions: (max - min).toInt(),
|
||||
onChanged: (value) => _updateValue(context, value.toInt()),
|
||||
);
|
||||
}
|
||||
|
||||
(double, double) _getSliderRange() {
|
||||
switch (functionCode) {
|
||||
case 'presence_time':
|
||||
return (0, 65535);
|
||||
case 'current_distance':
|
||||
return (1, 600);
|
||||
case 'illuminance_value':
|
||||
return (0, 10000);
|
||||
default:
|
||||
return (200, 300);
|
||||
}
|
||||
}
|
||||
|
||||
void _updateValue(BuildContext context, int value) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: functionCode,
|
||||
operationName: functionData.operationName,
|
||||
value: value,
|
||||
condition: functionData.condition,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _OperationalValuesList extends StatelessWidget {
|
||||
final List<WpsOperationalValue> values;
|
||||
final dynamic selectedValue;
|
||||
final AllDevicesModel? device;
|
||||
final String operationName;
|
||||
final String selectCode;
|
||||
|
||||
const _OperationalValuesList({
|
||||
required this.values,
|
||||
required this.selectedValue,
|
||||
required this.device,
|
||||
required this.operationName,
|
||||
required this.selectCode,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return operationName == 'Nobody Time'
|
||||
? _buildTimeWheel(context)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.all(20),
|
||||
itemCount: values.length,
|
||||
itemBuilder: (context, index) =>
|
||||
_buildValueItem(context, values[index]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTimeWheel(BuildContext context) {
|
||||
final currentTotalSeconds = selectedValue as int? ?? 0;
|
||||
return TimeWheelPicker(
|
||||
initialHours: currentTotalSeconds ~/ 3600,
|
||||
initialMinutes: (currentTotalSeconds % 3600) ~/ 60,
|
||||
initialSeconds: currentTotalSeconds % 60,
|
||||
onTimeChanged: (h, m, s) => _updateTotalSeconds(context, h, m, s),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueItem(BuildContext context, WpsOperationalValue value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildValueIcon(context, value),
|
||||
Expanded(child: _buildValueDescription(value)),
|
||||
_buildValueRadio(context, value),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueIcon(context, WpsOperationalValue value) {
|
||||
return Column(
|
||||
children: [
|
||||
if (_shouldShowTextDescription)
|
||||
Text(value.description.replaceAll("cm", '')),
|
||||
SvgPicture.asset(value.icon, width: 25, height: 25),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
bool get _shouldShowTextDescription =>
|
||||
operationName == 'Far Detection' ||
|
||||
operationName == 'Motionless Detection Sensitivity';
|
||||
|
||||
Widget _buildValueDescription(WpsOperationalValue value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(value.description),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildValueRadio(context, WpsOperationalValue value) {
|
||||
return Radio<dynamic>(
|
||||
value: value.value,
|
||||
groupValue: selectedValue,
|
||||
onChanged: (_) => _selectValue(context, value.value),
|
||||
);
|
||||
}
|
||||
|
||||
void _selectValue(BuildContext context, dynamic value) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectCode,
|
||||
operationName: operationName,
|
||||
value: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateTotalSeconds(BuildContext context, int h, int m, int s) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectCode,
|
||||
operationName: operationName,
|
||||
value: h * 3600 + m * 60 + s,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -26,7 +26,9 @@ class ThenContainer extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('THEN', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const Text('THEN',
|
||||
style: TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
state.isLoading && state.isUpdate == true
|
||||
? const Center(
|
||||
@ -39,12 +41,17 @@ class ThenContainer extends StatelessWidget {
|
||||
state.thenItems.length,
|
||||
(index) => GestureDetector(
|
||||
onTap: () async {
|
||||
if (state.thenItems[index]['deviceId'] == 'delay') {
|
||||
final result = await DelayHelper.showDelayPickerDialog(
|
||||
context, state.thenItems[index]);
|
||||
if (state.thenItems[index]
|
||||
['deviceId'] ==
|
||||
'delay') {
|
||||
final result = await DelayHelper
|
||||
.showDelayPickerDialog(context,
|
||||
state.thenItems[index]);
|
||||
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer({
|
||||
...state.thenItems[index],
|
||||
'imagePath': Assets.delay,
|
||||
'title': 'Delay',
|
||||
@ -53,58 +60,86 @@ class ThenContainer extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.thenItems[index]['type'] == 'automation') {
|
||||
if (state.thenItems[index]['type'] ==
|
||||
'automation') {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AutomationDialog(
|
||||
builder: (BuildContext context) =>
|
||||
AutomationDialog(
|
||||
automationName:
|
||||
state.thenItems[index]['name'] ?? 'Automation',
|
||||
state.thenItems[index]
|
||||
['name'] ??
|
||||
'Automation',
|
||||
automationId:
|
||||
state.thenItems[index]['deviceId'] ?? '',
|
||||
uniqueCustomId: state.thenItems[index]
|
||||
['uniqueCustomId'],
|
||||
state.thenItems[index]
|
||||
['deviceId'] ??
|
||||
'',
|
||||
uniqueCustomId:
|
||||
state.thenItems[index]
|
||||
['uniqueCustomId'],
|
||||
),
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer({
|
||||
...state.thenItems[index],
|
||||
'imagePath': Assets.automation,
|
||||
'title': state.thenItems[index]['name'] ??
|
||||
state.thenItems[index]['title'],
|
||||
'imagePath':
|
||||
Assets.automation,
|
||||
'title':
|
||||
state.thenItems[index]
|
||||
['name'] ??
|
||||
state.thenItems[index]
|
||||
['title'],
|
||||
}));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||
context, state.thenItems[index],
|
||||
removeComparetors: true);
|
||||
final result = await DeviceDialogHelper
|
||||
.showDeviceDialog(
|
||||
context: context,
|
||||
data: state.thenItems[index],
|
||||
removeComparetors: true,
|
||||
dialogType: "THEN");
|
||||
|
||||
if (result != null) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer(state.thenItems[index]));
|
||||
} else if (!['AC', '1G', '2G', '3G']
|
||||
.contains(state.thenItems[index]['productType'])) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToThenContainer(state.thenItems[index]));
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToThenContainer(
|
||||
state.thenItems[index]));
|
||||
} else if (![
|
||||
'AC',
|
||||
'1G',
|
||||
'2G',
|
||||
'3G',
|
||||
'WPS'
|
||||
].contains(state.thenItems[index]
|
||||
['productType'])) {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddToThenContainer(
|
||||
state.thenItems[index]));
|
||||
}
|
||||
},
|
||||
child: DraggableCard(
|
||||
imagePath: state.thenItems[index]['imagePath'] ?? '',
|
||||
title: state.thenItems[index]['title'] ?? '',
|
||||
imagePath: state.thenItems[index]
|
||||
['imagePath'] ??
|
||||
'',
|
||||
title: state.thenItems[index]
|
||||
['title'] ??
|
||||
'',
|
||||
deviceData: state.thenItems[index],
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4, vertical: 8),
|
||||
isFromThen: true,
|
||||
isFromIf: false,
|
||||
onRemove: () {
|
||||
context.read<RoutineBloc>().add(RemoveDragCard(
|
||||
index: index,
|
||||
isFromThen: true,
|
||||
key: state.thenItems[index]['uniqueCustomId']));
|
||||
context.read<RoutineBloc>().add(
|
||||
RemoveDragCard(
|
||||
index: index,
|
||||
isFromThen: true,
|
||||
key: state.thenItems[index]
|
||||
['uniqueCustomId']));
|
||||
},
|
||||
),
|
||||
))),
|
||||
@ -129,8 +164,8 @@ class ThenContainer extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (mutableData['type'] == 'automation') {
|
||||
int index =
|
||||
state.thenItems.indexWhere((item) => item['deviceId'] == mutableData['deviceId']);
|
||||
int index = state.thenItems.indexWhere(
|
||||
(item) => item['deviceId'] == mutableData['deviceId']);
|
||||
if (index != -1) {
|
||||
return;
|
||||
}
|
||||
@ -155,8 +190,8 @@ class ThenContainer extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (mutableData['type'] == 'tap_to_run' && state.isAutomation) {
|
||||
int index =
|
||||
state.thenItems.indexWhere((item) => item['deviceId'] == mutableData['deviceId']);
|
||||
int index = state.thenItems.indexWhere(
|
||||
(item) => item['deviceId'] == mutableData['deviceId']);
|
||||
if (index != -1) {
|
||||
return;
|
||||
}
|
||||
@ -174,7 +209,8 @@ class ThenContainer extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (mutableData['deviceId'] == 'delay') {
|
||||
final result = await DelayHelper.showDelayPickerDialog(context, mutableData);
|
||||
final result =
|
||||
await DelayHelper.showDelayPickerDialog(context, mutableData);
|
||||
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||
@ -186,11 +222,15 @@ class ThenContainer extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData,
|
||||
removeComparetors: true);
|
||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||
context: context,
|
||||
data: mutableData,
|
||||
removeComparetors: true,
|
||||
dialogType: "THEN");
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
||||
.contains(mutableData['productType'])) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
}
|
||||
},
|
||||
|
@ -83,7 +83,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
||||
),
|
||||
if (isExpanded && children != null && children!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48.0),
|
||||
padding: const EdgeInsets.only(left: 24.0),
|
||||
child: Column(
|
||||
children: children ?? [],
|
||||
),
|
||||
|
@ -33,14 +33,13 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
||||
builder: (context, state) {
|
||||
List<CommunityModel> list =
|
||||
state.isSearching ? state.filteredCommunity : state.communityList;
|
||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
||||
List<CommunityModel> list = state.isSearching ? state.filteredCommunity : state.communityList;
|
||||
return Container(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
decoration:
|
||||
widget.isSide == true ? subSectionContainerDecoration : null,
|
||||
decoration: widget.isSide == true
|
||||
? subSectionContainerDecoration.copyWith(color: ColorsManager.whiteColors)
|
||||
: const BoxDecoration(color: ColorsManager.whiteColors),
|
||||
child: state is SpaceTreeLoadingState
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Column(
|
||||
@ -50,8 +49,7 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
decoration: const BoxDecoration(
|
||||
color: ColorsManager.circleRolesBackground,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(20),
|
||||
topLeft: Radius.circular(20)),
|
||||
topRight: Radius.circular(20), topLeft: Radius.circular(20)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -60,35 +58,27 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(20)),
|
||||
border: Border.all(
|
||||
color: ColorsManager.grayBorder)),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
border: Border.all(color: ColorsManager.grayBorder)),
|
||||
child: TextFormField(
|
||||
style:
|
||||
const TextStyle(color: Colors.black),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
onChanged: (value) {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(SearchQueryEvent(value));
|
||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(value));
|
||||
},
|
||||
decoration: textBoxDecoration(radios: 20)!
|
||||
.copyWith(
|
||||
decoration: textBoxDecoration(radios: 20)!.copyWith(
|
||||
fillColor: Colors.white,
|
||||
suffixIcon: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(right: 16),
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: SvgPicture.asset(
|
||||
Assets.textFieldSearch,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
hintStyle: context.textTheme.bodyMedium
|
||||
?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
color: ColorsManager.textGray),
|
||||
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
color: ColorsManager.textGray),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -99,9 +89,7 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
)
|
||||
: CustomSearchBar(
|
||||
onSearchChanged: (query) {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(SearchQueryEvent(query));
|
||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(query));
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@ -117,18 +105,14 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
? Center(
|
||||
child: Text(
|
||||
'No results found',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Scrollbar(
|
||||
scrollbarOrientation:
|
||||
ScrollbarOrientation.left,
|
||||
scrollbarOrientation: ScrollbarOrientation.left,
|
||||
thumbVisibility: true,
|
||||
controller: _scrollController,
|
||||
child: Padding(
|
||||
@ -138,39 +122,30 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
shrinkWrap: true,
|
||||
children: list
|
||||
.map(
|
||||
(community) =>
|
||||
CustomExpansionTileSpaceTree(
|
||||
(community) => CustomExpansionTileSpaceTree(
|
||||
title: community.name,
|
||||
isSelected: state
|
||||
.selectedCommunities
|
||||
isSelected: state.selectedCommunities
|
||||
.contains(community.uuid),
|
||||
isSoldCheck: state
|
||||
.selectedCommunities
|
||||
isSoldCheck: state.selectedCommunities
|
||||
.contains(community.uuid),
|
||||
onExpansionChanged: () {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(OnCommunityExpanded(
|
||||
community.uuid));
|
||||
.add(OnCommunityExpanded(community.uuid));
|
||||
},
|
||||
isExpanded: state
|
||||
.expandedCommunities
|
||||
isExpanded: state.expandedCommunities
|
||||
.contains(community.uuid),
|
||||
onItemSelected: () {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(OnCommunitySelected(
|
||||
community.uuid,
|
||||
community.spaces));
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunitySelected(
|
||||
community.uuid, community.spaces));
|
||||
widget.onSelect();
|
||||
},
|
||||
children:
|
||||
community.spaces.map((space) {
|
||||
children: community.spaces.map((space) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
title: space.name,
|
||||
isExpanded: state
|
||||
.expandedSpaces
|
||||
.contains(space.uuid),
|
||||
isExpanded:
|
||||
state.expandedSpaces.contains(space.uuid),
|
||||
onItemSelected: () {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceSelected(community, space.uuid ?? '',
|
||||
@ -178,20 +153,14 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
widget.onSelect();
|
||||
},
|
||||
onExpansionChanged: () {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(OnSpaceExpanded(
|
||||
community.uuid,
|
||||
space.uuid ?? ''));
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceExpanded(
|
||||
community.uuid, space.uuid ?? ''));
|
||||
},
|
||||
isSelected: state
|
||||
.selectedSpaces
|
||||
.contains(
|
||||
space.uuid) ||
|
||||
state.soldCheck
|
||||
.contains(space.uuid),
|
||||
isSoldCheck: state.soldCheck
|
||||
.contains(space.uuid),
|
||||
isSelected:
|
||||
state.selectedSpaces.contains(space.uuid) ||
|
||||
state.soldCheck.contains(space.uuid),
|
||||
isSoldCheck: state.soldCheck.contains(space.uuid),
|
||||
children: _buildNestedSpaces(
|
||||
context, state, space, community),
|
||||
);
|
||||
@ -279,8 +248,8 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
BuildContext context, SpaceTreeState state, SpaceModel space, CommunityModel community) {
|
||||
return space.children.map((child) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
isSelected: state.selectedSpaces.contains(child.uuid) ||
|
||||
state.soldCheck.contains(child.uuid),
|
||||
isSelected:
|
||||
state.selectedSpaces.contains(child.uuid) || state.soldCheck.contains(child.uuid),
|
||||
isSoldCheck: state.soldCheck.contains(child.uuid),
|
||||
title: child.name,
|
||||
isExpanded: state.expandedSpaces.contains(child.uuid),
|
||||
|
@ -24,6 +24,8 @@ class AddDeviceTypeWidget extends StatelessWidget {
|
||||
final String spaceName;
|
||||
final bool isCreate;
|
||||
final Function(List<Tag>, List<SubspaceModel>?)? onSave;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
|
||||
const AddDeviceTypeWidget(
|
||||
{super.key,
|
||||
@ -35,7 +37,8 @@ class AddDeviceTypeWidget extends StatelessWidget {
|
||||
this.allTags,
|
||||
this.spaceTags,
|
||||
this.onSave,
|
||||
required this.spaceName});
|
||||
required this.spaceName,
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -134,7 +137,8 @@ class AddDeviceTypeWidget extends StatelessWidget {
|
||||
spaceName: spaceName,
|
||||
initialTags: initialTags,
|
||||
title: dialogTitle,
|
||||
onSave: onSave),
|
||||
onSave: onSave,
|
||||
projectTags: projectTags),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
@ -19,8 +20,7 @@ import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||
import 'package:syncrow_web/utils/constants/action_enum.dart' as custom_action;
|
||||
|
||||
class SpaceManagementBloc
|
||||
extends Bloc<SpaceManagementEvent, SpaceManagementState> {
|
||||
class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementState> {
|
||||
final CommunitySpaceManagementApi _api;
|
||||
final ProductApi _productApi;
|
||||
final SpaceModelManagementApi _spaceModelApi;
|
||||
@ -28,6 +28,7 @@ class SpaceManagementBloc
|
||||
List<ProductModel>? _cachedProducts;
|
||||
List<SpaceTemplateModel>? _cachedSpaceModels;
|
||||
final SpaceTreeBloc _spaceTreeBloc;
|
||||
List<Tag>? _cachedTags;
|
||||
|
||||
SpaceManagementBloc(
|
||||
this._api,
|
||||
@ -52,42 +53,50 @@ class SpaceManagementBloc
|
||||
|
||||
Future<void> _updateSpaceModelCache(
|
||||
UpdateSpaceModelCache event, Emitter<SpaceManagementState> emit) async {
|
||||
if (_cachedSpaceModels != null) {
|
||||
_cachedSpaceModels = _cachedSpaceModels!.map((model) {
|
||||
return model.uuid == event.updatedModel.uuid
|
||||
? event.updatedModel
|
||||
: model;
|
||||
}).toList();
|
||||
} else {
|
||||
_cachedSpaceModels = await fetchSpaceModels();
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
List<SpaceTemplateModel> allSpaceModels = [];
|
||||
|
||||
bool hasNext = true;
|
||||
int page = 1;
|
||||
|
||||
while (hasNext) {
|
||||
final spaceModels = await _spaceModelApi.listSpaceModels(page: page, projectId: projectUuid);
|
||||
if (spaceModels.isNotEmpty) {
|
||||
allSpaceModels.addAll(spaceModels);
|
||||
page++;
|
||||
} else {
|
||||
hasNext = false;
|
||||
}
|
||||
}
|
||||
|
||||
_cachedSpaceModels = allSpaceModels;
|
||||
await fetchTags();
|
||||
|
||||
emit(SpaceModelLoaded(
|
||||
communities: state is SpaceManagementLoaded
|
||||
? (state as SpaceManagementLoaded).communities
|
||||
: [],
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: List.from(_cachedSpaceModels ?? []),
|
||||
));
|
||||
communities:
|
||||
state is SpaceManagementLoaded ? (state as SpaceManagementLoaded).communities : [],
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: List.from(_cachedSpaceModels ?? []),
|
||||
allTags: _cachedTags ?? []));
|
||||
}
|
||||
|
||||
void _deleteSpaceModelFromCache(DeleteSpaceModelFromCache event,
|
||||
Emitter<SpaceManagementState> emit) async {
|
||||
void _deleteSpaceModelFromCache(
|
||||
DeleteSpaceModelFromCache event, Emitter<SpaceManagementState> emit) async {
|
||||
if (_cachedSpaceModels != null) {
|
||||
_cachedSpaceModels = _cachedSpaceModels!
|
||||
.where((model) => model.uuid != event.deletedUuid)
|
||||
.toList();
|
||||
_cachedSpaceModels =
|
||||
_cachedSpaceModels!.where((model) => model.uuid != event.deletedUuid).toList();
|
||||
} else {
|
||||
_cachedSpaceModels = await fetchSpaceModels();
|
||||
}
|
||||
await fetchTags();
|
||||
|
||||
emit(SpaceModelLoaded(
|
||||
communities: state is SpaceManagementLoaded
|
||||
? (state as SpaceManagementLoaded).communities
|
||||
: [],
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: List.from(_cachedSpaceModels ?? []),
|
||||
));
|
||||
communities:
|
||||
state is SpaceManagementLoaded ? (state as SpaceManagementLoaded).communities : [],
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: List.from(_cachedSpaceModels ?? []),
|
||||
allTags: _cachedTags ?? []));
|
||||
}
|
||||
|
||||
void updateCachedSpaceModels(List<SpaceTemplateModel> updatedModels) {
|
||||
@ -112,8 +121,8 @@ class SpaceManagementBloc
|
||||
int page = 1;
|
||||
|
||||
while (hasNext) {
|
||||
final spaceModels = await _spaceModelApi.listSpaceModels(
|
||||
page: page, projectId: projectUuid);
|
||||
final spaceModels =
|
||||
await _spaceModelApi.listSpaceModels(page: page, projectId: projectUuid);
|
||||
if (spaceModels.isNotEmpty) {
|
||||
allSpaceModels.addAll(spaceModels);
|
||||
page++;
|
||||
@ -130,6 +139,20 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<Tag>> fetchTags() async {
|
||||
try {
|
||||
if (_cachedTags != null) {
|
||||
return _cachedTags!;
|
||||
}
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
final allTags = await _spaceModelApi.listTags(projectId: projectUuid);
|
||||
_cachedTags = allTags;
|
||||
return allTags;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
void _onUpdateCommunity(
|
||||
UpdateCommunityEvent event,
|
||||
Emitter<SpaceManagementState> emit,
|
||||
@ -137,14 +160,13 @@ class SpaceManagementBloc
|
||||
final previousState = state;
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
await fetchTags();
|
||||
|
||||
emit(SpaceManagementLoading());
|
||||
final success = await _api.updateCommunity(
|
||||
event.communityUuid, event.name, projectUuid);
|
||||
final success = await _api.updateCommunity(event.communityUuid, event.name, projectUuid);
|
||||
if (success) {
|
||||
if (previousState is SpaceManagementLoaded) {
|
||||
final updatedCommunities =
|
||||
List<CommunityModel>.from(previousState.communities);
|
||||
final updatedCommunities = List<CommunityModel>.from(previousState.communities);
|
||||
for (var community in updatedCommunities) {
|
||||
if (community.uuid == event.communityUuid) {
|
||||
community.name = event.name;
|
||||
@ -157,11 +179,11 @@ class SpaceManagementBloc
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
emit(SpaceManagementLoaded(
|
||||
communities: updatedCommunities,
|
||||
products: previousState.products,
|
||||
selectedCommunity: previousState.selectedCommunity,
|
||||
spaceModels: prevSpaceModels,
|
||||
));
|
||||
communities: updatedCommunities,
|
||||
products: previousState.products,
|
||||
selectedCommunity: previousState.selectedCommunity,
|
||||
spaceModels: prevSpaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
}
|
||||
} else {
|
||||
emit(const SpaceManagementError('Failed to update the community.'));
|
||||
@ -189,8 +211,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<SpaceModel>> _fetchSpacesForCommunity(
|
||||
String communityUuid) async {
|
||||
Future<List<SpaceModel>> _fetchSpacesForCommunity(String communityUuid) async {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
return await _api.getSpaceHierarchy(communityUuid, projectUuid);
|
||||
@ -201,7 +222,7 @@ class SpaceManagementBloc
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
try {
|
||||
final previousState = state;
|
||||
await fetchTags();
|
||||
|
||||
if (event.communities.isEmpty) {
|
||||
emit(const SpaceManagementError('No communities provided.'));
|
||||
@ -211,62 +232,41 @@ class SpaceManagementBloc
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
emit(BlankState(
|
||||
communities: event.communities,
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
));
|
||||
communities: event.communities,
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
} catch (error) {
|
||||
emit(SpaceManagementError('Error loading communities: $error'));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onBlankState(
|
||||
BlankStateEvent event, Emitter<SpaceManagementState> emit) async {
|
||||
Future<void> _onBlankState(BlankStateEvent event, Emitter<SpaceManagementState> emit) async {
|
||||
try {
|
||||
final previousState = state;
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
var spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
List<CommunityModel> communities = await _waitForCommunityList(spaceBloc);
|
||||
await fetchSpaceModels();
|
||||
await fetchTags();
|
||||
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
if (previousState is SpaceManagementLoaded ||
|
||||
previousState is BlankState) {
|
||||
if (previousState is SpaceManagementLoaded || previousState is BlankState) {
|
||||
final prevCommunities = (previousState as dynamic).communities ?? [];
|
||||
emit(BlankState(
|
||||
communities: List<CommunityModel>.from(prevCommunities),
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
));
|
||||
communities: List<CommunityModel>.from(prevCommunities),
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
return;
|
||||
}
|
||||
|
||||
if (communities.isEmpty) {
|
||||
communities = await _api.fetchCommunities(projectUuid);
|
||||
|
||||
List<CommunityModel> updatedCommunities = await Future.wait(
|
||||
communities.map((community) async {
|
||||
List<SpaceModel> spaces =
|
||||
await _fetchSpacesForCommunity(community.uuid);
|
||||
return CommunityModel(
|
||||
uuid: community.uuid,
|
||||
createdAt: community.createdAt,
|
||||
updatedAt: community.updatedAt,
|
||||
name: community.name,
|
||||
description: community.description,
|
||||
spaces: spaces,
|
||||
region: community.region,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
|
||||
communities = updatedCommunities;
|
||||
}
|
||||
|
||||
emit(BlankState(
|
||||
spaceModels: prevSpaceModels,
|
||||
communities: communities,
|
||||
products: _cachedProducts ?? [],
|
||||
allTags: _cachedTags ?? [],
|
||||
));
|
||||
} catch (error) {
|
||||
emit(SpaceManagementError('Error loading communities: $error'));
|
||||
@ -279,21 +279,20 @@ class SpaceManagementBloc
|
||||
) async {
|
||||
var spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
_onloadProducts();
|
||||
|
||||
await fetchTags();
|
||||
// Wait until `communityList` is loaded
|
||||
List<CommunityModel> communities = await _waitForCommunityList(spaceBloc);
|
||||
|
||||
// Fetch space models after communities are available
|
||||
final prevSpaceModels = await fetchSpaceModels();
|
||||
emit(SpaceManagementLoaded(
|
||||
communities: communities,
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
));
|
||||
communities: communities,
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
}
|
||||
|
||||
Future<List<CommunityModel>> _waitForCommunityList(
|
||||
SpaceTreeBloc spaceBloc) async {
|
||||
Future<List<CommunityModel>> _waitForCommunityList(SpaceTreeBloc spaceBloc) async {
|
||||
// Check if communityList is already populated
|
||||
if (spaceBloc.state.communityList.isNotEmpty) {
|
||||
return spaceBloc.state.communityList;
|
||||
@ -320,8 +319,7 @@ class SpaceManagementBloc
|
||||
emit(SpaceManagementLoading());
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
final success =
|
||||
await _api.deleteCommunity(event.communityUuid, projectUuid);
|
||||
final success = await _api.deleteCommunity(event.communityUuid, projectUuid);
|
||||
if (success) {
|
||||
// add(LoadCommunityAndSpacesEvent());
|
||||
} else {
|
||||
@ -342,14 +340,13 @@ class SpaceManagementBloc
|
||||
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
CommunityModel? newCommunity = await _api.createCommunity(
|
||||
event.name, event.description, projectUuid);
|
||||
await fetchTags();
|
||||
CommunityModel? newCommunity =
|
||||
await _api.createCommunity(event.name, event.description, projectUuid);
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
if (newCommunity != null) {
|
||||
if (previousState is SpaceManagementLoaded ||
|
||||
previousState is BlankState) {
|
||||
if (previousState is SpaceManagementLoaded || previousState is BlankState) {
|
||||
final prevCommunities = List<CommunityModel>.from(
|
||||
(previousState as dynamic).communities,
|
||||
);
|
||||
@ -357,11 +354,13 @@ class SpaceManagementBloc
|
||||
_spaceTreeBloc.add(OnCommunityAdded(newCommunity));
|
||||
|
||||
emit(SpaceManagementLoaded(
|
||||
spaceModels: prevSpaceModels,
|
||||
communities: updatedCommunities,
|
||||
products: _cachedProducts ?? [],
|
||||
selectedCommunity: newCommunity,
|
||||
selectedSpace: null));
|
||||
spaceModels: prevSpaceModels,
|
||||
communities: updatedCommunities,
|
||||
products: _cachedProducts ?? [],
|
||||
selectedCommunity: newCommunity,
|
||||
selectedSpace: null,
|
||||
allTags: _cachedTags ?? [],
|
||||
));
|
||||
}
|
||||
} else {
|
||||
emit(const SpaceManagementError('Error creating community'));
|
||||
@ -401,11 +400,12 @@ class SpaceManagementBloc
|
||||
required Emitter<SpaceManagementState> emit,
|
||||
CommunityModel? selectedCommunity,
|
||||
SpaceModel? selectedSpace,
|
||||
}) {
|
||||
}) async {
|
||||
final previousState = state;
|
||||
emit(SpaceManagementLoading());
|
||||
|
||||
try {
|
||||
await fetchTags();
|
||||
if (previousState is SpaceManagementLoaded ||
|
||||
previousState is BlankState ||
|
||||
previousState is SpaceModelLoaded) {
|
||||
@ -421,7 +421,8 @@ class SpaceManagementBloc
|
||||
products: _cachedProducts ?? [],
|
||||
selectedCommunity: selectedCommunity,
|
||||
selectedSpace: selectedSpace,
|
||||
spaceModels: spaceModels));
|
||||
spaceModels: spaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(SpaceManagementError('Error updating state: $e'));
|
||||
@ -437,7 +438,7 @@ class SpaceManagementBloc
|
||||
|
||||
try {
|
||||
final updatedSpaces =
|
||||
await saveSpacesHierarchically(event.spaces, event.communityUuid);
|
||||
await saveSpacesHierarchically(event.context, event.spaces, event.communityUuid);
|
||||
|
||||
final allSpaces = await _fetchSpacesForCommunity(event.communityUuid);
|
||||
|
||||
@ -467,29 +468,35 @@ class SpaceManagementBloc
|
||||
Emitter<SpaceManagementState> emit,
|
||||
) async {
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
await fetchTags();
|
||||
final communities = List<CommunityModel>.from(previousState.communities);
|
||||
|
||||
for (var community in communities) {
|
||||
if (community.uuid == communityUuid) {
|
||||
community.spaces = allSpaces;
|
||||
_spaceTreeBloc.add(OnCommunityUpdated(community));
|
||||
_spaceTreeBloc.add(InitialEvent());
|
||||
|
||||
emit(SpaceManagementLoaded(
|
||||
communities: communities,
|
||||
products: _cachedProducts ?? [],
|
||||
selectedCommunity: community,
|
||||
selectedSpace: null,
|
||||
spaceModels: prevSpaceModels));
|
||||
spaceModels: prevSpaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<SpaceModel>> saveSpacesHierarchically(
|
||||
List<SpaceModel> spaces, String communityUuid) async {
|
||||
BuildContext context, List<SpaceModel> spaces, String communityUuid) async {
|
||||
final orderedSpaces = flattenHierarchy(spaces);
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
List<CommunityModel> communities = spaceBloc.state.communityList;
|
||||
CommunityModel? selectedCommunity = communities.firstWhere(
|
||||
(community) => community.uuid == communityUuid,
|
||||
);
|
||||
|
||||
final parentsToDelete = orderedSpaces.where((space) =>
|
||||
space.status == SpaceStatus.deleted &&
|
||||
@ -511,8 +518,13 @@ class SpaceManagementBloc
|
||||
if (space.uuid != null && space.uuid!.isNotEmpty) {
|
||||
List<TagModelUpdate> tagUpdates = [];
|
||||
|
||||
final prevSpace =
|
||||
await _api.getSpace(communityUuid, space.uuid!, projectUuid);
|
||||
List<SpaceModel> matchedSpaces =
|
||||
findMatchingSpaces(selectedCommunity.spaces, space.uuid!);
|
||||
|
||||
if (matchedSpaces.isEmpty) continue;
|
||||
|
||||
final prevSpace = matchedSpaces[0];
|
||||
|
||||
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
|
||||
final List<SubspaceModel>? newSubspaces = space.subspaces;
|
||||
@ -522,19 +534,17 @@ class SpaceManagementBloc
|
||||
if (prevSubspaces != null || newSubspaces != null) {
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
final existsInNew = newSubspaces
|
||||
.any((subspace) => subspace.uuid == prevSubspace.uuid);
|
||||
final existsInNew =
|
||||
newSubspaces.any((subspace) => subspace.uuid == prevSubspace.uuid);
|
||||
if (!existsInNew) {
|
||||
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||
action: custom_action.Action.delete,
|
||||
uuid: prevSubspace.uuid));
|
||||
action: custom_action.Action.delete, uuid: prevSubspace.uuid));
|
||||
}
|
||||
}
|
||||
} else if (prevSubspaces != null && newSubspaces == null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
subspaceUpdates.add(UpdateSubspaceTemplateModel(
|
||||
action: custom_action.Action.delete,
|
||||
uuid: prevSubspace.uuid));
|
||||
action: custom_action.Action.delete, uuid: prevSubspace.uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,7 +558,7 @@ class SpaceManagementBloc
|
||||
for (var tag in newSubspace.tags!) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.add,
|
||||
uuid: tag.uuid == '' ? null : tag.uuid,
|
||||
newTagUuid: tag.uuid == '' ? null : tag.uuid,
|
||||
tag: tag.tag,
|
||||
productUuid: tag.product?.uuid));
|
||||
}
|
||||
@ -562,9 +572,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
final newSubspaceMap = {
|
||||
for (var subspace in newSubspaces) subspace.uuid: subspace
|
||||
};
|
||||
final newSubspaceMap = {for (var subspace in newSubspaces) subspace.uuid: subspace};
|
||||
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
final newSubspace = newSubspaceMap[prevSubspace.uuid];
|
||||
@ -593,6 +601,7 @@ class SpaceManagementBloc
|
||||
subspaces: subspaceUpdates,
|
||||
tags: tagUpdates,
|
||||
direction: space.incomingConnection?.direction,
|
||||
spaceModelUuid: space.spaceModel?.uuid,
|
||||
projectId: projectUuid);
|
||||
} else {
|
||||
// Call create if the space does not have a UUID
|
||||
@ -601,10 +610,8 @@ class SpaceManagementBloc
|
||||
: [];
|
||||
|
||||
final createSubspaceBodyModels = space.subspaces?.map((subspace) {
|
||||
final tagBodyModels = subspace.tags
|
||||
?.map((tag) => tag.toCreateTagBodyModel())
|
||||
.toList() ??
|
||||
[];
|
||||
final tagBodyModels =
|
||||
subspace.tags?.map((tag) => tag.toCreateTagBodyModel()).toList() ?? [];
|
||||
return CreateSubspaceModel()
|
||||
..subspaceName = subspace.subspaceName
|
||||
..tags = tagBodyModels;
|
||||
@ -657,45 +664,22 @@ class SpaceManagementBloc
|
||||
return result.toList(); // Convert back to a list
|
||||
}
|
||||
|
||||
void _onLoadSpaceModel(
|
||||
SpaceModelLoadEvent event, Emitter<SpaceManagementState> emit) async {
|
||||
void _onLoadSpaceModel(SpaceModelLoadEvent event, Emitter<SpaceManagementState> emit) async {
|
||||
emit(SpaceManagementLoading());
|
||||
|
||||
try {
|
||||
var prevState = state;
|
||||
await fetchTags();
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
var spaceBloc = event.context.read<SpaceTreeBloc>();
|
||||
List<CommunityModel> communities = spaceBloc.state.communityList;
|
||||
|
||||
var prevSpaceModels = await fetchSpaceModels();
|
||||
|
||||
if (communities.isEmpty) {
|
||||
communities = await _api.fetchCommunities(projectUuid);
|
||||
|
||||
List<CommunityModel> updatedCommunities = await Future.wait(
|
||||
communities.map((community) async {
|
||||
List<SpaceModel> spaces =
|
||||
await _fetchSpacesForCommunity(community.uuid);
|
||||
return CommunityModel(
|
||||
uuid: community.uuid,
|
||||
createdAt: community.createdAt,
|
||||
updatedAt: community.updatedAt,
|
||||
name: community.name,
|
||||
description: community.description,
|
||||
spaces: spaces,
|
||||
region: community.region,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
|
||||
communities = updatedCommunities;
|
||||
}
|
||||
|
||||
emit(SpaceModelLoaded(
|
||||
communities: communities,
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
));
|
||||
communities: communities,
|
||||
products: _cachedProducts ?? [],
|
||||
spaceModels: prevSpaceModels,
|
||||
allTags: _cachedTags ?? []));
|
||||
} catch (e) {
|
||||
emit(SpaceManagementError('Error loading communities and spaces: $e'));
|
||||
}
|
||||
@ -713,7 +697,7 @@ class SpaceManagementBloc
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.add,
|
||||
tag: newTag.tag,
|
||||
uuid: newTag.uuid,
|
||||
newTagUuid: newTag.uuid,
|
||||
productUuid: newTag.product?.uuid,
|
||||
));
|
||||
}
|
||||
@ -724,17 +708,14 @@ class SpaceManagementBloc
|
||||
// Case 1: Tags deleted
|
||||
if (prevTags != null && newTags != null) {
|
||||
for (var prevTag in prevTags) {
|
||||
final existsInNew =
|
||||
newTags.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||
final existsInNew = newTags.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||
if (!existsInNew) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.delete, uuid: prevTag.uuid));
|
||||
tagUpdates.add(TagModelUpdate(action: custom_action.Action.delete, uuid: prevTag.uuid));
|
||||
}
|
||||
}
|
||||
} else if (prevTags != null && newTags == null) {
|
||||
for (var prevTag in prevTags) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.delete, uuid: prevTag.uuid));
|
||||
tagUpdates.add(TagModelUpdate(action: custom_action.Action.delete, uuid: prevTag.uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@ -749,7 +730,7 @@ class SpaceManagementBloc
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.add,
|
||||
tag: newTag.tag,
|
||||
uuid: newTag.uuid == '' ? null : newTag.uuid,
|
||||
newTagUuid: newTag.uuid == '' ? null : newTag.uuid,
|
||||
productUuid: newTag.product?.uuid));
|
||||
processedTags.add(newTag.tag);
|
||||
}
|
||||
@ -766,6 +747,7 @@ class SpaceManagementBloc
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: custom_action.Action.update,
|
||||
uuid: newTag.uuid,
|
||||
newTagUuid: newTag.uuid,
|
||||
tag: newTag.tag,
|
||||
));
|
||||
} else {}
|
||||
@ -775,4 +757,18 @@ class SpaceManagementBloc
|
||||
|
||||
return tagUpdates;
|
||||
}
|
||||
|
||||
List<SpaceModel> findMatchingSpaces(List<SpaceModel> spaces, String targetUuid) {
|
||||
List<SpaceModel> matched = [];
|
||||
|
||||
for (var space in spaces) {
|
||||
if (space.uuid == targetUuid) {
|
||||
matched.add(space);
|
||||
}
|
||||
matched
|
||||
.addAll(findMatchingSpaces(space.children, targetUuid)); // Recursively search in children
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
}
|
||||
|
@ -58,14 +58,16 @@ class CreateSpaceEvent extends SpaceManagementEvent {
|
||||
class SaveSpacesEvent extends SpaceManagementEvent {
|
||||
final List<SpaceModel> spaces;
|
||||
final String communityUuid;
|
||||
final BuildContext context;
|
||||
|
||||
const SaveSpacesEvent({
|
||||
const SaveSpacesEvent(
|
||||
this.context, {
|
||||
required this.spaces,
|
||||
required this.communityUuid,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [spaces, communityUuid];
|
||||
List<Object> get props => [spaces, communityUuid, context];
|
||||
}
|
||||
|
||||
class UpdateSpacePositionEvent extends SpaceManagementEvent {
|
||||
@ -170,4 +172,4 @@ class UpdateSpaceModelCache extends SpaceManagementEvent {
|
||||
class DeleteSpaceModelFromCache extends SpaceManagementEvent {
|
||||
final String deletedUuid;
|
||||
DeleteSpaceModelFromCache(this.deletedUuid);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
|
||||
abstract class SpaceManagementState extends Equatable {
|
||||
@ -21,22 +22,25 @@ class SpaceManagementLoaded extends SpaceManagementState {
|
||||
CommunityModel? selectedCommunity;
|
||||
SpaceModel? selectedSpace;
|
||||
List<SpaceTemplateModel>? spaceModels;
|
||||
List<Tag> allTags;
|
||||
|
||||
SpaceManagementLoaded(
|
||||
{required this.communities,
|
||||
required this.products,
|
||||
this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
this.spaceModels});
|
||||
this.spaceModels,
|
||||
required this.allTags});
|
||||
}
|
||||
|
||||
class BlankState extends SpaceManagementState {
|
||||
final List<CommunityModel> communities;
|
||||
final List<ProductModel> products;
|
||||
List<SpaceTemplateModel>? spaceModels;
|
||||
final List<Tag> allTags;
|
||||
|
||||
BlankState(
|
||||
{required this.communities, required this.products, this.spaceModels});
|
||||
{required this.communities, required this.products, this.spaceModels, required this.allTags});
|
||||
}
|
||||
|
||||
class SpaceCreationSuccess extends SpaceManagementState {
|
||||
@ -61,14 +65,14 @@ class SpaceModelLoaded extends SpaceManagementState {
|
||||
List<SpaceTemplateModel> spaceModels;
|
||||
final List<ProductModel> products;
|
||||
final List<CommunityModel> communities;
|
||||
final List<Tag> allTags;
|
||||
|
||||
SpaceModelLoaded({
|
||||
required this.communities,
|
||||
required this.products,
|
||||
required this.spaceModels,
|
||||
});
|
||||
SpaceModelLoaded(
|
||||
{required this.communities,
|
||||
required this.products,
|
||||
required this.spaceModels,
|
||||
required this.allTags});
|
||||
|
||||
@override
|
||||
List<Object> get props => [communities, products, spaceModels];
|
||||
List<Object> get props => [communities, products, spaceModels, allTags];
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ class SpaceModel {
|
||||
String? icon;
|
||||
final String? spaceTuyaUuid;
|
||||
String name;
|
||||
String? lastThreeParents;
|
||||
final bool isPrivate;
|
||||
final String? invitationCode;
|
||||
SpaceModel? parent;
|
||||
@ -33,6 +34,7 @@ class SpaceModel {
|
||||
SpaceModel({
|
||||
this.uuid,
|
||||
String? internalId,
|
||||
this.lastThreeParents,
|
||||
this.spaceTuyaUuid,
|
||||
required this.icon,
|
||||
required this.name,
|
||||
@ -67,6 +69,7 @@ class SpaceModel {
|
||||
internalId: internalId,
|
||||
uuid: json['uuid'] ?? '',
|
||||
name: json['spaceName'],
|
||||
lastThreeParents: json['lastThreeParents'],
|
||||
isPrivate: json['isPrivate'] ?? false,
|
||||
invitationCode: json['invitationCode'],
|
||||
subspaces: (json['subspaces'] as List<dynamic>?)
|
||||
@ -125,6 +128,7 @@ class SpaceModel {
|
||||
'uuid': uuid ?? '',
|
||||
'spaceTuyaUuid': spaceTuyaUuid,
|
||||
'name': name,
|
||||
'lastThreeParents': lastThreeParents,
|
||||
'isPrivate': isPrivate,
|
||||
'invitationCode': invitationCode,
|
||||
'parent': parent?.uuid,
|
||||
|
@ -25,22 +25,21 @@ class Tag extends BaseTag {
|
||||
return Tag(
|
||||
uuid: json['uuid'] ?? '',
|
||||
internalId: internalId,
|
||||
tag: json['tag'] ?? '',
|
||||
product: json['product'] != null
|
||||
? ProductModel.fromMap(json['product'])
|
||||
: null,
|
||||
tag: json['name'] ?? '',
|
||||
product: json['product'] != null ? ProductModel.fromMap(json['product']) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Tag copyWith({
|
||||
String? uuid,
|
||||
String? tag,
|
||||
ProductModel? product,
|
||||
String? location,
|
||||
String? internalId,
|
||||
}) {
|
||||
return Tag(
|
||||
uuid: uuid,
|
||||
uuid: uuid ?? this.uuid,
|
||||
tag: tag ?? this.tag,
|
||||
product: product ?? this.product,
|
||||
location: location ?? this.location,
|
||||
@ -60,7 +59,7 @@ class Tag extends BaseTag {
|
||||
extension TagModelExtensions on Tag {
|
||||
TagBodyModel toTagBodyModel() {
|
||||
return TagBodyModel()
|
||||
..uuid = uuid ?? ''
|
||||
..uuid = uuid
|
||||
..tag = tag ?? ''
|
||||
..productUuid = product?.uuid;
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/shared/navigate_home_grid_view.dart';
|
||||
@ -62,9 +60,9 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
selectedSpace: null,
|
||||
products: state.products,
|
||||
shouldNavigateToSpaceModelPage: false,
|
||||
projectTags: state.allTags,
|
||||
);
|
||||
} else if (state is SpaceManagementLoaded) {
|
||||
|
||||
return LoadedSpaceView(
|
||||
communities: state.communities,
|
||||
selectedCommunity: state.selectedCommunity,
|
||||
@ -72,6 +70,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
products: state.products,
|
||||
spaceModels: state.spaceModels,
|
||||
shouldNavigateToSpaceModelPage: false,
|
||||
projectTags: state.allTags,
|
||||
);
|
||||
} else if (state is SpaceModelLoaded) {
|
||||
return LoadedSpaceView(
|
||||
@ -79,6 +78,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
products: state.products,
|
||||
spaceModels: state.spaceModels,
|
||||
shouldNavigateToSpaceModelPage: true,
|
||||
projectTags: state.allTags,
|
||||
);
|
||||
} else if (state is SpaceManagementError) {
|
||||
return Center(child: Text('Error: ${state.errorMessage}'));
|
||||
|
@ -36,16 +36,17 @@ class CommunityStructureArea extends StatefulWidget {
|
||||
final List<CommunityModel> communities;
|
||||
final List<SpaceModel> spaces;
|
||||
final List<SpaceTemplateModel>? spaceModels;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
CommunityStructureArea({
|
||||
this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
required this.communities,
|
||||
this.products,
|
||||
required this.spaces,
|
||||
this.onSpaceSelected,
|
||||
this.spaceModels,
|
||||
});
|
||||
CommunityStructureArea(
|
||||
{this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
required this.communities,
|
||||
this.products,
|
||||
required this.spaces,
|
||||
this.onSpaceSelected,
|
||||
this.spaceModels,
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
_CommunityStructureAreaState createState() => _CommunityStructureAreaState();
|
||||
@ -64,8 +65,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
spaces = widget.spaces.isNotEmpty ? flattenSpaces(widget.spaces) : [];
|
||||
connections =
|
||||
widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
connections = widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
_adjustCanvasSizeForSpaces();
|
||||
_nameController = TextEditingController(
|
||||
text: widget.selectedCommunity?.name ?? '',
|
||||
@ -92,14 +92,12 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
if (oldWidget.spaces != widget.spaces) {
|
||||
setState(() {
|
||||
spaces = widget.spaces.isNotEmpty ? flattenSpaces(widget.spaces) : [];
|
||||
connections =
|
||||
widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
connections = widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
_adjustCanvasSizeForSpaces();
|
||||
});
|
||||
}
|
||||
|
||||
if (widget.selectedSpace != oldWidget.selectedSpace &&
|
||||
widget.selectedSpace != null) {
|
||||
if (widget.selectedSpace != oldWidget.selectedSpace && widget.selectedSpace != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_moveToSpace(widget.selectedSpace!);
|
||||
});
|
||||
@ -182,8 +180,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
connection, widget.selectedSpace)
|
||||
? 1.0
|
||||
: 0.3, // Adjust opacity
|
||||
child: CustomPaint(
|
||||
painter: CurvedLinePainter([connection])),
|
||||
child: CustomPaint(painter: CurvedLinePainter([connection])),
|
||||
),
|
||||
for (var entry in spaces.asMap().entries)
|
||||
if (entry.value.status != SpaceStatus.deleted &&
|
||||
@ -193,15 +190,12 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
top: entry.value.position.dy,
|
||||
child: SpaceCardWidget(
|
||||
index: entry.key,
|
||||
onButtonTap: (int index, Offset newPosition,
|
||||
String direction) {
|
||||
_showCreateSpaceDialog(
|
||||
screenSize,
|
||||
position:
|
||||
spaces[index].position + newPosition,
|
||||
parentIndex: index,
|
||||
direction: direction,
|
||||
);
|
||||
onButtonTap: (int index, Offset newPosition, String direction) {
|
||||
_showCreateSpaceDialog(screenSize,
|
||||
position: spaces[index].position + newPosition,
|
||||
parentIndex: index,
|
||||
direction: direction,
|
||||
projectTags: widget.projectTags);
|
||||
},
|
||||
position: entry.value.position,
|
||||
isHovered: entry.value.isHovered,
|
||||
@ -211,9 +205,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
_updateNodePosition(entry.value, newPosition);
|
||||
},
|
||||
buildSpaceContainer: (int index) {
|
||||
final bool isHighlighted =
|
||||
SpaceHelper.isHighlightedSpace(
|
||||
spaces[index], widget.selectedSpace);
|
||||
final bool isHighlighted = SpaceHelper.isHighlightedSpace(
|
||||
spaces[index], widget.selectedSpace);
|
||||
|
||||
return Opacity(
|
||||
opacity: isHighlighted ? 1.0 : 0.3,
|
||||
@ -238,7 +231,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
onTap: () {
|
||||
_showCreateSpaceDialog(screenSize,
|
||||
canvasHeight: canvasHeight,
|
||||
canvasWidth: canvasWidth);
|
||||
canvasWidth: canvasWidth,
|
||||
projectTags: widget.projectTags);
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -292,26 +286,22 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
int? parentIndex,
|
||||
String? direction,
|
||||
double? canvasWidth,
|
||||
double? canvasHeight}) {
|
||||
double? canvasHeight,
|
||||
required List<Tag> projectTags}) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CreateSpaceDialog(
|
||||
products: widget.products,
|
||||
spaceModels: widget.spaceModels,
|
||||
allTags:
|
||||
TagHelper.getAllTagValues(widget.communities, widget.spaceModels),
|
||||
allTags: TagHelper.getAllTagValues(widget.communities, widget.spaceModels),
|
||||
parentSpace: parentIndex != null ? spaces[parentIndex] : null,
|
||||
onCreateSpace: (String name,
|
||||
String icon,
|
||||
List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel,
|
||||
List<SubspaceModel>? subspaces,
|
||||
List<Tag>? tags) {
|
||||
projectTags: projectTags,
|
||||
onCreateSpace: (String name, String icon, List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel, List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||
setState(() {
|
||||
// Set the first space in the center or use passed position
|
||||
Offset centerPosition =
|
||||
position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
Offset centerPosition = position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
SpaceModel newSpace = SpaceModel(
|
||||
name: name,
|
||||
icon: icon,
|
||||
@ -356,21 +346,17 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
spaceModels: widget.spaceModels,
|
||||
name: widget.selectedSpace!.name,
|
||||
icon: widget.selectedSpace!.icon,
|
||||
parentSpace: SpaceHelper.findSpaceByInternalId(
|
||||
widget.selectedSpace?.parent?.internalId, spaces),
|
||||
projectTags: widget.projectTags,
|
||||
parentSpace:
|
||||
SpaceHelper.findSpaceByInternalId(widget.selectedSpace?.parent?.internalId, spaces),
|
||||
editSpace: widget.selectedSpace,
|
||||
currentSpaceModel: widget.selectedSpace?.spaceModel,
|
||||
tags: widget.selectedSpace?.tags,
|
||||
subspaces: widget.selectedSpace?.subspaces,
|
||||
isEdit: true,
|
||||
allTags: TagHelper.getAllTagValues(
|
||||
widget.communities, widget.spaceModels),
|
||||
onCreateSpace: (String name,
|
||||
String icon,
|
||||
List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel,
|
||||
List<SubspaceModel>? subspaces,
|
||||
List<Tag>? tags) {
|
||||
allTags: TagHelper.getAllTagValues(widget.communities, widget.spaceModels),
|
||||
onCreateSpace: (String name, String icon, List<SelectedProduct> selectedProducts,
|
||||
SpaceTemplateModel? spaceModel, List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||
setState(() {
|
||||
// Update the space's properties
|
||||
widget.selectedSpace!.name = name;
|
||||
@ -380,8 +366,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
widget.selectedSpace!.tags = tags;
|
||||
|
||||
if (widget.selectedSpace!.status != SpaceStatus.newSpace) {
|
||||
widget.selectedSpace!.status =
|
||||
SpaceStatus.modified; // Mark as modified
|
||||
widget.selectedSpace!.status = SpaceStatus.modified; // Mark as modified
|
||||
}
|
||||
|
||||
for (var space in spaces) {
|
||||
@ -411,8 +396,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
List<SpaceModel> result = [];
|
||||
|
||||
void flatten(SpaceModel space) {
|
||||
if (space.status == SpaceStatus.deleted ||
|
||||
space.status == SpaceStatus.parentDeleted) {
|
||||
if (space.status == SpaceStatus.deleted || space.status == SpaceStatus.parentDeleted) {
|
||||
return;
|
||||
}
|
||||
result.add(space);
|
||||
@ -476,6 +460,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
String communityUuid = widget.selectedCommunity!.uuid;
|
||||
|
||||
context.read<SpaceManagementBloc>().add(SaveSpacesEvent(
|
||||
context,
|
||||
spaces: spacesToSave,
|
||||
communityUuid: communityUuid,
|
||||
));
|
||||
@ -527,16 +512,13 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
void _selectSpace(BuildContext context, SpaceModel space) {
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
SelectSpaceEvent(
|
||||
selectedCommunity: widget.selectedCommunity,
|
||||
selectedSpace: space),
|
||||
SelectSpaceEvent(selectedCommunity: widget.selectedCommunity, selectedSpace: space),
|
||||
);
|
||||
}
|
||||
|
||||
void _deselectSpace(BuildContext context) {
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
SelectSpaceEvent(
|
||||
selectedCommunity: widget.selectedCommunity, selectedSpace: null),
|
||||
SelectSpaceEvent(selectedCommunity: widget.selectedCommunity, selectedSpace: null),
|
||||
);
|
||||
}
|
||||
|
||||
@ -625,19 +607,16 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
const double horizontalGap = 200.0;
|
||||
const double verticalGap = 100.0;
|
||||
|
||||
SpaceModel duplicateRecursive(SpaceModel original, Offset parentPosition,
|
||||
SpaceModel? duplicatedParent) {
|
||||
Offset newPosition =
|
||||
Offset(parentPosition.dx + horizontalGap, original.position.dy);
|
||||
SpaceModel duplicateRecursive(
|
||||
SpaceModel original, Offset parentPosition, SpaceModel? duplicatedParent) {
|
||||
Offset newPosition = Offset(parentPosition.dx + horizontalGap, original.position.dy);
|
||||
|
||||
while (spaces.any((s) =>
|
||||
(s.position - newPosition).distance < horizontalGap &&
|
||||
s.status != SpaceStatus.deleted)) {
|
||||
(s.position - newPosition).distance < horizontalGap && s.status != SpaceStatus.deleted)) {
|
||||
newPosition += Offset(horizontalGap, 0);
|
||||
}
|
||||
|
||||
final duplicatedName =
|
||||
SpaceHelper.generateUniqueSpaceName(original.name, spaces);
|
||||
final duplicatedName = SpaceHelper.generateUniqueSpaceName(original.name, spaces);
|
||||
|
||||
final List<SubspaceModel>? duplicatedSubspaces;
|
||||
final List<Tag>? duplicatedTags;
|
||||
@ -681,8 +660,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
if (original.parent != null && duplicatedParent == null) {
|
||||
final originalParent = original.parent!;
|
||||
final duplicatedParent =
|
||||
originalToDuplicate[originalParent] ?? originalParent;
|
||||
final duplicatedParent = originalToDuplicate[originalParent] ?? originalParent;
|
||||
|
||||
final parentConnection = Connection(
|
||||
startSpace: duplicatedParent,
|
||||
@ -698,8 +676,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
final childrenWithDownDirection = original.children
|
||||
.where((child) =>
|
||||
child.incomingConnection?.direction == "down" &&
|
||||
child.status != SpaceStatus.deleted)
|
||||
child.incomingConnection?.direction == "down" && child.status != SpaceStatus.deleted)
|
||||
.toList();
|
||||
|
||||
Offset childStartPosition = childrenWithDownDirection.length == 1
|
||||
@ -707,8 +684,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
: newPosition + Offset(0, verticalGap);
|
||||
|
||||
for (final child in original.children) {
|
||||
final isDownDirection =
|
||||
child.incomingConnection?.direction == "down" ?? false;
|
||||
final isDownDirection = child.incomingConnection?.direction == "down" ?? false;
|
||||
|
||||
if (isDownDirection && childrenWithDownDirection.length == 1) {
|
||||
childStartPosition = duplicated.position + Offset(0, verticalGap);
|
||||
@ -716,8 +692,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
childStartPosition = duplicated.position + Offset(horizontalGap, 0);
|
||||
}
|
||||
|
||||
final duplicatedChild =
|
||||
duplicateRecursive(child, childStartPosition, duplicated);
|
||||
final duplicatedChild = duplicateRecursive(child, childStartPosition, duplicated);
|
||||
duplicated.children.add(duplicatedChild);
|
||||
childStartPosition += Offset(0, verticalGap);
|
||||
}
|
||||
@ -728,8 +703,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
if (space.parent == null) {
|
||||
duplicateRecursive(space, space.position, null);
|
||||
} else {
|
||||
final duplicatedParent =
|
||||
originalToDuplicate[space.parent!] ?? space.parent!;
|
||||
final duplicatedParent = originalToDuplicate[space.parent!] ?? space.parent!;
|
||||
duplicateRecursive(space, space.position, duplicatedParent);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class CommunityTile extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 16.0),
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: CustomExpansionTile(
|
||||
title: title,
|
||||
initiallyExpanded: isExpanded,
|
||||
|
@ -42,6 +42,7 @@ class CreateSpaceDialog extends StatefulWidget {
|
||||
final List<Tag>? tags;
|
||||
final List<String>? allTags;
|
||||
final SpaceTemplateModel? currentSpaceModel;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const CreateSpaceDialog(
|
||||
{super.key,
|
||||
@ -57,7 +58,8 @@ class CreateSpaceDialog extends StatefulWidget {
|
||||
this.spaceModels,
|
||||
this.subspaces,
|
||||
this.tags,
|
||||
this.currentSpaceModel});
|
||||
this.currentSpaceModel,
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
CreateSpaceDialogState createState() => CreateSpaceDialogState();
|
||||
@ -80,10 +82,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
super.initState();
|
||||
selectedIcon = widget.icon ?? Assets.location;
|
||||
nameController = TextEditingController(text: widget.name ?? '');
|
||||
selectedProducts =
|
||||
widget.selectedProducts.isNotEmpty ? widget.selectedProducts : [];
|
||||
isOkButtonEnabled =
|
||||
enteredName.isNotEmpty || nameController.text.isNotEmpty;
|
||||
selectedProducts = widget.selectedProducts.isNotEmpty ? widget.selectedProducts : [];
|
||||
isOkButtonEnabled = enteredName.isNotEmpty || nameController.text.isNotEmpty;
|
||||
if (widget.currentSpaceModel != null) {
|
||||
subspaces = [];
|
||||
tags = [];
|
||||
@ -96,15 +96,13 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool isSpaceModelDisabled = (tags != null && tags!.isNotEmpty ||
|
||||
subspaces != null && subspaces!.isNotEmpty);
|
||||
bool isSpaceModelDisabled =
|
||||
(tags != null && tags!.isNotEmpty || subspaces != null && subspaces!.isNotEmpty);
|
||||
bool isTagsAndSubspaceModelDisabled = (selectedSpaceModel != null);
|
||||
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
return AlertDialog(
|
||||
title: widget.isEdit
|
||||
? const Text('Edit Space')
|
||||
: const Text('Create New Space'),
|
||||
title: widget.isEdit ? const Text('Edit Space') : const Text('Create New Space'),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
content: SizedBox(
|
||||
width: screenWidth * 0.5,
|
||||
@ -178,7 +176,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
isNameFieldInvalid = value.isEmpty;
|
||||
|
||||
if (!isNameFieldInvalid) {
|
||||
if (SpaceHelper.isNameConflict(value, widget.parentSpace, widget.editSpace)) {
|
||||
if (SpaceHelper.isNameConflict(
|
||||
value, widget.parentSpace, widget.editSpace)) {
|
||||
isNameFieldExist = true;
|
||||
isOkButtonEnabled = false;
|
||||
} else {
|
||||
@ -245,9 +244,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
isSpaceModelDisabled
|
||||
? null
|
||||
: _showLinkSpaceModelDialog(context);
|
||||
isSpaceModelDisabled ? null : _showLinkSpaceModelDialog(context);
|
||||
},
|
||||
child: ButtonContentWidget(
|
||||
svgAssets: Assets.link,
|
||||
@ -257,8 +254,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
)
|
||||
: Container(
|
||||
width: screenWidth * 0.25,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10.0, horizontal: 16.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
@ -273,8 +269,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(
|
||||
color: ColorsManager.spaceColor),
|
||||
.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
@ -302,6 +297,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
),
|
||||
onDeleted: () => setState(() {
|
||||
this.selectedSpaceModel = null;
|
||||
subspaces = widget.subspaces ?? [];
|
||||
tags = widget.tags ?? [];
|
||||
})),
|
||||
],
|
||||
),
|
||||
@ -343,8 +340,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
onPressed: () async {
|
||||
isTagsAndSubspaceModelDisabled
|
||||
? null
|
||||
: _showSubSpaceDialog(context, enteredName,
|
||||
[], false, widget.products, subspaces);
|
||||
: _showSubSpaceDialog(
|
||||
context, enteredName, [], false, widget.products, subspaces);
|
||||
},
|
||||
child: ButtonContentWidget(
|
||||
icon: Icons.add,
|
||||
@ -371,22 +368,16 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
if (subspaces != null)
|
||||
...subspaces!.map((subspace) {
|
||||
return Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SubspaceNameDisplayWidget(
|
||||
text: subspace.subspaceName,
|
||||
validateName: (updatedName) {
|
||||
bool nameExists =
|
||||
subspaces!.any((s) {
|
||||
bool isSameId = s.internalId ==
|
||||
subspace.internalId;
|
||||
bool isSameName = s.subspaceName
|
||||
.trim()
|
||||
.toLowerCase() ==
|
||||
updatedName
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
bool nameExists = subspaces!.any((s) {
|
||||
bool isSameId = s.internalId == subspace.internalId;
|
||||
bool isSameName =
|
||||
s.subspaceName.trim().toLowerCase() ==
|
||||
updatedName.trim().toLowerCase();
|
||||
|
||||
return !isSameId && isSameName;
|
||||
});
|
||||
@ -395,8 +386,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
},
|
||||
onNameChanged: (updatedName) {
|
||||
setState(() {
|
||||
subspace.subspaceName =
|
||||
updatedName;
|
||||
subspace.subspaceName = updatedName;
|
||||
});
|
||||
},
|
||||
),
|
||||
@ -405,8 +395,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
}),
|
||||
EditChip(
|
||||
onTap: () async {
|
||||
_showSubSpaceDialog(context, enteredName,
|
||||
[], true, widget.products, subspaces);
|
||||
_showSubSpaceDialog(context, enteredName, [], true,
|
||||
widget.products, subspaces);
|
||||
},
|
||||
)
|
||||
],
|
||||
@ -415,9 +405,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
(tags?.isNotEmpty == true ||
|
||||
subspaces?.any((subspace) =>
|
||||
subspace.tags?.isNotEmpty == true) ==
|
||||
true)
|
||||
subspaces?.any((subspace) => subspace.tags?.isNotEmpty == true) == true)
|
||||
? SizedBox(
|
||||
width: screenWidth * 0.25,
|
||||
child: Container(
|
||||
@ -437,16 +425,14 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
// Combine tags from spaceModel and subspaces
|
||||
...TagHelper.groupTags([
|
||||
...?tags,
|
||||
...?subspaces?.expand(
|
||||
(subspace) => subspace.tags ?? [])
|
||||
...?subspaces?.expand((subspace) => subspace.tags ?? [])
|
||||
]).entries.map(
|
||||
(entry) => Chip(
|
||||
avatar: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: SvgPicture.asset(
|
||||
entry.key.icon ??
|
||||
'assets/icons/gateway.svg',
|
||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
@ -455,15 +441,11 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(
|
||||
color: ColorsManager
|
||||
.spaceColor),
|
||||
?.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor:
|
||||
ColorsManager.whiteColors,
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(16),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.spaceColor,
|
||||
),
|
||||
@ -472,23 +454,21 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
),
|
||||
|
||||
EditChip(onTap: () async {
|
||||
final result = await showDialog(
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AssignTagDialog(
|
||||
products: widget.products,
|
||||
subspaces: subspaces,
|
||||
allTags: widget.allTags,
|
||||
addedProducts: TagHelper
|
||||
.createInitialSelectedProductsForTags(
|
||||
addedProducts:
|
||||
TagHelper.createInitialSelectedProductsForTags(
|
||||
tags ?? [], subspaces),
|
||||
title: 'Edit Device',
|
||||
initialTags:
|
||||
TagHelper.generateInitialForTags(
|
||||
spaceTags: tags,
|
||||
subspaces: subspaces),
|
||||
initialTags: TagHelper.generateInitialForTags(
|
||||
spaceTags: tags, subspaces: subspaces),
|
||||
spaceName: widget.name ?? '',
|
||||
onSave:
|
||||
(updatedTags, updatedSubspaces) {
|
||||
projectTags: widget.projectTags,
|
||||
onSave: (updatedTags, updatedSubspaces) {
|
||||
setState(() {
|
||||
tags = updatedTags;
|
||||
subspaces = updatedSubspaces;
|
||||
@ -547,25 +527,17 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
String newName = enteredName.isNotEmpty
|
||||
? enteredName
|
||||
: (widget.name ?? '');
|
||||
String newName = enteredName.isNotEmpty ? enteredName : (widget.name ?? '');
|
||||
if (newName.isNotEmpty) {
|
||||
widget.onCreateSpace(
|
||||
newName,
|
||||
selectedIcon,
|
||||
selectedProducts,
|
||||
selectedSpaceModel,
|
||||
subspaces,
|
||||
tags);
|
||||
widget.onCreateSpace(newName, selectedIcon, selectedProducts,
|
||||
selectedSpaceModel, subspaces, tags);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
borderRadius: 10,
|
||||
backgroundColor: isOkButtonEnabled
|
||||
? ColorsManager.secondaryColor
|
||||
: ColorsManager.grayColor,
|
||||
backgroundColor:
|
||||
isOkButtonEnabled ? ColorsManager.secondaryColor : ColorsManager.grayColor,
|
||||
foregroundColor: ColorsManager.whiteColors,
|
||||
child: const Text('OK'),
|
||||
),
|
||||
@ -592,7 +564,6 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void _showLinkSpaceModelDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@ -613,13 +584,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showSubSpaceDialog(
|
||||
BuildContext context,
|
||||
String name,
|
||||
final List<Tag>? spaceTags,
|
||||
bool isEdit,
|
||||
List<ProductModel>? products,
|
||||
final List<SubspaceModel>? existingSubSpaces) {
|
||||
void _showSubSpaceDialog(BuildContext context, String name, final List<Tag>? spaceTags,
|
||||
bool isEdit, List<ProductModel>? products, final List<SubspaceModel>? existingSubSpaces) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -634,12 +600,10 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
final List<Tag> tagsToAppendToSpace = [];
|
||||
|
||||
if (slectedSubspaces != null) {
|
||||
final updatedIds =
|
||||
slectedSubspaces.map((s) => s.internalId).toSet();
|
||||
final updatedIds = slectedSubspaces.map((s) => s.internalId).toSet();
|
||||
if (existingSubSpaces != null) {
|
||||
final deletedSubspaces = existingSubSpaces
|
||||
.where((s) => !updatedIds.contains(s.internalId))
|
||||
.toList();
|
||||
final deletedSubspaces =
|
||||
existingSubSpaces.where((s) => !updatedIds.contains(s.internalId)).toList();
|
||||
for (var s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
tagsToAppendToSpace.addAll(s.tags!);
|
||||
@ -659,20 +623,20 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showTagCreateDialog(BuildContext context, String name, bool isEdit,
|
||||
List<ProductModel>? products) {
|
||||
void _showTagCreateDialog(
|
||||
BuildContext context, String name, bool isEdit, List<ProductModel>? products) {
|
||||
isEdit
|
||||
? showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AssignTagDialog(
|
||||
title: 'Edit Device',
|
||||
addedProducts: TagHelper.createInitialSelectedProductsForTags(
|
||||
tags, subspaces),
|
||||
addedProducts: TagHelper.createInitialSelectedProductsForTags(tags, subspaces),
|
||||
spaceName: name,
|
||||
products: products,
|
||||
subspaces: subspaces,
|
||||
allTags: widget.allTags,
|
||||
projectTags: widget.projectTags,
|
||||
onSave: (selectedSpaceTags, selectedSubspaces) {
|
||||
setState(() {
|
||||
tags = selectedSpaceTags;
|
||||
@ -682,8 +646,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
if (subspaces != null) {
|
||||
for (final subspace in subspaces!) {
|
||||
for (final selectedSubspace in selectedSubspaces) {
|
||||
if (subspace.subspaceName ==
|
||||
selectedSubspace.subspaceName) {
|
||||
if (subspace.subspaceName == selectedSubspace.subspaceName) {
|
||||
subspace.tags = selectedSubspace.tags;
|
||||
}
|
||||
}
|
||||
@ -705,9 +668,9 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
spaceTags: tags,
|
||||
isCreate: true,
|
||||
allTags: widget.allTags,
|
||||
projectTags: widget.projectTags,
|
||||
initialSelectedProducts:
|
||||
TagHelper.createInitialSelectedProductsForTags(
|
||||
tags, subspaces),
|
||||
TagHelper.createInitialSelectedProductsForTags(tags, subspaces),
|
||||
onSave: (selectedSpaceTags, selectedSubspaces) {
|
||||
setState(() {
|
||||
tags = selectedSpaceTags;
|
||||
@ -717,8 +680,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
||||
if (subspaces != null) {
|
||||
for (final subspace in subspaces!) {
|
||||
for (final selectedSubspace in selectedSubspaces) {
|
||||
if (subspace.subspaceName ==
|
||||
selectedSubspace.subspaceName) {
|
||||
if (subspace.subspaceName == selectedSubspace.subspaceName) {
|
||||
subspace.tags = selectedSubspace.tags;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/gradient_canvas_border_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart';
|
||||
@ -19,16 +21,17 @@ class LoadedSpaceView extends StatefulWidget {
|
||||
final List<ProductModel>? products;
|
||||
final List<SpaceTemplateModel>? spaceModels;
|
||||
final bool shouldNavigateToSpaceModelPage;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const LoadedSpaceView({
|
||||
super.key,
|
||||
required this.communities,
|
||||
this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
this.products,
|
||||
this.spaceModels,
|
||||
required this.shouldNavigateToSpaceModelPage,
|
||||
});
|
||||
const LoadedSpaceView(
|
||||
{super.key,
|
||||
required this.communities,
|
||||
this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
this.products,
|
||||
this.spaceModels,
|
||||
required this.shouldNavigateToSpaceModelPage,
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
_LoadedSpaceViewState createState() => _LoadedSpaceViewState();
|
||||
@ -78,26 +81,25 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
widget.shouldNavigateToSpaceModelPage
|
||||
? _spaceModels.isNotEmpty
|
||||
? Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 300, child: SpaceTreeView(onSelect: () {})),
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (context) => SpaceModelBloc(
|
||||
api: SpaceModelManagementApi(),
|
||||
initialSpaceModels: _spaceModels,
|
||||
),
|
||||
child: SpaceModelPage(
|
||||
products: widget.products,
|
||||
onSpaceModelsUpdated: _onSpaceModelsUpdated,
|
||||
),
|
||||
),
|
||||
? Row(
|
||||
children: [
|
||||
SizedBox(width: 300, child: SpaceTreeView(onSelect: () {})),
|
||||
Expanded(
|
||||
child: BlocProvider(
|
||||
create: (context) => SpaceModelBloc(
|
||||
BlocProvider.of<SpaceTreeBloc>(context),
|
||||
api: SpaceModelManagementApi(),
|
||||
initialSpaceModels: widget.spaceModels ?? [],
|
||||
),
|
||||
],
|
||||
)
|
||||
: const Center(child: CircularProgressIndicator())
|
||||
child: SpaceModelPage(
|
||||
products: widget.products,
|
||||
onSpaceModelsUpdated: _onSpaceModelsUpdated,
|
||||
projectTags: widget.projectTags,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
children: [
|
||||
SidebarWidget(
|
||||
@ -113,6 +115,7 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
||||
products: widget.products,
|
||||
communities: widget.communities,
|
||||
spaceModels: _spaceModels,
|
||||
projectTags: widget.projectTags,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -205,30 +205,32 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community) {
|
||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) {
|
||||
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
||||
return SpaceTile(
|
||||
title: space.name,
|
||||
key: ValueKey(space.uuid),
|
||||
isSelected: _selectedId == space.uuid,
|
||||
initiallyExpanded: isExpandedSpace,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
_handleExpansionChange(space.uuid ?? '', expanded);
|
||||
},
|
||||
onItemSelected: () {
|
||||
setState(() {
|
||||
_selectedId = space.uuid;
|
||||
_selectedSpaceUuid = space.uuid;
|
||||
});
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: depth * 16.0),
|
||||
child: SpaceTile(
|
||||
title: space.name,
|
||||
key: ValueKey(space.uuid),
|
||||
isSelected: _selectedId == space.uuid,
|
||||
initiallyExpanded: isExpandedSpace,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
_handleExpansionChange(space.uuid ?? '', expanded);
|
||||
},
|
||||
onItemSelected: () {
|
||||
setState(() {
|
||||
_selectedId = space.uuid;
|
||||
_selectedSpaceUuid = space.uuid;
|
||||
});
|
||||
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
SelectSpaceEvent(selectedCommunity: community, selectedSpace: space),
|
||||
);
|
||||
},
|
||||
children: space.children.isNotEmpty
|
||||
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()
|
||||
: [], // Recursively render child spaces if available
|
||||
);
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
SelectSpaceEvent(selectedCommunity: community, selectedSpace: space),
|
||||
);
|
||||
},
|
||||
children: space.children.isNotEmpty
|
||||
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()
|
||||
: [], // Recursively render child spaces if available
|
||||
));
|
||||
}
|
||||
|
||||
void _handleExpansionChange(String uuid, bool expanded) {}
|
||||
|
@ -35,18 +35,20 @@ class _SpaceTileState extends State<SpaceTile> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomExpansionTile(
|
||||
isSelected: widget.isSelected,
|
||||
title: widget.title,
|
||||
initiallyExpanded: _isExpanded,
|
||||
onItemSelected: widget.onItemSelected,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
setState(() {
|
||||
_isExpanded = expanded;
|
||||
});
|
||||
widget.onExpansionChanged(expanded);
|
||||
},
|
||||
children: widget.children ?? [],
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0),
|
||||
child: CustomExpansionTile(
|
||||
isSelected: widget.isSelected,
|
||||
title: widget.title,
|
||||
initiallyExpanded: _isExpanded,
|
||||
onItemSelected: widget.onItemSelected,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
setState(() {
|
||||
_isExpanded = expanded;
|
||||
});
|
||||
widget.onExpansionChanged(expanded);
|
||||
},
|
||||
children: widget.children ?? [],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -4,17 +4,16 @@ import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_e
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag/bloc/assign_tag_state.dart';
|
||||
|
||||
class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
final List<String> allTags;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
AssignTagBloc(this.allTags) : super(AssignTagInitial()) {
|
||||
AssignTagBloc(this.projectTags) : super(AssignTagInitial()) {
|
||||
on<InitializeTags>((event, emit) {
|
||||
final initialTags = event.initialTags ?? [];
|
||||
|
||||
final existingTagCounts = <String, int>{};
|
||||
for (var tag in initialTags) {
|
||||
if (tag.product != null) {
|
||||
existingTagCounts[tag.product!.uuid] =
|
||||
(existingTagCounts[tag.product!.uuid] ?? 0) + 1;
|
||||
existingTagCounts[tag.product!.uuid] = (existingTagCounts[tag.product!.uuid] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,17 +22,14 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
for (var selectedProduct in event.addedProducts) {
|
||||
final existingCount = existingTagCounts[selectedProduct.productId] ?? 0;
|
||||
|
||||
if (selectedProduct.count == 0 ||
|
||||
selectedProduct.count <= existingCount) {
|
||||
tags.addAll(initialTags
|
||||
.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
if (selectedProduct.count == 0 || selectedProduct.count <= existingCount) {
|
||||
tags.addAll(initialTags.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
continue;
|
||||
}
|
||||
|
||||
final missingCount = selectedProduct.count - existingCount;
|
||||
|
||||
tags.addAll(initialTags
|
||||
.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
tags.addAll(initialTags.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
|
||||
if (missingCount > 0) {
|
||||
tags.addAll(List.generate(
|
||||
@ -47,11 +43,11 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
}
|
||||
}
|
||||
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagLoaded(
|
||||
tags: tags,
|
||||
updatedTags: updatedTags,
|
||||
updatedTags: updatedTags,
|
||||
isSaveEnabled: _validateTags(tags),
|
||||
errorMessage: '',
|
||||
));
|
||||
@ -62,9 +58,16 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
|
||||
if (currentState is AssignTagLoaded && currentState.tags.isNotEmpty) {
|
||||
final tags = List<Tag>.from(currentState.tags);
|
||||
tags[event.index] = tags[event.index].copyWith(tag: event.tag);
|
||||
if (event.index < 0 || event.index >= tags.length) return;
|
||||
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
tags[event.index] = tags[event.index].copyWith(
|
||||
tag: event.tag.tag,
|
||||
uuid: event.tag.uuid,
|
||||
product: event.tag.product,
|
||||
internalId: event.tag.internalId,
|
||||
location: event.tag.location,
|
||||
);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagLoaded(
|
||||
tags: tags,
|
||||
@ -82,10 +85,9 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
final tags = List<Tag>.from(currentState.tags);
|
||||
|
||||
// Update the location
|
||||
tags[event.index] =
|
||||
tags[event.index].copyWith(location: event.location);
|
||||
tags[event.index] = tags[event.index].copyWith(location: event.location);
|
||||
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagLoaded(
|
||||
tags: tags,
|
||||
@ -104,7 +106,7 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
|
||||
emit(AssignTagLoaded(
|
||||
tags: tags,
|
||||
updatedTags: _calculateAvailableTags(allTags, tags),
|
||||
updatedTags: _calculateAvailableTags(projectTags, tags),
|
||||
isSaveEnabled: _validateTags(tags),
|
||||
errorMessage: _getValidationError(tags),
|
||||
));
|
||||
@ -115,11 +117,10 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
final currentState = state;
|
||||
|
||||
if (currentState is AssignTagLoaded && currentState.tags.isNotEmpty) {
|
||||
final tags = List<Tag>.from(currentState.tags)
|
||||
..remove(event.tagToDelete);
|
||||
final tags = List<Tag>.from(currentState.tags)..remove(event.tagToDelete);
|
||||
|
||||
// Recalculate available tags
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagLoaded(
|
||||
tags: tags,
|
||||
@ -140,10 +141,8 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
|
||||
// Get validation error for duplicate tags
|
||||
String? _getValidationError(List<Tag> tags) {
|
||||
final nonEmptyTags = tags
|
||||
.map((tag) => tag.tag?.trim() ?? '')
|
||||
.where((tag) => tag.isNotEmpty)
|
||||
.toList();
|
||||
final nonEmptyTags =
|
||||
tags.map((tag) => tag.tag?.trim() ?? '').where((tag) => tag.isNotEmpty).toList();
|
||||
|
||||
final duplicateTags = nonEmptyTags
|
||||
.fold<Map<String, int>>({}, (map, tag) {
|
||||
@ -162,14 +161,16 @@ class AssignTagBloc extends Bloc<AssignTagEvent, AssignTagState> {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> _calculateAvailableTags(List<String> allTags, List<Tag> tags) {
|
||||
final selectedTags = tags
|
||||
List<Tag> _calculateAvailableTags(List<Tag> allTags, List<Tag> selectedTags) {
|
||||
final selectedTagSet = selectedTags
|
||||
.where((tag) => (tag.tag?.trim().isNotEmpty ?? false))
|
||||
.map((tag) => tag.tag!.trim())
|
||||
.toSet();
|
||||
|
||||
final availableTags =
|
||||
allTags.where((tag) => !selectedTags.contains(tag.trim())).toList();
|
||||
final availableTags = allTags
|
||||
.where((tag) => tag.tag != null && !selectedTagSet.contains(tag.tag!.trim()))
|
||||
.toList();
|
||||
|
||||
return availableTags;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class InitializeTags extends AssignTagEvent {
|
||||
|
||||
class UpdateTagEvent extends AssignTagEvent {
|
||||
final int index;
|
||||
final String tag;
|
||||
final Tag tag;
|
||||
|
||||
const UpdateTagEvent({required this.index, required this.tag});
|
||||
|
||||
|
@ -5,7 +5,7 @@ abstract class AssignTagState extends Equatable {
|
||||
const AssignTagState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class AssignTagInitial extends AssignTagState {}
|
||||
@ -14,7 +14,7 @@ class AssignTagLoading extends AssignTagState {}
|
||||
|
||||
class AssignTagLoaded extends AssignTagState {
|
||||
final List<Tag> tags;
|
||||
final List<String> updatedTags;
|
||||
final List<Tag> updatedTags;
|
||||
|
||||
final bool isSaveEnabled;
|
||||
final String? errorMessage;
|
||||
@ -27,8 +27,7 @@ class AssignTagLoaded extends AssignTagState {
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props =>
|
||||
[tags, updatedTags, isSaveEnabled, errorMessage ?? ''];
|
||||
List<Object?> get props => [tags, updatedTags, isSaveEnabled, errorMessage ?? ''];
|
||||
}
|
||||
|
||||
class AssignTagError extends AssignTagState {
|
||||
@ -37,5 +36,5 @@ class AssignTagError extends AssignTagState {
|
||||
const AssignTagError(this.errorMessage);
|
||||
|
||||
@override
|
||||
List<Object> get props => [errorMessage];
|
||||
List<Object?> get props => [errorMessage];
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/common/dialog_dropdown.dart';
|
||||
import 'package:syncrow_web/common/dialog_textfield_dropdown.dart';
|
||||
import 'package:syncrow_web/common/tag_dialog_textfield_dropdown.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/add_device_type/views/add_device_type_widget.dart';
|
||||
@ -26,6 +26,7 @@ class AssignTagDialog extends StatelessWidget {
|
||||
final String spaceName;
|
||||
final String title;
|
||||
final Function(List<Tag>, List<SubspaceModel>?)? onSave;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const AssignTagDialog(
|
||||
{Key? key,
|
||||
@ -37,18 +38,17 @@ class AssignTagDialog extends StatelessWidget {
|
||||
this.allTags,
|
||||
required this.spaceName,
|
||||
required this.title,
|
||||
this.onSave})
|
||||
this.onSave,
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<String> locations = (subspaces ?? [])
|
||||
.map((subspace) => subspace.subspaceName)
|
||||
.toList()
|
||||
..add('Main Space');
|
||||
final List<String> locations =
|
||||
(subspaces ?? []).map((subspace) => subspace.subspaceName).toList()..add('Main Space');
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) => AssignTagBloc(allTags ?? [])
|
||||
create: (_) => AssignTagBloc(projectTags)
|
||||
..add(InitializeTags(
|
||||
initialTags: initialTags,
|
||||
addedProducts: addedProducts,
|
||||
@ -70,8 +70,7 @@ class AssignTagDialog extends StatelessWidget {
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: DataTable(
|
||||
headingRowColor: WidgetStateProperty.all(
|
||||
ColorsManager.dataHeaderGrey),
|
||||
headingRowColor: WidgetStateProperty.all(ColorsManager.dataHeaderGrey),
|
||||
key: ValueKey(state.tags.length),
|
||||
border: TableBorder.all(
|
||||
color: ColorsManager.dataHeaderGrey,
|
||||
@ -80,22 +79,15 @@ class AssignTagDialog extends StatelessWidget {
|
||||
),
|
||||
columns: [
|
||||
DataColumn(
|
||||
label: Text('#',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium)),
|
||||
label: Text('#', style: Theme.of(context).textTheme.bodyMedium)),
|
||||
DataColumn(
|
||||
label: Text('Device',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium)),
|
||||
label: Text('Device', style: Theme.of(context).textTheme.bodyMedium)),
|
||||
DataColumn(
|
||||
numeric: false,
|
||||
label: Text('Tag',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium)),
|
||||
label: Text('Tag', style: Theme.of(context).textTheme.bodyMedium)),
|
||||
DataColumn(
|
||||
label: Text('Location',
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium)),
|
||||
label:
|
||||
Text('Location', style: Theme.of(context).textTheme.bodyMedium)),
|
||||
],
|
||||
rows: state.tags.isEmpty
|
||||
? [
|
||||
@ -103,12 +95,8 @@ class AssignTagDialog extends StatelessWidget {
|
||||
DataCell(
|
||||
Center(
|
||||
child: Text('No Data Available',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: ColorsManager
|
||||
.lightGrayColor,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
)),
|
||||
),
|
||||
),
|
||||
@ -126,8 +114,7 @@ class AssignTagDialog extends StatelessWidget {
|
||||
DataCell(Text((index + 1).toString())),
|
||||
DataCell(
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
@ -141,31 +128,25 @@ class AssignTagDialog extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: ColorsManager
|
||||
.lightGrayColor,
|
||||
color: ColorsManager.lightGrayColor,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
color: ColorsManager
|
||||
.lightGreyColor,
|
||||
color: ColorsManager.lightGreyColor,
|
||||
size: 16,
|
||||
),
|
||||
onPressed: () {
|
||||
context
|
||||
.read<AssignTagBloc>()
|
||||
.add(DeleteTag(
|
||||
tagToDelete: tag,
|
||||
tags: state.tags));
|
||||
context.read<AssignTagBloc>().add(
|
||||
DeleteTag(tagToDelete: tag, tags: state.tags));
|
||||
|
||||
controllers.removeAt(index);
|
||||
},
|
||||
tooltip: 'Delete Tag',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints:
|
||||
const BoxConstraints(),
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -173,23 +154,20 @@ class AssignTagDialog extends StatelessWidget {
|
||||
),
|
||||
DataCell(
|
||||
Container(
|
||||
alignment: Alignment
|
||||
.centerLeft, // Align cell content to the left
|
||||
alignment:
|
||||
Alignment.centerLeft, // Align cell content to the left
|
||||
child: SizedBox(
|
||||
width: double
|
||||
.infinity, // Ensure full width for dropdown
|
||||
child: DialogTextfieldDropdown(
|
||||
key: ValueKey(
|
||||
'dropdown_${Uuid().v4()}_${index}'),
|
||||
width: double.infinity,
|
||||
child: TagDialogTextfieldDropdown(
|
||||
key: ValueKey('dropdown_${const Uuid().v4()}_$index'),
|
||||
items: state.updatedTags,
|
||||
initialValue: tag.tag,
|
||||
product: tag.product?.uuid ?? 'Unknown',
|
||||
initialValue: tag,
|
||||
onSelected: (value) {
|
||||
controller.text = value;
|
||||
context
|
||||
.read<AssignTagBloc>()
|
||||
.add(UpdateTagEvent(
|
||||
controller.text = value.tag ?? '';
|
||||
context.read<AssignTagBloc>().add(UpdateTagEvent(
|
||||
index: index,
|
||||
tag: value.trim(),
|
||||
tag: value,
|
||||
));
|
||||
},
|
||||
),
|
||||
@ -201,12 +179,9 @@ class AssignTagDialog extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
child: DialogDropdown(
|
||||
items: locations,
|
||||
selectedValue:
|
||||
tag.location ?? 'Main Space',
|
||||
selectedValue: tag.location ?? 'Main Space',
|
||||
onSelected: (value) {
|
||||
context
|
||||
.read<AssignTagBloc>()
|
||||
.add(UpdateLocation(
|
||||
context.read<AssignTagBloc>().add(UpdateLocation(
|
||||
index: index,
|
||||
location: value,
|
||||
));
|
||||
@ -238,13 +213,11 @@ class AssignTagDialog extends StatelessWidget {
|
||||
label: 'Add New Device',
|
||||
onPressed: () async {
|
||||
final updatedTags = List<Tag>.from(state.tags);
|
||||
final result =
|
||||
TagHelper.processTags(updatedTags, subspaces);
|
||||
final result = TagHelper.processTags(updatedTags, subspaces);
|
||||
|
||||
final processedTags =
|
||||
result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces = List<SubspaceModel>.from(
|
||||
result['subspaces'] as List<dynamic>);
|
||||
final processedTags = result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceModel>.from(result['subspaces'] as List<dynamic>);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@ -253,8 +226,9 @@ class AssignTagDialog extends StatelessWidget {
|
||||
builder: (context) => AddDeviceTypeWidget(
|
||||
products: products,
|
||||
subspaces: processedSubspaces,
|
||||
initialSelectedProducts: TagHelper
|
||||
.createInitialSelectedProductsForTags(
|
||||
projectTags: projectTags,
|
||||
initialSelectedProducts:
|
||||
TagHelper.createInitialSelectedProductsForTags(
|
||||
processedTags, processedSubspaces),
|
||||
spaceName: spaceName,
|
||||
spaceTags: processedTags,
|
||||
@ -278,14 +252,11 @@ class AssignTagDialog extends StatelessWidget {
|
||||
onPressed: state.isSaveEnabled
|
||||
? () async {
|
||||
final updatedTags = List<Tag>.from(state.tags);
|
||||
final result = TagHelper.processTags(
|
||||
updatedTags, subspaces);
|
||||
final result = TagHelper.processTags(updatedTags, subspaces);
|
||||
|
||||
final processedTags =
|
||||
result['updatedTags'] as List<Tag>;
|
||||
final processedTags = result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceModel>.from(
|
||||
result['subspaces'] as List<dynamic>);
|
||||
List<SubspaceModel>.from(result['subspaces'] as List<dynamic>);
|
||||
onSave?.call(processedTags, processedSubspaces);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
@ -1,45 +1,40 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
|
||||
class AssignTagModelBloc
|
||||
extends Bloc<AssignTagModelEvent, AssignTagModelState> {
|
||||
final List<String> allTags;
|
||||
class AssignTagModelBloc extends Bloc<AssignTagModelEvent, AssignTagModelState> {
|
||||
final List<Tag> projectTags;
|
||||
|
||||
AssignTagModelBloc(this.allTags) : super(AssignTagModelInitial()) {
|
||||
AssignTagModelBloc(this.projectTags) : super(AssignTagModelInitial()) {
|
||||
on<InitializeTagModels>((event, emit) {
|
||||
final initialTags = event.initialTags ?? [];
|
||||
final initialTags = event.initialTags;
|
||||
|
||||
final existingTagCounts = <String, int>{};
|
||||
for (var tag in initialTags) {
|
||||
if (tag.product != null) {
|
||||
existingTagCounts[tag.product!.uuid] =
|
||||
(existingTagCounts[tag.product!.uuid] ?? 0) + 1;
|
||||
existingTagCounts[tag.product!.uuid] = (existingTagCounts[tag.product!.uuid] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
final tags = <TagModel>[];
|
||||
final tags = <Tag>[];
|
||||
|
||||
for (var selectedProduct in event.addedProducts) {
|
||||
final existingCount = existingTagCounts[selectedProduct.productId] ?? 0;
|
||||
|
||||
if (selectedProduct.count == 0 ||
|
||||
selectedProduct.count <= existingCount) {
|
||||
tags.addAll(initialTags
|
||||
.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
if (selectedProduct.count == 0 || selectedProduct.count <= existingCount) {
|
||||
tags.addAll(initialTags.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
continue;
|
||||
}
|
||||
|
||||
final missingCount = selectedProduct.count - existingCount;
|
||||
|
||||
tags.addAll(initialTags
|
||||
.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
tags.addAll(initialTags.where((tag) => tag.product?.uuid == selectedProduct.productId));
|
||||
|
||||
if (missingCount > 0) {
|
||||
tags.addAll(List.generate(
|
||||
missingCount,
|
||||
(index) => TagModel(
|
||||
(index) => Tag(
|
||||
tag: '',
|
||||
product: selectedProduct.product,
|
||||
location: 'Main Space',
|
||||
@ -48,7 +43,7 @@ class AssignTagModelBloc
|
||||
}
|
||||
}
|
||||
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagModelLoaded(
|
||||
tags: tags,
|
||||
@ -59,11 +54,20 @@ class AssignTagModelBloc
|
||||
|
||||
on<UpdateTag>((event, emit) {
|
||||
final currentState = state;
|
||||
if (currentState is AssignTagModelLoaded &&
|
||||
currentState.tags.isNotEmpty) {
|
||||
final tags = List<TagModel>.from(currentState.tags);
|
||||
tags[event.index] = tags[event.index].copyWith(tag: event.tag);
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
|
||||
final tags = List<Tag>.from(currentState.tags);
|
||||
|
||||
if (event.index < 0 || event.index >= tags.length) return;
|
||||
|
||||
tags[event.index] = tags[event.index].copyWith(
|
||||
tag: event.tag.tag,
|
||||
uuid: event.tag.uuid,
|
||||
product: event.tag.product,
|
||||
internalId: event.tag.internalId,
|
||||
location: event.tag.location,
|
||||
);
|
||||
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagModelLoaded(
|
||||
tags: tags,
|
||||
@ -77,15 +81,12 @@ class AssignTagModelBloc
|
||||
on<UpdateLocation>((event, emit) {
|
||||
final currentState = state;
|
||||
|
||||
if (currentState is AssignTagModelLoaded &&
|
||||
currentState.tags.isNotEmpty) {
|
||||
final tags = List<TagModel>.from(currentState.tags);
|
||||
|
||||
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
|
||||
final tags = List<Tag>.from(currentState.tags);
|
||||
// Use copyWith for immutability
|
||||
tags[event.index] =
|
||||
tags[event.index].copyWith(location: event.location);
|
||||
tags[event.index] = tags[event.index].copyWith(location: event.location);
|
||||
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagModelLoaded(
|
||||
tags: tags,
|
||||
@ -99,13 +100,12 @@ class AssignTagModelBloc
|
||||
on<ValidateTagModels>((event, emit) {
|
||||
final currentState = state;
|
||||
|
||||
if (currentState is AssignTagModelLoaded &&
|
||||
currentState.tags.isNotEmpty) {
|
||||
final tags = List<TagModel>.from(currentState.tags);
|
||||
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
|
||||
final tags = List<Tag>.from(currentState.tags);
|
||||
|
||||
emit(AssignTagModelLoaded(
|
||||
tags: tags,
|
||||
updatedTags: _calculateAvailableTags(allTags, tags),
|
||||
updatedTags: _calculateAvailableTags(projectTags, tags),
|
||||
isSaveEnabled: _validateTags(tags),
|
||||
errorMessage: _getValidationError(tags),
|
||||
));
|
||||
@ -115,12 +115,10 @@ class AssignTagModelBloc
|
||||
on<DeleteTagModel>((event, emit) {
|
||||
final currentState = state;
|
||||
|
||||
if (currentState is AssignTagModelLoaded &&
|
||||
currentState.tags.isNotEmpty) {
|
||||
final tags = List<TagModel>.from(currentState.tags)
|
||||
..remove(event.tagToDelete);
|
||||
if (currentState is AssignTagModelLoaded && currentState.tags.isNotEmpty) {
|
||||
final tags = List<Tag>.from(currentState.tags)..remove(event.tagToDelete);
|
||||
|
||||
final updatedTags = _calculateAvailableTags(allTags, tags);
|
||||
final updatedTags = _calculateAvailableTags(projectTags, tags);
|
||||
|
||||
emit(AssignTagModelLoaded(
|
||||
tags: tags,
|
||||
@ -128,24 +126,22 @@ class AssignTagModelBloc
|
||||
isSaveEnabled: _validateTags(tags),
|
||||
errorMessage: _getValidationError(tags),
|
||||
));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool _validateTags(List<TagModel> tags) {
|
||||
bool _validateTags(List<Tag> tags) {
|
||||
final uniqueTags = tags.map((tag) => tag.tag?.trim() ?? '').toSet();
|
||||
final hasEmptyTag = tags.any((tag) => (tag.tag?.trim() ?? '').isEmpty);
|
||||
final isValid = uniqueTags.length == tags.length && !hasEmptyTag;
|
||||
return isValid;
|
||||
}
|
||||
|
||||
String? _getValidationError(List<TagModel> tags) {
|
||||
String? _getValidationError(List<Tag> tags) {
|
||||
// Check for duplicate tags
|
||||
|
||||
final nonEmptyTags = tags
|
||||
.map((tag) => tag.tag?.trim() ?? '')
|
||||
.where((tag) => tag.isNotEmpty)
|
||||
.toList();
|
||||
final nonEmptyTags =
|
||||
tags.map((tag) => tag.tag?.trim() ?? '').where((tag) => tag.isNotEmpty).toList();
|
||||
|
||||
final duplicateTags = nonEmptyTags
|
||||
.fold<Map<String, int>>({}, (map, tag) {
|
||||
@ -164,15 +160,16 @@ class AssignTagModelBloc
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> _calculateAvailableTags(
|
||||
List<String> allTags, List<TagModel> tags) {
|
||||
final selectedTags = tags
|
||||
List<Tag> _calculateAvailableTags(List<Tag> allTags, List<Tag> selectedTags) {
|
||||
final selectedTagSet = selectedTags
|
||||
.where((tag) => (tag.tag?.trim().isNotEmpty ?? false))
|
||||
.map((tag) => tag.tag!.trim())
|
||||
.toSet();
|
||||
|
||||
final availableTags =
|
||||
allTags.where((tag) => !selectedTags.contains(tag.trim())).toList();
|
||||
final availableTags = allTags
|
||||
.where((tag) => tag.tag != null && !selectedTagSet.contains(tag.tag!.trim()))
|
||||
.toList();
|
||||
|
||||
return availableTags;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
|
||||
abstract class AssignTagModelEvent extends Equatable {
|
||||
@ -10,7 +10,7 @@ abstract class AssignTagModelEvent extends Equatable {
|
||||
}
|
||||
|
||||
class InitializeTagModels extends AssignTagModelEvent {
|
||||
final List<TagModel> initialTags;
|
||||
final List<Tag> initialTags;
|
||||
final List<SelectedProduct> addedProducts;
|
||||
|
||||
const InitializeTagModels({
|
||||
@ -24,7 +24,7 @@ class InitializeTagModels extends AssignTagModelEvent {
|
||||
|
||||
class UpdateTag extends AssignTagModelEvent {
|
||||
final int index;
|
||||
final String tag;
|
||||
final Tag tag;
|
||||
|
||||
const UpdateTag({required this.index, required this.tag});
|
||||
|
||||
@ -45,8 +45,8 @@ class UpdateLocation extends AssignTagModelEvent {
|
||||
class ValidateTagModels extends AssignTagModelEvent {}
|
||||
|
||||
class DeleteTagModel extends AssignTagModelEvent {
|
||||
final TagModel tagToDelete;
|
||||
final List<TagModel> tags;
|
||||
final Tag tagToDelete;
|
||||
final List<Tag> tags;
|
||||
|
||||
const DeleteTagModel({required this.tagToDelete, required this.tags});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
|
||||
abstract class AssignTagModelState extends Equatable {
|
||||
const AssignTagModelState();
|
||||
@ -13,11 +13,11 @@ class AssignTagModelInitial extends AssignTagModelState {}
|
||||
class AssignTagModelLoading extends AssignTagModelState {}
|
||||
|
||||
class AssignTagModelLoaded extends AssignTagModelState {
|
||||
final List<TagModel> tags;
|
||||
final List<Tag> tags;
|
||||
final bool isSaveEnabled;
|
||||
final String? errorMessage;
|
||||
|
||||
final List<String> updatedTags;
|
||||
final List<Tag> updatedTags;
|
||||
|
||||
const AssignTagModelLoaded({
|
||||
required this.tags,
|
||||
|
@ -1,17 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/common/dialog_dropdown.dart';
|
||||
import 'package:syncrow_web/common/dialog_textfield_dropdown.dart';
|
||||
import 'package:syncrow_web/common/tag_dialog_textfield_dropdown.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/bloc/assign_tag_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/create_space_model_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
@ -23,8 +23,8 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
final List<SubspaceTemplateModel>? subspaces;
|
||||
final SpaceTemplateModel? spaceModel;
|
||||
|
||||
final List<TagModel> initialTags;
|
||||
final ValueChanged<List<TagModel>>? onTagsAssigned;
|
||||
final List<Tag> initialTags;
|
||||
final ValueChanged<List<Tag>>? onTagsAssigned;
|
||||
final List<SelectedProduct> addedProducts;
|
||||
final List<String>? allTags;
|
||||
final String spaceName;
|
||||
@ -32,6 +32,7 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
final BuildContext? pageContext;
|
||||
final List<String>? otherSpaceModels;
|
||||
final List<SpaceTemplateModel>? allSpaceModels;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const AssignTagModelsDialog(
|
||||
{Key? key,
|
||||
@ -46,18 +47,17 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.spaceModel,
|
||||
this.allSpaceModels})
|
||||
this.allSpaceModels,
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<String> locations = (subspaces ?? [])
|
||||
.map((subspace) => subspace.subspaceName)
|
||||
.toList()
|
||||
..add('Main Space');
|
||||
final List<String> locations =
|
||||
(subspaces ?? []).map((subspace) => subspace.subspaceName).toList()..add('Main Space');
|
||||
|
||||
return BlocProvider(
|
||||
create: (_) => AssignTagModelBloc(allTags ?? [])
|
||||
create: (_) => AssignTagModelBloc(projectTags)
|
||||
..add(InitializeTagModels(
|
||||
initialTags: initialTags,
|
||||
addedProducts: addedProducts,
|
||||
@ -81,8 +81,7 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: DataTable(
|
||||
headingRowColor: WidgetStateProperty.all(
|
||||
ColorsManager.dataHeaderGrey),
|
||||
headingRowColor: WidgetStateProperty.all(ColorsManager.dataHeaderGrey),
|
||||
key: ValueKey(state.tags.length),
|
||||
border: TableBorder.all(
|
||||
color: ColorsManager.dataHeaderGrey,
|
||||
@ -91,26 +90,17 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
),
|
||||
columns: [
|
||||
DataColumn(
|
||||
label: Text('#',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium)),
|
||||
label: Text('#', style: Theme.of(context).textTheme.bodyMedium)),
|
||||
DataColumn(
|
||||
label: Text('Device',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium)),
|
||||
style: Theme.of(context).textTheme.bodyMedium)),
|
||||
DataColumn(
|
||||
numeric: false,
|
||||
label: Text('Tag',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium)),
|
||||
label:
|
||||
Text('Tag', style: Theme.of(context).textTheme.bodyMedium)),
|
||||
DataColumn(
|
||||
label: Text('Location',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium)),
|
||||
style: Theme.of(context).textTheme.bodyMedium)),
|
||||
],
|
||||
rows: state.tags.isEmpty
|
||||
? [
|
||||
@ -118,13 +108,10 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
DataCell(
|
||||
Center(
|
||||
child: Text('No Devices Available',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(
|
||||
color: ColorsManager
|
||||
.lightGrayColor,
|
||||
)),
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
)),
|
||||
),
|
||||
),
|
||||
const DataCell(SizedBox()),
|
||||
@ -141,8 +128,7 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
DataCell(Text((index + 1).toString())),
|
||||
DataCell(
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
@ -156,31 +142,25 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: ColorsManager
|
||||
.lightGrayColor,
|
||||
color: ColorsManager.lightGrayColor,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
color: ColorsManager
|
||||
.lightGreyColor,
|
||||
color: ColorsManager.lightGreyColor,
|
||||
size: 16,
|
||||
),
|
||||
onPressed: () {
|
||||
context
|
||||
.read<
|
||||
AssignTagModelBloc>()
|
||||
.add(DeleteTagModel(
|
||||
tagToDelete: tag,
|
||||
tags: state.tags));
|
||||
context.read<AssignTagModelBloc>().add(
|
||||
DeleteTagModel(
|
||||
tagToDelete: tag, tags: state.tags));
|
||||
controllers.removeAt(index);
|
||||
},
|
||||
tooltip: 'Delete Tag',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints:
|
||||
const BoxConstraints(),
|
||||
constraints: const BoxConstraints(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -191,19 +171,16 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
alignment: Alignment
|
||||
.centerLeft, // Align cell content to the left
|
||||
child: SizedBox(
|
||||
width: double
|
||||
.infinity, // Ensure full width for dropdown
|
||||
child: DialogTextfieldDropdown(
|
||||
key: ValueKey(
|
||||
'dropdown_${Uuid().v4()}_${index}'),
|
||||
width: double.infinity,
|
||||
child: TagDialogTextfieldDropdown(
|
||||
key: ValueKey(
|
||||
'dropdown_${const Uuid().v4()}_$index'),
|
||||
product: tag.product?.uuid ?? 'Unknown',
|
||||
items: state.updatedTags,
|
||||
initialValue: tag.tag,
|
||||
initialValue: tag,
|
||||
onSelected: (value) {
|
||||
controller.text = value;
|
||||
context
|
||||
.read<
|
||||
AssignTagModelBloc>()
|
||||
.add(UpdateTag(
|
||||
controller.text = value.tag ?? '';
|
||||
context.read<AssignTagModelBloc>().add(UpdateTag(
|
||||
index: index,
|
||||
tag: value,
|
||||
));
|
||||
@ -217,12 +194,10 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
child: DialogDropdown(
|
||||
items: locations,
|
||||
selectedValue: tag.location ??
|
||||
'Main Space',
|
||||
selectedValue: tag.location ?? 'Main Space',
|
||||
onSelected: (value) {
|
||||
context
|
||||
.read<
|
||||
AssignTagModelBloc>()
|
||||
.read<AssignTagModelBloc>()
|
||||
.add(UpdateLocation(
|
||||
index: index,
|
||||
location: value,
|
||||
@ -254,17 +229,13 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
builder: (buttonContext) => CancelButton(
|
||||
label: 'Add New Device',
|
||||
onPressed: () async {
|
||||
final updatedTags =
|
||||
List<TagModel>.from(state.tags);
|
||||
final updatedTags = List<Tag>.from(state.tags);
|
||||
final result =
|
||||
TagHelper.updateSubspaceTagModels(
|
||||
updatedTags, subspaces);
|
||||
TagHelper.updateSubspaceTagModels(updatedTags, subspaces);
|
||||
|
||||
final processedTags =
|
||||
result['updatedTags'] as List<TagModel>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceTemplateModel>.from(
|
||||
result['subspaces'] as List<dynamic>);
|
||||
final processedTags = result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces = List<SubspaceTemplateModel>.from(
|
||||
result['subspaces'] as List<dynamic>);
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
@ -272,28 +243,25 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
await showDialog<bool>(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (dialogContext) =>
|
||||
AddDeviceTypeModelWidget(
|
||||
products: products,
|
||||
subspaces: processedSubspaces,
|
||||
isCreate: false,
|
||||
initialSelectedProducts: TagHelper
|
||||
.createInitialSelectedProducts(
|
||||
processedTags,
|
||||
processedSubspaces),
|
||||
allTags: allTags,
|
||||
spaceName: spaceName,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
spaceTagModels: processedTags,
|
||||
pageContext: pageContext,
|
||||
spaceModel: SpaceTemplateModel(
|
||||
modelName: spaceName,
|
||||
tags: updatedTags,
|
||||
uuid: spaceModel?.uuid,
|
||||
internalId:
|
||||
spaceModel?.internalId,
|
||||
subspaceModels:
|
||||
processedSubspaces)),
|
||||
builder: (dialogContext) => AddDeviceTypeModelWidget(
|
||||
products: products,
|
||||
subspaces: processedSubspaces,
|
||||
isCreate: false,
|
||||
initialSelectedProducts:
|
||||
TagHelper.createInitialSelectedProducts(
|
||||
processedTags, processedSubspaces),
|
||||
allTags: allTags,
|
||||
spaceName: spaceName,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
spaceTagModels: processedTags,
|
||||
pageContext: pageContext,
|
||||
projectTags: projectTags,
|
||||
spaceModel: SpaceTemplateModel(
|
||||
modelName: spaceName,
|
||||
tags: updatedTags,
|
||||
uuid: spaceModel?.uuid,
|
||||
internalId: spaceModel?.internalId,
|
||||
subspaceModels: processedSubspaces)),
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -310,22 +278,16 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
: ColorsManager.whiteColorsWithOpacity,
|
||||
onPressed: state.isSaveEnabled
|
||||
? () async {
|
||||
final updatedTags =
|
||||
List<TagModel>.from(state.tags);
|
||||
final updatedTags = List<Tag>.from(state.tags);
|
||||
|
||||
final result =
|
||||
TagHelper.updateSubspaceTagModels(
|
||||
updatedTags, subspaces);
|
||||
TagHelper.updateSubspaceTagModels(updatedTags, subspaces);
|
||||
|
||||
final processedTags =
|
||||
result['updatedTags'] as List<TagModel>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceTemplateModel>.from(
|
||||
result['subspaces']
|
||||
as List<dynamic>);
|
||||
final processedTags = result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces = List<SubspaceTemplateModel>.from(
|
||||
result['subspaces'] as List<dynamic>);
|
||||
|
||||
Navigator.of(context)
|
||||
.popUntil((route) => route.isFirst);
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
@ -334,16 +296,15 @@ class AssignTagModelsDialog extends StatelessWidget {
|
||||
products: products,
|
||||
allSpaceModels: allSpaceModels,
|
||||
allTags: allTags,
|
||||
projectTags: projectTags,
|
||||
pageContext: pageContext,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
spaceModel: SpaceTemplateModel(
|
||||
modelName: spaceName,
|
||||
tags: processedTags,
|
||||
uuid: spaceModel?.uuid,
|
||||
internalId:
|
||||
spaceModel?.internalId,
|
||||
subspaceModels:
|
||||
processedSubspaces),
|
||||
internalId: spaceModel?.internalId,
|
||||
subspaceModels: processedSubspaces),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -7,7 +7,6 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_mo
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
|
||||
class TagHelper {
|
||||
static Map<String, dynamic> updateTags<T>({
|
||||
@ -131,9 +130,9 @@ class TagHelper {
|
||||
}
|
||||
|
||||
static List<String> getAvailableTagModels(
|
||||
List<String> allTags, List<TagModel> currentTags, TagModel currentTag) {
|
||||
List<String> allTags, List<Tag> currentTags, Tag currentTag) {
|
||||
List<String> availableTagsForTagModel =
|
||||
TagHelper.getAvailableTags<TagModel>(
|
||||
TagHelper.getAvailableTags<Tag>(
|
||||
allTags: allTags,
|
||||
currentTags: currentTags,
|
||||
currentTag: currentTag,
|
||||
@ -142,11 +141,11 @@ class TagHelper {
|
||||
return availableTagsForTagModel;
|
||||
}
|
||||
|
||||
static List<TagModel> generateInitialTags({
|
||||
List<TagModel>? spaceTagModels,
|
||||
static List<Tag> generateInitialTags({
|
||||
List<Tag>? spaceTagModels,
|
||||
List<SubspaceTemplateModel>? subspaces,
|
||||
}) {
|
||||
final List<TagModel> initialTags = [];
|
||||
final List<Tag> initialTags = [];
|
||||
|
||||
if (spaceTagModels != null) {
|
||||
initialTags.addAll(spaceTagModels);
|
||||
@ -212,7 +211,7 @@ class TagHelper {
|
||||
}
|
||||
|
||||
static List<SelectedProduct> createInitialSelectedProducts(
|
||||
List<TagModel>? tags, List<SubspaceTemplateModel>? subspaces) {
|
||||
List<Tag>? tags, List<SubspaceTemplateModel>? subspaces) {
|
||||
final Map<ProductModel, int> productCounts = {};
|
||||
|
||||
if (tags != null) {
|
||||
@ -282,7 +281,7 @@ class TagHelper {
|
||||
}
|
||||
|
||||
static int? checkTagExistInSubspaceModels(
|
||||
TagModel tag, List<dynamic>? subspaces) {
|
||||
Tag tag, List<dynamic>? subspaces) {
|
||||
if (subspaces == null) return null;
|
||||
|
||||
for (int i = 0; i < subspaces.length; i++) {
|
||||
@ -298,8 +297,8 @@ class TagHelper {
|
||||
}
|
||||
|
||||
static Map<String, dynamic> updateSubspaceTagModels(
|
||||
List<TagModel> updatedTags, List<SubspaceTemplateModel>? subspaces) {
|
||||
final result = TagHelper.updateTags<TagModel>(
|
||||
List<Tag> updatedTags, List<SubspaceTemplateModel>? subspaces) {
|
||||
final result = TagHelper.updateTags<Tag>(
|
||||
updatedTags: updatedTags,
|
||||
subspaces: subspaces,
|
||||
getInternalId: (tag) => tag.internalId,
|
||||
@ -311,7 +310,7 @@ class TagHelper {
|
||||
checkTagExistInSubspace: checkTagExistInSubspaceModels,
|
||||
);
|
||||
|
||||
final processedTags = result['updatedTags'] as List<TagModel>;
|
||||
final processedTags = result['updatedTags'] as List<Tag>;
|
||||
final processedSubspaces =
|
||||
List<SubspaceTemplateModel>.from(result['subspaces'] as List<dynamic>);
|
||||
|
||||
|
@ -28,10 +28,11 @@ class LinkSpaceToModelBloc
|
||||
try {
|
||||
BuildContext context = NavigationService.navigatorKey.currentContext!;
|
||||
var spaceBloc = context.read<SpaceTreeBloc>();
|
||||
spacesListIds.clear();
|
||||
for (var communityId in spaceBloc.state.selectedCommunities) {
|
||||
List<String> spacesList =
|
||||
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
|
||||
spacesListIds = spacesList;
|
||||
spacesListIds.addAll(spacesList);
|
||||
}
|
||||
hasSelectedSpaces =
|
||||
spaceBloc.state.selectedCommunities.any((communityId) {
|
||||
|
@ -5,6 +5,8 @@ abstract class LinkSpaceToModelState {
|
||||
class SpaceModelInitial extends LinkSpaceToModelState {}
|
||||
|
||||
class SpaceModelLoading extends LinkSpaceToModelState {}
|
||||
class LinkSpaceModelLoading extends LinkSpaceToModelState {}
|
||||
|
||||
|
||||
class SpaceModelSelectedState extends LinkSpaceToModelState {
|
||||
final int selectedIndex;
|
||||
|
@ -1,11 +1,11 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||
import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||
@ -94,14 +94,9 @@ class CreateSpaceModelBloc
|
||||
orElse: () => subspace,
|
||||
);
|
||||
|
||||
// Update the subspace's tags
|
||||
final eventTagIds = matchingEventSubspace.tags
|
||||
?.map((e) => e.internalId)
|
||||
.toSet() ??
|
||||
{};
|
||||
|
||||
final updatedTags = [
|
||||
...?subspace.tags?.map<TagModel>((tag) {
|
||||
...?subspace.tags?.map<Tag>((tag) {
|
||||
final matchingTag =
|
||||
matchingEventSubspace.tags?.firstWhere(
|
||||
(e) => e.internalId == tag.internalId,
|
||||
@ -112,14 +107,14 @@ class CreateSpaceModelBloc
|
||||
? tag.copyWith(tag: matchingTag?.tag)
|
||||
: tag;
|
||||
}) ??
|
||||
<TagModel>[],
|
||||
<Tag>[],
|
||||
...?matchingEventSubspace.tags?.where(
|
||||
(e) =>
|
||||
subspace.tags
|
||||
?.every((t) => t.internalId != e.internalId) ??
|
||||
true,
|
||||
) ??
|
||||
<TagModel>[],
|
||||
<Tag>[],
|
||||
];
|
||||
return subspace.copyWith(
|
||||
subspaceName: matchingEventSubspace.subspaceName,
|
||||
@ -244,7 +239,7 @@ class CreateSpaceModelBloc
|
||||
}
|
||||
|
||||
if (newSubspaces != null) {
|
||||
for (var newSubspace in newSubspaces!) {
|
||||
for (var newSubspace in newSubspaces) {
|
||||
// Tag without UUID
|
||||
if ((newSubspace.uuid == null || newSubspace.uuid!.isEmpty)) {
|
||||
final List<TagModelUpdate> tagUpdates = [];
|
||||
@ -253,7 +248,7 @@ class CreateSpaceModelBloc
|
||||
for (var tag in newSubspace.tags!) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: Action.add,
|
||||
uuid: tag.uuid == '' ? null : tag.uuid,
|
||||
newTagUuid: tag.uuid == '' ? null : tag.uuid,
|
||||
tag: tag.tag,
|
||||
productUuid: tag.product?.uuid));
|
||||
}
|
||||
@ -268,7 +263,7 @@ class CreateSpaceModelBloc
|
||||
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
final newSubspaceMap = {
|
||||
for (var subspace in newSubspaces!) subspace.uuid: subspace
|
||||
for (var subspace in newSubspaces) subspace.uuid: subspace
|
||||
};
|
||||
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
@ -309,8 +304,8 @@ class CreateSpaceModelBloc
|
||||
}
|
||||
|
||||
List<TagModelUpdate> processTagUpdates(
|
||||
List<TagModel>? prevTags,
|
||||
List<TagModel>? newTags,
|
||||
List<Tag>? prevTags,
|
||||
List<Tag>? newTags,
|
||||
) {
|
||||
final List<TagModelUpdate> tagUpdates = [];
|
||||
final processedTags = <String?>{};
|
||||
@ -320,7 +315,7 @@ class CreateSpaceModelBloc
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: Action.add,
|
||||
tag: newTag.tag,
|
||||
uuid: newTag.uuid,
|
||||
newTagUuid: newTag.uuid,
|
||||
productUuid: newTag.product?.uuid,
|
||||
));
|
||||
}
|
||||
@ -332,7 +327,7 @@ class CreateSpaceModelBloc
|
||||
if (prevTags != null && newTags != null) {
|
||||
for (var prevTag in prevTags) {
|
||||
final existsInNew =
|
||||
newTags!.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||
newTags.any((newTag) => newTag.uuid == prevTag.uuid);
|
||||
if (!existsInNew) {
|
||||
tagUpdates
|
||||
.add(TagModelUpdate(action: Action.delete, uuid: prevTag.uuid));
|
||||
@ -349,14 +344,14 @@ class CreateSpaceModelBloc
|
||||
if (newTags != null) {
|
||||
final prevTagUuids = prevTags?.map((t) => t.uuid).toSet() ?? {};
|
||||
|
||||
for (var newTag in newTags!) {
|
||||
for (var newTag in newTags) {
|
||||
// Tag without UUID
|
||||
if ((newTag.uuid == null || !prevTagUuids.contains(newTag.uuid)) &&
|
||||
!processedTags.contains(newTag.tag)) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: Action.add,
|
||||
tag: newTag.tag,
|
||||
uuid: newTag.uuid == '' ? null : newTag.uuid,
|
||||
newTagUuid: newTag.uuid == '' ? null : newTag.uuid,
|
||||
productUuid: newTag.product?.uuid));
|
||||
processedTags.add(newTag.tag);
|
||||
}
|
||||
@ -365,14 +360,15 @@ class CreateSpaceModelBloc
|
||||
|
||||
// Case 3: Tags updated
|
||||
if (prevTags != null && newTags != null) {
|
||||
final newTagMap = {for (var tag in newTags!) tag.uuid: tag};
|
||||
final newTagMap = {for (var tag in newTags) tag.uuid: tag};
|
||||
|
||||
for (var prevTag in prevTags!) {
|
||||
for (var prevTag in prevTags) {
|
||||
final newTag = newTagMap[prevTag.uuid];
|
||||
if (newTag != null) {
|
||||
tagUpdates.add(TagModelUpdate(
|
||||
action: Action.update,
|
||||
uuid: newTag.uuid,
|
||||
uuid: prevTag.uuid,
|
||||
newTagUuid: newTag.uuid,
|
||||
tag: newTag.tag,
|
||||
));
|
||||
} else {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
|
||||
abstract class CreateSpaceModelEvent extends Equatable {
|
||||
const CreateSpaceModelEvent();
|
||||
@ -49,7 +49,7 @@ class AddSubspacesToSpaceTemplate extends CreateSpaceModelEvent {
|
||||
}
|
||||
|
||||
class AddTagsToSpaceTemplate extends CreateSpaceModelEvent {
|
||||
final List<TagModel> tags;
|
||||
final List<Tag> tags;
|
||||
|
||||
AddTagsToSpaceTemplate(this.tags);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
@ -9,33 +9,30 @@ import 'package:syncrow_web/services/space_model_mang_api.dart';
|
||||
|
||||
class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||
final SpaceModelManagementApi api;
|
||||
final SpaceTreeBloc _spaceTreeBloc;
|
||||
|
||||
SpaceModelBloc({
|
||||
SpaceModelBloc(
|
||||
this._spaceTreeBloc, {
|
||||
required this.api,
|
||||
required List<SpaceTemplateModel> initialSpaceModels,
|
||||
}) : super(SpaceModelLoaded(spaceModels: initialSpaceModels)) {
|
||||
log('Initial Space Models in: ${initialSpaceModels.map((e) => e.toJson()).toList()}');
|
||||
|
||||
on<CreateSpaceModel>(_onCreateSpaceModel);
|
||||
on<UpdateSpaceModel>(_onUpdateSpaceModel);
|
||||
on<DeleteSpaceModel>(_onDeleteSpaceModel);
|
||||
}
|
||||
|
||||
Future<void> _onCreateSpaceModel(
|
||||
CreateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||
Future<void> _onCreateSpaceModel(CreateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||
final currentState = state;
|
||||
|
||||
if (currentState is SpaceModelLoaded) {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
final newSpaceModel = await api.getSpaceModel(
|
||||
event.newSpaceModel.uuid ?? '', projectUuid);
|
||||
final newSpaceModel = await api.getSpaceModel(event.newSpaceModel.uuid ?? '', projectUuid);
|
||||
|
||||
if (newSpaceModel != null) {
|
||||
final updatedSpaceModels =
|
||||
List<SpaceTemplateModel>.from(currentState.spaceModels)
|
||||
..add(newSpaceModel);
|
||||
final updatedSpaceModels = List<SpaceTemplateModel>.from(currentState.spaceModels)
|
||||
..add(newSpaceModel);
|
||||
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||
}
|
||||
} catch (e) {
|
||||
@ -44,19 +41,18 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onUpdateSpaceModel(
|
||||
UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||
Future<void> _onUpdateSpaceModel(UpdateSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||
final currentState = state;
|
||||
if (currentState is SpaceModelLoaded) {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
final newSpaceModel =
|
||||
await api.getSpaceModel(event.spaceModelUuid, projectUuid);
|
||||
final newSpaceModel = await api.getSpaceModel(event.spaceModelUuid, projectUuid);
|
||||
if (newSpaceModel != null) {
|
||||
final updatedSpaceModels = currentState.spaceModels.map((model) {
|
||||
return model.uuid == event.spaceModelUuid ? newSpaceModel : model;
|
||||
}).toList();
|
||||
_spaceTreeBloc.add(InitialEvent());
|
||||
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||
}
|
||||
} catch (e) {
|
||||
@ -65,22 +61,20 @@ class SpaceModelBloc extends Bloc<SpaceModelEvent, SpaceModelState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onDeleteSpaceModel(
|
||||
DeleteSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||
Future<void> _onDeleteSpaceModel(DeleteSpaceModel event, Emitter<SpaceModelState> emit) async {
|
||||
final currentState = state;
|
||||
|
||||
if (currentState is SpaceModelLoaded) {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
final deletedSuccessfully =
|
||||
await api.deleteSpaceModel(event.spaceModelUuid, projectUuid);
|
||||
final deletedSuccessfully = await api.deleteSpaceModel(event.spaceModelUuid, projectUuid);
|
||||
|
||||
if (deletedSuccessfully) {
|
||||
final updatedSpaceModels = currentState.spaceModels
|
||||
.where((model) => model.uuid != event.spaceModelUuid)
|
||||
.toList();
|
||||
|
||||
_spaceTreeBloc.add(InitialEvent());
|
||||
emit(SpaceModelLoaded(spaceModels: updatedSpaceModels));
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -6,7 +6,7 @@ class TagBodyModel {
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'uuid': uuid,
|
||||
'tag': tag,
|
||||
'name': tag,
|
||||
'productUuid': productUuid,
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||
import 'package:syncrow_web/utils/constants/action_enum.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@ -9,9 +9,9 @@ class SpaceTemplateModel extends Equatable {
|
||||
String? uuid;
|
||||
String modelName;
|
||||
List<SubspaceTemplateModel>? subspaceModels;
|
||||
final List<TagModel>? tags;
|
||||
final List<Tag>? tags;
|
||||
String internalId;
|
||||
String? createdAt;
|
||||
DateTime? createdAt;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [modelName, subspaceModels, tags];
|
||||
@ -24,24 +24,25 @@ class SpaceTemplateModel extends Equatable {
|
||||
this.tags,
|
||||
this.createdAt,
|
||||
}) : internalId = internalId ?? const Uuid().v4();
|
||||
|
||||
factory SpaceTemplateModel.fromJson(Map<String, dynamic> json) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
|
||||
return SpaceTemplateModel(
|
||||
uuid: json['uuid'] ?? '',
|
||||
createdAt: json['createdAt'] ?? '',
|
||||
createdAt: json['createdAt'] != null
|
||||
? DateTime.tryParse(json['createdAt'])
|
||||
: null,
|
||||
internalId: internalId,
|
||||
modelName: json['modelName'] ?? '',
|
||||
subspaceModels: (json['subspaceModels'] as List<dynamic>?)
|
||||
?.where((e) => e is Map<String, dynamic>) // Validate type
|
||||
?.where((e) => e is Map<String, dynamic>)
|
||||
.map((e) =>
|
||||
SubspaceTemplateModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
tags: (json['tags'] as List<dynamic>?)
|
||||
?.where((item) => item is Map<String, dynamic>) // Validate type
|
||||
.map((item) => TagModel.fromJson(item as Map<String, dynamic>))
|
||||
.map((item) => Tag.fromJson(item as Map<String, dynamic>))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
@ -50,7 +51,7 @@ class SpaceTemplateModel extends Equatable {
|
||||
String? uuid,
|
||||
String? modelName,
|
||||
List<SubspaceTemplateModel>? subspaceModels,
|
||||
List<TagModel>? tags,
|
||||
List<Tag>? tags,
|
||||
String? internalId,
|
||||
}) {
|
||||
return SpaceTemplateModel(
|
||||
|
@ -1,11 +1,11 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class SubspaceTemplateModel {
|
||||
final String? uuid;
|
||||
String subspaceName;
|
||||
final bool disabled;
|
||||
List<TagModel>? tags;
|
||||
List<Tag>? tags;
|
||||
String internalId;
|
||||
|
||||
SubspaceTemplateModel({
|
||||
@ -25,7 +25,7 @@ class SubspaceTemplateModel {
|
||||
internalId: internalId,
|
||||
disabled: json['disabled'] ?? false,
|
||||
tags: (json['tags'] as List<dynamic>?)
|
||||
?.map((item) => TagModel.fromJson(item))
|
||||
?.map((item) => Tag.fromJson(item))
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
@ -44,7 +44,7 @@ class SubspaceTemplateModel {
|
||||
String? uuid,
|
||||
String? subspaceName,
|
||||
bool? disabled,
|
||||
List<TagModel>? tags,
|
||||
List<Tag>? tags,
|
||||
String? internalId,
|
||||
}) {
|
||||
return SubspaceTemplateModel(
|
||||
|
@ -4,7 +4,7 @@ class CreateTagBodyModel {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'tag': tag,
|
||||
'name': tag,
|
||||
'productUuid': productUuid,
|
||||
};
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/base_tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class TagModel extends BaseTag {
|
||||
TagModel({
|
||||
String? uuid,
|
||||
required String? tag,
|
||||
ProductModel? product,
|
||||
String? internalId,
|
||||
String? location,
|
||||
}) : super(
|
||||
uuid: uuid,
|
||||
tag: tag,
|
||||
product: product,
|
||||
internalId: internalId,
|
||||
location: location,
|
||||
);
|
||||
factory TagModel.fromJson(Map<String, dynamic> json) {
|
||||
final String internalId = json['internalId'] ?? const Uuid().v4();
|
||||
|
||||
return TagModel(
|
||||
uuid: json['uuid'] ,
|
||||
internalId: internalId,
|
||||
tag: json['tag'] ?? '',
|
||||
product: json['product'] != null
|
||||
? ProductModel.fromMap(json['product'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
TagModel copyWith(
|
||||
{String? tag,
|
||||
ProductModel? product,
|
||||
String? uuid,
|
||||
String? location,
|
||||
String? internalId}) {
|
||||
return TagModel(
|
||||
tag: tag ?? this.tag,
|
||||
product: product ?? this.product,
|
||||
location: location ?? this.location,
|
||||
internalId: internalId ?? this.internalId,
|
||||
uuid:uuid?? this.uuid
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'uuid': uuid,
|
||||
'tag': tag,
|
||||
'product': product?.toMap(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
extension TagModelExtensions on TagModel {
|
||||
TagBodyModel toTagBodyModel() {
|
||||
return TagBodyModel()
|
||||
..uuid = uuid
|
||||
..tag = tag ?? ''
|
||||
..productUuid = product?.uuid;
|
||||
}
|
||||
}
|
@ -5,12 +5,14 @@ class TagModelUpdate {
|
||||
final String? uuid;
|
||||
final String? tag;
|
||||
final String? productUuid;
|
||||
final String? newTagUuid;
|
||||
|
||||
TagModelUpdate({
|
||||
required this.action,
|
||||
this.uuid,
|
||||
this.tag,
|
||||
this.productUuid,
|
||||
this.newTagUuid,
|
||||
});
|
||||
|
||||
factory TagModelUpdate.fromJson(Map<String, dynamic> json) {
|
||||
@ -26,9 +28,10 @@ class TagModelUpdate {
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'action': action.value,
|
||||
'uuid': uuid, // Nullable field
|
||||
'tag': tag,
|
||||
'tagUuid': uuid,
|
||||
'name': tag,
|
||||
'productUuid': productUuid,
|
||||
'newTagUuid': newTagUuid
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/space_model_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
@ -12,8 +13,10 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class SpaceModelPage extends StatelessWidget {
|
||||
final List<ProductModel>? products;
|
||||
final Function(List<SpaceTemplateModel>)? onSpaceModelsUpdated;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const SpaceModelPage({Key? key, this.products, this.onSpaceModelsUpdated})
|
||||
const SpaceModelPage(
|
||||
{Key? key, this.products, this.onSpaceModelsUpdated, required this.projectTags})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -60,6 +63,7 @@ class SpaceModelPage extends StatelessWidget {
|
||||
allTags: allTagValues,
|
||||
pageContext: context,
|
||||
otherSpaceModels: allSpaceModelNames,
|
||||
projectTags: projectTags,
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -69,8 +73,7 @@ class SpaceModelPage extends StatelessWidget {
|
||||
}
|
||||
// Render existing space model
|
||||
final model = spaceModels[index];
|
||||
final otherModel =
|
||||
List<String>.from(allSpaceModelNames);
|
||||
final otherModel = List<String>.from(allSpaceModelNames);
|
||||
otherModel.remove(model.modelName);
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
@ -84,6 +87,7 @@ class SpaceModelPage extends StatelessWidget {
|
||||
otherSpaceModels: otherModel,
|
||||
pageContext: context,
|
||||
allSpaceModels: spaceModels,
|
||||
projectTags: projectTags,
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -107,10 +111,8 @@ class SpaceModelPage extends StatelessWidget {
|
||||
return Center(
|
||||
child: Text(
|
||||
'Error: ${state.message}',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(color: ColorsManager.warningRed),
|
||||
style:
|
||||
Theme.of(context).textTheme.bodySmall?.copyWith(color: ColorsManager.warningRed),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/bloc/create_space_model_state.dart';
|
||||
@ -25,6 +26,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
final BuildContext? pageContext;
|
||||
final List<String>? otherSpaceModels;
|
||||
final List<SpaceTemplateModel>? allSpaceModels;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const CreateSpaceModelDialog(
|
||||
{Key? key,
|
||||
@ -33,7 +35,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
this.spaceModel,
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.allSpaceModels})
|
||||
this.allSpaceModels,
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -68,8 +71,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
|
||||
spaceNameController.addListener(() {
|
||||
bloc.add(UpdateSpaceTemplateName(
|
||||
name: spaceNameController.text,
|
||||
allModels: otherSpaceModels ?? []));
|
||||
name: spaceNameController.text, allModels: otherSpaceModels ?? []));
|
||||
});
|
||||
|
||||
return bloc;
|
||||
@ -87,9 +89,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
spaceModel?.uuid == null
|
||||
? 'Create New Space Model'
|
||||
: 'Edit Space Model',
|
||||
spaceModel?.uuid == null ? 'Create New Space Model' : 'Edit Space Model',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineLarge
|
||||
@ -101,10 +101,8 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
child: TextField(
|
||||
controller: spaceNameController,
|
||||
onChanged: (value) {
|
||||
context.read<CreateSpaceModelBloc>().add(
|
||||
UpdateSpaceTemplateName(
|
||||
name: value,
|
||||
allModels: otherSpaceModels ?? []));
|
||||
context.read<CreateSpaceModelBloc>().add(UpdateSpaceTemplateName(
|
||||
name: value, allModels: otherSpaceModels ?? []));
|
||||
},
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
@ -157,6 +155,7 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
pageContext: pageContext,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
allSpaceModels: allSpaceModels,
|
||||
projectTags: projectTags,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
SizedBox(
|
||||
@ -179,84 +178,55 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
!isNameValid)
|
||||
? null
|
||||
: () {
|
||||
final updatedSpaceTemplate =
|
||||
updatedSpaceModel.copyWith(
|
||||
modelName:
|
||||
spaceNameController.text.trim(),
|
||||
final updatedSpaceTemplate = updatedSpaceModel.copyWith(
|
||||
modelName: spaceNameController.text.trim(),
|
||||
);
|
||||
if (updatedSpaceModel.uuid == null) {
|
||||
context
|
||||
.read<CreateSpaceModelBloc>()
|
||||
.add(
|
||||
context.read<CreateSpaceModelBloc>().add(
|
||||
CreateSpaceTemplate(
|
||||
spaceTemplate:
|
||||
updatedSpaceTemplate,
|
||||
spaceTemplate: updatedSpaceTemplate,
|
||||
onCreate: (newModel) {
|
||||
if (pageContext != null) {
|
||||
pageContext!.read<SpaceModelBloc>().add(
|
||||
CreateSpaceModel(newSpaceModel: newModel));
|
||||
pageContext!
|
||||
.read<SpaceModelBloc>()
|
||||
.add(CreateSpaceModel(
|
||||
newSpaceModel:
|
||||
newModel));
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceManagementBloc>()
|
||||
.add(
|
||||
UpdateSpaceModelCache(
|
||||
newModel));
|
||||
.read<SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(newModel));
|
||||
}
|
||||
Navigator.of(context)
|
||||
.pop(); // Close the dialog
|
||||
Navigator.of(context).pop(); // Close the dialog
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (pageContext != null) {
|
||||
final currentState = pageContext!
|
||||
.read<SpaceModelBloc>()
|
||||
.state;
|
||||
if (currentState
|
||||
is SpaceModelLoaded) {
|
||||
final spaceModels =
|
||||
List<SpaceTemplateModel>.from(
|
||||
currentState.spaceModels);
|
||||
final currentState =
|
||||
pageContext!.read<SpaceModelBloc>().state;
|
||||
if (currentState is SpaceModelLoaded) {
|
||||
final spaceModels = List<SpaceTemplateModel>.from(
|
||||
currentState.spaceModels);
|
||||
|
||||
final SpaceTemplateModel?
|
||||
currentSpaceModel = spaceModels
|
||||
.cast<SpaceTemplateModel?>()
|
||||
.firstWhere(
|
||||
(sm) =>
|
||||
sm?.uuid ==
|
||||
updatedSpaceModel
|
||||
.uuid,
|
||||
final SpaceTemplateModel? currentSpaceModel =
|
||||
spaceModels.cast<SpaceTemplateModel?>().firstWhere(
|
||||
(sm) => sm?.uuid == updatedSpaceModel.uuid,
|
||||
orElse: () => null,
|
||||
);
|
||||
if (currentSpaceModel != null) {
|
||||
context
|
||||
.read<CreateSpaceModelBloc>()
|
||||
.add(ModifySpaceTemplate(
|
||||
spaceTemplate:
|
||||
currentSpaceModel,
|
||||
updatedSpaceTemplate:
|
||||
updatedSpaceTemplate,
|
||||
spaceTemplate: currentSpaceModel,
|
||||
updatedSpaceTemplate: updatedSpaceTemplate,
|
||||
onUpdate: (newModel) {
|
||||
if (pageContext !=
|
||||
null) {
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceModelBloc>()
|
||||
.add(UpdateSpaceModel(
|
||||
if (pageContext != null) {
|
||||
pageContext!.read<SpaceModelBloc>().add(
|
||||
UpdateSpaceModel(
|
||||
spaceModelUuid:
|
||||
newModel.uuid ??
|
||||
''));
|
||||
newModel.uuid ?? ''));
|
||||
pageContext!
|
||||
.read<
|
||||
SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(
|
||||
newModel));
|
||||
.read<SpaceManagementBloc>()
|
||||
.add(UpdateSpaceModelCache(newModel));
|
||||
}
|
||||
Navigator.of(context)
|
||||
.pop();
|
||||
Navigator.of(context).pop();
|
||||
}));
|
||||
}
|
||||
}
|
||||
@ -265,11 +235,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
},
|
||||
backgroundColor: ColorsManager.secondaryColor,
|
||||
borderRadius: 10,
|
||||
foregroundColor: ((state.errorMessage != null &&
|
||||
state.errorMessage != '') ||
|
||||
!isNameValid)
|
||||
? ColorsManager.whiteColorsWithOpacity
|
||||
: ColorsManager.whiteColors,
|
||||
foregroundColor:
|
||||
((state.errorMessage != null && state.errorMessage != '') ||
|
||||
!isNameValid)
|
||||
? ColorsManager.whiteColorsWithOpacity
|
||||
: ColorsManager.whiteColors,
|
||||
child: const Text('OK'),
|
||||
),
|
||||
),
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/link_space_model/bloc/link_space_to_model_event.dart';
|
||||
@ -45,6 +46,12 @@ class _LinkSpaceModelSpacesDialogState
|
||||
}
|
||||
|
||||
Widget _buildDialogContent() {
|
||||
widget.spaceModel.createdAt.toString();
|
||||
String formattedDate =
|
||||
DateFormat('yyyy-MM-dd').format(widget.spaceModel.createdAt!);
|
||||
String formattedTime =
|
||||
DateFormat('HH:mm:ss').format(widget.spaceModel.createdAt!);
|
||||
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
@ -75,8 +82,31 @@ class _LinkSpaceModelSpacesDialogState
|
||||
const SizedBox(height: 16),
|
||||
_buildDetailRow(
|
||||
"Space model name:", widget.spaceModel.modelName),
|
||||
_buildDetailRow("Creation date and time:",
|
||||
widget.spaceModel.createdAt.toString()),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
child: Text(
|
||||
"Creation date and time:",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"$formattedDate $formattedTime",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// _buildDetailRow("Creation date and time:",
|
||||
// widget.spaceModel.createdAt.toString()),
|
||||
_buildDetailRow("Created by:", "Admin"),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
|
@ -18,8 +18,10 @@ import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dynamic_
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dynamic_room_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
import 'package:syncrow_web/utils/string_utils.dart';
|
||||
|
||||
class SpaceModelCardWidget extends StatelessWidget {
|
||||
class SpaceModelCardWidget extends StatelessWidget with HelperResponsiveLayout {
|
||||
final SpaceTemplateModel model;
|
||||
final BuildContext? pageContext;
|
||||
final bool topActionsDisabled;
|
||||
@ -76,120 +78,109 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
model.modelName,
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
Expanded(
|
||||
child: Text(
|
||||
StringUtils.capitalizeFirstLetter(model.modelName),
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: isSmallScreenSize(context) ? 13 : 20,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return BlocProvider<LinkSpaceToModelBloc>(
|
||||
create: (_) => LinkSpaceToModelBloc(),
|
||||
child: BlocListener<LinkSpaceToModelBloc,
|
||||
LinkSpaceToModelState>(
|
||||
listener: (context, state) {
|
||||
final _bloc =
|
||||
BlocProvider.of<LinkSpaceToModelBloc>(
|
||||
context);
|
||||
if (state is SpaceModelLoading) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(20)),
|
||||
elevation: 10,
|
||||
backgroundColor: Colors.white,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
vertical: 30,
|
||||
horizontal: 50),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomLoadingIndicator(),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"Linking in progress",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight:
|
||||
FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (!topActionsDisabled)
|
||||
Row(
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return BlocProvider<LinkSpaceToModelBloc>(
|
||||
create: (_) => LinkSpaceToModelBloc(),
|
||||
child: BlocListener<LinkSpaceToModelBloc, LinkSpaceToModelState>(
|
||||
listenWhen: (previous, current) {
|
||||
return previous != current;
|
||||
},
|
||||
listener: (context, state) {
|
||||
final _bloc = BlocProvider.of<LinkSpaceToModelBloc>(context);
|
||||
if (state is SpaceModelLoading) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
elevation: 10,
|
||||
backgroundColor: Colors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 30, horizontal: 50),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CustomLoadingIndicator(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (state
|
||||
is AlreadyHaveLinkedState) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
showOverwriteDialog(
|
||||
context, _bloc, model);
|
||||
} else if (state
|
||||
is SpaceValidationSuccess) {
|
||||
_bloc.add(LinkSpaceModelEvent(
|
||||
isOverWrite: false,
|
||||
selectedSpaceMode: model.uuid));
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (state is AlreadyHaveLinkedState) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
showOverwriteDialog(context, _bloc, model);
|
||||
} else if (state is SpaceValidationSuccess) {
|
||||
_bloc.add(LinkSpaceModelEvent(
|
||||
isOverWrite: false, selectedSpaceMode: model.uuid));
|
||||
|
||||
Future.delayed(const Duration(seconds: 1),
|
||||
() {
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
});
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return const LinkingSuccessful();
|
||||
},
|
||||
).then((v) {
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2), () {
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
});
|
||||
});
|
||||
} else if (state is SpaceModelLinkSuccess) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return const LinkingSuccessful();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LinkSpaceModelSpacesDialog(
|
||||
spaceModel: model,
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return const LinkingSuccessful();
|
||||
},
|
||||
).then((v) {
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
});
|
||||
});
|
||||
} else if (state is SpaceModelLinkSuccess) {
|
||||
Navigator.of(dialogContext).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext successDialogContext) {
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
Navigator.of(successDialogContext).pop();
|
||||
});
|
||||
|
||||
return const LinkingSuccessful();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LinkSpaceModelSpacesDialog(
|
||||
spaceModel: model,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.spaceLinkIcon,
|
||||
fit: BoxFit.contain,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.spaceLinkIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (!topActionsDisabled)
|
||||
InkWell(
|
||||
onTap: () {
|
||||
_showDeleteDialog(context);
|
||||
@ -199,49 +190,8 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// model.modelName,
|
||||
// style:
|
||||
// Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
// color: Colors.black,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// maxLines: 1,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// ),
|
||||
// ),
|
||||
// if (!topActionsDisabled)
|
||||
// GestureDetector(
|
||||
// onTap: () => _showDeleteDialog(context),
|
||||
// child: Container(
|
||||
// width: 36, // Adjust size as needed
|
||||
// height: 36,
|
||||
// decoration: BoxDecoration(
|
||||
// shape: BoxShape.circle,
|
||||
// color: Colors.white,
|
||||
// boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withOpacity(0.1),
|
||||
// spreadRadius: 2,
|
||||
// blurRadius: 5,
|
||||
// offset: const Offset(0, 2),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// child: Center(
|
||||
// child: SvgPicture.asset(
|
||||
// Assets.deleteSpaceModel, // Your actual SVG path
|
||||
// width: 20,
|
||||
// height: 20,
|
||||
// colorFilter: const ColorFilter.mode(
|
||||
// Colors.grey, BlendMode.srcIn),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!showOnlyName) ...[
|
||||
@ -268,8 +218,7 @@ class SpaceModelCardWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (productTagCount.isNotEmpty &&
|
||||
model.subspaceModels != null)
|
||||
if (productTagCount.isNotEmpty && model.subspaceModels != null)
|
||||
Container(
|
||||
width: 1.0,
|
||||
color: ColorsManager.softGray,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/common/edit_chip.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/views/create_subspace_model_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/subspace_name_label_widget.dart';
|
||||
@ -10,9 +10,9 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
class SubspaceModelCreate extends StatefulWidget {
|
||||
final List<SubspaceTemplateModel> subspaces;
|
||||
final void Function(
|
||||
List<SubspaceTemplateModel> newSubspaces, List<TagModel>? tags)?
|
||||
List<SubspaceTemplateModel> newSubspaces, List<Tag>? tags)?
|
||||
onSpaceModelUpdate;
|
||||
final List<TagModel> tags;
|
||||
final List<Tag> tags;
|
||||
|
||||
const SubspaceModelCreate({
|
||||
Key? key,
|
||||
@ -28,7 +28,7 @@ class SubspaceModelCreate extends StatefulWidget {
|
||||
class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
|
||||
late List<SubspaceTemplateModel> _subspaces;
|
||||
String? errorSubspaceId;
|
||||
late List<TagModel> _tags;
|
||||
late List<Tag> _tags;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -117,7 +117,7 @@ class _SubspaceModelCreateState extends State<SubspaceModelCreate> {
|
||||
.where((s) => !updatedIds.contains(s.internalId))
|
||||
.toList();
|
||||
|
||||
final List<TagModel> tagsToAppendToSpace = [];
|
||||
final List<Tag> tagsToAppendToSpace = [];
|
||||
|
||||
for (var s in deletedSubspaces) {
|
||||
if (s.tags != null) {
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/common/edit_chip.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/assign_tag_models_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
@ -20,6 +21,7 @@ class TagChipDisplay extends StatelessWidget {
|
||||
final BuildContext? pageContext;
|
||||
final List<String>? otherSpaceModels;
|
||||
final List<SpaceTemplateModel>? allSpaceModels;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const TagChipDisplay(BuildContext context,
|
||||
{Key? key,
|
||||
@ -31,14 +33,14 @@ class TagChipDisplay extends StatelessWidget {
|
||||
required this.spaceNameController,
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.allSpaceModels})
|
||||
this.allSpaceModels,
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return (spaceModel?.tags?.isNotEmpty == true ||
|
||||
spaceModel?.subspaceModels
|
||||
?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||
spaceModel?.subspaceModels?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||
true)
|
||||
? SizedBox(
|
||||
width: screenWidth * 0.25,
|
||||
@ -59,8 +61,7 @@ class TagChipDisplay extends StatelessWidget {
|
||||
// Combine tags from spaceModel and subspaces
|
||||
...TagHelper.groupTags([
|
||||
...?spaceModel?.tags,
|
||||
...?spaceModel?.subspaceModels
|
||||
?.expand((subspace) => subspace.tags ?? [])
|
||||
...?spaceModel?.subspaceModels?.expand((subspace) => subspace.tags ?? [])
|
||||
]).entries.map(
|
||||
(entry) => Chip(
|
||||
avatar: SizedBox(
|
||||
@ -76,9 +77,7 @@ class TagChipDisplay extends StatelessWidget {
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color:
|
||||
ColorsManager.spaceColor),
|
||||
.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
@ -105,13 +104,12 @@ class TagChipDisplay extends StatelessWidget {
|
||||
spaceModel: spaceModel,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
initialTags: TagHelper.generateInitialTags(
|
||||
subspaces: subspaces,
|
||||
spaceTagModels: spaceModel?.tags ?? []),
|
||||
subspaces: subspaces, spaceTagModels: spaceModel?.tags ?? []),
|
||||
title: 'Edit Device',
|
||||
addedProducts:
|
||||
TagHelper.createInitialSelectedProducts(
|
||||
spaceModel?.tags ?? [], subspaces),
|
||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||
spaceModel?.tags ?? [], subspaces),
|
||||
spaceName: spaceModel?.modelName ?? '',
|
||||
projectTags: projectTags,
|
||||
));
|
||||
})
|
||||
],
|
||||
@ -134,6 +132,7 @@ class TagChipDisplay extends StatelessWidget {
|
||||
isCreate: true,
|
||||
spaceModel: spaceModel,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
projectTags: projectTags,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
|
||||
abstract class AddDeviceModelState extends Equatable {
|
||||
const AddDeviceModelState();
|
||||
@ -15,7 +15,7 @@ class AddDeviceModelLoading extends AddDeviceModelState {}
|
||||
|
||||
class AddDeviceModelLoaded extends AddDeviceModelState {
|
||||
final List<SelectedProduct> selectedProducts;
|
||||
final List<TagModel> initialTag;
|
||||
final List<Tag> initialTag;
|
||||
|
||||
const AddDeviceModelLoaded({
|
||||
required this.selectedProducts,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
|
||||
abstract class AddDeviceTypeModelEvent extends Equatable {
|
||||
const AddDeviceTypeModelEvent();
|
||||
@ -25,7 +25,7 @@ class UpdateProductCountEvent extends AddDeviceTypeModelEvent {
|
||||
|
||||
|
||||
class InitializeDeviceTypeModel extends AddDeviceTypeModelEvent {
|
||||
final List<TagModel> initialTags;
|
||||
final List<Tag> initialTags;
|
||||
final List<SelectedProduct> addedProducts;
|
||||
|
||||
const InitializeDeviceTypeModel({
|
||||
|
@ -2,13 +2,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/assign_tag_models/views/assign_tag_models_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/helper/tag_helper.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/dialog/create_space_model_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_model_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/tag_model/bloc/add_device_model_state.dart';
|
||||
@ -20,7 +20,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
final List<ProductModel>? products;
|
||||
final List<SelectedProduct>? initialSelectedProducts;
|
||||
final List<SubspaceTemplateModel>? subspaces;
|
||||
final List<TagModel>? spaceTagModels;
|
||||
final List<Tag>? spaceTagModels;
|
||||
final List<String>? allTags;
|
||||
final String spaceName;
|
||||
final bool isCreate;
|
||||
@ -28,6 +28,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
final BuildContext? pageContext;
|
||||
final SpaceTemplateModel? spaceModel;
|
||||
final List<SpaceTemplateModel>? allSpaceModels;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const AddDeviceTypeModelWidget(
|
||||
{super.key,
|
||||
@ -41,7 +42,8 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.spaceModel,
|
||||
this.allSpaceModels});
|
||||
this.allSpaceModels,
|
||||
required this.projectTags});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -78,8 +80,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: ScrollableGridViewWidget(
|
||||
isCreate: isCreate,
|
||||
products: products,
|
||||
@ -112,6 +113,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
allSpaceModels: allSpaceModels,
|
||||
products: products,
|
||||
allTags: allTags,
|
||||
projectTags: projectTags,
|
||||
pageContext: pageContext,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
spaceModel: SpaceTemplateModel(
|
||||
@ -137,6 +139,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
subspaces: subspaces,
|
||||
addedProducts: initialSelectedProducts ?? [],
|
||||
allTags: allTags,
|
||||
projectTags: projectTags,
|
||||
spaceName: spaceName,
|
||||
initialTags: initialTags,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
@ -149,11 +152,10 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
),
|
||||
SizedBox(
|
||||
width: 140,
|
||||
child:
|
||||
BlocBuilder<AddDeviceTypeModelBloc, AddDeviceModelState>(
|
||||
child: BlocBuilder<AddDeviceTypeModelBloc, AddDeviceModelState>(
|
||||
builder: (context, state) {
|
||||
final isDisabled = state is AddDeviceModelLoaded &&
|
||||
state.selectedProducts.isEmpty;
|
||||
final isDisabled =
|
||||
state is AddDeviceModelLoaded && state.selectedProducts.isEmpty;
|
||||
|
||||
return DefaultButton(
|
||||
backgroundColor: ColorsManager.secondaryColor,
|
||||
@ -166,15 +168,13 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
: () async {
|
||||
if (state is AddDeviceModelLoaded &&
|
||||
state.selectedProducts.isNotEmpty) {
|
||||
final initialTags =
|
||||
TagHelper.generateInitialTags(
|
||||
final initialTags = TagHelper.generateInitialTags(
|
||||
spaceTagModels: spaceTagModels,
|
||||
subspaces: subspaces,
|
||||
);
|
||||
|
||||
final dialogTitle = initialTags.isNotEmpty
|
||||
? 'Edit Device'
|
||||
: 'Assign Tags';
|
||||
final dialogTitle =
|
||||
initialTags.isNotEmpty ? 'Edit Device' : 'Assign Tags';
|
||||
Navigator.of(context).pop();
|
||||
await showDialog<bool>(
|
||||
context: context,
|
||||
@ -184,6 +184,7 @@ class AddDeviceTypeModelWidget extends StatelessWidget {
|
||||
subspaces: subspaces,
|
||||
addedProducts: state.selectedProducts,
|
||||
allTags: allTags,
|
||||
projectTags: projectTags,
|
||||
spaceName: spaceName,
|
||||
initialTags: initialTags,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
|
@ -9,10 +9,10 @@ import 'package:syncrow_web/pages/device_managment/water_heater/models/schedule_
|
||||
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
|
||||
import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||
|
||||
class DevicesManagementApi {
|
||||
Future<List<AllDevicesModel>> fetchDevices(String communityId, String spaceId, String projectId) async {
|
||||
Future<List<AllDevicesModel>> fetchDevices(
|
||||
String communityId, String spaceId, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: communityId.isNotEmpty && spaceId.isNotEmpty
|
||||
@ -23,8 +23,9 @@ class DevicesManagementApi {
|
||||
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData =
|
||||
communityId.isNotEmpty && spaceId.isNotEmpty ? json['data'] : json;
|
||||
List<dynamic> jsonData = communityId.isNotEmpty && spaceId.isNotEmpty
|
||||
? json['data']
|
||||
: json;
|
||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||
return AllDevicesModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -33,7 +34,7 @@ class DevicesManagementApi {
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching $e');
|
||||
debugPrint('fetchDevices Error fetching $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -92,7 +93,8 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deviceBatchControl(List<String> uuids, String code, dynamic value) async {
|
||||
Future<bool> deviceBatchControl(
|
||||
List<String> uuids, String code, dynamic value) async {
|
||||
try {
|
||||
final body = {
|
||||
'devicesUuid': uuids,
|
||||
@ -116,7 +118,8 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
@ -150,7 +153,9 @@ class DevicesManagementApi {
|
||||
String code,
|
||||
) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDeviceLogs.replaceAll('{uuid}', uuid).replaceAll('{code}', code),
|
||||
path: ApiEndpoints.getDeviceLogs
|
||||
.replaceAll('{uuid}', uuid)
|
||||
.replaceAll('{code}', code),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
@ -223,7 +228,8 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> addScheduleRecord(ScheduleEntry sendSchedule, String uuid) async {
|
||||
Future<bool> addScheduleRecord(
|
||||
ScheduleEntry sendSchedule, String uuid) async {
|
||||
try {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
||||
@ -240,7 +246,8 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ScheduleModel>> getDeviceSchedules(String uuid, String category) async {
|
||||
Future<List<ScheduleModel>> getDeviceSchedules(
|
||||
String uuid, String category) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getScheduleByDeviceId
|
||||
@ -263,7 +270,9 @@ class DevicesManagementApi {
|
||||
}
|
||||
|
||||
Future<bool> updateScheduleRecord(
|
||||
{required bool enable, required String uuid, required String scheduleId}) async {
|
||||
{required bool enable,
|
||||
required String uuid,
|
||||
required String scheduleId}) async {
|
||||
try {
|
||||
final response = await HTTPService().put(
|
||||
path: ApiEndpoints.updateScheduleByDeviceId
|
||||
@ -284,7 +293,8 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> editScheduleRecord(String uuid, ScheduleEntry newSchedule) async {
|
||||
Future<bool> editScheduleRecord(
|
||||
String uuid, ScheduleEntry newSchedule) async {
|
||||
try {
|
||||
final response = await HTTPService().put(
|
||||
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/automation_scene_trigger_bloc/automation_status_update.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/create_scene_and_autoamtion/create_scene_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/icon_model.dart';
|
||||
@ -6,7 +7,6 @@ import 'package:syncrow_web/pages/routines/models/routine_details_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/routine_model.dart';
|
||||
import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||
|
||||
class SceneApi {
|
||||
static final HTTPService _httpService = HTTPService();
|
||||
@ -35,10 +35,11 @@ class SceneApi {
|
||||
//
|
||||
// create automation
|
||||
static Future<Map<String, dynamic>> createAutomation(
|
||||
CreateAutomationModel createAutomationModel) async {
|
||||
CreateAutomationModel createAutomationModel, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.createAutomation,
|
||||
path:
|
||||
ApiEndpoints.createAutomation.replaceAll('{projectId}', projectId),
|
||||
body: createAutomationModel.toMap(),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
@ -99,11 +100,14 @@ class SceneApi {
|
||||
|
||||
//getAutomation
|
||||
|
||||
static Future<List<ScenesModel>> getAutomation(String spaceId) async {
|
||||
static Future<List<ScenesModel>> getAutomation(
|
||||
String spaceId, String communityId, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path:
|
||||
ApiEndpoints.getSpaceAutomation.replaceAll('{spaceUuid}', spaceId),
|
||||
path: ApiEndpoints.getSpaceAutomation
|
||||
.replaceAll('{spaceUuid}', spaceId)
|
||||
.replaceAll('{communityId}', communityId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<ScenesModel> scenes = [];
|
||||
@ -134,11 +138,12 @@ class SceneApi {
|
||||
|
||||
//automation details
|
||||
static Future<RoutineDetailsModel> getAutomationDetails(
|
||||
String automationId) async {
|
||||
String automationId, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getAutomationDetails
|
||||
.replaceAll('{automationId}', automationId),
|
||||
.replaceAll('{automationId}', automationId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => RoutineDetailsModel.fromMap(json),
|
||||
);
|
||||
@ -166,12 +171,13 @@ class SceneApi {
|
||||
}
|
||||
|
||||
//update automation
|
||||
static updateAutomation(
|
||||
CreateAutomationModel createAutomationModel, String automationId) async {
|
||||
static updateAutomation(CreateAutomationModel createAutomationModel,
|
||||
String automationId, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.updateAutomation
|
||||
.replaceAll('{automationId}', automationId),
|
||||
.replaceAll('{automationId}', automationId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
body: createAutomationModel
|
||||
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||
expectedResponseModel: (json) {
|
||||
@ -218,12 +224,14 @@ class SceneApi {
|
||||
|
||||
// delete automation
|
||||
static Future<bool> deleteAutomation(
|
||||
{required String unitUuid, required String automationId}) async {
|
||||
{required String unitUuid,
|
||||
required String automationId,
|
||||
required String projectId}) async {
|
||||
try {
|
||||
final response = await _httpService.delete(
|
||||
path: ApiEndpoints.deleteAutomation
|
||||
.replaceAll('{automationId}', automationId)
|
||||
.replaceAll('{unitUuid}', unitUuid),
|
||||
.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json['statusCode'] == 200,
|
||||
);
|
||||
@ -232,4 +240,59 @@ class SceneApi {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> updateAutomationStatus(String automationId,
|
||||
AutomationStatusUpdate createAutomationEnable, String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.patch(
|
||||
path: ApiEndpoints.updateAutomationStatus
|
||||
.replaceAll('{automationId}', automationId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
body: createAutomationEnable.toMap(),
|
||||
expectedResponseModel: (json) => json['success'],
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> triggerScene(String sceneId) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.triggerScene.replaceAll('{sceneId}', sceneId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json['success'],
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<ScenesModel>> getAutomationByUnitId(
|
||||
String unitId,
|
||||
String communityId,
|
||||
String projectId,
|
||||
) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUnitAutomation
|
||||
.replaceAll('{unitUuid}', unitId)
|
||||
.replaceAll('{communityId}', communityId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<ScenesModel> scenes = [];
|
||||
for (var scene in json) {
|
||||
scenes.add(ScenesModel.fromJson(scene));
|
||||
}
|
||||
return scenes;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,6 +227,7 @@ class CommunitySpaceManagementApi {
|
||||
required Offset position,
|
||||
List<TagModelUpdate>? tags,
|
||||
List<UpdateSubspaceTemplateModel>? subspaces,
|
||||
String? spaceModelUuid,
|
||||
required String projectId}) async {
|
||||
try {
|
||||
final body = {
|
||||
@ -238,6 +239,7 @@ class CommunitySpaceManagementApi {
|
||||
'icon': icon,
|
||||
'subspace': subspaces,
|
||||
'tags': tags,
|
||||
'spaceModelUuid': spaceModelUuid,
|
||||
};
|
||||
if (parentId != null) {
|
||||
body['parentUuid'] = parentId;
|
||||
@ -300,4 +302,24 @@ class CommunitySpaceManagementApi {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Future<List<SpaceModel>> getSpaceOnlyWithDevices(
|
||||
{String? communityId, String? projectId}) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.spaceOnlyWithDevices
|
||||
.replaceAll('{communityId}', communityId!)
|
||||
.replaceAll('{projectId}', projectId!),
|
||||
expectedResponseModel: (json) {
|
||||
final spaceModels = (json['data'] as List)
|
||||
.map((spaceJson) => SpaceModel.fromJson(spaceJson))
|
||||
.toList();
|
||||
return spaceModels;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching space hierarchy: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/services/api/http_service.dart';
|
||||
@ -32,8 +33,8 @@ class SpaceModelManagementApi {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<String?> updateSpaceModel(CreateSpaceTemplateBodyModel spaceModel,
|
||||
String spaceModelUuid, String projectId) async {
|
||||
Future<String?> updateSpaceModel(
|
||||
CreateSpaceTemplateBodyModel spaceModel, String spaceModelUuid, String projectId) async {
|
||||
final response = await HTTPService().put(
|
||||
path: ApiEndpoints.updateSpaceModel
|
||||
.replaceAll('{projectId}', projectId)
|
||||
@ -46,8 +47,7 @@ class SpaceModelManagementApi {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<SpaceTemplateModel?> getSpaceModel(
|
||||
String spaceModelUuid, String projectId) async {
|
||||
Future<SpaceTemplateModel?> getSpaceModel(String spaceModelUuid, String projectId) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getSpaceModel
|
||||
.replaceAll('{projectId}', projectId)
|
||||
@ -102,4 +102,17 @@ class SpaceModelManagementApi {
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<List<Tag>> listTags({required String projectId}) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.listTags.replaceAll('{projectId}', projectId),
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json['data'];
|
||||
return jsonData.map((jsonItem) {
|
||||
return Tag.fromJson(jsonItem);
|
||||
}).toList();
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|