Compare commits

..

66 Commits

Author SHA1 Message Date
47f1a9a6cd push 3G glass switches 2024-10-04 17:40:52 +03:00
7661f54427 push 1G , 2G glass switches 2024-10-04 17:07:00 +03:00
4fabbf7a77 Merge pull request #30 from SyncrowIOT/sep_bug_fixes2
Sep bug fixes2
2024-10-02 10:40:25 +03:00
30dd3a1ee2 push ac schedule ac fake design 2024-10-02 02:54:18 +03:00
9dbf4b0540 push batch door sensor, design bugs 2024-10-02 01:41:15 +03:00
05d027f8ff Merge pull request #29 from SyncrowIOT/sep_bug_fixes2
schedule bug fixes,  icons and design fixes
2024-10-01 10:28:57 +03:00
0d49ad5106 change themostat widget 2024-10-01 00:32:17 +03:00
9e5d5c0d84 push bug fixes 2024-10-01 00:27:03 +03:00
92d32e4d84 push bug fixes 2024-09-30 19:55:25 +03:00
0731507d3b Merge pull request #28 from SyncrowIOT/sep_bug_fixes
Sep bug fixes
2024-09-25 00:25:28 +03:00
58938d4598 Added syncrow icons, changed the description, increased the width of the control button 2024-09-25 00:23:47 +03:00
e690ddc23a push selectAll bug, design and icons fixes 2024-09-24 22:10:36 +03:00
215fe60bc0 Merge pull request #27 from SyncrowIOT/schedual_view
Schedual view
2024-09-24 12:31:39 +03:00
6568b26cb1 push centered 2 gang switch 2024-09-24 11:01:45 +03:00
d47b0f4c71 push schedules active enable api 2024-09-24 10:45:17 +03:00
f3f6369237 push schedule apis 2024-09-24 00:51:13 +03:00
18265e7b06 Merge pull request #26 from SyncrowIOT/schedual_view
Schedual view
2024-09-23 11:51:05 +03:00
6e3ad984e1 change timer picker theme color 2024-09-23 09:22:32 +03:00
0c530e9ea6 push water heater batch control view 2024-09-23 08:32:49 +03:00
b5eeeedcd2 push ac temp step amount and main door icons 2024-09-23 07:29:04 +03:00
2955533209 push factory reset logic and call for all devices 2024-09-22 21:56:17 +03:00
3a28f0ef9a refactor schedule view and cleaning 2024-09-22 20:47:34 +03:00
b3d891b2c8 add the delete api 2024-09-22 14:51:15 +03:00
f99744338c connecting apis and changes the table design to match figma 2024-09-22 14:17:52 +03:00
66f45721e5 working on schedual table 2024-09-22 00:16:44 +03:00
921ccf0132 push schedule basic design and bloc manegment 2024-09-20 02:27:07 +03:00
26816b99cd push countdown logic 2024-09-20 00:41:59 +03:00
facdef4741 Merge pull request #25 from SyncrowIOT/batch_control
Batch control
2024-09-19 10:24:57 +03:00
adf553ee9e Commented out a line in water heater bloc 2024-09-19 10:18:40 +03:00
f2504e5f67 add reset event 2024-09-19 09:41:23 +03:00
b3807f2980 push save and stop buttons 2024-09-19 01:31:52 +03:00
ba95f6774b push schedual counddown design 2024-09-18 21:29:02 +03:00
536ac8857e push notification dialog design 2024-09-18 18:01:22 +03:00
619d964cd7 push curtain batch control 2024-09-18 15:08:43 +03:00
6d805ddfd7 push one gang switch 2024-09-18 14:33:01 +03:00
bc309adba7 push 2 G switch batch control 2024-09-18 14:25:52 +03:00
67667e4405 push 3 gang batch control 2024-09-18 14:09:23 +03:00
c354abbeca push wall sensor batch control 2024-09-18 13:55:36 +03:00
fd09db6835 push ceiling sensor batch control 2024-09-18 13:15:43 +03:00
abb0a58468 push ac batch control 2024-09-18 12:27:00 +03:00
7c28012d79 connect reports to main door 2024-09-18 02:23:42 +03:00
9876ff2e03 push main door device design 2024-09-18 01:36:17 +03:00
7d5b5340db push water heater single control 2024-09-18 00:30:03 +03:00
185d94d800 merge with dev 2024-09-17 23:42:13 +03:00
db7a072ecf wokring on connecting batch api 2024-09-17 23:41:22 +03:00
bcd49ad0e8 Merge pull request #23 from SyncrowIOT/sp_462
Authorizer search field & Date-Time Filters & Update Table View Columns
2024-09-17 14:35:20 +03:00
3c8d3feba3 start working on scheduling 2024-09-17 01:28:35 +03:00
e577cd3279 schedual asset 2024-09-17 01:07:26 +03:00
60b51657a6 working on water heater 2024-09-17 00:22:51 +03:00
b18b96064a push 1g, 2g 2024-09-16 11:03:40 +03:00
b513f31214 push 1gang and 2 gang, better naming 2024-09-15 23:21:06 +03:00
7c97d01ddb Authorizer search field & Date-Time Filters & Update Table View Columns 2024-09-12 14:54:04 +03:00
28ec5beac9 Hide the sidebar 2024-09-12 14:47:15 +03:00
46691dfff6 Merge pull request #22 from SyncrowIOT/fix_hour_picker_dialog
new HourPicker
2024-09-12 14:27:09 +03:00
0ac3e79c30 new HourPicker 2024-09-12 14:18:53 +03:00
ebd92c1011 push ceiling sensor batch 2024-09-12 13:49:40 +03:00
b4932c644e push wall sensor 2024-09-12 13:41:13 +03:00
222331f107 ac batch control design 2024-09-12 11:49:57 +03:00
3171916faf curtain batch control design 2024-09-12 11:21:51 +03:00
28579e0778 push door lock and living room batch design 2024-09-12 11:07:50 +03:00
dbb3450c32 new HourPicker 2024-09-11 16:04:54 +03:00
c3d8e6a52e add batch controll box selection logic 2024-09-11 00:27:51 +03:00
8c3df39cf4 fix changes 2024-09-09 12:44:55 +03:00
7f862fac2a fix changes 2024-09-09 14:51:06 +03:00
770db5383b fix changes 2024-09-09 13:36:26 +03:00
eddd4828bb Merge pull request #18 from SyncrowIOT/web_changes_1
fix changes
2024-09-09 13:12:22 +03:00
155 changed files with 9565 additions and 552 deletions

View File

@ -1,7 +1,5 @@
# syncrow_web
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.

5
assets/icons/ac_lock.svg Normal file
View File

@ -0,0 +1,5 @@
<svg width="25" height="35" viewBox="0 0 25 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.3952 0C7.16271 0.00642578 2.92244 4.24662 2.91602 9.47919V15.3125C2.91602 15.7152 3.2425 16.0417 3.64521 16.0417H6.5619C6.9646 16.0417 7.29109 15.7152 7.29109 15.3125V9.47919C7.29102 6.66019 9.57627 4.375 12.3952 4.375C15.2141 4.375 17.4994 6.66019 17.4994 9.47919V15.3125C17.4994 15.7152 17.8259 16.0417 18.2286 16.0417H21.1452C21.5479 16.0417 21.8744 15.7152 21.8744 15.3125V9.47919C21.868 4.24662 17.6277 0.00642578 12.3952 0Z" fill="#455A64"/>
<path d="M3.64581 14.5833H21.1458C23.1593 14.5833 24.7916 16.2155 24.7916 18.2291V31.3541C24.7916 33.3677 23.1593 34.9999 21.1458 34.9999H3.64581C1.63229 34.9999 0 33.3677 0 31.3541V18.2291C0 16.2155 1.63229 14.5833 3.64581 14.5833Z" fill="#2F66D3"/>
<path d="M16.0417 22.6041C16.0501 20.5906 14.4248 18.9514 12.4112 18.9429C10.3977 18.9344 8.75851 20.5598 8.75003 22.5733C8.74415 23.9651 9.53118 25.2388 10.7785 25.8562L10.2156 29.7937C10.1592 30.1924 10.4367 30.5613 10.8355 30.6177C10.8692 30.6225 10.9034 30.6249 10.9375 30.6249H13.8542C14.2569 30.629 14.5866 30.3059 14.5907 29.9032C14.591 29.8661 14.5886 29.8289 14.5833 29.7922L14.0203 25.8547C15.2524 25.2381 16.0337 23.9817 16.0417 22.6041Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,28 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.6724 33.345C25.8803 33.345 33.3447 25.8805 33.3447 16.6726C33.3447 7.46472 25.8803 0.000244141 16.6724 0.000244141C7.46448 0.000244141 0 7.46472 0 16.6726C0 25.8805 7.46448 33.345 16.6724 33.345Z" fill="#F07281"/>
<path d="M17.3767 33.3303C17.1436 33.3401 16.9084 33.345 16.6725 33.345C7.46478 33.345 0 25.8802 0 16.6725C0 7.46478 7.46478 0 16.6725 0C16.9084 0 17.1436 0.00492188 17.3767 0.0147656C8.4957 0.38377 1.40841 7.70068 1.40841 16.6725C1.40841 25.6443 8.4957 32.9613 17.3767 33.3303Z" fill="#EB5569"/>
<path d="M16.6726 31.1577C24.6725 31.1577 31.1577 24.6725 31.1577 16.6726C31.1577 8.67269 24.6725 2.1875 16.6726 2.1875C8.67269 2.1875 2.1875 8.67269 2.1875 16.6726C2.1875 24.6725 8.67269 31.1577 16.6726 31.1577Z" fill="#EAF6FF"/>
<path d="M17.7291 31.1197C17.3805 31.145 17.0276 31.1577 16.6727 31.1577C8.67269 31.1577 2.1875 24.6725 2.1875 16.6725C2.1875 8.67244 8.67275 2.18726 16.6728 2.18726C17.0277 2.18726 17.3805 2.1999 17.7291 2.22526C10.2221 2.76619 4.30022 9.02743 4.30022 16.6725C4.30022 24.3175 10.2221 30.5788 17.7291 31.1197Z" fill="#D8ECFE"/>
<path d="M15.7672 8.23932L16.4138 7.82301C16.5715 7.72143 16.7741 7.72143 16.9319 7.82301L17.5785 8.23932C17.6957 8.31479 17.7666 8.44474 17.7666 8.58419V16.8661H15.5791V8.58419C15.579 8.44474 15.6499 8.31486 15.7672 8.23932Z" fill="#5680A6"/>
<path d="M17.377 8.10996L16.9876 8.36063V16.8662H15.5791V8.62163C15.5791 8.45893 15.6617 8.30738 15.7985 8.21933L16.4136 7.82326C16.5714 7.72167 16.774 7.72167 16.9318 7.82326L17.377 8.10996Z" fill="#497090"/>
<path d="M23.5067 16.9316L23.1106 17.5467C23.0225 17.6835 22.871 17.7662 22.7083 17.7662H16.6729V15.5789H22.7083C22.871 15.5789 23.0225 15.6615 23.1106 15.7983L23.5067 16.4135C23.6083 16.5712 23.6083 16.7738 23.5067 16.9316Z" fill="#5680A6"/>
<path d="M19.6131 16.6725C19.6131 17.0591 19.5384 17.4281 19.4018 17.7662H16.6729V15.5789H19.4018C19.5384 15.9169 19.6131 16.2859 19.6131 16.6725Z" fill="#497090"/>
<path d="M16.6723 18.2039C17.5182 18.2039 18.2039 17.5182 18.2039 16.6723C18.2039 15.8264 17.5182 15.1406 16.6723 15.1406C15.8264 15.1406 15.1406 15.8264 15.1406 16.6723C15.1406 17.5182 15.8264 18.2039 16.6723 18.2039Z" fill="#F07281"/>
<path d="M17.3765 18.0323C17.166 18.1422 16.9265 18.2042 16.6723 18.2042C15.8265 18.2042 15.1406 17.5183 15.1406 16.6725C15.1406 15.8268 15.8265 15.1409 16.6723 15.1409C16.9265 15.1409 17.166 15.2029 17.3765 15.3127C16.885 15.567 16.549 16.081 16.549 16.6726C16.549 17.2642 16.885 17.7781 17.3765 18.0323Z" fill="#EB5569"/>
<path d="M34.5329 28.7151V27.6225C34.5329 27.4043 34.3853 27.2137 34.174 27.1592L32.9876 26.853C32.8555 26.3207 32.6457 25.8193 32.37 25.3617L32.9923 24.3064C33.1032 24.1184 33.0728 23.8793 32.9185 23.7249L32.1459 22.9523C31.9916 22.798 31.7524 22.7676 31.5644 22.8785L30.5091 23.5008C30.0516 23.2251 29.5501 23.0153 29.0178 22.8832L28.7116 21.6968C28.6571 21.4855 28.4665 21.3379 28.2483 21.3379H27.1557C26.9375 21.3379 26.7469 21.4855 26.6924 21.6968L26.3862 22.8832C25.8539 23.0153 25.3525 23.2252 24.8949 23.5008L23.8396 22.8785C23.6516 22.7676 23.4125 22.798 23.2581 22.9523L22.4855 23.7249C22.3313 23.8792 22.3009 24.1184 22.4117 24.3064L23.0341 25.3617C22.7583 25.8193 22.5485 26.3207 22.4164 26.853L21.23 27.1592C21.0188 27.2137 20.8711 27.4043 20.8711 27.6225V28.7151C20.8711 28.9333 21.0188 29.1239 21.23 29.1784L22.4164 29.4846C22.5485 30.0169 22.7584 30.5183 23.0341 30.9759L22.4117 32.0312C22.3008 32.2192 22.3313 32.4583 22.4855 32.6127L23.2581 33.3853C23.4124 33.5396 23.6516 33.5699 23.8396 33.4591L24.8949 32.8368C25.3525 33.1125 25.8539 33.3223 26.3862 33.4544L26.6924 34.6408C26.7469 34.8521 26.9375 34.9997 27.1557 34.9997H28.2483C28.4665 34.9997 28.6571 34.8521 28.7116 34.6408L29.0178 33.4544C29.5501 33.3223 30.0516 33.1124 30.5091 32.8368L31.5644 33.4591C31.7524 33.57 31.9915 33.5396 32.1459 33.3853L32.9185 32.6127C33.0728 32.4584 33.1031 32.2192 32.9923 32.0312L32.37 30.9759C32.6457 30.5183 32.8555 30.0169 32.9876 29.4846L34.174 29.1784C34.3853 29.1239 34.5329 28.9333 34.5329 28.7151Z" fill="#88B4F5"/>
<path d="M22.2796 27.252V29.0858L23.8246 29.4844C23.9563 30.0168 24.1662 30.5182 24.4423 30.976L23.6317 32.3506L24.4057 33.1246L23.8391 33.4588C23.6511 33.5696 23.4119 33.5393 23.2576 33.3849L22.4853 32.6127C22.331 32.4584 22.3007 32.2192 22.4115 32.0313L23.0338 30.976C22.7577 30.5182 22.5479 30.0168 22.4162 29.4844L21.23 29.1784C21.0187 29.124 20.8711 28.9333 20.8711 28.7151V27.6226C20.8711 27.4044 21.0187 27.2139 21.2299 27.1593L22.4162 26.8527C22.5479 26.321 22.7577 25.8189 23.0338 25.3619L22.4115 24.3064C22.3007 24.1185 22.331 23.8794 22.4853 23.7251L23.2577 22.9523C23.4119 22.7978 23.6512 22.7675 23.8392 22.8784L24.4057 23.2125L23.6317 23.9872L24.4423 25.3619C24.1662 25.8189 23.9564 26.321 23.8246 26.8527L22.2796 27.252Z" fill="#6EA2F2"/>
<path d="M27.7946 33.4542L28.1932 35H27.1555C26.9372 35 26.7466 34.8523 26.6921 34.6409L26.3861 33.4542C26.1361 33.393 25.8924 33.3134 25.6572 33.2176L26.303 32.8367C26.7608 33.1126 27.2622 33.3225 27.7946 33.4542Z" fill="#6EA2F2"/>
<path d="M27.1555 21.3379H28.1932L27.7946 22.883C27.2622 23.0154 26.7608 23.2252 26.303 23.5006L25.6572 23.1196C25.8925 23.0245 26.1361 22.945 26.3861 22.883L26.6921 21.6969C26.7466 21.4855 26.9373 21.3379 27.1555 21.3379Z" fill="#6EA2F2"/>
<path d="M27.7023 31.4612C29.5205 31.4612 30.9944 29.9873 30.9944 28.1691C30.9944 26.3509 29.5205 24.877 27.7023 24.877C25.8841 24.877 24.4102 26.3509 24.4102 28.1691C24.4102 29.9873 25.8841 31.4612 27.7023 31.4612Z" fill="#5680A6"/>
<path d="M28.7581 31.2882C28.4264 31.4009 28.0707 31.4615 27.7017 31.4615C25.8841 31.4615 24.4102 29.9875 24.4102 28.1692C24.4102 26.3509 25.8841 24.877 27.7017 24.877C28.0707 24.877 28.4263 24.9375 28.7581 25.0502C27.4588 25.4903 26.5229 26.7206 26.5229 28.1692C26.5229 29.6178 27.4588 30.8481 28.7581 31.2882Z" fill="#497090"/>
<path d="M16.6727 6.19289C16.381 6.19289 16.1445 5.95644 16.1445 5.66475V4.30036C16.1445 4.00867 16.381 3.77222 16.6727 3.77222C16.9644 3.77222 17.2008 4.00867 17.2008 4.30036V5.66468C17.2008 5.95637 16.9644 6.19289 16.6727 6.19289Z" fill="#88B4F5"/>
<path d="M16.6727 29.5729C16.381 29.5729 16.1445 29.3365 16.1445 29.0448V27.6805C16.1445 27.3888 16.381 27.1523 16.6727 27.1523C16.9644 27.1523 17.2008 27.3888 17.2008 27.6805V29.0448C17.2008 29.3364 16.9644 29.5729 16.6727 29.5729Z" fill="#88B4F5"/>
<path d="M5.66492 17.2006H4.30061C4.00892 17.2006 3.77246 16.9641 3.77246 16.6724C3.77246 16.3807 4.00892 16.1443 4.30061 16.1443H5.66492C5.95661 16.1443 6.19307 16.3807 6.19307 16.6724C6.19307 16.9641 5.95661 17.2006 5.66492 17.2006Z" fill="#88B4F5"/>
<path d="M29.0448 17.2006H27.6805C27.3887 17.2006 27.1523 16.9641 27.1523 16.6724C27.1523 16.3807 27.3888 16.1443 27.6805 16.1443H29.0448C29.3366 16.1443 29.5729 16.3807 29.5729 16.6724C29.5729 16.9641 29.3365 17.2006 29.0448 17.2006Z" fill="#88B4F5"/>
<path d="M5.95843 23.3868C5.77591 23.3868 5.59838 23.2921 5.50056 23.1226C5.35468 22.87 5.44122 22.547 5.69388 22.4012L6.8754 21.719C7.12785 21.5733 7.45099 21.6597 7.59687 21.9123C7.74275 22.1649 7.6562 22.488 7.40355 22.6338L6.22202 23.3159C6.1389 23.364 6.04805 23.3868 5.95843 23.3868Z" fill="#88B4F5"/>
<path d="M26.2065 11.6969C26.0239 11.6969 25.8464 11.6022 25.7486 11.4327C25.6027 11.1801 25.6893 10.8571 25.9419 10.7113L27.1234 10.0291C27.376 9.88328 27.699 9.96976 27.8449 10.2224C27.9908 10.475 27.9042 10.7981 27.6516 10.9439L26.4701 11.626C26.3869 11.6741 26.296 11.6969 26.2065 11.6969Z" fill="#88B4F5"/>
<path d="M7.139 11.6967C7.04938 11.6967 6.9586 11.6739 6.8754 11.6259L5.69388 10.9437C5.44122 10.7978 5.35468 10.4748 5.50056 10.2222C5.64637 9.96957 5.96937 9.88296 6.22202 10.0289L7.40355 10.7111C7.6562 10.8569 7.74275 11.1799 7.59687 11.4325C7.49904 11.602 7.32152 11.6967 7.139 11.6967Z" fill="#88B4F5"/>
<path d="M10.4858 27.9156C10.3962 27.9156 10.3054 27.8928 10.2222 27.8447C9.96954 27.6988 9.883 27.3758 10.0289 27.1232L10.711 25.9417C10.8568 25.6891 11.1799 25.6024 11.4325 25.7484C11.6852 25.8943 11.7717 26.2173 11.6258 26.4699L10.9437 27.6514C10.8458 27.8208 10.6683 27.9156 10.4858 27.9156Z" fill="#88B4F5"/>
<path d="M22.1762 7.66776C22.0866 7.66776 21.9958 7.64492 21.9126 7.59687C21.66 7.45106 21.5734 7.12799 21.7193 6.8754L22.4015 5.69388C22.5473 5.44122 22.8702 5.35468 23.1229 5.50056C23.3755 5.64637 23.4621 5.96944 23.3162 6.22202L22.6341 7.40355C22.5363 7.57301 22.3587 7.66776 22.1762 7.66776Z" fill="#88B4F5"/>
<path d="M11.1689 7.66776C10.9864 7.66776 10.8089 7.57301 10.711 7.40355L10.0289 6.22202C9.883 5.96944 9.96954 5.64637 10.2222 5.50056C10.4747 5.35468 10.7979 5.44122 10.9437 5.69388L11.6258 6.8754C11.7717 7.12799 11.6852 7.45106 11.4325 7.59687C11.3494 7.64486 11.2585 7.66776 11.1689 7.66776Z" fill="#88B4F5"/>
</svg>

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -0,0 +1,15 @@
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.92516 12.1457C6.6709 11.6094 6.03272 11.3809 5.49988 11.6364L0.830003 13.8763C0.355091 13.9861 0 14.4121 0 14.9238V20.3082C0 20.9031 0.478601 21.385 1.06937 21.385C1.66001 21.385 2.13847 20.9031 2.13847 20.3082V16.5989L5.49988 18.2112C5.64826 18.2825 5.80469 18.3161 5.95867 18.3161C6.35844 18.3161 6.74154 18.0893 6.92516 17.7017C7.1786 17.1648 6.95249 16.5222 6.41937 16.2664L3.61977 14.9237L6.41937 13.581C6.95262 13.3253 7.1786 12.6828 6.92516 12.1457Z" fill="#D5D5D5"/>
<path d="M12.3651 10.6137C12.5194 10.6137 12.6755 10.5802 12.8243 10.5089L19.2289 7.43717C19.762 7.1812 19.9886 6.53854 19.7347 6.00156C19.481 5.46528 18.8432 5.23697 18.3094 5.49225L11.9046 8.56423C11.3714 8.82006 11.1453 9.46245 11.3989 9.99956C11.5824 10.3868 11.9655 10.6137 12.3651 10.6137Z" fill="#D5D5D5"/>
<path d="M25.6338 4.36467L28.9106 2.79269V6.54683C28.9106 7.14161 29.3893 7.62367 29.9797 7.62367C30.5704 7.62367 31.0488 7.14161 31.0488 6.54683V2.77315L34.3669 4.36467C34.5157 4.43582 34.6719 4.46953 34.8261 4.46953C35.2256 4.46953 35.6089 4.24274 35.7922 3.85522C36.0459 3.31825 35.8198 2.67572 35.2866 2.41989L30.46 0.104656C30.169 -0.0348854 29.8315 -0.0348854 29.5405 0.104656L24.7142 2.41989C24.1811 2.67572 23.9548 3.31811 24.2085 3.85522C24.4628 4.39261 25.1019 4.62119 25.6338 4.36467Z" fill="#D5D5D5"/>
<path d="M40.7719 7.43681L47.1768 10.5089C47.3249 10.5802 47.4816 10.6138 47.6358 10.6138C48.0353 10.6138 48.4186 10.387 48.6019 9.99948C48.8555 9.4625 48.6295 8.81998 48.0963 8.56415L41.6912 5.49189C41.1588 5.23648 40.5206 5.46451 40.2662 6.0012C40.0124 6.53818 40.2386 7.1807 40.7719 7.43681Z" fill="#D5D5D5"/>
<path d="M48.9237 20.886C49.4568 20.6303 49.683 19.9878 49.4292 19.4506C49.1755 18.9139 48.537 18.6855 48.0042 18.9417L43.9005 20.9106L31.0489 14.7463V9.94598C31.0489 9.35079 30.5704 8.86914 29.9798 8.86914C29.3893 8.86914 28.9107 9.35093 28.9107 9.94598V14.7658L16.101 20.9101L12.4202 19.1445C11.8858 18.8886 11.2492 19.1168 10.9949 19.6539C10.7412 20.1909 10.9674 20.8335 11.5006 21.0894L15.4821 22.9992V37.0011L11.4358 38.9419C10.9027 39.1977 10.6766 39.8401 10.9301 40.3774C11.1135 40.7648 11.4966 40.9915 11.8962 40.9915C12.0505 40.9915 12.2071 40.958 12.3553 40.8867L16.1012 39.09L28.9107 45.2342V48.9046C28.9107 49.4996 29.3893 49.9814 29.9798 49.9814C30.5704 49.9814 31.0489 49.4995 31.0489 48.9046V45.254L43.8996 39.0901L47.7917 40.957C47.9404 41.0282 48.0967 41.0619 48.2508 41.0619C48.6503 41.0619 49.0335 40.8351 49.2169 40.4476C49.4707 39.9106 49.2443 39.2681 48.7112 39.0121L44.5188 37.0013V22.9992L48.9237 20.886ZM42.3806 37.4328L31.049 42.8681V29.4597L42.3806 24.0241V37.4328ZM17.6875 37.1364C17.6685 37.0962 17.6434 37.0615 17.6203 37.0249V24.0243L28.9107 29.4399V42.8485L17.7848 37.5119C17.7746 37.3852 17.7449 37.2579 17.6875 37.1364ZM30.0004 16.6291L41.4126 22.103L30.0004 27.5767L18.5882 22.103L30.0004 16.6291Z" fill="#D5D5D5"/>
<path d="M47.1767 49.4916L40.772 52.5637C40.2389 52.8196 40.0123 53.4622 40.2662 53.9987C40.4497 54.3864 40.8329 54.6129 41.2324 54.6129C41.3865 54.6129 41.5432 54.5793 41.6915 54.5086L48.0964 51.4363C48.6295 51.1805 48.8556 50.5377 48.602 50.0007C48.3479 49.464 47.7094 49.237 47.1767 49.4916Z" fill="#D5D5D5"/>
<path d="M34.367 55.636L31.0489 57.2276V52.9362C31.0489 52.3414 30.5704 51.8594 29.9798 51.8594C29.3893 51.8594 28.9107 52.3414 28.9107 52.9362V57.2081L25.6338 55.636C25.1002 55.3814 24.4628 55.6084 24.2086 56.1455C23.9548 56.6825 24.181 57.3248 24.7142 57.5806L29.5408 59.8956C29.6862 59.965 29.8433 60 30.0005 60C30.1578 60 30.3149 59.965 30.4603 59.8956L35.2869 57.5806C35.82 57.3248 36.0462 56.6825 35.7925 56.1455C35.5383 55.6084 34.8997 55.3819 34.367 55.636Z" fill="#D5D5D5"/>
<path d="M19.2289 52.5636L12.824 49.4914C12.2922 49.2362 11.6534 49.4635 11.3989 50.0005C11.1453 50.5375 11.3714 51.1803 11.9046 51.4361L18.3096 54.5083C18.4577 54.5791 18.6144 54.6127 18.7685 54.6127C19.168 54.6127 19.5512 54.3861 19.7346 53.9985C19.9883 53.4621 19.762 52.8195 19.2289 52.5636Z" fill="#D5D5D5"/>
<path d="M6.92516 42.2985C6.6709 41.7618 6.03272 41.5345 5.49988 41.7894L2.13847 43.4014V39.3708C2.13847 38.776 1.66001 38.2939 1.06937 38.2939C0.478601 38.2939 0 38.776 0 39.3708V44.7553C0 44.8898 0.0274617 45.0171 0.0724116 45.1359C0.0941352 45.5271 0.319158 45.8792 0.673293 46.0493L5.49988 48.3645C5.64826 48.4354 5.80469 48.4692 5.95867 48.4692C6.35844 48.4692 6.74154 48.2424 6.92516 47.855C7.1786 47.3181 6.95249 46.6755 6.41937 46.4194L3.61977 45.077L6.41937 43.7343C6.95262 43.4783 7.1786 42.8355 6.92516 42.2985Z" fill="#D5D5D5"/>
<path d="M1.06937 34.0934C1.66001 34.0934 2.13847 33.6114 2.13847 33.0163V26.6623C2.13847 26.0675 1.66001 25.5854 1.06937 25.5854C0.478601 25.5854 0 26.0675 0 26.6623V33.0163C0.000136626 33.6114 0.478738 34.0934 1.06937 34.0934Z" fill="#D5D5D5"/>
<path d="M59.1707 13.8762L54.5008 11.6362C53.9669 11.3801 53.3298 11.6088 53.0757 12.1455C52.8221 12.6828 53.0482 13.3252 53.5813 13.5811L56.3809 14.9239L53.5813 16.2666C53.0482 16.5224 52.8221 17.1648 53.0757 17.7019C53.259 18.0894 53.6422 18.3162 54.0417 18.3162C54.196 18.3162 54.3527 18.2826 54.5008 18.2113L57.8622 16.599V20.3083C57.8622 20.9032 58.3407 21.3852 58.9313 21.3852C59.5219 21.3852 60.0003 20.9032 60.0003 20.3083V14.924C60.0003 14.4119 59.6456 13.986 59.1707 13.8762Z" fill="#D5D5D5"/>
<path d="M58.9314 25.5854C58.3406 25.5854 57.8623 26.0675 57.8623 26.6623V33.0163C57.8623 33.6114 58.3408 34.0931 58.9314 34.0931C59.522 34.0931 60.0004 33.6113 60.0004 33.0163V26.6623C60.0004 26.0675 59.5222 25.5854 58.9314 25.5854Z" fill="#D5D5D5"/>
<path d="M58.9313 38.2935C58.3405 38.2935 57.8622 38.7755 57.8622 39.3703V43.4009L54.5008 41.7889C53.9669 41.5336 53.3298 41.7611 53.0757 42.2981C52.8221 42.835 53.0482 43.4778 53.5813 43.7337L56.3809 45.0764L53.5813 46.4188C53.0482 46.6749 52.8221 47.3174 53.0757 47.8544C53.259 48.2418 53.6422 48.4686 54.0417 48.4686C54.196 48.4686 54.3527 48.4347 54.5008 48.3639L59.3274 46.0486C59.6815 45.8785 59.9065 45.5265 59.9283 45.1353C59.9731 45.0165 60.0003 44.8892 60.0003 44.7546V39.3702C60.0003 38.7755 59.5221 38.2935 58.9313 38.2935Z" fill="#D5D5D5"/>
</svg>

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -1,10 +1,4 @@
<svg width="17" height="22" viewBox="0 0 17 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.771 11.6328H8.13623L7.81885 11L8.13623 10.3672H8.771V11.6328Z" fill="#292827"/>
<path d="M7.50146 10.3672H8.13623V11.6328H7.50146V10.3672Z" fill="#464443"/>
<path d="M4.8042 10.3672H6.07373V11.6328H4.8042V10.3672Z" fill="#464443"/>
<path d="M10.1987 10.3672H11.4683V11.6328H10.1987V10.3672Z" fill="#292827"/>
<path d="M8.13626 2.88879C3.64275 2.88879 0 6.52029 0 11C0 13.0387 0.754651 14.9015 2.00036 16.3265L3.9143 14.4184C3.15343 13.4856 2.69708 12.296 2.69708 11C2.69708 8.00525 5.13225 5.57757 8.13621 5.57757H8.8105V2.88879H8.13626Z" fill="#30BBEC"/>
<path d="M14.2725 5.67358L12.3586 7.58168C13.1195 8.51449 13.5758 9.70409 13.5758 11.0001C13.5758 13.9949 11.1407 16.4225 8.13669 16.4225H7.4624V19.1113H8.13665C12.6302 19.1113 16.2729 15.4798 16.2729 11.0001C16.2729 8.96142 15.5183 7.09859 14.2725 5.67358Z" fill="#1F8DCD"/>
<path d="M8.13623 0.199951V8.26637L12.1819 4.23316L8.13623 0.199951Z" fill="#16A5D9"/>
<path d="M8.13648 21.8V13.7336L4.09082 17.7668L8.13648 21.8Z" fill="#16A5D9"/>
<svg width="35" height="30" viewBox="0 0 35 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M27.4702 3.86642L24.351 7.51614C22.56 5.82834 20.1489 4.79201 17.5 4.79201C11.9882 4.79201 7.50309 9.27708 7.50309 14.7889C7.50309 15.0111 7.5113 15.2319 7.52565 15.4506H9.73845C10.4774 15.4506 10.8725 16.3209 10.3872 16.8773L8.47038 19.0757L5.30055 22.7125L4.41734 21.6994L0.213911 16.8773C-0.272125 16.3209 0.123677 15.4506 0.862644 15.4506H2.72613C2.71656 15.2312 2.71109 15.0104 2.71109 14.7889C2.71109 10.8384 4.24918 7.12444 7.04235 4.33126C9.83552 1.53809 13.5495 0 17.5 0C21.2249 0 24.7393 1.36856 27.4702 3.86642Z" fill="#619CED"/>
<path d="M34.1379 15.491H32.273C32.1021 19.1776 30.5852 22.6188 27.9582 25.2466C25.165 28.0397 21.451 29.5778 17.5005 29.5778C14.1003 29.5778 10.8758 28.4376 8.26172 26.3383L11.3817 22.6886C13.0742 24.0024 15.1975 24.7858 17.5005 24.7858C22.7765 24.7858 27.1105 20.6767 27.4721 15.491H25.2621C24.5231 15.491 24.128 14.6214 24.6133 14.0643L26.9143 11.425L29.7 8.22914L31.6516 10.4679L34.7866 14.0643C35.2726 14.6214 34.8768 15.491 34.1379 15.491Z" fill="#619CED"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,8 @@
<svg width="32" height="35" viewBox="0 0 32 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.20859 17.5333C2.20859 22.0298 4.44255 26.0045 7.86104 28.408C8.46346 28.8318 8.4955 29.7117 7.91685 30.1672L7.90056 30.18C7.52272 30.4775 6.99293 30.4973 6.59933 30.2209C2.6086 27.4182 0 22.7802 0 17.5333C0 9.02288 7.04447 2.11406 15.5378 2.04143V4.25055C8.26345 4.32265 2.20859 10.2421 2.20859 17.5333Z" fill="#1ED688"/>
<path d="M15.9433 0.065948L20.0021 2.84224C20.2195 2.99097 20.2195 3.31167 20.0021 3.46041L15.9433 6.2367C15.6947 6.4068 15.3574 6.22869 15.3574 5.92775V0.375166C15.3574 0.0739588 15.6947 -0.103882 15.9433 0.065948Z" fill="#1AB975"/>
<path d="M29.0795 17.4666C29.0795 12.9701 26.8453 8.99537 23.4268 6.59185C22.8243 6.16808 22.7923 5.28822 23.371 4.83267L23.3872 4.81985C23.7651 4.52238 24.2949 4.50262 24.6885 4.779C28.6795 7.58172 31.2878 12.2197 31.2878 17.4666C31.2878 25.977 24.2553 32.8858 15.7617 32.9585V30.7493C23.0361 30.6772 29.0795 24.758 29.0795 17.4666Z" fill="#1ED688"/>
<path d="M15.3449 34.9339L11.2861 32.1576C11.0687 32.0089 11.0687 31.6882 11.2861 31.5395L15.3449 28.7632C15.5932 28.5931 15.9308 28.7712 15.9308 29.0721V34.6247C15.9308 34.9259 15.5932 35.104 15.3449 34.9339Z" fill="#1AB975"/>
<path d="M22.5325 15.7787L15.884 21.2923L14.2079 22.6824C13.813 23.0095 13.3131 23.1871 12.8047 23.1871C12.72 23.1871 12.6354 23.1823 12.5499 23.1724C11.9568 23.1027 11.411 22.7882 11.053 22.3099L8.46759 18.8637C7.88387 18.0853 8.04168 16.9803 8.82034 16.3955C9.59953 15.8118 10.7045 15.9696 11.2885 16.7483L13.0338 19.0754L13.0479 19.0639L20.2822 13.0643C21.0318 12.4432 22.1432 12.5468 22.7645 13.2964C23.3859 14.0459 23.282 15.1573 22.5325 15.7787Z" fill="#1ED688"/>
<path d="M22.5334 15.7787L15.8849 21.2923C14.7976 20.7494 13.8414 19.9991 13.0488 19.0639L20.2832 13.0643C21.0327 12.4432 22.1441 12.5468 22.7654 13.2964C23.3868 14.0459 23.2829 15.1573 22.5334 15.7787Z" fill="#35E298"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,23 @@
<svg width="29" height="38" viewBox="0 0 29 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_i_2351_2766)">
<path d="M0 5.18168C0 2.69345 1.82822 0.560776 4.30407 0.312864C8.58098 -0.115392 11.9929 -0.0966095 16.2213 0.32393C18.7091 0.57135 20.5548 2.70894 20.5548 5.20899V32.7835C20.5548 35.246 18.7637 37.3665 16.3165 37.6408C12.0557 38.1183 8.5855 38.1222 4.24256 37.6376C1.79332 37.3643 0 35.2435 0 32.7791V5.18168Z" fill="#EAF6FF"/>
</g>
<path d="M17.5761 23.3577C17.7051 23.3577 17.8341 23.3086 17.9325 23.2102C18.1293 23.0133 18.1293 22.6943 17.9325 22.4975C16.2479 20.813 16.2479 18.0721 17.9325 16.3875C18.1293 16.1907 18.1293 15.8717 17.9325 15.6749C17.7356 15.4782 17.4166 15.4782 17.2198 15.6749C15.1423 17.7525 15.1423 21.1327 17.2198 23.2103C17.3182 23.3086 17.4472 23.3577 17.5761 23.3577Z" fill="#8AC9FE"/>
<path d="M18.6358 21.4001C18.744 21.4001 18.8522 21.3588 18.9348 21.2762C19.0999 21.1111 19.0999 20.8434 18.9347 20.6783C18.6046 20.3483 18.4228 19.9093 18.4228 19.4424C18.4228 18.9756 18.6046 18.5367 18.9347 18.2066C19.0999 18.0415 19.0999 17.7738 18.9348 17.6087C18.7696 17.4436 18.5019 17.4436 18.3369 17.6087C17.847 18.0985 17.5772 18.7497 17.5772 19.4424C17.5772 20.1352 17.847 20.7864 18.3369 21.2763C18.4193 21.3587 18.5276 21.4001 18.6358 21.4001Z" fill="#8AC9FE"/>
<path d="M11.1713 30.5347L11.1713 32.4539C11.1713 32.8359 10.8617 33.1455 10.4797 33.1455C10.0976 33.1455 9.78809 32.8359 9.78809 32.4539L9.78809 30.5347C9.78809 30.1527 10.0976 29.8431 10.4797 29.8431C10.8617 29.8431 11.1713 30.1527 11.1713 30.5347Z" fill="#B3DAFE"/>
<path d="M21.5342 8.79642C21.5342 7.91189 22.1118 7.11379 22.9777 6.93351C24.3924 6.63901 25.5238 6.65107 26.9209 6.93884C27.7961 7.1191 28.3858 7.92191 28.3858 8.81547V31.0421C28.3858 31.9071 27.8339 32.6929 26.9918 32.8912C25.5575 33.2289 24.3936 33.2319 22.9318 32.8895C22.0881 32.6918 21.5342 31.9055 21.5342 31.039V8.79642Z" fill="#EAF6FF"/>
<path d="M23.9952 23.3577C23.8662 23.3577 23.7372 23.3086 23.6388 23.2102C23.442 23.0133 23.442 22.6943 23.6388 22.4975C25.3234 20.813 25.3234 18.0721 23.6388 16.3875C23.442 16.1907 23.442 15.8717 23.6388 15.6749C23.8357 15.4782 24.1547 15.4782 24.3515 15.6749C26.429 17.7525 26.429 21.1327 24.3515 23.2103C24.2531 23.3086 24.1241 23.3577 23.9952 23.3577Z" fill="#8AC9FE"/>
<path d="M22.9355 21.4001C22.8273 21.4001 22.7191 21.3588 22.6365 21.2762C22.4714 21.1111 22.4714 20.8434 22.6366 20.6783C22.9666 20.3483 23.1485 19.9093 23.1485 19.4424C23.1485 18.9756 22.9666 18.5367 22.6366 18.2066C22.4714 18.0415 22.4714 17.7738 22.6365 17.6087C22.8017 17.4436 23.0694 17.4436 23.2344 17.6087C23.7243 18.0985 23.9941 18.7497 23.9941 19.4424C23.9941 20.1352 23.7243 20.7864 23.2344 21.2763C23.1519 21.3587 23.0437 21.4001 22.9355 21.4001Z" fill="#8AC9FE"/>
<defs>
<filter id="filter0_i_2351_2766" x="-1" y="0" width="21.5547" height="38" 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 dx="-1"/>
<feGaussianBlur stdDeviation="1.5"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.538295 0 0 0 0 0.538295 0 0 0 0 0.538295 0 0 0 0.3 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_2351_2766"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,10 @@
<svg width="31" height="35" viewBox="0 0 31 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.4316 6.37335C16.8654 6.37335 16.4062 5.91425 16.4062 5.34796V3.07617C16.4062 2.51077 15.9463 2.05078 15.3809 2.05078C14.8155 2.05078 14.3555 2.51077 14.3555 3.07617V5.34796C14.3555 5.91425 13.8964 6.37335 13.3301 6.37335C12.7638 6.37335 12.3047 5.91425 12.3047 5.34796V3.07617C12.3047 1.37997 13.6847 0 15.3809 0C17.0771 0 18.457 1.37997 18.457 3.07617V5.34796C18.457 5.91425 17.9979 6.37335 17.4316 6.37335Z" fill="#FFB454"/>
<path d="M16.4062 3.07617V5.34796C16.4062 5.91425 16.8654 6.37335 17.4316 6.37335C17.9979 6.37335 18.457 5.91425 18.457 5.34796V3.07617C18.457 1.37997 17.0771 0 15.3809 0V2.05078C15.9463 2.05078 16.4062 2.51077 16.4062 3.07617Z" fill="#FF8E00"/>
<path d="M15.3809 35C12.5539 35 10.2539 32.7 10.2539 29.873C10.2539 29.3068 10.713 28.8477 11.2793 28.8477H19.4824C20.0487 28.8477 20.5078 29.3068 20.5078 29.873C20.5078 32.7 18.2079 35 15.3809 35Z" fill="#FFB454"/>
<path d="M19.4824 28.8477H15.3809V35C18.2079 35 20.5078 32.7 20.5078 29.873C20.5078 29.3068 20.0487 28.8477 19.4824 28.8477Z" fill="#FF8E00"/>
<path d="M29.7363 30.8984H1.0254C0.614562 30.8984 0.243439 30.6532 0.0822478 30.2753C-0.0789436 29.8975 0.000968566 29.4599 0.285344 29.1633C3.18706 26.1372 4.78517 22.1616 4.78517 17.9691V14.6973C4.78517 8.85479 9.5384 4.10156 15.3809 4.10156C21.2233 4.10156 25.9766 8.85479 25.9766 14.6973V17.9691C25.9766 22.1617 27.5747 26.1372 30.4765 29.1633C30.7608 29.4599 30.8407 29.8975 30.6795 30.2753C30.5184 30.6532 30.1472 30.8984 29.7363 30.8984Z" fill="#FFE278"/>
<path d="M29.7363 30.8984C30.1472 30.8984 30.5183 30.6532 30.6795 30.2753C30.8407 29.8975 30.7608 29.4599 30.4765 29.1633C27.5747 26.1372 25.9766 22.1616 25.9766 17.9691V14.6973C25.9766 8.85479 21.2233 4.10156 15.3809 4.10156V30.8984H29.7363Z" fill="#FFB454"/>
<path d="M29.7359 15.7226C29.1696 15.7226 28.7105 15.2635 28.7105 14.6972C28.7105 11.1366 27.3239 7.78912 24.8062 5.27144C24.4057 4.87099 24.4057 4.22178 24.8062 3.82133C25.2066 3.42088 25.8559 3.42088 26.2563 3.82133C29.1614 6.72633 30.7613 10.5888 30.7613 14.6972C30.7613 15.2635 30.3022 15.7226 29.7359 15.7226Z" fill="#08475E"/>
<path d="M1.02539 15.7226C0.459102 15.7226 0 15.2635 0 14.6972C0 10.5888 1.59988 6.7264 4.50495 3.82133C4.90533 3.42088 5.55461 3.42088 5.95506 3.82133C6.35551 4.22178 6.35551 4.87099 5.95506 5.27144C3.43738 7.78918 2.05078 11.1367 2.05078 14.6972C2.05078 15.2635 1.59168 15.7226 1.02539 15.7226Z" fill="#0A789B"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,18 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.62771 22.7848L0.0206433 9.97422C-0.0455284 9.78766 0.0527038 9.58101 0.239256 9.51286C6.29643 7.33432 13.1218 5.30816 18.9563 2.81865C19.2171 2.65418 19.4217 2.81667 19.534 3.12757L26.7725 21.7858L28.7381 27.2523C28.8043 27.4388 28.7081 27.6475 28.5215 27.7137L14.6702 32.6947L9.27087 34.6366C9.08432 34.7048 8.87774 34.6065 8.80958 34.4199L4.62771 22.7848Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.46894 18.5338L6.16844 5.11738C6.13433 4.92078 6.26674 4.73423 6.46129 4.70012L22.3042 1.98393L25.9325 1.38613C26.1311 1.29986 26.454 1.40015 26.5302 1.84352L30.4493 21.4146L31.4301 27.1398C31.4642 27.3345 31.3318 27.523 31.1372 27.5571L16.6301 30.0446L10.974 31.0155C10.7795 31.0477 10.5909 30.9152 10.5568 30.7206L8.46894 18.5338Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.9063 14.5779V27.4768C12.9063 27.6835 13.0748 27.854 13.2814 27.854H19.2684H28.1315H29.4051H34.624C34.8305 27.854 34.999 27.6835 34.999 27.4768V21.4166V4.67611V4.50159H31.1882C30.8212 4.50159 30.059 4.55375 30.059 3.72127L30.0509 0H13.2813C13.0748 0 12.9062 0.168505 12.9062 0.375155V3.59487V4.957V14.5779H12.9063Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.54915 7.34229C4.40308 8.0645 2.27704 8.78063 0.239256 9.51283C0.0527037 9.58105 -0.0455284 9.78763 0.0206433 9.97418L4.62771 22.7848L8.80958 34.4199C8.87781 34.6065 9.08439 34.7048 9.27087 34.6365L14.6702 32.6947L26.9732 28.2713L6.54915 7.34229Z" fill="#B5C4CF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.9076 3.59473L6.46129 4.70003C6.26674 4.73414 6.13433 4.92069 6.16844 5.11729L6.54955 7.34197L8.469 18.5337L10.5569 30.7205C10.591 30.9151 10.7795 31.0474 10.9741 31.0154L16.6301 30.0445L26.9735 28.2711L29.4064 27.8538H28.1328L12.9076 3.59473Z" fill="#D7E7EC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M34.999 21.4166V4.67611V4.50159V4.44342C34.999 4.33507 34.9528 4.31702 34.7864 4.15453L30.6727 0.230712C30.4782 0.0461424 30.4461 0 30.3318 0H30.0509H13.2813C13.0748 0 12.9062 0.168505 12.9062 0.375155V27.4768C12.9062 27.6835 13.0748 27.854 13.2813 27.854H34.6239C34.8305 27.854 34.999 27.6835 34.999 27.4768V21.4166Z" fill="#EDF3F4"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.9077 3.59473L11.3975 3.85353V28.8629C11.3975 29.0716 11.566 29.2401 11.7725 29.2401H17.7595H21.3216L26.9736 28.2712L29.4065 27.8539H28.1329H26.5665H19.2698H13.2828C13.0762 27.8539 12.9077 27.6834 12.9077 27.4768C12.9077 19.5167 12.9077 11.5547 12.9077 3.59473Z" fill="#B5C4CF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.46896 18.5336L6.54951 7.3418C6.03005 7.51632 5.51257 7.69084 4.99707 7.86536L5.23578 9.25558L7.15524 20.4473L9.24518 32.6341C9.27724 32.8286 9.46578 32.961 9.66033 32.929L15.3164 31.9581L18 31.4987L26.0829 28.59L25.9867 28.4395L21.3214 29.2399L16.6302 30.0444L10.9741 31.0153C10.7796 31.0474 10.591 30.915 10.5569 30.7204L8.46896 18.5336Z" fill="#9AAFB7"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M34.9998 21.4166V4.67611V4.50159C34.9998 4.29897 34.9337 4.29699 34.7873 4.15453L30.6736 0.230712C30.4791 0.0461424 30.447 0 30.3326 0H30.0518H25.8779C30.9784 6.8286 31.2692 19.1377 27.4845 26.8209C27.31 27.178 27.1275 27.521 26.937 27.854H28.1323H29.4059H34.6248C34.8313 27.854 34.9998 27.6835 34.9998 27.4768V21.4166Z" fill="#D7E7EC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.0607 3.72127C30.0607 4.55375 30.8229 4.50159 31.19 4.50159H35.0008V4.44342C35.0008 4.33507 34.9546 4.31702 34.7882 4.15453L30.6745 0.230712C30.48 0.0461424 30.4479 0 30.3336 0H30.0527L30.0607 3.72127Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M34.7882 4.15453L30.6745 0.230712C30.48 0.0461424 30.4479 0 30.3336 0H30.0527L30.0607 3.7212C30.0607 4.55368 30.8229 4.50152 31.19 4.50152H35.0008V4.44335C35.0008 4.33507 34.9546 4.31702 34.7882 4.15453Z" fill="#B5C4CF"/>
<path d="M31.6094 8.20367H16.5086C16.2169 8.20367 15.9805 7.96715 15.9805 7.67532C15.9805 7.3835 16.2169 7.14697 16.5086 7.14697H31.6094C31.9011 7.14697 32.1376 7.3835 32.1376 7.67532C32.1376 7.96715 31.9012 8.20367 31.6094 8.20367Z" fill="#9AAFB7"/>
<path d="M31.6094 11.9566H16.5086C16.2169 11.9566 15.9805 11.7201 15.9805 11.4283C15.9805 11.1364 16.2169 10.8999 16.5086 10.8999H31.6094C31.9011 10.8999 32.1376 11.1364 32.1376 11.4283C32.1376 11.7201 31.9012 11.9566 31.6094 11.9566Z" fill="#9AAFB7"/>
<path d="M31.6094 15.7105H16.5086C16.2169 15.7105 15.9805 15.474 15.9805 15.1822C15.9805 14.8903 16.2169 14.6538 16.5086 14.6538H31.6094C31.9011 14.6538 32.1376 14.8903 32.1376 15.1822C32.1376 15.474 31.9012 15.7105 31.6094 15.7105Z" fill="#9AAFB7"/>
<path d="M31.6094 19.4634H16.5086C16.2169 19.4634 15.9805 19.2269 15.9805 18.9351C15.9805 18.6433 16.2169 18.4067 16.5086 18.4067H31.6094C31.9011 18.4067 32.1376 18.6433 32.1376 18.9351C32.1376 19.2269 31.9012 19.4634 31.6094 19.4634Z" fill="#9AAFB7"/>
<path d="M31.6094 23.2169H16.5086C16.2169 23.2169 15.9805 22.9803 15.9805 22.6885C15.9805 22.3967 16.2169 22.1602 16.5086 22.1602H31.6094C31.9011 22.1602 32.1376 22.3967 32.1376 22.6885C32.1376 22.9803 31.9012 23.2169 31.6094 23.2169Z" fill="#9AAFB7"/>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,24 @@
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="30" cy="30" r="30" fill="white"/>
<g filter="url(#filter0_i_2351_2399)">
<path d="M16 16.1817C16 13.6934 17.8282 11.5608 20.3041 11.3129C24.581 10.8846 27.9929 10.9034 32.2213 11.3239C34.7091 11.5713 36.5548 13.7089 36.5548 16.209V43.7835C36.5548 46.246 34.7637 48.3665 32.3165 48.6408C28.0557 49.1183 24.5855 49.1222 20.2426 48.6376C17.7933 48.3643 16 46.2435 16 43.7791V16.1817Z" fill="#EAF6FF"/>
</g>
<path d="M33.5761 34.3577C33.7051 34.3577 33.8341 34.3086 33.9325 34.2102C34.1293 34.0133 34.1293 33.6943 33.9325 33.4975C32.2479 31.813 32.2479 29.0721 33.9325 27.3875C34.1293 27.1907 34.1293 26.8717 33.9325 26.6749C33.7356 26.4782 33.4166 26.4782 33.2198 26.6749C31.1423 28.7525 31.1423 32.1327 33.2198 34.2103C33.3182 34.3086 33.4472 34.3577 33.5761 34.3577Z" fill="#8AC9FE"/>
<path d="M34.6358 32.4001C34.744 32.4001 34.8522 32.3588 34.9348 32.2762C35.0999 32.1111 35.0999 31.8434 34.9347 31.6783C34.6046 31.3483 34.4228 30.9093 34.4228 30.4424C34.4228 29.9756 34.6046 29.5367 34.9347 29.2066C35.0999 29.0415 35.0999 28.7738 34.9348 28.6087C34.7696 28.4436 34.5019 28.4436 34.3369 28.6087C33.847 29.0985 33.5772 29.7497 33.5772 30.4424C33.5772 31.1352 33.847 31.7864 34.3369 32.2763C34.4193 32.3587 34.5276 32.4001 34.6358 32.4001Z" fill="#8AC9FE"/>
<path d="M27.1713 41.5347L27.1713 43.4539C27.1713 43.8359 26.8617 44.1455 26.4797 44.1455C26.0976 44.1455 25.7881 43.8359 25.7881 43.4539L25.7881 41.5347C25.7881 41.1527 26.0976 40.8431 26.4797 40.8431C26.8617 40.8431 27.1713 41.1527 27.1713 41.5347Z" fill="#B3DAFE"/>
<path d="M37.5342 19.7964C37.5342 18.9119 38.1118 18.1138 38.9777 17.9335C40.3924 17.639 41.5238 17.6511 42.9209 17.9388C43.7961 18.1191 44.3858 18.9219 44.3858 19.8155V42.0421C44.3858 42.9071 43.8339 43.6929 42.9918 43.8912C41.5575 44.2289 40.3936 44.2319 38.9318 43.8895C38.0881 43.6918 37.5342 42.9055 37.5342 42.039V19.7964Z" fill="#EAF6FF"/>
<path d="M39.9952 34.3577C39.8662 34.3577 39.7372 34.3086 39.6388 34.2102C39.442 34.0133 39.442 33.6943 39.6388 33.4975C41.3234 31.813 41.3234 29.0721 39.6388 27.3875C39.442 27.1907 39.442 26.8717 39.6388 26.6749C39.8357 26.4782 40.1547 26.4782 40.3515 26.6749C42.429 28.7525 42.429 32.1327 40.3515 34.2103C40.2531 34.3086 40.1241 34.3577 39.9952 34.3577Z" fill="#8AC9FE"/>
<path d="M38.9355 32.4001C38.8273 32.4001 38.7191 32.3588 38.6365 32.2762C38.4714 32.1111 38.4714 31.8434 38.6366 31.6783C38.9666 31.3483 39.1485 30.9093 39.1485 30.4424C39.1485 29.9756 38.9666 29.5367 38.6366 29.2066C38.4714 29.0415 38.4714 28.7738 38.6365 28.6087C38.8017 28.4436 39.0694 28.4436 39.2344 28.6087C39.7243 29.0985 39.9941 29.7497 39.9941 30.4424C39.9941 31.1352 39.7243 31.7864 39.2344 32.2763C39.1519 32.3587 39.0437 32.4001 38.9355 32.4001Z" fill="#8AC9FE"/>
<defs>
<filter id="filter0_i_2351_2399" x="15" y="11" width="21.5547" height="38" 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 dx="-1"/>
<feGaussianBlur stdDeviation="1.5"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.538295 0 0 0 0 0.538295 0 0 0 0 0.538295 0 0 0 0.3 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_2351_2399"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,19 @@
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="30" cy="30" r="30" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M16.6277 34.7848L12.0206 21.9742C11.9545 21.7877 12.0527 21.581 12.2393 21.5129C18.2964 19.3343 25.1218 17.3082 30.9563 14.8187C31.2171 14.6542 31.4217 14.8167 31.534 15.1276L38.7725 33.7858L40.7381 39.2523C40.8043 39.4388 40.7081 39.6475 40.5215 39.7137L26.6702 44.6947L21.2709 46.6366C21.0843 46.7048 20.8777 46.6065 20.8096 46.4199L16.6277 34.7848Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.4689 30.5338L18.1684 17.1174C18.1343 16.9208 18.2667 16.7342 18.4613 16.7001L34.3042 13.9839L37.9325 13.3861C38.1311 13.2999 38.454 13.4001 38.5302 13.8435L42.4493 33.4146L43.4301 39.1398C43.4642 39.3345 43.3318 39.523 43.1372 39.5571L28.6301 42.0446L22.974 43.0155C22.7795 43.0477 22.5909 42.9152 22.5568 42.7206L20.4689 30.5338Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9063 26.5779V39.4768C24.9063 39.6835 25.0748 39.854 25.2814 39.854H31.2684H40.1315H41.4051H46.624C46.8305 39.854 46.999 39.6835 46.999 39.4768V33.4166V16.6761V16.5016H43.1882C42.8212 16.5016 42.059 16.5537 42.059 15.7213L42.0509 12H25.2813C25.0748 12 24.9062 12.1685 24.9062 12.3752V15.5949V16.957V26.5779H24.9063Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5492 19.3423C16.4031 20.0645 14.277 20.7806 12.2393 21.5128C12.0527 21.581 11.9545 21.7876 12.0206 21.9742L16.6277 34.7848L20.8096 46.4199C20.8778 46.6065 21.0844 46.7048 21.2709 46.6365L26.6702 44.6947L38.9732 40.2713L18.5492 19.3423Z" fill="#B5C4CF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9076 15.5947L18.4613 16.7C18.2667 16.7341 18.1343 16.9207 18.1684 17.1173L18.5495 19.342L20.469 30.5337L22.5569 42.7205C22.591 42.9151 22.7795 43.0474 22.9741 43.0154L28.6301 42.0445L38.9735 40.2711L41.4064 39.8538H40.1328L24.9076 15.5947Z" fill="#D7E7EC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M46.999 33.4166V16.6761V16.5016V16.4434C46.999 16.3351 46.9528 16.317 46.7864 16.1545L42.6727 12.2307C42.4782 12.0461 42.4461 12 42.3318 12H42.0509H25.2813C25.0748 12 24.9062 12.1685 24.9062 12.3752V39.4768C24.9062 39.6835 25.0748 39.854 25.2813 39.854H46.6239C46.8305 39.854 46.999 39.6835 46.999 39.4768V33.4166Z" fill="#EDF3F4"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9077 15.5947L23.3975 15.8535V40.8629C23.3975 41.0716 23.566 41.2401 23.7725 41.2401H29.7595H33.3216L38.9736 40.2712L41.4065 39.8539H40.1329H38.5665H31.2698H25.2828C25.0762 39.8539 24.9077 39.6834 24.9077 39.4768C24.9077 31.5167 24.9077 23.5547 24.9077 15.5947Z" fill="#B5C4CF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.469 30.5336L18.5495 19.3418C18.03 19.5163 17.5126 19.6908 16.9971 19.8654L17.2358 21.2556L19.1552 32.4473L21.2452 44.6341C21.2772 44.8286 21.4658 44.961 21.6603 44.929L27.3164 43.9581L30 43.4987L38.0829 40.59L37.9867 40.4395L33.3214 41.2399L28.6302 42.0444L22.9741 43.0153C22.7796 43.0474 22.591 42.915 22.5569 42.7204L20.469 30.5336Z" fill="#9AAFB7"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M46.9998 33.4166V16.6761V16.5016C46.9998 16.299 46.9337 16.297 46.7873 16.1545L42.6736 12.2307C42.4791 12.0461 42.447 12 42.3326 12H42.0518H37.8779C42.9784 18.8286 43.2692 31.1377 39.4845 38.8209C39.31 39.178 39.1275 39.521 38.937 39.854H40.1323H41.4059H46.6248C46.8313 39.854 46.9998 39.6835 46.9998 39.4768V33.4166Z" fill="#D7E7EC"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M42.0607 15.7213C42.0607 16.5537 42.8229 16.5016 43.19 16.5016H47.0008V16.4434C47.0008 16.3351 46.9546 16.317 46.7882 16.1545L42.6745 12.2307C42.48 12.0461 42.4479 12 42.3336 12H42.0527L42.0607 15.7213Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M46.7882 16.1545L42.6745 12.2307C42.48 12.0461 42.4479 12 42.3336 12H42.0527L42.0607 15.7212C42.0607 16.5537 42.8229 16.5015 43.19 16.5015H47.0008V16.4433C47.0008 16.3351 46.9546 16.317 46.7882 16.1545Z" fill="#B5C4CF"/>
<path d="M43.6094 20.2037H28.5086C28.2169 20.2037 27.9805 19.9671 27.9805 19.6753C27.9805 19.3835 28.2169 19.147 28.5086 19.147H43.6094C43.9011 19.147 44.1376 19.3835 44.1376 19.6753C44.1376 19.9671 43.9012 20.2037 43.6094 20.2037Z" fill="#9AAFB7"/>
<path d="M43.6094 23.9566H28.5086C28.2169 23.9566 27.9805 23.7201 27.9805 23.4283C27.9805 23.1364 28.2169 22.8999 28.5086 22.8999H43.6094C43.9011 22.8999 44.1376 23.1364 44.1376 23.4283C44.1376 23.7201 43.9012 23.9566 43.6094 23.9566Z" fill="#9AAFB7"/>
<path d="M43.6094 27.7105H28.5086C28.2169 27.7105 27.9805 27.474 27.9805 27.1822C27.9805 26.8903 28.2169 26.6538 28.5086 26.6538H43.6094C43.9011 26.6538 44.1376 26.8903 44.1376 27.1822C44.1376 27.474 43.9012 27.7105 43.6094 27.7105Z" fill="#9AAFB7"/>
<path d="M43.6094 31.4634H28.5086C28.2169 31.4634 27.9805 31.2269 27.9805 30.9351C27.9805 30.6433 28.2169 30.4067 28.5086 30.4067H43.6094C43.9011 30.4067 44.1376 30.6433 44.1376 30.9351C44.1376 31.2269 43.9012 31.4634 43.6094 31.4634Z" fill="#9AAFB7"/>
<path d="M43.6094 35.2169H28.5086C28.2169 35.2169 27.9805 34.9803 27.9805 34.6885C27.9805 34.3967 28.2169 34.1602 28.5086 34.1602H43.6094C43.9011 34.1602 44.1376 34.3967 44.1376 34.6885C44.1376 34.9803 43.9012 35.2169 43.6094 35.2169Z" fill="#9AAFB7"/>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,20 @@
<svg width="36" height="33" viewBox="0 0 36 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M32.7404 13.0391H30.5674V19.5582H32.7404C34.5406 19.5582 36 18.0988 36 16.2986C36 14.4984 34.5406 13.0391 32.7404 13.0391Z" fill="#A5A8AB"/>
<path d="M30.5674 13.0391H3.25956C1.45934 13.0391 0 14.4984 0 16.2986C0 18.0988 1.45934 19.5582 3.25956 19.5582H30.5674C32.3676 19.5582 33.827 18.0988 33.827 16.2986C33.827 14.4984 32.3676 13.0391 30.5674 13.0391Z" fill="#C2C4C6"/>
<path d="M32.7404 15.2119H30.5674V17.385H32.7404C33.3405 17.385 33.8269 16.8985 33.8269 16.2984C33.8269 15.6984 33.3405 15.2119 32.7404 15.2119Z" fill="#414851"/>
<path d="M30.5672 15.2119H3.25937C2.65932 15.2119 2.17285 15.6984 2.17285 16.2984C2.17285 16.8985 2.65932 17.385 3.25937 17.385H30.5672C31.1673 17.385 31.6537 16.8985 31.6537 16.2984C31.6537 15.6984 31.1673 15.2119 30.5672 15.2119Z" fill="#62676F"/>
<path d="M11.9521 10.8652V21.7304C14.9525 21.7304 17.3847 19.2981 17.3847 16.2978C17.3847 13.2975 14.9525 10.8652 11.9521 10.8652Z" fill="#FCBE64"/>
<path d="M15.2117 16.2978C15.2117 13.2975 13.7523 10.8652 11.9521 10.8652C8.95181 10.8652 6.51953 13.2975 6.51953 16.2978C6.51953 19.2981 8.95181 21.7304 11.9521 21.7304C13.7523 21.7304 15.2117 19.2981 15.2117 16.2978Z" fill="#FBDB63"/>
<path d="M32.7404 2.17285H30.5674V8.69197H32.7404C34.5406 8.69197 36 7.23263 36 5.43241C36 3.63219 34.5406 2.17285 32.7404 2.17285Z" fill="#A5A8AB"/>
<path d="M30.5674 2.17285H3.25956C1.45934 2.17285 0 3.63219 0 5.43241C0 7.23263 1.45934 8.69197 3.25956 8.69197H30.5674C32.3676 8.69197 33.827 7.23263 33.827 5.43241C33.827 3.63219 32.3676 2.17285 30.5674 2.17285Z" fill="#C2C4C6"/>
<path d="M32.7404 4.3457H30.5674V6.51874H32.7404C33.3405 6.51874 33.8269 6.03227 33.8269 5.43222C33.8269 4.83217 33.3405 4.3457 32.7404 4.3457Z" fill="#414851"/>
<path d="M30.5672 4.3457H3.25937C2.65932 4.3457 2.17285 4.83217 2.17285 5.43222C2.17285 6.03227 2.65932 6.51874 3.25937 6.51874H30.5672C31.1673 6.51874 31.6537 6.03227 31.6537 5.43222C31.6537 4.83217 31.1673 4.3457 30.5672 4.3457Z" fill="#62676F"/>
<path d="M24.0479 0V10.8652C27.0482 10.8652 29.4804 8.43291 29.4804 5.4326C29.4804 2.43228 27.0482 0 24.0479 0Z" fill="#FA342D"/>
<path d="M27.3074 5.4326C27.3074 2.43228 25.848 0 24.0478 0C21.0475 0 18.6152 2.43228 18.6152 5.4326C18.6152 8.43291 21.0475 10.8652 24.0478 10.8652C25.848 10.8652 27.3074 8.43291 27.3074 5.4326Z" fill="#FE5E49"/>
<path d="M32.7404 23.9033H30.5674V30.4224H32.7404C34.5406 30.4224 36 28.9631 36 27.1629C36 25.3627 34.5406 23.9033 32.7404 23.9033Z" fill="#A5A8AB"/>
<path d="M30.5674 23.9033H3.25956C1.45934 23.9033 0 25.3627 0 27.1629C0 28.9631 1.45934 30.4224 3.25956 30.4224H30.5674C32.3676 30.4224 33.827 28.9631 33.827 27.1629C33.827 25.3627 32.3676 23.9033 30.5674 23.9033Z" fill="#C2C4C6"/>
<path d="M32.7404 26.0762H30.5674V28.2492H32.7404C33.3405 28.2492 33.8269 27.7627 33.8269 27.1627C33.8269 26.5626 33.3405 26.0762 32.7404 26.0762Z" fill="#414851"/>
<path d="M30.5672 26.0762H3.25937C2.65932 26.0762 2.17285 26.5626 2.17285 27.1627C2.17285 27.7627 2.65932 28.2492 3.25937 28.2492H30.5672C31.1673 28.2492 31.6537 27.7627 31.6537 27.1627C31.6537 26.5626 31.1673 26.0762 30.5672 26.0762Z" fill="#62676F"/>
<path d="M24.0479 21.7295V32.5947C27.0482 32.5947 29.4804 30.1624 29.4804 27.1621C29.4804 24.1618 27.0482 21.7295 24.0479 21.7295Z" fill="#7D99E8"/>
<path d="M27.3074 27.1621C27.3074 24.1618 25.848 21.7295 24.0478 21.7295C21.0475 21.7295 18.6152 24.1618 18.6152 27.1621C18.6152 30.1624 21.0475 32.5947 24.0478 32.5947C25.848 32.5947 27.3074 30.1624 27.3074 27.1621Z" fill="#83B3F1"/>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,22 @@
<svg width="25" height="36" viewBox="0 0 25 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.67036 31.6755C9.37913 31.6755 9.14303 31.9116 9.14303 32.2029V33.5343C9.14303 34.3122 8.5101 34.9452 7.73219 34.9452H6.41014C6.11891 34.9452 5.88281 35.1813 5.88281 35.4725C5.88281 35.7637 6.11891 35.9998 6.41014 35.9998H7.73219C9.09163 35.9998 10.1977 34.8938 10.1977 33.5343V32.2029C10.1977 31.9116 9.96158 31.6755 9.67036 31.6755Z" fill="#72BBFF"/>
<path d="M10.6115 29.458H8.7285C8.43727 29.458 8.20117 29.6941 8.20117 29.9853V31.2785C8.20117 32.0885 8.86012 32.7473 9.67002 32.7473C10.4799 32.7473 11.1389 32.0884 11.1389 31.2785V29.9853C11.1389 29.6941 10.9028 29.458 10.6115 29.458Z" fill="#6B717D"/>
<path d="M14.4785 31.6755C14.7697 31.6755 15.0058 31.9116 15.0058 32.2029V33.5343C15.0058 34.3122 15.6388 34.9452 16.4167 34.9452H17.7387C18.0299 34.9452 18.266 35.1813 18.266 35.4725C18.266 35.7637 18.0299 35.9998 17.7387 35.9998H16.4167C15.0572 35.9998 13.9512 34.8938 13.9512 33.5343V32.2029C13.9512 31.9116 14.1873 31.6755 14.4785 31.6755Z" fill="#FF6C6C"/>
<path d="M13.5371 29.4583H15.4201C15.7114 29.4583 15.9475 29.6944 15.9475 29.9856V31.2787C15.9475 32.0887 15.2885 32.7476 14.4786 32.7476C13.6687 32.7476 13.0098 32.0886 13.0098 31.2787V29.9856C13.0098 29.6944 13.2459 29.4583 13.5371 29.4583Z" fill="#6B717D"/>
<path d="M2.14594 3.29248H0.527327C0.236102 3.29248 0 3.52858 0 3.81981C0 4.11103 0.236102 4.34714 0.527327 4.34714H2.14594C2.43717 4.34714 2.67327 4.11103 2.67327 3.81981C2.67327 3.52858 2.43717 3.29248 2.14594 3.29248Z" fill="#6B717D"/>
<path d="M2.14594 5.75342H0.527327C0.236102 5.75342 0 5.98952 0 6.28075C0 6.57197 0.236102 6.80807 0.527327 6.80807H2.14594C2.43717 6.80807 2.67327 6.57197 2.67327 6.28075C2.67327 5.98952 2.43717 5.75342 2.14594 5.75342Z" fill="#6B717D"/>
<path d="M23.6186 17.7485H22C21.7088 17.7485 21.4727 17.9846 21.4727 18.2759C21.4727 18.5671 21.7088 18.8032 22 18.8032H23.6186C23.9098 18.8032 24.1459 18.5671 24.1459 18.2759C24.1459 17.9846 23.9098 17.7485 23.6186 17.7485Z" fill="#6B717D"/>
<path d="M19.5902 27.5019V29.9663C19.5902 30.2574 19.354 30.4936 19.0629 30.4936H5.08592C4.79484 30.4936 4.55859 30.2574 4.55859 29.9663V27.5019C4.55859 27.2109 4.79484 26.9746 5.08592 26.9746H19.0629C19.354 26.9746 19.5902 27.2109 19.5902 27.5019Z" fill="#D6EAEC"/>
<path d="M19.5898 27.5019V29.9663C19.5898 30.2574 19.3535 30.4936 19.0624 30.4936H16.9531C17.2442 30.4936 17.4805 30.2574 17.4805 29.9663V27.5019C17.4805 27.2109 17.2442 26.9746 16.9531 26.9746H19.0624C19.3535 26.9746 19.5898 27.2109 19.5898 27.5019Z" fill="#B5D9DD"/>
<path d="M22.5287 1.66214V22.3242L20.4194 22.8994L12.0736 25.1767L1.61914 22.3242V1.66214C1.61914 0.745289 2.36443 0 3.28128 0H20.8666C21.7827 0 22.5287 0.745289 22.5287 1.66214Z" fill="#D6EAEC"/>
<path d="M22.5273 1.66214V22.3242L20.418 22.8994V1.66214C20.418 0.745289 19.672 0 18.7559 0H20.8652C21.7813 0 22.5273 0.745289 22.5273 1.66214Z" fill="#B5D9DD"/>
<path d="M22.5287 22.3242V26.3671C22.5287 27.2839 21.7827 28.0292 20.8666 28.0292H3.28128C2.36443 28.0292 1.61914 27.2839 1.61914 26.3671V22.3242H22.5287Z" fill="#6B717D"/>
<path d="M22.5273 22.3242V26.3671C22.5273 27.2839 21.7813 28.0292 20.8652 28.0292H18.7559C19.672 28.0292 20.418 27.2839 20.418 26.3671V22.3242H22.5273Z" fill="#47505E"/>
<path d="M12.43 13.9283C12.2285 13.744 11.9196 13.744 11.7181 13.9283C11.6376 14.0019 9.74805 15.7519 9.74805 17.6083C9.74805 18.8909 10.7915 19.9344 12.0741 19.9344C13.3567 19.9344 14.4001 18.8909 14.4001 17.6083C14.4 15.7519 12.5104 14.0019 12.43 13.9283Z" fill="#72BBFF"/>
<path d="M16.1576 8.85955C17.0908 6.60807 16.0222 4.02635 13.7707 3.0931C11.5192 2.15986 8.93748 3.2285 8.00424 5.47998C7.071 7.73146 8.13964 10.3132 10.3911 11.2464C12.6426 12.1797 15.2243 11.111 16.1576 8.85955Z" fill="#B5D9DD"/>
<path d="M14.7283 7.16982C14.7283 9.02109 13.9254 10.5271 12.0741 10.5271C11.7957 10.5271 11.525 10.4927 11.2655 10.428C9.80379 10.0659 8.7168 8.74266 8.7168 7.16982C8.7168 5.59698 9.80379 4.27374 11.2655 3.91164C11.525 3.84695 11.7957 3.8125 12.0741 3.8125C13.9254 3.8125 14.7283 5.31855 14.7283 7.16982Z" fill="white"/>
<path d="M15.4315 7.16982C15.4315 9.02109 13.9255 10.5271 12.0742 10.5271C11.7958 10.5271 11.5251 10.4927 11.2656 10.428C12.7274 10.0659 13.8144 8.74266 13.8144 7.16982C13.8144 5.59698 12.7274 4.27374 11.2656 3.91164C11.5251 3.84695 11.7958 3.8125 12.0742 3.8125C13.9255 3.8125 15.4315 5.31855 15.4315 7.16982Z" fill="#D6EAEC"/>
<path d="M12.4478 6.79706C12.2418 6.59105 11.908 6.59112 11.7021 6.79706L10.5783 7.92094C10.3723 8.12688 10.3723 8.4608 10.5783 8.66667C10.6812 8.76961 10.8162 8.82115 10.9512 8.82115C11.0861 8.82115 11.2211 8.76968 11.324 8.66667L12.4478 7.5428C12.6538 7.33685 12.6538 7.00294 12.4478 6.79706Z" fill="#FF6C6C"/>
<path d="M5.55469 25.7041C5.84593 25.7041 6.08203 25.468 6.08203 25.1768C6.08203 24.8855 5.84593 24.6494 5.55469 24.6494C5.26344 24.6494 5.02734 24.8855 5.02734 25.1768C5.02734 25.468 5.26344 25.7041 5.55469 25.7041Z" fill="#47505E"/>
<path d="M18.5918 25.7041C18.883 25.7041 19.1191 25.468 19.1191 25.1768C19.1191 24.8855 18.883 24.6494 18.5918 24.6494C18.3006 24.6494 18.0645 24.8855 18.0645 25.1768C18.0645 25.468 18.3006 25.7041 18.5918 25.7041Z" fill="#47505E"/>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,28 @@
<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.6724 33.3447C25.8803 33.3447 33.3447 25.8803 33.3447 16.6724C33.3447 7.46448 25.8803 0 16.6724 0C7.46448 0 0 7.46448 0 16.6724C0 25.8803 7.46448 33.3447 16.6724 33.3447Z" fill="#F07281"/>
<path d="M17.3767 33.3303C17.1436 33.3401 16.9084 33.345 16.6725 33.345C7.46478 33.345 0 25.8802 0 16.6725C0 7.46478 7.46478 0 16.6725 0C16.9084 0 17.1436 0.00492188 17.3767 0.0147656C8.4957 0.38377 1.40841 7.70068 1.40841 16.6725C1.40841 25.6443 8.4957 32.9613 17.3767 33.3303Z" fill="#EB5569"/>
<path d="M16.6726 31.1577C24.6725 31.1577 31.1577 24.6725 31.1577 16.6726C31.1577 8.67269 24.6725 2.1875 16.6726 2.1875C8.67269 2.1875 2.1875 8.67269 2.1875 16.6726C2.1875 24.6725 8.67269 31.1577 16.6726 31.1577Z" fill="#EAF6FF"/>
<path d="M17.7291 31.1199C17.3805 31.1453 17.0276 31.1579 16.6727 31.1579C8.67269 31.1579 2.1875 24.6727 2.1875 16.6727C2.1875 8.67269 8.67275 2.1875 16.6728 2.1875C17.0277 2.1875 17.3805 2.20015 17.7291 2.22551C10.2221 2.76644 4.30022 9.02768 4.30022 16.6727C4.30022 24.3178 10.2221 30.5791 17.7291 31.1199Z" fill="#D8ECFE"/>
<path d="M15.7672 8.23957L16.4138 7.82326C16.5715 7.72167 16.7741 7.72167 16.9319 7.82326L17.5785 8.23957C17.6957 8.31503 17.7666 8.44498 17.7666 8.58444V16.8663H15.5791V8.58444C15.579 8.44498 15.6499 8.3151 15.7672 8.23957Z" fill="#5680A6"/>
<path d="M17.377 8.10996L16.9876 8.36063V16.8662H15.5791V8.62163C15.5791 8.45893 15.6617 8.30738 15.7985 8.21933L16.4136 7.82326C16.5714 7.72167 16.774 7.72167 16.9318 7.82326L17.377 8.10996Z" fill="#497090"/>
<path d="M23.5067 16.9318L23.1106 17.547C23.0225 17.6837 22.871 17.7664 22.7083 17.7664H16.6729V15.5791H22.7083C22.871 15.5791 23.0225 15.6617 23.1106 15.7985L23.5067 16.4137C23.6083 16.5715 23.6083 16.774 23.5067 16.9318Z" fill="#5680A6"/>
<path d="M19.6131 16.6727C19.6131 17.0594 19.5384 17.4284 19.4018 17.7664H16.6729V15.5791H19.4018C19.5384 15.9171 19.6131 16.2861 19.6131 16.6727Z" fill="#497090"/>
<path d="M16.6723 18.2039C17.5182 18.2039 18.2039 17.5182 18.2039 16.6723C18.2039 15.8264 17.5182 15.1406 16.6723 15.1406C15.8264 15.1406 15.1406 15.8264 15.1406 16.6723C15.1406 17.5182 15.8264 18.2039 16.6723 18.2039Z" fill="#F07281"/>
<path d="M17.3765 18.0326C17.166 18.1424 16.9265 18.2044 16.6723 18.2044C15.8265 18.2044 15.1406 17.5185 15.1406 16.6728C15.1406 15.827 15.8265 15.1411 16.6723 15.1411C16.9265 15.1411 17.166 15.2031 17.3765 15.313C16.885 15.5672 16.549 16.0813 16.549 16.6728C16.549 17.2644 16.885 17.7783 17.3765 18.0326Z" fill="#EB5569"/>
<path d="M34.5329 28.7151V27.6225C34.5329 27.4043 34.3853 27.2137 34.174 27.1592L32.9876 26.853C32.8555 26.3207 32.6457 25.8193 32.37 25.3617L32.9923 24.3064C33.1032 24.1184 33.0728 23.8793 32.9185 23.7249L32.1459 22.9523C31.9916 22.798 31.7524 22.7676 31.5644 22.8785L30.5091 23.5008C30.0516 23.2251 29.5501 23.0153 29.0178 22.8832L28.7116 21.6968C28.6571 21.4855 28.4665 21.3379 28.2483 21.3379H27.1557C26.9375 21.3379 26.7469 21.4855 26.6924 21.6968L26.3862 22.8832C25.8539 23.0153 25.3525 23.2252 24.8949 23.5008L23.8396 22.8785C23.6516 22.7676 23.4125 22.798 23.2581 22.9523L22.4855 23.7249C22.3313 23.8792 22.3009 24.1184 22.4117 24.3064L23.0341 25.3617C22.7583 25.8193 22.5485 26.3207 22.4164 26.853L21.23 27.1592C21.0188 27.2137 20.8711 27.4043 20.8711 27.6225V28.7151C20.8711 28.9333 21.0188 29.1239 21.23 29.1784L22.4164 29.4846C22.5485 30.0169 22.7584 30.5183 23.0341 30.9759L22.4117 32.0312C22.3008 32.2192 22.3313 32.4583 22.4855 32.6127L23.2581 33.3853C23.4124 33.5396 23.6516 33.5699 23.8396 33.4591L24.8949 32.8368C25.3525 33.1125 25.8539 33.3223 26.3862 33.4544L26.6924 34.6408C26.7469 34.8521 26.9375 34.9997 27.1557 34.9997H28.2483C28.4665 34.9997 28.6571 34.8521 28.7116 34.6408L29.0178 33.4544C29.5501 33.3223 30.0516 33.1124 30.5091 32.8368L31.5644 33.4591C31.7524 33.57 31.9915 33.5396 32.1459 33.3853L32.9185 32.6127C33.0728 32.4584 33.1031 32.2192 32.9923 32.0312L32.37 30.9759C32.6457 30.5183 32.8555 30.0169 32.9876 29.4846L34.174 29.1784C34.3853 29.1239 34.5329 28.9333 34.5329 28.7151Z" fill="#88B4F5"/>
<path d="M22.2796 27.252V29.0858L23.8246 29.4844C23.9563 30.0168 24.1662 30.5182 24.4423 30.976L23.6317 32.3506L24.4057 33.1246L23.8391 33.4588C23.6511 33.5696 23.4119 33.5393 23.2576 33.3849L22.4853 32.6127C22.331 32.4584 22.3007 32.2192 22.4115 32.0313L23.0338 30.976C22.7577 30.5182 22.5479 30.0168 22.4162 29.4844L21.23 29.1784C21.0187 29.124 20.8711 28.9333 20.8711 28.7151V27.6226C20.8711 27.4044 21.0187 27.2139 21.2299 27.1593L22.4162 26.8527C22.5479 26.321 22.7577 25.8189 23.0338 25.3619L22.4115 24.3064C22.3007 24.1185 22.331 23.8794 22.4853 23.7251L23.2577 22.9523C23.4119 22.7978 23.6512 22.7675 23.8392 22.8784L24.4057 23.2125L23.6317 23.9872L24.4423 25.3619C24.1662 25.8189 23.9564 26.321 23.8246 26.8527L22.2796 27.252Z" fill="#6EA2F2"/>
<path d="M27.7946 33.454L28.1932 34.9997H27.1555C26.9372 34.9997 26.7466 34.8521 26.6921 34.6407L26.3861 33.454C26.1361 33.3927 25.8924 33.3132 25.6572 33.2174L26.303 32.8364C26.7608 33.1124 27.2622 33.3223 27.7946 33.454Z" fill="#6EA2F2"/>
<path d="M27.1555 21.3379H28.1932L27.7946 22.883C27.2622 23.0154 26.7608 23.2252 26.303 23.5006L25.6572 23.1196C25.8925 23.0245 26.1361 22.945 26.3861 22.883L26.6921 21.6969C26.7466 21.4855 26.9373 21.3379 27.1555 21.3379Z" fill="#6EA2F2"/>
<path d="M27.7023 31.4612C29.5205 31.4612 30.9944 29.9873 30.9944 28.1691C30.9944 26.3509 29.5205 24.877 27.7023 24.877C25.8841 24.877 24.4102 26.3509 24.4102 28.1691C24.4102 29.9873 25.8841 31.4612 27.7023 31.4612Z" fill="#5680A6"/>
<path d="M28.7581 31.2882C28.4264 31.4009 28.0707 31.4615 27.7017 31.4615C25.8841 31.4615 24.4102 29.9875 24.4102 28.1692C24.4102 26.3509 25.8841 24.877 27.7017 24.877C28.0707 24.877 28.4263 24.9375 28.7581 25.0502C27.4588 25.4903 26.5229 26.7206 26.5229 28.1692C26.5229 29.6178 27.4588 30.8481 28.7581 31.2882Z" fill="#497090"/>
<path d="M16.6727 6.19265C16.381 6.19265 16.1445 5.95619 16.1445 5.6645V4.30012C16.1445 4.00843 16.381 3.77197 16.6727 3.77197C16.9644 3.77197 17.2008 4.00843 17.2008 4.30012V5.66443C17.2008 5.95612 16.9644 6.19265 16.6727 6.19265Z" fill="#88B4F5"/>
<path d="M16.6727 29.5729C16.381 29.5729 16.1445 29.3365 16.1445 29.0448V27.6805C16.1445 27.3888 16.381 27.1523 16.6727 27.1523C16.9644 27.1523 17.2008 27.3888 17.2008 27.6805V29.0448C17.2008 29.3364 16.9644 29.5729 16.6727 29.5729Z" fill="#88B4F5"/>
<path d="M5.66492 17.2003H4.30061C4.00892 17.2003 3.77246 16.9639 3.77246 16.6722C3.77246 16.3805 4.00892 16.144 4.30061 16.144H5.66492C5.95661 16.144 6.19307 16.3805 6.19307 16.6722C6.19307 16.9639 5.95661 17.2003 5.66492 17.2003Z" fill="#88B4F5"/>
<path d="M29.0448 17.2003H27.6805C27.3887 17.2003 27.1523 16.9639 27.1523 16.6722C27.1523 16.3805 27.3888 16.144 27.6805 16.144H29.0448C29.3366 16.144 29.5729 16.3805 29.5729 16.6722C29.5729 16.9639 29.3365 17.2003 29.0448 17.2003Z" fill="#88B4F5"/>
<path d="M5.95843 23.3866C5.77591 23.3866 5.59838 23.2918 5.50056 23.1224C5.35468 22.8698 5.44122 22.5467 5.69388 22.4009L6.8754 21.7188C7.12785 21.573 7.45099 21.6594 7.59687 21.9121C7.74275 22.1647 7.6562 22.4877 7.40355 22.6335L6.22202 23.3157C6.1389 23.3638 6.04805 23.3866 5.95843 23.3866Z" fill="#88B4F5"/>
<path d="M26.2065 11.6967C26.0239 11.6967 25.8464 11.6019 25.7486 11.4325C25.6027 11.1799 25.6893 10.8568 25.9419 10.711L27.1234 10.0288C27.376 9.88304 27.699 9.96951 27.8449 10.2222C27.9908 10.4748 27.9042 10.7978 27.6516 10.9436L26.4701 11.6258C26.3869 11.6738 26.296 11.6967 26.2065 11.6967Z" fill="#88B4F5"/>
<path d="M7.139 11.6967C7.04938 11.6967 6.9586 11.6739 6.8754 11.6259L5.69388 10.9437C5.44122 10.7978 5.35468 10.4748 5.50056 10.2222C5.64637 9.96957 5.96937 9.88296 6.22202 10.0289L7.40355 10.7111C7.6562 10.8569 7.74275 11.1799 7.59687 11.4325C7.49904 11.602 7.32152 11.6967 7.139 11.6967Z" fill="#88B4F5"/>
<path d="M10.4858 27.9149C10.3962 27.9149 10.3054 27.892 10.2222 27.844C9.96954 27.6981 9.883 27.3751 10.0289 27.1225L10.711 25.941C10.8568 25.6883 11.1799 25.6017 11.4325 25.7477C11.6852 25.8935 11.7717 26.2165 11.6258 26.4691L10.9437 27.6506C10.8458 27.8201 10.6683 27.9149 10.4858 27.9149Z" fill="#88B4F5"/>
<path d="M22.1752 7.66727C22.0856 7.66727 21.9948 7.64444 21.9116 7.59638C21.659 7.45057 21.5724 7.1275 21.7183 6.87491L22.4005 5.69339C22.5463 5.44073 22.8692 5.35419 23.1219 5.50007C23.3745 5.64588 23.4611 5.96895 23.3153 6.22154L22.6331 7.40306C22.5353 7.57252 22.3578 7.66727 22.1752 7.66727Z" fill="#88B4F5"/>
<path d="M11.1689 7.66727C10.9864 7.66727 10.8089 7.57252 10.711 7.40306L10.0289 6.22154C9.883 5.96895 9.96954 5.64588 10.2222 5.50007C10.4747 5.35419 10.7979 5.44073 10.9437 5.69339L11.6258 6.87491C11.7717 7.1275 11.6852 7.45057 11.4325 7.59638C11.3494 7.64437 11.2585 7.66727 11.1689 7.66727Z" fill="#88B4F5"/>
</svg>

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -2,11 +2,11 @@ import 'package:flutter/gestures.dart';
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/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/visitor_password/bloc/visitor_password_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:syncrow_web/services/locator.dart';
import 'package:syncrow_web/utils/app_routes.dart';
import 'package:syncrow_web/utils/constants/routes_const.dart';
@ -14,8 +14,7 @@ import 'package:syncrow_web/utils/theme/theme.dart';
Future<void> main() async {
try {
const environment =
String.fromEnvironment('FLAVOR', defaultValue: 'development');
const environment = String.fromEnvironment('FLAVOR', defaultValue: 'development');
await dotenv.load(fileName: '.env.$environment');
WidgetsFlutterBinding.ensureInitialized();
initialSetup();
@ -45,11 +44,9 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
//HomeBloc.fetchUserInfo();
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => HomeBloc()..add(const FetchUserInfo())),
BlocProvider(create: (context) => HomeBloc()..add(const FetchUserInfo())),
BlocProvider<VisitorPasswordBloc>(
create: (context) => VisitorPasswordBloc(),
)

View File

@ -3,25 +3,27 @@ import 'package:flutter_bloc/flutter_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/access_management/model/password_model.dart';
import 'package:syncrow_web/pages/common/hour_picker_dialog.dart';
import 'package:syncrow_web/services/access_mang_api.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/app_enum.dart';
import 'package:syncrow_web/utils/snack_bar.dart';
class AccessBloc extends Bloc<AccessEvent, AccessState> {
AccessBloc() : super((AccessInitial())) {
on<FetchTableData>(_onFetchTableData);
// on<TabChangedEvent>(selectFilterTap);
on<SelectTime>(selectTime);
on<FilterDataEvent>(_filterData);
on<ResetSearch>(resetSearch);
on<TabChangedEvent>(onTabChanged);
}
String startTime = 'Start Date';
String endTime = 'End Date';
int? effectiveTimeTimeStamp;
int? expirationTimeTimeStamp;
TextEditingController passwordName = TextEditingController();
TextEditingController emailAuthorizer = TextEditingController();
List<PasswordModel> filteredData = [];
List<PasswordModel> data = [];
@ -62,57 +64,61 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
}
Future<void> selectTime(SelectTime event, Emitter<AccessState> emit) async {
Future<void> selectTime(SelectTime event, Emitter<AccessState> emit,) async {
emit(AccessLoaded());
final DateTime? picked = await showDatePicker(
context: event.context,
initialDate: DateTime.now(),
firstDate: DateTime(2015, 8),
lastDate: DateTime(2101),
firstDate: DateTime.now().add(const Duration(days: -5095)),
lastDate: DateTime.now().add(const Duration(days: 2095)),
);
if (picked != null) {
final selectedDateTime = DateTime(
picked.year,
picked.month,
picked.day,
final TimeOfDay? timePicked = await showHourPicker(
context: event.context,
initialTime: TimeOfDay.now(),
);
final selectedTimestamp = DateTime(
selectedDateTime.year,
selectedDateTime.month,
selectedDateTime.day,
selectedDateTime.hour,
selectedDateTime.minute,
).millisecondsSinceEpoch ~/
1000; // Divide by 1000 to remove milliseconds
if (event.isStart) {
if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
if (timePicked != null) {
final DateTime selectedDateTime = DateTime(
picked.year,
picked.month,
picked.day,
timePicked.hour,
timePicked.minute,
);
final int selectedTimestamp = selectedDateTime.millisecondsSinceEpoch ~/ 1000;
if (event.isStart) {
if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
} else {
startTime = selectedDateTime.toString().split('.').first;
effectiveTimeTimeStamp = selectedTimestamp;
}
} else {
startTime =
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
effectiveTimeTimeStamp = selectedTimestamp;
}
} else {
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.');
} else {
endTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
expirationTimeTimeStamp = selectedTimestamp;
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.');
} else {
endTime = selectedDateTime.toString().split('.').first;
expirationTimeTimeStamp = selectedTimestamp;
}
}
}
}
emit(ChangeTimeState());
}
Future<void> _filterData(FilterDataEvent event, Emitter<AccessState> emit) async {
emit(AccessLoaded());
try {
print(event.emailAuthorizer?.toLowerCase());
// Convert search text to lower case for case-insensitive search
final searchText = event.passwordName?.toLowerCase() ?? '';
final searchEmailText = event.emailAuthorizer?.toLowerCase() ?? '';
filteredData = data.where((item) {
bool matchesCriteria = true;
// Convert timestamp to DateTime and extract date component
DateTime effectiveDate =
DateTime.fromMillisecondsSinceEpoch(int.parse(item.effectiveTime.toString()) * 1000)
@ -122,9 +128,8 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
DateTime.fromMillisecondsSinceEpoch(int.parse(item.invalidTime.toString()) * 1000)
.toUtc()
.toLocal();
DateTime effectiveDateOnly =
DateTime(effectiveDate.year, effectiveDate.month, effectiveDate.day);
DateTime invalidDateOnly = DateTime(invalidDate.year, invalidDate.month, invalidDate.day);
DateTime effectiveDateAndTime = DateTime(effectiveDate.year, effectiveDate.month, effectiveDate.day,effectiveDate.hour,effectiveDate.minute);
DateTime invalidDateAndTime = DateTime(invalidDate.year, invalidDate.month, invalidDate.day,invalidDate.hour,invalidDate.minute);
// Filter by password name, making the search case-insensitive
if (searchText.isNotEmpty) {
@ -133,36 +138,51 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
matchesCriteria = false;
}
}
// Filter by start date only
if (event.startTime != null && event.endTime == null) {
DateTime startDateOnly =
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
startDateOnly = DateTime(startDateOnly.year, startDateOnly.month, startDateOnly.day);
if (effectiveDateOnly.isBefore(startDateOnly)) {
if (searchEmailText.isNotEmpty) {
final bool matchesName = item.authorizerEmail.toString().toLowerCase().contains(searchEmailText);
if (!matchesName) {
matchesCriteria = false;
}
}
// Filter by start date only
if (event.startTime != null && event.endTime == null) {
DateTime startDateTime =
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
startDateTime = DateTime(
startDateTime.year,
startDateTime.month,
startDateTime.day,
startDateTime.hour,
startDateTime.minute);
if (effectiveDateAndTime.isBefore(startDateTime)) {
matchesCriteria = false;
}
}
// Filter by end date only
if (event.endTime != null && event.startTime == null) {
DateTime endDateOnly =
DateTime startDateTime =
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
endDateOnly = DateTime(endDateOnly.year, endDateOnly.month, endDateOnly.day);
if (invalidDateOnly.isAfter(endDateOnly)) {
startDateTime = DateTime(
startDateTime.year,
startDateTime.month,
startDateTime.day,
startDateTime.hour,
startDateTime.minute
);
if (invalidDateAndTime.isAfter(startDateTime)) {
matchesCriteria = false;
}
}
// Filter by both start date and end date
if (event.startTime != null && event.endTime != null) {
DateTime startDateOnly =
DateTime startDateTime =
DateTime.fromMillisecondsSinceEpoch(event.startTime! * 1000).toUtc().toLocal();
DateTime endDateOnly =
DateTime endDateTime =
DateTime.fromMillisecondsSinceEpoch(event.endTime! * 1000).toUtc().toLocal();
startDateOnly = DateTime(startDateOnly.year, startDateOnly.month, startDateOnly.day);
endDateOnly = DateTime(endDateOnly.year, endDateOnly.month, endDateOnly.day);
if (effectiveDateOnly.isBefore(startDateOnly) || invalidDateOnly.isAfter(endDateOnly)) {
startDateTime = DateTime(startDateTime.year, startDateTime.month, startDateTime.day,startDateTime.hour,startDateTime.minute);
endDateTime = DateTime(endDateTime.year, endDateTime.month, endDateTime.day,endDateTime.hour,endDateTime.minute);
if (effectiveDateAndTime.isBefore(startDateTime) || invalidDateAndTime.isAfter(endDateTime)) {
matchesCriteria = false;
}
}
@ -186,12 +206,12 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
}
resetSearch(ResetSearch event, Emitter<AccessState> emit) async {
emit(AccessLoaded());
startTime = 'Start Time';
endTime = 'End Time';
passwordName.clear();
emailAuthorizer.clear();
selectedIndex = 0;
effectiveTimeTimeStamp = null;
expirationTimeTimeStamp = null;
@ -200,9 +220,11 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
String timestampToDate(dynamic timestamp) {
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(int.parse(timestamp) * 1000);
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')}";
return "${dateTime.year}/${dateTime.month.toString().padLeft(2, '0')}/${dateTime.day.toString().padLeft(2, '0')} "
" ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}";
}
Future<void> onTabChanged(TabChangedEvent event, Emitter<AccessState> emit) async {
try {
emit(AccessLoaded());
@ -227,6 +249,7 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
add(FilterDataEvent(
selectedTabIndex: selectedIndex,
passwordName: passwordName.text.toLowerCase(),
emailAuthorizer: emailAuthorizer.text.toLowerCase(),
startTime: effectiveTimeTimeStamp,
endTime: expirationTimeTimeStamp));
emit(TableLoaded(filteredData));
@ -234,4 +257,6 @@ class AccessBloc extends Bloc<AccessEvent, AccessState> {
emit(FailedState(e.toString()));
}
}
}

View File

@ -28,12 +28,14 @@ class SelectTime extends AccessEvent {
class FilterDataEvent extends AccessEvent {
final String? passwordName;
final String? emailAuthorizer;
final int? startTime;
final int? endTime;
final int selectedTabIndex; // Add this field
const FilterDataEvent({
this.passwordName,
this.emailAuthorizer,
this.startTime,
this.endTime,
required this.selectedTabIndex, // Initialize this field

View File

@ -6,10 +6,13 @@ class PasswordModel {
final dynamic effectiveTime;
final dynamic passwordCreated;
final dynamic createdTime;
final dynamic passwordName; // New field
final dynamic passwordName;
final AccessStatus passwordStatus;
final AccessType passwordType;
final dynamic deviceUuid;
final dynamic authorizerEmail;
final dynamic authorizerDate;
final dynamic deviceName;
PasswordModel({
this.passwordId,
@ -17,10 +20,13 @@ class PasswordModel {
this.effectiveTime,
this.passwordCreated,
this.createdTime,
this.passwordName, // New field
this.passwordName,
required this.passwordStatus,
required this.passwordType,
this.deviceUuid,
this.authorizerEmail,
this.authorizerDate,
this.deviceName,
});
factory PasswordModel.fromJson(Map<String, dynamic> json) {
@ -34,6 +40,9 @@ class PasswordModel {
passwordStatus: AccessStatusExtension.fromString(json['passwordStatus']),
passwordType: AccessTypeExtension.fromString(json['passwordType']),
deviceUuid: json['deviceUuid'],
authorizerEmail: json['authorizerEmail'],
authorizerDate: json['authorizerDate'],
deviceName: json['deviceName'],
);
}
@ -44,10 +53,13 @@ class PasswordModel {
'effectiveTime': effectiveTime,
'passwordCreated': passwordCreated,
'createdTime': createdTime,
'passwodName': passwordName, // New field
'passwordName': passwordName, // New field
'passwordStatus': passwordStatus,
'passwordType': passwordType,
'deviceUuid': deviceUuid,
'authorizerEmail': authorizerEmail,
'authorizerDate': authorizerDate,
'deviceName': deviceName,
};
}
}

View File

@ -24,13 +24,14 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
@override
Widget build(BuildContext context) {
final isLargeScreen = isLargeScreenSize(context);
final isSmallScreen = isSmallScreenSize(context);
final isHalfMediumScreen = isHafMediumScreenSize(context);
final padding = isLargeScreen ? const EdgeInsets.all(30) : const EdgeInsets.all(15);
return WebScaffold(
enableMenuSideba: false,
enableMenuSidebar: false,
appBarTitle: FittedBox(
child: Text(
'Access Management',
@ -85,7 +86,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
_buildVisitorAdminPasswords(context, accessBloc),
const SizedBox(height: 20),
Expanded(
child: DynamicTable(
child: DynamicTable(
tableName: 'AccessManagement',
uuidIndex: 1,
withSelectAll: true,
@ -96,7 +97,8 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
headers: const [
'Name',
'Access Type',
'Access Period',
'Access Start',
'Access End',
'Accessible Device',
'Authorizer',
'Authorization Date & Time',
@ -106,10 +108,11 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
return [
item.passwordName,
item.passwordType.value,
('${accessBloc.timestampToDate(item.effectiveTime)} - ${accessBloc.timestampToDate(item.invalidTime)}'),
item.deviceUuid.toString(),
'',
'',
accessBloc.timestampToDate(item.effectiveTime),
accessBloc.timestampToDate(item.invalidTime),
item.deviceName.toString(),
item.authorizerEmail.toString(),
accessBloc.timestampToDate(item.invalidTime),
item.passwordStatus.value,
];
}).toList(),
@ -166,6 +169,8 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
}
Row _buildNormalSearchWidgets(BuildContext context, AccessBloc accessBloc) {
TimeOfDay _selectedTime = TimeOfDay.now();
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
@ -182,6 +187,17 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
),
),
const SizedBox(width: 15),
SizedBox(
width: 250,
child: CustomWebTextField(
controller: accessBloc.emailAuthorizer,
height: 43,
isRequired: false,
textFieldName: 'Authorizer',
description: '',
),
),
const SizedBox(width: 15),
SizedBox(
child: DateTimeWebWidget(
icon: Assets.calendarIcon,
@ -189,7 +205,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
title: 'Access Time',
size: MediaQuery.of(context).size,
endTime: () {
accessBloc.add(SelectTime(context: context, isStart: false));
accessBloc.add(SelectTime(context: context, isStart: false));
},
startTime: () {
accessBloc.add(SelectTime(context: context, isStart: true));
@ -202,6 +218,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
SearchResetButtons(
onSearch: () {
accessBloc.add(FilterDataEvent(
emailAuthorizer:accessBloc.emailAuthorizer.text.toLowerCase() ,
selectedTabIndex: BlocProvider.of<AccessBloc>(context).selectedIndex,
passwordName: accessBloc.passwordName.text.toLowerCase(),
startTime: accessBloc.effectiveTimeTimeStamp,
@ -247,10 +264,12 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
SearchResetButtons(
onSearch: () {
accessBloc.add(FilterDataEvent(
emailAuthorizer:accessBloc.emailAuthorizer.text.toLowerCase() ,
selectedTabIndex: BlocProvider.of<AccessBloc>(context).selectedIndex,
passwordName: accessBloc.passwordName.text.toLowerCase(),
startTime: accessBloc.effectiveTimeTimeStamp,
endTime: accessBloc.expirationTimeTimeStamp));
endTime: accessBloc.expirationTimeTimeStamp
));
},
onReset: () {
accessBloc.add(ResetSearch());
@ -259,4 +278,6 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout {
],
);
}
}

View File

@ -139,9 +139,11 @@ class ForgetPasswordWebPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(height: 10),
SizedBox(
child: _buildDropdownField(
context, forgetBloc, size))
Form(
key: forgetBloc.forgetRegionKey,
child: SizedBox(
child: _buildDropdownField(
context, forgetBloc, size)))
],
),
const SizedBox(height: 20),
@ -207,31 +209,23 @@ class ForgetPasswordWebPage extends StatelessWidget {
decoration:
textBoxDecoration()!.copyWith(
hintText: 'Enter Code',
hintStyle: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color:
ColorsManager.grayColor,
fontWeight:
FontWeight.w400),
hintStyle: Theme.of(context).textTheme
.bodySmall!.copyWith(
color: ColorsManager.grayColor,
fontWeight: FontWeight.w400),
suffixIcon: SizedBox(
width: 100,
child: Center(
child: InkWell(
onTap: state is TimerState &&
!state
.isButtonEnabled &&
state.remainingTime !=
1
!state.isButtonEnabled &&
state.remainingTime != 1
? null
: () {
if (forgetBloc
.forgetEmailKey
.currentState!
.validate()) {
forgetBloc.add(
StartTimerEvent());
if (forgetBloc.forgetEmailKey.currentState!.validate()||forgetBloc.forgetRegionKey.currentState!.validate()) {
if(forgetBloc.forgetRegionKey.currentState!.validate()){
forgetBloc.add(StartTimerEvent());
}
}
},
child: Text(
@ -428,7 +422,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
),
),
const SizedBox(height: 10),
Container(
SizedBox(
width: size.width * 0.9,
child: FormField<String>(
validator: (value) {
@ -493,7 +487,10 @@ class ForgetPasswordWebPage extends StatelessWidget {
return DropdownMenuItem<String>(
value: region.id,
child: Text(
style: Theme.of(context).textTheme.bodyMedium,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400,
),
region.name,
overflow: TextOverflow.ellipsis,
maxLines: 1,
@ -568,4 +565,5 @@ class ForgetPasswordWebPage extends StatelessWidget {
);
}
}

View File

@ -17,6 +17,8 @@ class DefaultButton extends StatelessWidget {
this.borderRadius,
this.height,
this.padding,
this.borderColor,
this.elevation,
});
final void Function()? onPressed;
final Widget child;
@ -31,6 +33,9 @@ class DefaultButton extends StatelessWidget {
final ButtonStyle? customButtonStyle;
final Color? backgroundColor;
final Color? foregroundColor;
final Color? borderColor;
final double? elevation;
@override
Widget build(BuildContext context) {
return ElevatedButton(
@ -39,40 +44,42 @@ class DefaultButton extends StatelessWidget {
? null
: customButtonStyle ??
ButtonStyle(
textStyle: MaterialStateProperty.all(
textStyle: WidgetStateProperty.all(
customTextStyle ??
Theme.of(context).textTheme.bodySmall!.copyWith(
fontSize: 13,
color: foregroundColor,
fontWeight: FontWeight.normal),
),
foregroundColor: MaterialStateProperty.all(
foregroundColor: WidgetStateProperty.all(
isSecondary
? Colors.black
: enabled
? foregroundColor ?? Colors.white
: Colors.black,
),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
backgroundColor: WidgetStateProperty.resolveWith<Color>(
(Set<WidgetState> states) {
return enabled
? backgroundColor ?? ColorsManager.primaryColor
: Colors.black.withOpacity(0.2);
}),
shape: MaterialStateProperty.all(
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
side: BorderSide(color: borderColor ?? Colors.transparent),
borderRadius: BorderRadius.circular(borderRadius ?? 20),
),
),
fixedSize: MaterialStateProperty.all(
fixedSize: WidgetStateProperty.all(
const Size.fromHeight(50),
),
padding: MaterialStateProperty.all(
padding: WidgetStateProperty.all(
EdgeInsets.all(padding ?? 10),
),
minimumSize: MaterialStateProperty.all(
minimumSize: WidgetStateProperty.all(
const Size.fromHeight(50),
),
elevation: WidgetStateProperty.all(elevation ?? 0),
),
child: SizedBox(
height: height ?? 50,

View File

@ -1,9 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_bloc.dart';
import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_event.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
@ -12,6 +9,7 @@ class CurtainToggle extends StatelessWidget {
final String code;
final String deviceId;
final String label;
final Null Function(dynamic value) onChanged;
const CurtainToggle({
super.key,
@ -19,6 +17,7 @@ class CurtainToggle extends StatelessWidget {
required this.code,
required this.deviceId,
required this.label,
required this.onChanged,
});
@override
@ -54,15 +53,7 @@ class CurtainToggle extends StatelessWidget {
child: CupertinoSwitch(
value: value,
activeColor: ColorsManager.dialogBlueTitle,
onChanged: (newValue) {
context.read<CurtainBloc>().add(
CurtainControl(
deviceId: deviceId,
code: code,
value: newValue,
),
);
},
onChanged: onChanged,
),
),
],

View File

@ -17,6 +17,7 @@ class DynamicTable extends StatefulWidget {
final void Function(int, bool, dynamic)? onRowSelected;
final List<String>? initialSelectedIds;
final int uuidIndex;
final Function(dynamic selectedRows)? onSelectionChanged;
const DynamicTable({
super.key,
required this.headers,
@ -32,6 +33,7 @@ class DynamicTable extends StatefulWidget {
this.onRowSelected,
this.initialSelectedIds,
required this.uuidIndex,
this.onSelectionChanged,
});
@override
@ -39,7 +41,7 @@ class DynamicTable extends StatefulWidget {
}
class _DynamicTableState extends State<DynamicTable> {
late List<bool> _selected;
late List<bool> _selectedRows;
bool _selectAll = false;
@override
@ -51,45 +53,30 @@ class _DynamicTableState extends State<DynamicTable> {
@override
void didUpdateWidget(DynamicTable oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.data != widget.data) {
if (oldWidget.data.length != widget.data.length) {
_initializeSelection();
}
}
void _initializeSelection() {
if (widget.data.isEmpty) {
_selected = [];
_selectAll = false;
} else {
_selected = List<bool>.generate(widget.data.length, (index) {
// Check if the initialSelectedIds contains the deviceUuid
// uuidIndex is the index of the column containing the deviceUuid
final deviceUuid = widget.data[index][widget.uuidIndex];
return widget.initialSelectedIds != null &&
widget.initialSelectedIds!.contains(deviceUuid);
});
_selectAll = _selected.every((element) => element == true);
}
}
void _toggleRowSelection(int index) {
setState(() {
_selected[index] = !_selected[index];
if (widget.onRowSelected != null) {
widget.onRowSelected!(index, _selected[index], widget.data[index]);
}
});
_selectedRows = List<bool>.filled(widget.data.length, false);
_selectAll = false;
}
void _toggleSelectAll(bool? value) {
setState(() {
_selectAll = value ?? false;
_selected = List<bool>.filled(widget.data.length, _selectAll);
if (widget.selectAll != null) {
widget.selectAll!(_selectAll);
}
_selectedRows = List<bool>.filled(widget.data.length, _selectAll);
});
widget.onSelectionChanged?.call(_selectedRows);
}
void _toggleRowSelection(int index) {
setState(() {
_selectedRows[index] = !_selectedRows[index];
_selectAll = _selectedRows.every((isSelected) => isSelected);
});
widget.onSelectionChanged?.call(_selectedRows);
}
@override
@ -185,8 +172,7 @@ class _DynamicTableState extends State<DynamicTable> {
),
),
child: Checkbox(
value: widget.data.isNotEmpty &&
_selected.every((element) => element == true),
value: _selectAll,
onChanged: widget.withSelectAll && widget.data.isNotEmpty
? _toggleSelectAll
: null,
@ -210,7 +196,7 @@ class _DynamicTableState extends State<DynamicTable> {
alignment: Alignment.centerLeft,
child: Center(
child: Checkbox(
value: _selected[index],
value: _selectedRows[index],
onChanged: (bool? value) {
_toggleRowSelection(index);
},

View File

@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
class HourPickerDialog extends StatefulWidget {
final TimeOfDay initialTime;
const HourPickerDialog({super.key, required this.initialTime});
@override
@ -9,70 +12,50 @@ class HourPickerDialog extends StatefulWidget {
}
class _HourPickerDialogState extends State<HourPickerDialog> {
late int _selectedHour;
bool _isPm = true;
late String selectedHour;
@override
void initState() {
super.initState();
_selectedHour = widget.initialTime.hour > 12
? widget.initialTime.hour - 12
: widget.initialTime.hour;
_isPm = widget.initialTime.period == DayPeriod.am;
// Initialize the selectedHour with the initial time passed to the dialog
selectedHour = widget.initialTime.hour.toString().padLeft(2, '0') + ':00';
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Select Hour'),
content: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
DropdownButton<int>(
value: _selectedHour,
items: List.generate(12, (index) {
int displayHour = index + 1;
return DropdownMenuItem(
value: displayHour,
child: Text(displayHour.toString()),
);
}),
onChanged: (value) {
setState(() {
_selectedHour = value!;
});
},
),
SizedBox(width: 16.0),
DropdownButton<bool>(
value: _isPm,
items: const [
DropdownMenuItem(
value: true,
child: Text('AM'),
),
DropdownMenuItem(
value:false ,
child: Text('PM'),
),
],
onChanged: (value) {
setState(() {
_isPm = value!;
});
},
),
],
content: DropdownButton<String>(
value: selectedHour, // Show the currently selected hour
items: List.generate(24, (index) {
String hour = index.toString().padLeft(2, '0');
return DropdownMenuItem<String>(
value: '$hour:00',
child: Text('$hour:00'),
);
}),
onChanged: (String? newValue) {
if (newValue != null) {
setState(() {
selectedHour = newValue; // Update the selected hour without closing the dialog
});
}
},
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(null),
onPressed: () => Navigator.of(context).pop(null), // Close the dialog without selection
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
int hour = _isPm ? _selectedHour + 12 : _selectedHour;
Navigator.of(context).pop(TimeOfDay(hour: hour, minute: 0));
// Close the dialog and return the selected time
Navigator.of(context).pop(
TimeOfDay(
hour: int.parse(selectedHour.split(':')[0]),
minute: 0,
),
);
},
child: const Text('OK'),
),
@ -86,6 +69,7 @@ Future<TimeOfDay?> showHourPicker({
required TimeOfDay initialTime,
}) {
return showDialog<TimeOfDay>(
barrierDismissible: false,
context: context,
builder: (context) => HourPickerDialog(initialTime: initialTime),
);

View File

@ -14,12 +14,15 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
Timer? _timer;
AcBloc({required this.deviceId}) : super(AcsInitialState()) {
on<AcFetchDeviceStatus>(_onFetchAcStatus);
on<AcControl>(_onAcControl);
on<AcFetchDeviceStatusEvent>(_onFetchAcStatus);
on<AcFetchBatchStatusEvent>(_onFetchAcBatchStatus);
on<AcControlEvent>(_onAcControl);
on<AcBatchControlEvent>(_onAcBatchControl);
on<AcFactoryResetEvent>(_onFactoryReset);
}
FutureOr<void> _onFetchAcStatus(
AcFetchDeviceStatus event, Emitter<AcsState> emit) async {
AcFetchDeviceStatusEvent event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
try {
final status =
@ -31,7 +34,8 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
}
}
FutureOr<void> _onAcControl(AcControl event, Emitter<AcsState> emit) async {
FutureOr<void> _onAcControl(
AcControlEvent event, Emitter<AcsState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value, emit);
@ -39,6 +43,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
emit(ACStatusLoaded(deviceStatus));
await _runDebounce(
isBatch: false,
deviceId: event.deviceId,
code: event.code,
value: event.value,
@ -48,27 +53,43 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
}
Future<void> _runDebounce({
required String deviceId,
required dynamic deviceId,
required String code,
required dynamic value,
required dynamic oldValue,
required Emitter<AcsState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(seconds: 1), () async {
try {
final response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
late bool response;
if (isBatch) {
response = await DevicesManagementApi()
.deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
_revertValueAndEmit(deviceId, code, oldValue, emit);
_revertValueAndEmit(id, code, oldValue, emit);
}
} catch (e) {
if (e is DioException && e.response != null) {
debugPrint('Error response: ${e.response?.data}');
}
_revertValueAndEmit(deviceId, code, oldValue, emit);
_revertValueAndEmit(id, code, oldValue, emit);
}
});
}
@ -77,7 +98,6 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
String deviceId, String code, dynamic oldValue, Emitter<AcsState> emit) {
_updateLocalValue(code, oldValue, emit);
emit(ACStatusLoaded(deviceStatus));
emit(const AcsFailedState(error: 'Failed to control the device.'));
}
void _updateLocalValue(String code, dynamic value, Emitter<AcsState> emit) {
@ -133,4 +153,54 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
return null;
}
}
FutureOr<void> _onFetchAcBatchStatus(
AcFetchBatchStatusEvent event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
try {
final status =
await DevicesManagementApi().getBatchStatus(event.devicesIds);
deviceStatus =
AcStatusModel.fromJson(event.devicesIds.first, status.status);
emit(ACStatusLoaded(deviceStatus));
} catch (e) {
emit(AcsFailedState(error: e.toString()));
}
}
FutureOr<void> _onAcBatchControl(
AcBatchControlEvent event, Emitter<AcsState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value, emit);
emit(ACStatusLoaded(deviceStatus));
await _runDebounce(
isBatch: true,
deviceId: event.devicesIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
);
}
FutureOr<void> _onFactoryReset(
AcFactoryResetEvent event, Emitter<AcsState> emit) async {
emit(AcsLoadingState());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryResetModel,
event.deviceId,
);
if (!response) {
emit(const AcsFailedState(error: 'Failed'));
} else {
add(AcFetchDeviceStatusEvent(event.deviceId));
}
} catch (e) {
emit(AcsFailedState(error: e.toString()));
}
}
}

View File

@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
sealed class AcsEvent extends Equatable {
const AcsEvent();
@ -7,21 +8,30 @@ sealed class AcsEvent extends Equatable {
List<Object> get props => [];
}
class AcFetchDeviceStatus extends AcsEvent {
class AcFetchDeviceStatusEvent extends AcsEvent {
final String deviceId;
const AcFetchDeviceStatus(this.deviceId);
const AcFetchDeviceStatusEvent(this.deviceId);
@override
List<Object> get props => [deviceId];
}
class AcControl extends AcsEvent {
class AcFetchBatchStatusEvent extends AcsEvent {
final List<String> devicesIds;
const AcFetchBatchStatusEvent(this.devicesIds);
@override
List<Object> get props => [devicesIds];
}
class AcControlEvent extends AcsEvent {
final String deviceId;
final String code;
final dynamic value;
const AcControl({
const AcControlEvent({
required this.deviceId,
required this.code,
required this.value,
@ -30,3 +40,31 @@ class AcControl extends AcsEvent {
@override
List<Object> get props => [deviceId, code, value];
}
class AcBatchControlEvent extends AcsEvent {
final List<String> devicesIds;
final String code;
final dynamic value;
const AcBatchControlEvent({
required this.devicesIds,
required this.code,
required this.value,
});
@override
List<Object> get props => [devicesIds, code, value];
}
class AcFactoryResetEvent extends AcsEvent {
final String deviceId;
final FactoryResetModel factoryResetModel;
const AcFactoryResetEvent({
required this.deviceId,
required this.factoryResetModel,
});
@override
List<Object> get props => [deviceId, factoryResetModel];
}

View File

@ -22,6 +22,16 @@ class ACStatusLoaded extends AcsState {
List<Object> get props => [status, timestamp];
}
class AcBatchStatusLoaded extends AcsState {
final AcStatusModel status;
final DateTime timestamp;
AcBatchStatusLoaded(this.status) : timestamp = DateTime.now();
@override
List<Object> get props => [status, timestamp];
}
class AcsFailedState extends AcsState {
final String error;

View File

@ -40,16 +40,16 @@ class AcStatusModel {
acSwitch = status.value ?? false;
break;
case 'mode':
mode = status.value ?? 'cold'; // default to 'cold' if null
mode = status.value ?? 'cold';
break;
case 'temp_set':
tempSet = status.value ?? 210; // default value if null
tempSet = status.value ?? 210;
break;
case 'temp_current':
currentTemp = status.value ?? 210; // default value if null
currentTemp = status.value ?? 210;
break;
case 'level':
fanSpeeds = status.value ?? 'low'; // default value if null
fanSpeeds = status.value ?? 'low';
break;
case 'child_lock':
childLock = status.value ?? false;

View File

@ -0,0 +1,166 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_state.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/batch_control_list/batch_ac_mode.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/batch_control_list/batch_current_temp.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/batch_control_list/batch_fan_speed.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.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';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class AcDeviceBatchControlView extends StatelessWidget
with HelperResponsiveLayout {
const AcDeviceBatchControlView({super.key, required this.devicesIds});
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return BlocProvider(
create: (context) => AcBloc(deviceId: devicesIds.first)
..add(AcFetchBatchStatusEvent(devicesIds)),
child: BlocBuilder<AcBloc, AcsState>(
builder: (context, state) {
if (state is ACStatusLoaded) {
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
deviceId: devicesIds.first,
code: 'switch',
value: state.status.acSwitch,
label: 'ThermoState',
icon: Assets.ac,
onChange: (value) {
context.read<AcBloc>().add(AcBatchControlEvent(
devicesIds: devicesIds,
code: 'switch',
value: value,
));
},
),
BatchCurrentTemp(
currentTemp: state.status.currentTemp,
tempSet: state.status.tempSet,
code: 'temp_set',
devicesIds: devicesIds,
),
BatchAcMode(
value: state.status.acMode,
code: 'mode',
devicesIds: devicesIds,
),
BatchFanSpeedControl(
value: state.status.acFanSpeed,
code: 'level',
devicesIds: devicesIds,
),
ToggleWidget(
label: '',
labelWidget: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {},
icon: const Icon(
Icons.remove,
size: 28,
color: ColorsManager.greyColor,
),
),
Text(
'06',
style: context.textTheme.titleLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
Text(
'h',
style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blackColor),
),
Text(
'30',
style: context.textTheme.titleLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
Text('m',
style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blackColor)),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.add,
size: 28,
color: ColorsManager.greyColor,
),
),
],
),
value: false,
code: 'ac_schedule',
deviceId: devicesIds.first,
icon: Assets.acSchedule,
onChange: (value) {},
),
ToggleWidget(
deviceId: devicesIds.first,
code: 'child_lock',
value: state.status.childLock,
label: 'Child Lock',
icon: state.status.childLock ? Assets.unlock : Assets.acLock,
onChange: (value) {
context.read<AcBloc>().add(AcBatchControlEvent(
devicesIds: devicesIds,
code: 'child_lock',
value: value,
));
},
),
FirmwareUpdateWidget(deviceId: devicesIds.first, version: 5),
FactoryResetWidget(
callFactoryReset: () {
context.read<AcBloc>().add(AcFactoryResetEvent(
deviceId: state.status.uuid,
factoryResetModel:
FactoryResetModel(devicesUuid: devicesIds),
));
},
),
],
);
} else if (state is AcsLoadingState) {
return const Center(child: CircularProgressIndicator());
} else {
return const Center(child: Text('Error fetching status'));
}
},
),
);
}
}

View File

@ -4,15 +4,17 @@ import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_state.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/ac_mode.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/ac_toggle.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/current_temp.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/control_list/fan_speed.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.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';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
const AcDeviceControl({super.key, required this.device});
class AcDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
const AcDeviceControlsView({super.key, required this.device});
final AllDevicesModel device;
@ -23,7 +25,7 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
final isMedium = isMediumScreenSize(context);
return BlocProvider(
create: (context) => AcBloc(deviceId: device.uuid!)
..add(AcFetchDeviceStatus(device.uuid!)),
..add(AcFetchDeviceStatusEvent(device.uuid!)),
child: BlocBuilder<AcBloc, AcsState>(
builder: (context, state) {
if (state is ACStatusLoaded) {
@ -42,10 +44,21 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
mainAxisSpacing: 12,
),
children: [
AcToggle(
ToggleWidget(
label: 'Thermostat',
value: state.status.acSwitch,
code: 'switch',
deviceId: device.uuid!,
icon: Assets.ac,
onChange: (value) {
context.read<AcBloc>().add(
AcControlEvent(
deviceId: device.uuid!,
code: 'switch',
value: value,
),
);
},
),
CurrentTemp(
currentTemp: state.status.currentTemp,
@ -63,13 +76,72 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
code: 'level',
deviceId: device.uuid!,
),
AcToggle(
value: state.status.childLock,
code: 'child_lock',
ToggleWidget(
label: '',
labelWidget: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
onPressed: () {},
icon: const Icon(
Icons.remove,
size: 28,
color: ColorsManager.greyColor,
),
),
Text(
'06',
style: context.textTheme.titleLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
Text(
'h',
style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blackColor),
),
Text(
'30',
style: context.textTheme.titleLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
Text('m',
style: context.textTheme.bodySmall!
.copyWith(color: ColorsManager.blackColor)),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.add,
size: 28,
color: ColorsManager.greyColor,
),
),
],
),
value: false,
code: 'ac_schedule',
deviceId: device.uuid!,
description: 'Child Lock',
icon:
state.status.childLock ? Assets.childLock:Assets.unlock ,
icon: Assets.acSchedule,
onChange: (value) {},
),
ToggleWidget(
deviceId: device.uuid!,
code: 'child_lock',
value: state.status.childLock,
label: 'Child Lock',
icon: state.status.childLock ? Assets.unlock : Assets.acLock,
onChange: (value) {
context.read<AcBloc>().add(
AcControlEvent(
deviceId: device.uuid!,
code: 'child_lock',
value: value,
),
);
},
),
],
);

View File

@ -0,0 +1,82 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
class BatchAcMode extends StatelessWidget {
const BatchAcMode({
super.key,
required this.value,
required this.code,
required this.devicesIds,
});
final TempModes value;
final String code;
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: ColorsManager.greyColor.withOpacity(0.2),
border: Border.all(color: ColorsManager.boxDivider),
),
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_buildIconContainer(context, TempModes.cold, Assets.freezing,
value == TempModes.cold),
_buildIconContainer(
context, TempModes.hot, Assets.acSun, value == TempModes.hot),
_buildIconContainer(context, TempModes.wind, Assets.acAirConditioner,
value == TempModes.wind),
],
),
);
}
Widget _buildIconContainer(
BuildContext context, TempModes mode, String assetPath, bool isSelected) {
return Flexible(
child: GestureDetector(
onTap: () {
context.read<AcBloc>().add(
AcBatchControlEvent(
devicesIds: devicesIds,
code: code,
value: mode.name,
),
);
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
border: Border.all(
color: isSelected ? Colors.blue : Colors.transparent,
width: 2.0,
),
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(4),
child: ClipOval(
child: SvgPicture.asset(
assetPath,
fit: BoxFit.contain,
),
),
),
),
);
}
}

View File

@ -0,0 +1,138 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
import 'package:syncrow_web/pages/device_managment/shared/celciuse_symbol.dart';
import 'package:syncrow_web/pages/device_managment/shared/increament_decreament.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
class BatchCurrentTemp extends StatefulWidget {
const BatchCurrentTemp({
super.key,
required this.code,
required this.devicesIds,
required this.currentTemp,
required this.tempSet,
});
final String code;
final List<String> devicesIds;
final int currentTemp;
final int tempSet;
@override
State<BatchCurrentTemp> createState() => _CurrentTempState();
}
class _CurrentTempState extends State<BatchCurrentTemp> {
late double _adjustedValue;
Timer? _debounce;
@override
void initState() {
super.initState();
_adjustedValue = _initialAdjustedValue(widget.tempSet);
}
double _initialAdjustedValue(dynamic value) {
if (value is int || value is double) {
double doubleValue = value.toDouble();
return doubleValue > 99 ? doubleValue / 10 : doubleValue;
} else {
throw ArgumentError('Invalid value type: Expected int or double');
}
}
void _onValueChanged(double newValue) {
if (_debounce?.isActive ?? false) {
_debounce?.cancel();
}
_debounce = Timer(const Duration(milliseconds: 500), () {
context.read<AcBloc>().add(
AcBatchControlEvent(
devicesIds: widget.devicesIds,
code: widget.code,
value: (newValue * 10).toInt(),
),
);
});
}
@override
void dispose() {
_debounce?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: ColorsManager.greyColor.withOpacity(0.2),
border: Border.all(color: ColorsManager.boxDivider),
),
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Current Temperature',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: Colors.grey),
),
const SizedBox(
height: 5,
),
Row(
children: [
Text(
(widget.currentTemp > 99
? widget.currentTemp / 10
: widget.currentTemp)
.toString(),
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(color: Colors.grey),
),
const CelsiusSymbol(
color: Colors.grey,
)
],
),
],
),
const Spacer(),
IncrementDecrementWidget(
value: _adjustedValue.toString(),
description: '°C',
descriptionColor: ColorsManager.dialogBlueTitle,
onIncrement: () {
if (_adjustedValue < 30) {
setState(() {
_adjustedValue = _adjustedValue + 0.5;
});
_onValueChanged(_adjustedValue);
}
},
onDecrement: () {
if (_adjustedValue > 20) {
setState(() {
_adjustedValue = _adjustedValue - 0.5;
});
_onValueChanged(_adjustedValue);
}
}),
],
),
);
}
}

View File

@ -0,0 +1,92 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
class BatchFanSpeedControl extends StatelessWidget {
const BatchFanSpeedControl({
super.key,
required this.value,
required this.code,
required this.devicesIds,
});
final FanSpeeds value;
final String code;
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: ColorsManager.greyColor.withOpacity(0.2),
border: Border.all(color: ColorsManager.boxDivider),
),
padding: const EdgeInsets.all(8),
child: Column(
children: [
Wrap(
runSpacing: 8,
spacing: 8,
children: [
_buildIconContainer(context, FanSpeeds.auto, Assets.acFanAuto,
value == FanSpeeds.auto),
_buildIconContainer(context, FanSpeeds.low, Assets.acFanLow,
value == FanSpeeds.low),
],
),
const SizedBox(height: 8),
Wrap(
runSpacing: 8,
spacing: 8,
children: [
_buildIconContainer(context, FanSpeeds.middle, Assets.acFanMiddle,
value == FanSpeeds.middle),
_buildIconContainer(context, FanSpeeds.high, Assets.acFanHigh,
value == FanSpeeds.high),
],
)
],
),
);
}
Widget _buildIconContainer(BuildContext context, FanSpeeds speed,
String assetPath, bool isSelected) {
return GestureDetector(
onTap: () {
context.read<AcBloc>().add(
AcBatchControlEvent(
devicesIds: devicesIds,
code: code,
value: speed.name,
),
);
},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
border: Border.all(
color: isSelected ? Colors.blue : Colors.transparent,
width: 2.0,
),
),
padding: const EdgeInsets.all(8),
child: ClipOval(
child: SvgPicture.asset(
assetPath,
fit: BoxFit.contain,
),
),
),
);
}
}

View File

@ -49,7 +49,7 @@ class AcMode extends StatelessWidget {
child: GestureDetector(
onTap: () {
context.read<AcBloc>().add(
AcControl(
AcControlEvent(
deviceId: deviceId,
code: code,
value: mode.name,

View File

@ -39,16 +39,21 @@ class AcToggle extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipOval(
child: Container(
color: ColorsManager.whiteColors,
child: SvgPicture.asset(
icon ?? Assets.acDevice,
width: 60,
height: 60,
fit: BoxFit.cover,
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
)),
padding: const EdgeInsets.all(8),
child: ClipOval(
child: SvgPicture.asset(
icon ?? Assets.lightPulp,
fit: BoxFit.contain,
),
),
),
SizedBox(
height: 20,
width: 35,
@ -57,7 +62,7 @@ class AcToggle extends StatelessWidget {
value: value,
onChanged: (newValue) {
context.read<AcBloc>().add(
AcControl(
AcControlEvent(
deviceId: deviceId,
code: code,
value: newValue,

View File

@ -50,7 +50,7 @@ class _CurrentTempState extends State<CurrentTemp> {
}
_debounce = Timer(const Duration(milliseconds: 500), () {
context.read<AcBloc>().add(
AcControl(
AcControlEvent(
deviceId: widget.deviceId,
code: widget.code,
value: (newValue * 10).toInt(),
@ -118,7 +118,7 @@ class _CurrentTempState extends State<CurrentTemp> {
onIncrement: () {
if (_adjustedValue < 30) {
setState(() {
_adjustedValue++;
_adjustedValue = _adjustedValue + 0.5;
});
_onValueChanged(_adjustedValue);
}
@ -126,7 +126,7 @@ class _CurrentTempState extends State<CurrentTemp> {
onDecrement: () {
if (_adjustedValue > 20) {
setState(() {
_adjustedValue--;
_adjustedValue = _adjustedValue - 0.5;
});
_onValueChanged(_adjustedValue);
}

View File

@ -40,6 +40,7 @@ class FanSpeedControl extends StatelessWidget {
value == FanSpeeds.low),
],
),
const SizedBox(height: 8),
Wrap(
runSpacing: 8,
spacing: 8,
@ -60,7 +61,7 @@ class FanSpeedControl extends StatelessWidget {
return GestureDetector(
onTap: () {
context.read<AcBloc>().add(
AcControl(
AcControlEvent(
deviceId: deviceId,
code: code,
value: speed.name,

View File

@ -2,6 +2,7 @@ import 'package:equatable/equatable.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/services/devices_mang_api.dart';
part 'device_managment_event.dart';
part 'device_managment_state.dart';
@ -23,6 +24,8 @@ class DeviceManagementBloc
on<SearchDevices>(_onSearchDevices);
on<SelectDevice>(_onSelectDevice);
on<ResetFilters>(_onResetFilters);
on<ResetSelectedDevices>(_onResetSelectedDevices);
on<UpdateSelection>(_onUpdateSelection);
}
Future<void> _onFetchDevices(
@ -41,6 +44,7 @@ class DeviceManagementBloc
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: null,
isControlButtonEnabled: false,
));
} catch (e) {
emit(DeviceManagementInitial());
@ -69,8 +73,8 @@ class DeviceManagementBloc
onlineCount: _onlineCount,
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice:
_selectedDevices.isNotEmpty ? _selectedDevices.first : null,
selectedDevice: _selectedDevices.isNotEmpty ? _selectedDevices : null,
isControlButtonEnabled: _selectedDevices.isNotEmpty,
));
if (productName.isNotEmpty) {
@ -92,9 +96,37 @@ class DeviceManagementBloc
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: null,
isControlButtonEnabled: false,
));
}
void _onResetSelectedDevices(
ResetSelectedDevices event, Emitter<DeviceManagementState> emit) {
_selectedDevices.clear();
if (state is DeviceManagementLoaded) {
emit(DeviceManagementLoaded(
devices: _devices,
selectedIndex: _selectedIndex,
onlineCount: _onlineCount,
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: null,
isControlButtonEnabled: false,
));
} else if (state is DeviceManagementFiltered) {
emit(DeviceManagementFiltered(
filteredDevices: (state as DeviceManagementFiltered).filteredDevices,
selectedIndex: _selectedIndex,
onlineCount: _onlineCount,
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: null,
isControlButtonEnabled: false,
));
}
}
void _onSelectedFilterChanged(
SelectedFilterChanged event, Emitter<DeviceManagementState> emit) {
_selectedIndex = event.selectedIndex;
@ -111,7 +143,10 @@ class DeviceManagementBloc
_selectedDevices.add(event.selectedDevice);
}
bool isControlButtonEnabled = _selectedDevices.length == 1;
List<AllDevicesModel> clonedSelectedDevices = List.from(_selectedDevices);
bool isControlButtonEnabled =
_checkIfControlButtonEnabled(clonedSelectedDevices);
if (state is DeviceManagementLoaded) {
emit(DeviceManagementLoaded(
@ -120,7 +155,9 @@ class DeviceManagementBloc
onlineCount: _onlineCount,
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: isControlButtonEnabled ? _selectedDevices.first : null,
selectedDevice:
clonedSelectedDevices.isNotEmpty ? clonedSelectedDevices : null,
isControlButtonEnabled: isControlButtonEnabled,
));
} else if (state is DeviceManagementFiltered) {
emit(DeviceManagementFiltered(
@ -129,11 +166,66 @@ class DeviceManagementBloc
onlineCount: _onlineCount,
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: isControlButtonEnabled ? _selectedDevices.first : null,
selectedDevice:
clonedSelectedDevices.isNotEmpty ? clonedSelectedDevices : null,
isControlButtonEnabled: isControlButtonEnabled,
));
}
}
void _onUpdateSelection(
UpdateSelection event, Emitter<DeviceManagementState> emit) {
List<AllDevicesModel> selectedDevices = [];
List<AllDevicesModel> devicesToSelectFrom = [];
if (state is DeviceManagementLoaded) {
devicesToSelectFrom = (state as DeviceManagementLoaded).devices;
} else if (state is DeviceManagementFiltered) {
devicesToSelectFrom = (state as DeviceManagementFiltered).filteredDevices;
}
for (int i = 0; i < event.selectedRows.length; i++) {
if (event.selectedRows[i]) {
selectedDevices.add(devicesToSelectFrom[i]);
}
}
if (state is DeviceManagementLoaded) {
final loadedState = state as DeviceManagementLoaded;
emit(DeviceManagementLoaded(
devices: loadedState.devices,
selectedIndex: loadedState.selectedIndex,
onlineCount: loadedState.onlineCount,
offlineCount: loadedState.offlineCount,
lowBatteryCount: loadedState.lowBatteryCount,
selectedDevice: selectedDevices,
isControlButtonEnabled: _checkIfControlButtonEnabled(selectedDevices),
));
} else if (state is DeviceManagementFiltered) {
final filteredState = state as DeviceManagementFiltered;
emit(DeviceManagementFiltered(
filteredDevices: filteredState.filteredDevices,
selectedIndex: filteredState.selectedIndex,
onlineCount: filteredState.onlineCount,
offlineCount: filteredState.offlineCount,
lowBatteryCount: filteredState.lowBatteryCount,
selectedDevice: selectedDevices,
isControlButtonEnabled: _checkIfControlButtonEnabled(selectedDevices),
));
}
}
bool _checkIfControlButtonEnabled(List<AllDevicesModel> selectedDevices) {
if (selectedDevices.length > 1) {
final productTypes =
selectedDevices.map((device) => device.productType).toSet();
return productTypes.length == 1;
} else if (selectedDevices.length == 1) {
return true;
}
return false;
}
void _calculateDeviceCounts() {
_onlineCount = _devices.where((device) => device.online == true).length;
_offlineCount = _devices.where((device) => device.online == false).length;
@ -158,12 +250,10 @@ class DeviceManagementBloc
void _onSearchDevices(
SearchDevices event, Emitter<DeviceManagementState> emit) {
// If the search fields are all empty, restore the last filtered devices
if ((event.community == null || event.community!.isEmpty) &&
(event.unitName == null || event.unitName!.isEmpty) &&
(event.productName == null || event.productName!.isEmpty)) {
productName = '';
// If the current state is filtered, re-emit the filtered state
if (state is DeviceManagementFiltered) {
add(FilterDevices(_getFilterFromIndex(_selectedIndex)));
}
@ -214,6 +304,7 @@ class DeviceManagementBloc
offlineCount: _offlineCount,
lowBatteryCount: _lowBatteryCount,
selectedDevice: null,
isControlButtonEnabled: false,
));
}
}

View File

@ -52,3 +52,11 @@ class SelectDevice extends DeviceManagementEvent {
}
class ResetFilters extends DeviceManagementEvent {}
class ResetSelectedDevices extends DeviceManagementEvent {}
class UpdateSelection extends DeviceManagementEvent {
final List<bool> selectedRows;
const UpdateSelection(this.selectedRows);
}

View File

@ -17,7 +17,8 @@ class DeviceManagementLoaded extends DeviceManagementState {
final int onlineCount;
final int offlineCount;
final int lowBatteryCount;
final AllDevicesModel? selectedDevice;
final List<AllDevicesModel>? selectedDevice;
final bool isControlButtonEnabled;
const DeviceManagementLoaded({
required this.devices,
@ -26,6 +27,7 @@ class DeviceManagementLoaded extends DeviceManagementState {
required this.offlineCount,
required this.lowBatteryCount,
this.selectedDevice,
required this.isControlButtonEnabled,
});
@override
@ -35,7 +37,8 @@ class DeviceManagementLoaded extends DeviceManagementState {
onlineCount,
offlineCount,
lowBatteryCount,
selectedDevice
selectedDevice,
isControlButtonEnabled
];
}
@ -45,7 +48,8 @@ class DeviceManagementFiltered extends DeviceManagementState {
final int onlineCount;
final int offlineCount;
final int lowBatteryCount;
final AllDevicesModel? selectedDevice;
final List<AllDevicesModel>? selectedDevice;
final bool isControlButtonEnabled;
const DeviceManagementFiltered({
required this.filteredDevices,
@ -54,6 +58,7 @@ class DeviceManagementFiltered extends DeviceManagementState {
required this.offlineCount,
required this.lowBatteryCount,
this.selectedDevice,
required this.isControlButtonEnabled,
});
@override
@ -63,7 +68,8 @@ class DeviceManagementFiltered extends DeviceManagementState {
onlineCount,
offlineCount,
lowBatteryCount,
selectedDevice
selectedDevice,
isControlButtonEnabled
];
}

View File

@ -1,39 +1,161 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/ac/view/ac_device_control.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_batch_status_view.dart';
import 'package:syncrow_web/pages/device_managment/curtain/view/curtain_status_view.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_status_view.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_control_view.dart';
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_view.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_door_control_view.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/view/one_gang_glass_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/view/wall_light_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/view/wall_light_device_control.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/view/three_gang_glass_switch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_batch_controls.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_device_control.dart';
import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_batch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/view/two_gang_glass_switch_control_view.dart';
import 'package:syncrow_web/pages/device_managment/two_gang_switch/view/wall_light_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/two_gang_switch/view/wall_light_device_control.dart';
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_conrtols.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/view/water_heater_batch_control.dart';
import 'package:syncrow_web/pages/device_managment/water_heater/view/water_heater_device_control.dart';
import '../../one_g_glass_switch/view/one_gang_glass_switch_control_view.dart';
mixin RouteControlsBasedCode {
Widget routeControlsWidgets({required AllDevicesModel device}) {
switch (device.productType) {
case '1G':
return WallLightDeviceControl(
deviceId: device.uuid!,
);
case '2G':
return TwoGangDeviceControlView(
deviceId: device.uuid!,
);
case '3G':
return LivingRoomDeviceControl(
return LivingRoomDeviceControlsView(
deviceId: device.uuid!,
);
case '1GT':
return OneGangGlassSwitchControlView(
deviceId: device.uuid!,
);
case '2GT':
return TwoGangGlassSwitchControlView(
deviceId: device.uuid!,
);
case '3GT':
return ThreeGangGlassSwitchControlView(
deviceId: device.uuid!,
);
case 'GW':
return GateWayControls(
return GateWayControlsView(
gatewayId: device.uuid!,
);
case 'DL':
return DoorLockView(device: device);
return DoorLockControlsView(device: device);
case 'WPS':
return WallSensorControls(device: device);
return WallSensorControlsView(device: device);
case 'CPS':
return CeilingSensorControls(
return CeilingSensorControlsView(
device: device,
);
case 'CUR':
return CurtainStatusView(
return CurtainStatusControlsView(
deviceId: device.uuid!,
);
case 'AC':
return AcDeviceControl(device: device);
return AcDeviceControlsView(device: device);
case 'WH':
return WaterHeaterDeviceControlView(
device: device,
);
case 'DS':
return MainDoorSensorControlView(device: device);
default:
return const SizedBox();
}
}
/*
3G:
1G:
2G:
GW:
DL:
WPS:
CPS:
AC:
CUR:
WH:
DS:
*/
Widget routeBatchControlsWidgets({required List<AllDevicesModel> devices}) {
switch (devices.first.productType) {
case '1G':
return WallLightBatchControlView(
deviceIds: devices.where((e) => (e.productType == '1G')).map((e) => e.uuid!).toList(),
);
case '2G':
return TwoGangBatchControlView(
deviceIds: devices.where((e) => (e.productType == '2G')).map((e) => e.uuid!).toList(),
);
case '3G':
return LivingRoomBatchControlsView(
deviceIds: devices.where((e) => (e.productType == '3G')).map((e) => e.uuid!).toList(),
);
case '1GT':
return OneGangGlassSwitchBatchControlView(
deviceIds: devices.where((e) => (e.productType == '1GT')).map((e) => e.uuid!).toList(),
);
case '2GT':
return TwoGangGlassSwitchBatchControlView(
deviceIds: devices.where((e) => (e.productType == '2GT')).map((e) => e.uuid!).toList(),
);
case '3GT':
return ThreeGangGlassSwitchBatchControlView(
deviceIds: devices.where((e) => (e.productType == '3GT')).map((e) => e.uuid!).toList(),
);
case 'GW':
return GatewayBatchControlView(
gatewayIds: devices.where((e) => (e.productType == 'GW')).map((e) => e.uuid!).toList(),
);
case 'DL':
return DoorLockBatchControlView(
devicesIds: devices.where((e) => (e.productType == 'DL')).map((e) => e.uuid!).toList());
case 'WPS':
return WallSensorBatchControlView(
devicesIds: devices.where((e) => (e.productType == 'WPS')).map((e) => e.uuid!).toList());
case 'CPS':
return CeilingSensorBatchControlView(
devicesIds: devices.where((e) => (e.productType == 'CPS')).map((e) => e.uuid!).toList(),
);
case 'CUR':
return CurtainBatchStatusView(
devicesIds: devices.where((e) => (e.productType == 'CUR')).map((e) => e.uuid!).toList(),
);
case 'AC':
return AcDeviceBatchControlView(
devicesIds: devices.where((e) => (e.productType == 'AC')).map((e) => e.uuid!).toList());
case 'WH':
return WaterHEaterBatchControlView(
deviceIds: devices.where((e) => (e.productType == 'WH')).map((e) => e.uuid!).toList(),
);
case 'DS':
return MainDoorSensorBatchView(
devicesIds: devices.where((e) => (e.productType == 'DS')).map((e) => e.uuid!).toList(),
);
default:
return const SizedBox();
}

View File

@ -13,11 +13,15 @@ class DeviceReport {
DeviceReport.fromJson(Map<String, dynamic> json)
: deviceUuid = json['deviceUuid'] as String?,
startTime = json['startTime'] as int?,
endTime = json['endTime'] as int?,
data = (json['data'] as List<dynamic>?)
?.map((e) => DeviceEvent.fromJson(e as Map<String, dynamic>))
.toList();
startTime = int.tryParse(json['startTime'].toString()) ??
json['startTime'] as int?,
endTime =
int.tryParse(json['endTime'].toString()) ?? json['endTime'] as int?,
data = json['data'] != null
? (json['data'] as List<dynamic>?)
?.map((e) => DeviceEvent.fromJson(e as Map<String, dynamic>))
.toList()
: [];
Map<String, dynamic> toJson() => {
'deviceUuid': deviceUuid,

View File

@ -1,5 +1,6 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/room.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/unit.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class AllDevicesModel {
/*
@ -62,6 +63,7 @@ class AllDevicesModel {
int? updateTime;
String? uuid;
int? batteryLevel;
String? productName;
AllDevicesModel({
this.room,
@ -89,6 +91,7 @@ class AllDevicesModel {
this.updateTime,
this.uuid,
this.batteryLevel,
this.productName,
});
AllDevicesModel.fromJson(Map<String, dynamic> json) {
room = (json['room'] != null && (json['room'] is Map))
@ -105,7 +108,7 @@ class AllDevicesModel {
categoryName = json['categoryName']?.toString();
createTime = int.tryParse(json['createTime']?.toString() ?? '');
gatewayId = json['gatewayId']?.toString();
icon = json['icon']?.toString();
icon = json['icon'] ?? _getDefaultIcon(productType);
ip = json['ip']?.toString();
lat = json['lat']?.toString();
localKey = json['localKey']?.toString();
@ -120,7 +123,37 @@ class AllDevicesModel {
updateTime = int.tryParse(json['updateTime']?.toString() ?? '');
uuid = json['uuid']?.toString();
batteryLevel = int.tryParse(json['battery']?.toString() ?? '');
productName = json['productName']?.toString();
}
String _getDefaultIcon(String? productType) {
switch (productType) {
case 'LightBulb':
return Assets.lightBulb;
case 'CeilingSensor':
case 'WallSensor':
return Assets.sensors;
case 'AC':
return Assets.ac;
case 'DoorLock':
return Assets.doorLock;
case 'Curtain':
return Assets.curtain;
case '3G':
case '2G':
case '1G':
return Assets.gangSwitch;
case 'Gateway':
return Assets.gateway;
case 'WH':
return Assets.blackLogo;
case 'DS':
return Assets.sensors;
default:
return Assets.logo;
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
if (room != null) {
@ -152,6 +185,70 @@ class AllDevicesModel {
data['updateTime'] = updateTime;
data['uuid'] = uuid;
data['battery'] = batteryLevel;
data['productName'] = productName;
return data;
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is AllDevicesModel &&
other.room == room &&
other.unit == unit &&
other.productUuid == productUuid &&
other.productType == productType &&
other.permissionType == permissionType &&
other.activeTime == activeTime &&
other.category == category &&
other.categoryName == categoryName &&
other.createTime == createTime &&
other.gatewayId == gatewayId &&
other.icon == icon &&
other.ip == ip &&
other.lat == lat &&
other.localKey == localKey &&
other.lon == lon &&
other.model == model &&
other.name == name &&
other.nodeId == nodeId &&
other.online == online &&
other.ownerId == ownerId &&
other.sub == sub &&
other.timeZone == timeZone &&
other.updateTime == updateTime &&
other.uuid == uuid &&
other.productName == productName &&
other.batteryLevel == batteryLevel;
}
@override
int get hashCode {
return room.hashCode ^
unit.hashCode ^
productUuid.hashCode ^
productType.hashCode ^
permissionType.hashCode ^
activeTime.hashCode ^
category.hashCode ^
categoryName.hashCode ^
createTime.hashCode ^
gatewayId.hashCode ^
icon.hashCode ^
ip.hashCode ^
lat.hashCode ^
localKey.hashCode ^
lon.hashCode ^
model.hashCode ^
name.hashCode ^
nodeId.hashCode ^
online.hashCode ^
ownerId.hashCode ^
sub.hashCode ^
timeZone.hashCode ^
updateTime.hashCode ^
uuid.hashCode ^
productName.hashCode ^
batteryLevel.hashCode;
}
}

View File

@ -0,0 +1,55 @@
import 'package:flutter/foundation.dart';
class FactoryResetModel {
final List<String> devicesUuid;
FactoryResetModel({
required this.devicesUuid,
});
factory FactoryResetModel.fromJson(Map<String, dynamic> json) {
return FactoryResetModel(
devicesUuid: List<String>.from(json['devicesUuid']),
);
}
Map<String, dynamic> toJson() {
return {
'devicesUuid': devicesUuid,
};
}
FactoryResetModel copyWith({
List<String>? devicesUuid,
}) {
return FactoryResetModel(
devicesUuid: devicesUuid ?? this.devicesUuid,
);
}
Map<String, dynamic> toMap() {
return {
'devicesUuid': devicesUuid,
};
}
factory FactoryResetModel.fromMap(Map<String, dynamic> map) {
return FactoryResetModel(
devicesUuid: List<String>.from(map['devicesUuid']),
);
}
@override
String toString() => 'FactoryReset(devicesUuid: $devicesUuid)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is FactoryResetModel &&
listEquals(other.devicesUuid, devicesUuid);
}
@override
int get hashCode => devicesUuid.hashCode;
}

View File

@ -21,13 +21,11 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
),
),
rightBody: const NavigateHomeGridView(),
enableMenuSideba: isLargeScreenSize(context),
scaffoldBody: BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
builder: (context, state) {
if (state is DeviceManagementLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is DeviceManagementLoaded ||
state is DeviceManagementFiltered) {
} else if (state is DeviceManagementLoaded || state is DeviceManagementFiltered) {
final devices = state is DeviceManagementLoaded
? state.devices
: (state as DeviceManagementFiltered).filteredDevices;
@ -42,3 +40,6 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
);
}
}

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_batch_control_dialog.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/pages/common/custom_table.dart';
@ -27,6 +28,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
int offlineCount = 0;
int lowBatteryCount = 0;
bool isControlButtonEnabled = false;
List<AllDevicesModel> selectedDevices = [];
if (state is DeviceManagementLoaded) {
devicesToShow = state.devices;
@ -34,14 +36,18 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
onlineCount = state.onlineCount;
offlineCount = state.offlineCount;
lowBatteryCount = state.lowBatteryCount;
isControlButtonEnabled = state.selectedDevice != null;
isControlButtonEnabled = state.isControlButtonEnabled;
selectedDevices = state.selectedDevice ??
context.read<DeviceManagementBloc>().selectedDevices;
} else if (state is DeviceManagementFiltered) {
devicesToShow = state.filteredDevices;
selectedIndex = state.selectedIndex;
onlineCount = state.onlineCount;
offlineCount = state.offlineCount;
lowBatteryCount = state.lowBatteryCount;
isControlButtonEnabled = state.selectedDevice != null;
isControlButtonEnabled = state.isControlButtonEnabled;
selectedDevices = state.selectedDevice ??
context.read<DeviceManagementBloc>().selectedDevices;
} else if (state is DeviceManagementInitial) {
devicesToShow = [];
selectedIndex = 0;
@ -55,8 +61,11 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
'Low Battery ($lowBatteryCount)',
];
final buttonLabel =
(selectedDevices.length > 1) ? 'Batch Control' : 'Control';
return Column(
children: [
children: [
Container(
padding: isLargeScreenSize(context)
? const EdgeInsets.all(30)
@ -69,7 +78,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
tabs: tabs,
selectedIndex: selectedIndex,
onTabChanged: (index) {
context.read<DeviceManagementBloc>()
context
.read<DeviceManagementBloc>()
.add(SelectedFilterChanged(index));
},
),
@ -78,25 +88,39 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
const SizedBox(height: 12),
Container(
height: 45,
width: 100,
width: 125,
decoration: containerDecoration,
child: Center(
child: DefaultButton(
onPressed: isControlButtonEnabled
? () {
final selectedDevice = context
.read<DeviceManagementBloc>()
.selectedDevices.first;
showDialog(
context: context,
builder: (context) => DeviceControlDialog(
device: selectedDevice),
);
if (selectedDevices.length == 1) {
showDialog(
context: context,
builder: (context) => DeviceControlDialog(
device: selectedDevices.first,
),
);
} else if (selectedDevices.length > 1) {
final productTypes = selectedDevices
.map((device) => device.productType)
.toSet();
if (productTypes.length == 1) {
showDialog(
context: context,
builder: (context) =>
DeviceBatchControlDialog(
devices: selectedDevices,
),
);
}
}
}
: null,
borderRadius: 9,
child: Text(
'Control',
buttonLabel,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: isControlButtonEnabled
@ -140,8 +164,8 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
],
data: devicesToShow.map((device) {
return [
device.categoryName ?? '',
device.name ?? '',
device.productName ?? '',
device.uuid ?? '',
device.unit?.name ?? '',
device.room?.name ?? '',
@ -155,6 +179,11 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
(device.updateTime ?? 0) * 1000)),
];
}).toList(),
onSelectionChanged: (selectedRows) {
context
.read<DeviceManagementBloc>()
.add(UpdateSelection(selectedRows));
},
initialSelectedIds: context
.read<DeviceManagementBloc>()
.selectedDevices

View File

@ -14,17 +14,21 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
CeilingSensorBloc({required this.deviceId}) : super(CeilingInitialState()) {
on<CeilingInitialEvent>(_fetchCeilingSensorStatus);
on<CeilingFetchDeviceStatusEvent>(_fetchCeilingSensorBatchControl);
on<CeilingChangeValueEvent>(_changeValue);
on<CeilingBatchControlEvent>(_onBatchControl);
on<GetCeilingDeviceReportsEvent>(_getDeviceReports);
on<ShowCeilingDescriptionEvent>(_showDescription);
on<BackToCeilingGridViewEvent>(_backToGridView);
on<CeilingFactoryResetEvent>(_onFactoryReset);
}
void _fetchCeilingSensorStatus(
CeilingInitialEvent event, Emitter<CeilingSensorState> emit) async {
emit(CeilingLoadingInitialState());
try {
var response = await DevicesManagementApi().getDeviceStatus(deviceId);
var response =
await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = CeilingSensorModel.fromJson(response.status);
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
// _listenToChanges();
@ -67,34 +71,76 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
}
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
await _runDeBouncer(
deviceId: deviceId, code: event.code, value: event.value, emit: emit);
deviceId: deviceId,
code: event.code,
value: event.value,
emit: emit,
isBatch: false,
);
}
Future<void> _onBatchControl(
CeilingBatchControlEvent event, Emitter<CeilingSensorState> emit) async {
emit(CeilingLoadingNewSate(ceilingSensorModel: deviceStatus));
if (event.code == 'sensitivity') {
deviceStatus.sensitivity = event.value;
} else if (event.code == 'none_body_time') {
deviceStatus.noBodyTime = event.value;
} else if (event.code == 'moving_max_dis') {
deviceStatus.maxDistance = event.value;
} else if (event.code == 'scene') {
deviceStatus.spaceType = getSpaceType(event.value);
}
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
await _runDeBouncer(
deviceId: event.deviceIds,
code: event.code,
value: event.value,
emit: emit,
isBatch: true,
);
}
_runDeBouncer({
required String deviceId,
required dynamic deviceId,
required String code,
required dynamic value,
required Emitter<CeilingSensorState> emit,
required bool isBatch,
}) {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(seconds: 1), () async {
try {
final response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
late bool response;
if (isBatch) {
response = await DevicesManagementApi()
.deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
add(CeilingInitialEvent());
add(CeilingInitialEvent(id));
}
if (response == true && code == 'scene') {
emit(CeilingLoadingInitialState());
await Future.delayed(const Duration(seconds: 1));
add(CeilingInitialEvent());
add(CeilingInitialEvent(id));
}
} catch (_) {
await Future.delayed(const Duration(milliseconds: 500));
add(CeilingInitialEvent());
add(CeilingInitialEvent(id));
}
});
}
@ -128,4 +174,37 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
BackToCeilingGridViewEvent event, Emitter<CeilingSensorState> emit) {
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
}
FutureOr<void> _fetchCeilingSensorBatchControl(
CeilingFetchDeviceStatusEvent event,
Emitter<CeilingSensorState> emit) async {
emit(CeilingLoadingInitialState());
try {
var response =
await DevicesManagementApi().getBatchStatus(event.devicesIds);
deviceStatus = CeilingSensorModel.fromJson(response.status);
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
} catch (e) {
emit(CeilingFailedState(error: e.toString()));
return;
}
}
FutureOr<void> _onFactoryReset(
CeilingFactoryResetEvent event, Emitter<CeilingSensorState> emit) async {
emit(CeilingLoadingNewSate(ceilingSensorModel: deviceStatus));
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryResetModel,
event.devicesId,
);
if (!response) {
emit(const CeilingFailedState(error: 'Failed'));
} else {
emit(CeilingUpdateState(ceilingSensorModel: deviceStatus));
}
} catch (e) {
emit(CeilingFailedState(error: e.toString()));
}
}
}

View File

@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
abstract class CeilingSensorEvent extends Equatable {
const CeilingSensorEvent();
@ -7,7 +8,37 @@ abstract class CeilingSensorEvent extends Equatable {
List<Object> get props => [];
}
class CeilingInitialEvent extends CeilingSensorEvent {}
class CeilingInitialEvent extends CeilingSensorEvent {
final String deviceId;
const CeilingInitialEvent(this.deviceId);
@override
List<Object> get props => [deviceId];
}
class CeilingFetchDeviceStatusEvent extends CeilingSensorEvent {
final List<String> devicesIds;
const CeilingFetchDeviceStatusEvent(this.devicesIds);
@override
List<Object> get props => [devicesIds];
}
class CeilingBatchControlEvent extends CeilingSensorEvent {
final List<String> deviceIds;
final String code;
final dynamic value;
const CeilingBatchControlEvent({
required this.deviceIds,
required this.code,
required this.value,
});
@override
List<Object> get props => [deviceIds, code, value];
}
class CeilingChangeValueEvent extends CeilingSensorEvent {
final dynamic value;
@ -39,3 +70,16 @@ class ShowCeilingDescriptionEvent extends CeilingSensorEvent {
}
class BackToCeilingGridViewEvent extends CeilingSensorEvent {}
class CeilingFactoryResetEvent extends CeilingSensorEvent {
final String devicesId;
final FactoryResetModel factoryResetModel;
const CeilingFactoryResetEvent({
required this.devicesId,
required this.factoryResetModel,
});
@override
List<Object> get props => [devicesId, factoryResetModel];
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
class CeilingSensorModel {
@ -91,6 +92,30 @@ class CeilingSensorModel {
spaceType: _spaceType,
);
}
CeilingSensorModel copyWith({
String? presenceState,
int? sensitivity,
String? checkingResult,
int? presenceRange,
int? sportsPara,
String? bodyMovement,
String? noBodyTime,
int? maxDistance,
SpaceTypes? spaceType,
}) {
return CeilingSensorModel(
presenceState: presenceState ?? this.presenceState,
sensitivity: sensitivity ?? this.sensitivity,
checkingResult: checkingResult ?? this.checkingResult,
presenceRange: presenceRange ?? this.presenceRange,
sportsPara: sportsPara ?? this.sportsPara,
bodyMovement: bodyMovement ?? this.bodyMovement,
noBodyTime: noBodyTime ?? this.noBodyTime,
maxDistance: maxDistance ?? this.maxDistance,
spaceType: spaceType ?? this.spaceType,
);
}
}
enum SpaceTypes {

View File

@ -0,0 +1,130 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/bloc.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/event.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/bloc/state.dart';
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/model/ceiling_sensor_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_space_type.dart';
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presence_update_data.dart';
import 'package:syncrow_web/pages/device_managment/shared/sensors_widgets/presense_nobody_time.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class CeilingSensorBatchControlView extends StatelessWidget
with HelperResponsiveLayout {
const CeilingSensorBatchControlView({super.key, required this.devicesIds});
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return BlocProvider(
create: (context) => CeilingSensorBloc(deviceId: devicesIds.first)
..add(CeilingFetchDeviceStatusEvent(devicesIds)),
child: BlocBuilder<CeilingSensorBloc, CeilingSensorState>(
builder: (context, state) {
if (state is CeilingLoadingInitialState ||
state is CeilingReportsLoadingState) {
return const Center(child: CircularProgressIndicator());
} else if (state is CeilingUpdateState) {
return _buildGridView(context, state.ceilingSensorModel,
isExtraLarge, isLarge, isMedium);
}
return const Center(child: Text('Error fetching status'));
},
),
);
}
Widget _buildGridView(BuildContext context, CeilingSensorModel model,
bool isExtraLarge, bool isLarge, bool isMedium) {
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
PresenceSpaceType(
description: 'Space Type',
value: model.spaceType,
action: (String value) => context.read<CeilingSensorBloc>().add(
CeilingBatchControlEvent(
deviceIds: devicesIds,
code: 'scene',
value: value,
),
),
),
PresenceUpdateData(
value: model.sensitivity.toDouble(),
title: 'Sensitivity:',
minValue: 1,
maxValue: 10,
steps: 1,
action: (int value) {
context.read<CeilingSensorBloc>().add(
CeilingBatchControlEvent(
deviceIds: devicesIds,
code: 'sensitivity',
value: value,
),
);
},
),
PresenceUpdateData(
value: model.maxDistance.toDouble(),
title: 'Maximum Distance:',
minValue: 0,
maxValue: 500,
steps: 50,
description: 'm',
action: (int value) => context.read<CeilingSensorBloc>().add(
CeilingBatchControlEvent(
deviceIds: devicesIds,
code: 'moving_max_dis',
value: value,
),
),
),
PresenceNoBodyTime(
value: model.noBodyTime,
title: 'Nobody Time:',
description: '',
action: (String value) => context.read<CeilingSensorBloc>().add(
CeilingBatchControlEvent(
deviceIds: devicesIds,
code: 'nobody_time',
value: value,
),
),
),
FirmwareUpdateWidget(deviceId: devicesIds.first, version: 4),
FactoryResetWidget(
callFactoryReset: () {
context.read<CeilingSensorBloc>().add(
CeilingFactoryResetEvent(
devicesId: devicesIds.first,
factoryResetModel:
FactoryResetModel(devicesUuid: devicesIds),
),
);
},
),
],
);
}
}

View File

@ -16,9 +16,9 @@ import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dar
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class CeilingSensorControls extends StatelessWidget
class CeilingSensorControlsView extends StatelessWidget
with HelperResponsiveLayout {
const CeilingSensorControls({super.key, required this.device});
const CeilingSensorControlsView({super.key, required this.device});
final AllDevicesModel device;
@ -29,7 +29,7 @@ class CeilingSensorControls extends StatelessWidget
final isMedium = isMediumScreenSize(context);
return BlocProvider(
create: (context) => CeilingSensorBloc(deviceId: device.uuid ?? '')
..add(CeilingInitialEvent()),
..add(CeilingInitialEvent(device.uuid ?? '')),
child: BlocBuilder<CeilingSensorBloc, CeilingSensorState>(
builder: (context, state) {
if (state is CeilingLoadingInitialState ||
@ -112,7 +112,7 @@ class CeilingSensorControls extends StatelessWidget
value: model.sensitivity.toDouble(),
title: 'Sensitivity:',
minValue: 1,
maxValue: 5,
maxValue: 10,
steps: 1,
action: (int value) {
context.read<CeilingSensorBloc>().add(

View File

@ -12,7 +12,10 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
CurtainBloc({required this.deviceId}) : super(CurtainInitial()) {
on<CurtainFetchDeviceStatus>(_onFetchDeviceStatus);
on<CurtainFetchBatchStatus>(_onFetchBatchStatus);
on<CurtainControl>(_onCurtainControl);
on<CurtainBatchControl>(_onCurtainBatchControl);
on<CurtainFactoryReset>(_onFactoryReset);
}
FutureOr<void> _onFetchDeviceStatus(
@ -44,16 +47,26 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: false,
);
}
Future<void> _runDebounce({
required String deviceId,
required dynamic deviceId,
required String code,
required bool value,
required bool oldValue,
required Emitter<CurtainState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
@ -61,14 +74,20 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
try {
final controlValue = value ? 'open' : 'close';
final response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: controlValue));
late bool response;
if (isBatch) {
response = await DevicesManagementApi()
.deviceBatchControl(deviceId, code, controlValue);
} else {
response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: controlValue));
}
if (!response) {
_revertValueAndEmit(deviceId, oldValue, emit);
_revertValueAndEmit(id, oldValue, emit);
}
} catch (e) {
_revertValueAndEmit(deviceId, oldValue, emit);
_revertValueAndEmit(id, oldValue, emit);
}
});
}
@ -88,4 +107,55 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
bool _checkStatus(String command) {
return command.toLowerCase() == 'open';
}
FutureOr<void> _onFetchBatchStatus(
CurtainFetchBatchStatus event, Emitter<CurtainState> emit) async {
emit(CurtainStatusLoading());
try {
final status =
await DevicesManagementApi().getBatchStatus(event.devicesIds);
deviceStatus = _checkStatus(status.status[0].value);
emit(CurtainStatusLoaded(deviceStatus));
} catch (e) {
emit(CurtainError(e.toString()));
}
}
FutureOr<void> _onCurtainBatchControl(
CurtainBatchControl event, Emitter<CurtainState> emit) async {
final oldValue = deviceStatus;
_updateLocalValue(event.value, emit);
emit(CurtainStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.devicesIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: true,
);
}
FutureOr<void> _onFactoryReset(
CurtainFactoryReset event, Emitter<CurtainState> emit) async {
emit(CurtainStatusLoading());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.deviceId,
);
if (!response) {
emit(const CurtainControlError('Failed'));
} else {
add(CurtainFetchDeviceStatus(event.deviceId));
}
} catch (e) {
emit(CurtainControlError(e.toString()));
}
}
}

View File

@ -1,6 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
sealed class CurtainEvent extends Equatable {
const CurtainEvent();
@ -18,6 +17,15 @@ class CurtainFetchDeviceStatus extends CurtainEvent {
List<Object> get props => [deviceId];
}
class CurtainFetchBatchStatus extends CurtainEvent {
final List<String> devicesIds;
const CurtainFetchBatchStatus(this.devicesIds);
@override
List<Object> get props => [devicesIds];
}
class CurtainControl extends CurtainEvent {
final String deviceId;
final String code;
@ -29,3 +37,26 @@ class CurtainControl extends CurtainEvent {
@override
List<Object> get props => [deviceId, code, value];
}
class CurtainBatchControl extends CurtainEvent {
final List<String> devicesIds;
final String code;
final bool value;
const CurtainBatchControl(
{required this.devicesIds, required this.code, required this.value});
@override
List<Object> get props => [devicesIds, code, value];
}
class CurtainFactoryReset extends CurtainEvent {
final String deviceId;
final FactoryResetModel factoryReset;
const CurtainFactoryReset(
{required this.deviceId, required this.factoryReset});
@override
List<Object> get props => [deviceId, factoryReset];
}

View File

@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/common/curtain_toggle.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_bloc.dart';
import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_event.dart';
import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_state.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class CurtainBatchStatusView extends StatelessWidget
with HelperResponsiveLayout {
const CurtainBatchStatusView({super.key, required this.devicesIds});
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => CurtainBloc(deviceId: devicesIds.first)
..add(CurtainFetchBatchStatus(devicesIds)),
child: BlocBuilder<CurtainBloc, CurtainState>(
builder: (context, state) {
if (state is CurtainStatusLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is CurtainStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is CurtainError || state is CurtainControlError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(BuildContext context, bool status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50, vertical: 20),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
CurtainToggle(
value: status,
code: 'control',
deviceId: devicesIds.first,
label: 'Curtains',
onChanged: (value) {
context.read<CurtainBloc>().add(CurtainBatchControl(
devicesIds: devicesIds,
code: 'control',
value: value,
));
},
),
FirmwareUpdateWidget(deviceId: devicesIds.first, version: 5),
FactoryResetWidget(
callFactoryReset: () {
context.read<CurtainBloc>().add(
CurtainFactoryReset(
deviceId: devicesIds.first,
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
),
);
},
),
],
);
}
}

View File

@ -6,10 +6,11 @@ import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_event.da
import 'package:syncrow_web/pages/device_managment/curtain/bloc/curtain_state.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class CurtainStatusView extends StatelessWidget with HelperResponsiveLayout {
class CurtainStatusControlsView extends StatelessWidget
with HelperResponsiveLayout {
final String deviceId;
const CurtainStatusView({super.key, required this.deviceId});
const CurtainStatusControlsView({super.key, required this.deviceId});
@override
Widget build(BuildContext context) {
@ -57,6 +58,15 @@ class CurtainStatusView extends StatelessWidget with HelperResponsiveLayout {
code: 'control',
deviceId: deviceId,
label: 'Curtains',
onChanged: (value) {
context.read<CurtainBloc>().add(
CurtainControl(
deviceId: deviceId,
code: 'control',
value: value,
),
);
},
),
const SizedBox.shrink(),
],

View File

@ -17,6 +17,7 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
on<DoorLockFetchStatus>(_onFetchDeviceStatus);
//on<DoorLockControl>(_onDoorLockControl);
on<UpdateLockEvent>(_updateLock);
on<DoorLockFactoryReset>(_onFactoryReset);
}
FutureOr<void> _onFetchDeviceStatus(
@ -113,4 +114,22 @@ class DoorLockBloc extends Bloc<DoorLockEvent, DoorLockState> {
return null;
}
}
FutureOr<void> _onFactoryReset(
DoorLockFactoryReset event, Emitter<DoorLockState> emit) async {
emit(DoorLockStatusLoading());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.deviceId,
);
if (!response) {
emit(const DoorLockControlError('Failed'));
} else {
add(DoorLockFetchStatus(event.deviceId));
}
} catch (e) {
emit(DoorLockControlError(e.toString()));
}
}
}

View File

@ -1,4 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
sealed class DoorLockEvent extends Equatable {
const DoorLockEvent();
@ -37,3 +38,16 @@ class UpdateLockEvent extends DoorLockEvent {
@override
List<Object> get props => [value];
}
class DoorLockFactoryReset extends DoorLockEvent {
final String deviceId;
final FactoryResetModel factoryReset;
const DoorLockFactoryReset({
required this.deviceId,
required this.factoryReset,
});
@override
List<Object> get props => [deviceId, factoryReset];
}

View File

@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_bloc.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_event.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class DoorLockBatchControlView extends StatelessWidget
with HelperResponsiveLayout {
const DoorLockBatchControlView({super.key, required this.devicesIds});
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 170,
height: 140,
child: FirmwareUpdateWidget(
deviceId: devicesIds.first,
version: 12,
),
),
const SizedBox(
width: 12,
),
SizedBox(
width: 170,
height: 140,
child: FactoryResetWidget(
callFactoryReset: () {
BlocProvider.of<DoorLockBloc>(context).add(
DoorLockFactoryReset(
deviceId: devicesIds.first,
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
),
);
},
),
),
],
);
}
}

View File

@ -7,10 +7,10 @@ import 'package:syncrow_web/pages/device_managment/door_lock/bloc/door_lock_stat
import 'package:syncrow_web/pages/device_managment/door_lock/models/door_lock_status_model.dart';
import 'package:syncrow_web/pages/device_managment/door_lock/widget/door_button.dart';
class DoorLockView extends StatelessWidget {
class DoorLockControlsView extends StatelessWidget {
final AllDevicesModel device;
const DoorLockView({super.key, required this.device});
const DoorLockControlsView({super.key, required this.device});
@override
Widget build(BuildContext context) {

View File

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
@ -12,6 +13,7 @@ class GateWayBloc extends Bloc<GateWayEvent, GateWayState> {
GateWayBloc() : super(GateWayInitial()) {
on<GateWayFetch>((event, emit) {});
on<GatWayById>(_getGatWayById);
on<GateWayFactoryReset>(_onFactoryReset);
}
FutureOr<void> _getGatWayById(
@ -27,4 +29,22 @@ class GateWayBloc extends Bloc<GateWayEvent, GateWayState> {
return;
}
}
FutureOr<void> _onFactoryReset(
GateWayFactoryReset event, Emitter<GateWayState> emit) async {
emit(GatewayLoadingState());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.deviceId,
);
if (!response) {
emit(const ErrorState(message: 'Failed'));
} else {
add(GatWayById(event.deviceId));
}
} catch (e) {
emit(ErrorState(message: e.toString()));
}
}
}

View File

@ -18,3 +18,15 @@ class GatWayById extends GateWayEvent {
final String getWayId;
const GatWayById(this.getWayId);
}
class GateWayFactoryReset extends GateWayEvent {
final String deviceId;
final FactoryResetModel factoryReset;
const GateWayFactoryReset({
required this.deviceId,
required this.factoryReset,
});
@override
List<Object> get props => [deviceId, factoryReset];
}

View File

@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/gateway/bloc/gate_way_bloc.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class GatewayBatchControlView extends StatelessWidget
with HelperResponsiveLayout {
const GatewayBatchControlView({super.key, required this.gatewayIds});
final List<String> gatewayIds;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => GateWayBloc()..add(GatWayById(gatewayIds.first)),
child: BlocBuilder<GateWayBloc, GateWayState>(
builder: (context, state) {
if (state is GatewayLoadingState) {
return const Center(child: CircularProgressIndicator());
} else if (state is UpdateGatewayState) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 170,
height: 140,
child: FirmwareUpdateWidget(
deviceId: gatewayIds.first, version: 2)),
const SizedBox(
width: 12,
),
SizedBox(
width: 170,
height: 140,
child: FactoryResetWidget(
callFactoryReset: () {
context.read<GateWayBloc>().add(
GateWayFactoryReset(
deviceId: gatewayIds.first,
factoryReset:
FactoryResetModel(devicesUuid: gatewayIds),
),
);
},
),
),
],
);
} else {
return const Center(child: Text('Error fetching status'));
}
},
),
);
}
}

View File

@ -7,8 +7,8 @@ import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class GateWayControls extends StatelessWidget with HelperResponsiveLayout {
const GateWayControls({super.key, required this.gatewayId});
class GateWayControlsView extends StatelessWidget with HelperResponsiveLayout {
const GateWayControlsView({super.key, required this.gatewayId});
final String gatewayId;
@ -67,26 +67,23 @@ class _DeviceItem extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 60,
ClipOval(
child: Container(
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
width: 60,
padding: const EdgeInsets.all(8),
color: ColorsManager.whiteColors,
child: SvgPicture.asset(
device.icon,
width: 35,
height: 35,
fit: BoxFit.contain,
),
margin: const EdgeInsets.symmetric(horizontal: 4),
padding: const EdgeInsets.all(4),
child: ClipOval(
child: SvgPicture.asset(
device.icon,
fit: BoxFit.fill,
),
),
),
)),
const Spacer(),
Text(
device.name ?? 'Unknown Device',
textAlign: TextAlign.center,
textAlign: TextAlign.start,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,

View File

@ -0,0 +1,159 @@
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_state.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/models/main_door_status_model.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
class MainDoorSensorBloc
extends Bloc<MainDoorSensorEvent, MainDoorSensorState> {
MainDoorSensorBloc() : super(MainDoorSensorInitial()) {
on<MainDoorSensorFetchDeviceEvent>(_onFetchDeviceStatus);
on<MainDoorSensorControl>(_onControl);
on<MainDoorSensorFetchBatchEvent>(_onFetchBatchStatus);
on<MainDoorSensorReportsEvent>(_fetchReports);
on<MainDoorSensorFactoryReset>(_factoryReset);
}
late MainDoorSensorStatusModel deviceStatus;
Timer? _timer;
FutureOr<void> _onFetchDeviceStatus(MainDoorSensorFetchDeviceEvent event,
Emitter<MainDoorSensorState> emit) async {
emit(MainDoorSensorLoadingState());
try {
final status = await DevicesManagementApi()
.getDeviceStatus(event.deviceId)
.then((value) => value.status);
deviceStatus = MainDoorSensorStatusModel.fromJson(event.deviceId, status);
emit(MainDoorSensorDeviceStatusLoaded(deviceStatus));
} catch (e) {
emit(MainDoorSensorFailedState(error: e.toString()));
}
}
FutureOr<void> _onControl(
MainDoorSensorControl event, Emitter<MainDoorSensorState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(MainDoorSensorDeviceStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceId,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
);
}
Future<void> _runDebounce({
required String deviceId,
required String code,
required bool value,
required bool oldValue,
required Emitter<MainDoorSensorState> emit,
}) async {
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(milliseconds: 500), () async {
try {
final response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
if (!response) {
_revertValueAndEmit(deviceId, code, oldValue, emit);
}
} catch (e) {
if (e is DioException && e.response != null) {
debugPrint('Error response: ${e.response?.data}');
}
_revertValueAndEmit(deviceId, code, oldValue, emit);
}
});
}
void _revertValueAndEmit(String deviceId, String code, bool oldValue,
Emitter<MainDoorSensorState> emit) {
_updateLocalValue(code, oldValue);
emit(MainDoorSensorDeviceStatusLoaded(deviceStatus));
}
void _updateLocalValue(String code, bool value) {
switch (code) {
case 'doorcontact_state':
deviceStatus = deviceStatus.copyWith(doorContactState: value);
break;
default:
break;
}
}
bool _getValueByCode(String code) {
switch (code) {
case 'doorcontact_state':
return deviceStatus.doorContactState;
default:
return false;
}
}
// Fetch batch status for multiple devices (if needed)
FutureOr<void> _onFetchBatchStatus(MainDoorSensorFetchBatchEvent event,
Emitter<MainDoorSensorState> emit) async {
emit(MainDoorSensorLoadingState());
try {
// final batchStatus =
// await DevicesManagementApi().getBatchDeviceStatus(event.deviceIds);
// Assuming you need to update multiple devices status here
// You might need a list or map of MainDoorSensorStatusModel for batch processing
// emit(MainDoorSensorBatchStatusLoaded(batchStatus));
} catch (e) {
emit(MainDoorSensorBatchFailedState(error: e.toString()));
}
}
FutureOr<void> _fetchReports(MainDoorSensorReportsEvent event,
Emitter<MainDoorSensorState> emit) async {
emit(MainDoorSensorLoadingState());
try {
final reports = await DevicesManagementApi.getDeviceReportsByDate(
event.deviceId, event.code, event.from, event.to);
emit(MainDoorSensorReportLoaded(reports));
} catch (e) {
emit(MainDoorSensorFailedState(error: e.toString()));
}
}
@override
Future<void> close() {
_timer?.cancel();
return super.close();
}
FutureOr<void> _factoryReset(MainDoorSensorFactoryReset event,
Emitter<MainDoorSensorState> emit) async {
emit(MainDoorSensorLoadingState());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.deviceId,
);
if (!response) {
emit(MainDoorSensorFailedState(error: 'Failed'));
} else {
add(MainDoorSensorFetchDeviceEvent(event.deviceId));
}
} catch (e) {
emit(MainDoorSensorFailedState(error: e.toString()));
}
}
}

View File

@ -0,0 +1,73 @@
import 'package:equatable/equatable.dart';
import '../../all_devices/models/factory_reset_model.dart';
class MainDoorSensorEvent extends Equatable {
@override
List<Object?> get props => [];
}
class MainDoorSensorFetchDeviceEvent extends MainDoorSensorEvent {
final String deviceId;
MainDoorSensorFetchDeviceEvent(this.deviceId);
@override
List<Object> get props => [deviceId];
}
class MainDoorSensorFetchBatchEvent extends MainDoorSensorEvent {
final String deviceId;
MainDoorSensorFetchBatchEvent(this.deviceId);
@override
List<Object> get props => [deviceId];
}
class MainDoorSensorControl extends MainDoorSensorEvent {
final String deviceId;
final String code;
final bool value;
MainDoorSensorControl(
{required this.deviceId, required this.code, required this.value});
@override
List<Object> get props => [deviceId, code, value];
}
class MainDoorSensorBatchControl extends MainDoorSensorEvent {
final List<String> deviceId;
final String code;
final bool value;
MainDoorSensorBatchControl(
{required this.deviceId, required this.code, required this.value});
@override
List<Object> get props => [deviceId, code, value];
}
class MainDoorSensorReportsEvent extends MainDoorSensorEvent {
final String deviceId;
final String code;
final String from;
final String to;
@override
List<Object> get props => [deviceId, code, from, to];
MainDoorSensorReportsEvent(
{required this.deviceId,
required this.code,
required this.from,
required this.to});
}
class MainDoorSensorFactoryReset extends MainDoorSensorEvent {
final String deviceId;
final FactoryResetModel factoryReset;
MainDoorSensorFactoryReset(
{required this.deviceId, required this.factoryReset});
}

View File

@ -0,0 +1,68 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_reports.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/models/main_door_status_model.dart';
class MainDoorSensorState extends Equatable {
@override
List<Object?> get props => [];
}
class MainDoorSensorInitial extends MainDoorSensorState {}
class MainDoorSensorLoadingState extends MainDoorSensorState {}
class MainDoorSensorDeviceStatusLoaded extends MainDoorSensorState {
final MainDoorSensorStatusModel status;
MainDoorSensorDeviceStatusLoaded(this.status);
@override
List<Object?> get props => [status];
}
class MainDoorSensorFailedState extends MainDoorSensorState {
final String error;
MainDoorSensorFailedState({required this.error});
@override
List<Object?> get props => [error];
}
class MainDoorSensorBatchFailedState extends MainDoorSensorState {
final String error;
MainDoorSensorBatchFailedState({required this.error});
@override
List<Object?> get props => [error];
}
class MainDoorSensorBatchStatusLoaded extends MainDoorSensorState {
final List<MainDoorSensorStatusModel> status;
MainDoorSensorBatchStatusLoaded(this.status);
@override
List<Object?> get props => [status];
}
class MainDoorSensorReportLoaded extends MainDoorSensorState {
final DeviceReport deviceReport;
MainDoorSensorReportLoaded(this.deviceReport);
@override
List<Object?> get props => [deviceReport];
}
class MainDoorSensorReportsLoadingState extends MainDoorSensorState {}
class MainDoorSensorReportsFailedState extends MainDoorSensorState {
final String error;
MainDoorSensorReportsFailedState({required this.error});
@override
List<Object?> get props => [error];
}

View File

@ -0,0 +1,47 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
class MainDoorSensorStatusModel {
final String uuid;
final bool doorContactState;
final int batteryPercentage;
MainDoorSensorStatusModel({
required this.uuid,
required this.doorContactState,
required this.batteryPercentage,
});
factory MainDoorSensorStatusModel.fromJson(String id, List<Status> jsonList) {
late bool doorContactState = false;
late int batteryPercentage = 0;
for (var status in jsonList) {
switch (status.code) {
case 'doorcontact_state':
doorContactState = status.value ?? false;
break;
case 'battery_percentage':
batteryPercentage = status.value ?? 0;
break;
}
}
return MainDoorSensorStatusModel(
uuid: id,
doorContactState: doorContactState,
batteryPercentage: batteryPercentage,
);
}
MainDoorSensorStatusModel copyWith({
String? uuid,
bool? doorContactState,
int? batteryPercentage,
}) {
return MainDoorSensorStatusModel(
uuid: uuid ?? this.uuid,
doorContactState: doorContactState ?? this.doorContactState,
batteryPercentage: batteryPercentage ?? this.batteryPercentage,
);
}
}

View File

@ -0,0 +1,197 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.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/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_state.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/models/main_door_status_model.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.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';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class MainDoorSensorControlView extends StatelessWidget
with HelperResponsiveLayout {
const MainDoorSensorControlView({super.key, required this.device});
final AllDevicesModel device;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => MainDoorSensorBloc()
..add(MainDoorSensorFetchDeviceEvent(device.uuid!)),
child: BlocBuilder<MainDoorSensorBloc, MainDoorSensorState>(
builder: (context, state) {
if (state is MainDoorSensorLoadingState ||
state is MainDoorSensorReportsLoadingState) {
return const Center(child: CircularProgressIndicator());
} else if (state is MainDoorSensorDeviceStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is MainDoorSensorReportLoaded) {
return ReportsTable(
report: state.deviceReport,
onRowTap: (index) {},
onClose: () {
context
.read<MainDoorSensorBloc>()
.add(MainDoorSensorFetchDeviceEvent(device.uuid!));
},
hideValueShowDescription: true,
mainDoorSensor: true,
);
} else if (state is MainDoorSensorFailedState ||
state is MainDoorSensorBatchFailedState) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
));
}
Widget _buildStatusControls(
BuildContext context, MainDoorSensorStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
IconNameStatusContainer(
isFullIcon: true,
name: status.doorContactState ? 'Open' : 'Close',
icon: Assets.openCloseDoor,
onTap: () {},
status: status.doorContactState,
textColor: status.doorContactState
? ColorsManager.red
: ColorsManager.blackColor,
paddingAmount: 8,
),
IconNameStatusContainer(
isFullIcon: true,
name: 'Open/Close\nRecord',
icon: Assets.openCloseRecords,
onTap: () {
final from = DateTime.now()
.subtract(const Duration(days: 30))
.millisecondsSinceEpoch;
final to = DateTime.now().millisecondsSinceEpoch;
context.read<MainDoorSensorBloc>().add(
MainDoorSensorReportsEvent(
deviceId: device.uuid!,
code: 'doorcontact_state',
from: from.toString(),
to: to.toString(),
),
);
},
status: false,
textColor: ColorsManager.blackColor,
),
IconNameStatusContainer(
isFullIcon: false,
name: 'Notifications\nSettings',
icon: Assets.mainDoorNotifi,
onTap: () {
showDialog(
context: context,
builder: (context) => const NotificationDialog(),
);
},
status: false,
textColor: ColorsManager.blackColor,
paddingAmount: 14,
),
],
);
}
}
class IconNameStatusContainer extends StatelessWidget {
const IconNameStatusContainer({
super.key,
required this.name,
required this.icon,
required this.onTap,
required this.status,
required this.textColor,
this.paddingAmount = 12,
required this.isFullIcon,
});
final String name;
final String icon;
final GestureTapCallback onTap;
final bool status;
final Color textColor;
final double? paddingAmount;
final bool isFullIcon;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isFullIcon)
ClipOval(
child: SvgPicture.asset(
icon,
fit: BoxFit.contain,
),
)
else
Container(
width: 60,
height: 60,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: ColorsManager.whiteColors,
),
//margin: const EdgeInsets.symmetric(horizontal: 4),
padding: EdgeInsets.all(paddingAmount ?? 12),
child: ClipOval(
child: SvgPicture.asset(
icon,
fit: BoxFit.contain,
),
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Text(
name,
textAlign: TextAlign.start,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: textColor,
),
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
class MainDoorSensorBatchView extends StatelessWidget {
const MainDoorSensorBatchView({super.key, required this.devicesIds});
final List<String> devicesIds;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 170,
height: 140,
child: FirmwareUpdateWidget(
deviceId: devicesIds.first,
version: 12,
),
),
const SizedBox(
width: 12,
),
SizedBox(
width: 170,
height: 140,
child: FactoryResetWidget(
callFactoryReset: () {
BlocProvider.of<MainDoorSensorBloc>(context).add(
MainDoorSensorFactoryReset(
deviceId: devicesIds.first,
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
),
);
},
),
),
],
);
}
}

View File

@ -0,0 +1,97 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class NotificationDialog extends StatelessWidget {
const NotificationDialog({super.key});
@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.white,
insetPadding: const EdgeInsets.all(20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
child: SizedBox(
width: 798,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(),
Text(
'Notification Settings',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 22,
color: ColorsManager.dialogBlueTitle,
),
),
Container(
width: 25,
decoration: BoxDecoration(
color: Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
),
child: IconButton(
padding: EdgeInsets.all(1),
icon: const Icon(
Icons.close,
color: Colors.grey,
size: 18,
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
],
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ToggleWidget(
value: true,
code: 'notification',
deviceId: '',
label: 'Low Battery',
onChange: (v) {},
icon: '-1',
),
ToggleWidget(
value: true,
code: 'notification',
deviceId: '',
label: 'Closing\nReminders',
onChange: (v) {},
icon: '-1',
),
ToggleWidget(
value: true,
code: 'notification',
deviceId: '',
label: 'Door Alarm',
onChange: (v) {},
icon: '-1',
),
],
),
],
),
),
),
),
);
}
}

View File

@ -0,0 +1,143 @@
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/models/once_gang_glass_status_model.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
part 'one_gang_glass_switch_event.dart';
part 'one_gang_glass_switch_state.dart';
class OneGangGlassSwitchBloc extends Bloc<OneGangGlassSwitchEvent, OneGangGlassSwitchState> {
OneGangGlassStatusModel deviceStatus;
Timer? _timer;
OneGangGlassSwitchBloc({required String deviceId})
: deviceStatus = OneGangGlassStatusModel(uuid: deviceId, switch1: false, countDown: 0),
super(OneGangGlassSwitchInitial()) {
on<OneGangGlassSwitchFetchDeviceEvent>(_onFetchDeviceStatus);
on<OneGangGlassSwitchControl>(_onControl);
on<OneGangGlassSwitchBatchControl>(_onBatchControl);
on<OneGangGlassSwitchFetchBatchStatusEvent>(_onFetchBatchStatus);
}
Future<void> _onFetchDeviceStatus(
OneGangGlassSwitchFetchDeviceEvent event, Emitter<OneGangGlassSwitchState> emit) async {
emit(OneGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = OneGangGlassStatusModel.fromJson(event.deviceId, status.status);
emit(OneGangGlassSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(OneGangGlassSwitchError(e.toString()));
}
}
Future<void> _onControl(OneGangGlassSwitchControl event, Emitter<OneGangGlassSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(OneGangGlassSwitchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceId,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: false,
);
}
Future<void> _onBatchControl(OneGangGlassSwitchBatchControl event, Emitter<OneGangGlassSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(OneGangGlassSwitchBatchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: true,
);
}
Future<void> _onFetchBatchStatus(
OneGangGlassSwitchFetchBatchStatusEvent event, Emitter<OneGangGlassSwitchState> emit) async {
emit(OneGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getBatchStatus(event.deviceIds);
deviceStatus = OneGangGlassStatusModel.fromJson(event.deviceIds.first, status.status);
emit(OneGangGlassSwitchBatchStatusLoaded(deviceStatus));
} catch (e) {
emit(OneGangGlassSwitchError(e.toString()));
}
}
Future<void> _runDebounce({
required dynamic deviceId,
required String code,
required bool value,
required bool oldValue,
required Emitter<OneGangGlassSwitchState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(milliseconds: 500), () async {
try {
late bool response;
if (isBatch) {
response = await DevicesManagementApi().deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi().deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
_revertValueAndEmit(id, code, oldValue, emit);
}
} catch (e) {
_revertValueAndEmit(id, code, oldValue, emit);
}
});
}
void _revertValueAndEmit(String deviceId, String code, bool oldValue, Emitter<OneGangGlassSwitchState> emit) {
_updateLocalValue(code, oldValue);
emit(OneGangGlassSwitchStatusLoaded(deviceStatus));
}
void _updateLocalValue(String code, bool value) {
if (code == 'switch_1') {
deviceStatus = deviceStatus.copyWith(switch1: value);
}
}
bool _getValueByCode(String code) {
switch (code) {
case 'switch_1':
return deviceStatus.switch1;
default:
return false;
}
}
@override
Future<void> close() {
_timer?.cancel();
return super.close();
}
}

View File

@ -0,0 +1,40 @@
part of 'one_gang_glass_switch_bloc.dart';
@immutable
abstract class OneGangGlassSwitchEvent {}
class OneGangGlassSwitchFetchDeviceEvent extends OneGangGlassSwitchEvent {
final String deviceId;
OneGangGlassSwitchFetchDeviceEvent(this.deviceId);
}
class OneGangGlassSwitchControl extends OneGangGlassSwitchEvent {
final String deviceId;
final String code;
final bool value;
OneGangGlassSwitchControl({
required this.deviceId,
required this.code,
required this.value,
});
}
class OneGangGlassSwitchBatchControl extends OneGangGlassSwitchEvent {
final List<String> deviceIds;
final String code;
final bool value;
OneGangGlassSwitchBatchControl({
required this.deviceIds,
required this.code,
required this.value,
});
}
class OneGangGlassSwitchFetchBatchStatusEvent extends OneGangGlassSwitchEvent {
final List<String> deviceIds;
OneGangGlassSwitchFetchBatchStatusEvent(this.deviceIds);
}

View File

@ -0,0 +1,32 @@
part of 'one_gang_glass_switch_bloc.dart';
@immutable
abstract class OneGangGlassSwitchState {}
class OneGangGlassSwitchInitial extends OneGangGlassSwitchState {}
class OneGangGlassSwitchLoading extends OneGangGlassSwitchState {}
class OneGangGlassSwitchStatusLoaded extends OneGangGlassSwitchState {
final OneGangGlassStatusModel status;
OneGangGlassSwitchStatusLoaded(this.status);
}
class OneGangGlassSwitchError extends OneGangGlassSwitchState {
final String message;
OneGangGlassSwitchError(this.message);
}
class OneGangGlassSwitchBatchStatusLoaded extends OneGangGlassSwitchState {
final OneGangGlassStatusModel status;
OneGangGlassSwitchBatchStatusLoaded(this.status);
}
class OneGangGlassSwitchBatchControlError extends OneGangGlassSwitchState {
final String message;
OneGangGlassSwitchBatchControlError(this.message);
}

View File

@ -0,0 +1,50 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
class OneGangGlassStatusModel {
final String uuid;
final bool switch1;
final int countDown;
OneGangGlassStatusModel({
required this.uuid,
required this.switch1,
required this.countDown,
});
factory OneGangGlassStatusModel.fromJson(String id, List<Status> jsonList) {
late bool switch1;
late int countDown;
for (var status in jsonList) {
switch (status.code) {
case 'switch_1':
switch1 = status.value ?? false;
break;
case 'countdown_1':
countDown = status.value ?? 0;
break;
}
}
return OneGangGlassStatusModel(
uuid: id,
switch1: switch1,
countDown: countDown,
);
}
OneGangGlassStatusModel copyWith({
String? uuid,
bool? switch1,
int? countDown,
}) {
return OneGangGlassStatusModel(
uuid: uuid ?? this.uuid,
switch1: switch1 ?? this.switch1,
countDown: countDown ?? this.countDown,
);
}
@override
String toString() => 'OneGangGlassStatusModel(uuid: $uuid, switch1: $switch1, countDown: $countDown)';
}

View File

@ -0,0 +1,80 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/bloc/one_gang_glass_switch_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/models/once_gang_glass_status_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class OneGangGlassSwitchBatchControlView extends StatelessWidget with HelperResponsiveLayout {
final List<String> deviceIds;
const OneGangGlassSwitchBatchControlView({required this.deviceIds, super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) =>
OneGangGlassSwitchBloc(deviceId: deviceIds.first)..add(OneGangGlassSwitchFetchBatchStatusEvent(deviceIds)),
child: BlocBuilder<OneGangGlassSwitchBloc, OneGangGlassSwitchState>(
builder: (context, state) {
if (state is OneGangGlassSwitchLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is OneGangGlassSwitchStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is OneGangGlassSwitchError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(BuildContext context, OneGangGlassStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceIds.first,
label: 'Wall Light',
onChange: (value) {
context.read<OneGangGlassSwitchBloc>().add(
OneGangGlassSwitchBatchControl(
deviceIds: deviceIds,
code: 'switch_1',
value: value,
),
);
},
),
FirmwareUpdateWidget(
deviceId: deviceIds.first,
version: 12, // adjust the version according to your requirement
),
FactoryResetWidget(
callFactoryReset: () {},
),
],
);
}
}

View File

@ -0,0 +1,90 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/bloc/one_gang_glass_switch_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_g_glass_switch/models/once_gang_glass_status_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class OneGangGlassSwitchControlView extends StatelessWidget with HelperResponsiveLayout {
final String deviceId;
const OneGangGlassSwitchControlView({required this.deviceId, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) =>
OneGangGlassSwitchBloc(deviceId: deviceId)..add(OneGangGlassSwitchFetchDeviceEvent(deviceId)),
child: BlocBuilder<OneGangGlassSwitchBloc, OneGangGlassSwitchState>(
builder: (context, state) {
if (state is OneGangGlassSwitchLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is OneGangGlassSwitchStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is OneGangGlassSwitchError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(BuildContext context, OneGangGlassStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Lightً',
onChange: (value) {
context.read<OneGangGlassSwitchBloc>().add(
OneGangGlassSwitchControl(
deviceId: deviceId,
code: 'switch_1',
value: value,
),
);
},
),
ToggleWidget(
value: false,
code: '',
deviceId: deviceId,
label: 'Preferences',
icon: Assets.preferences,
onChange: (value) {},
showToggle: false,
),
ToggleWidget(
value: false,
code: '',
deviceId: deviceId,
label: 'Scheduling',
icon: Assets.scheduling,
onChange: (value) {},
showToggle: false,
),
],
);
}
}

View File

@ -0,0 +1,175 @@
import 'dart:async';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_event.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_state.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/models/wall_light_status_model.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
class WallLightSwitchBloc
extends Bloc<WallLightSwitchEvent, WallLightSwitchState> {
WallLightSwitchBloc({required this.deviceId})
: super(WallLightSwitchInitial()) {
on<WallLightSwitchFetchDeviceEvent>(_onFetchDeviceStatus);
on<WallLightSwitchControl>(_onControl);
on<WallLightSwitchFetchBatchEvent>(_onFetchBatchStatus);
on<WallLightSwitchBatchControl>(_onBatchControl);
on<WallLightFactoryReset>(_onFactoryReset);
}
late WallLightStatusModel deviceStatus;
final String deviceId;
Timer? _timer;
FutureOr<void> _onFetchDeviceStatus(WallLightSwitchFetchDeviceEvent event,
Emitter<WallLightSwitchState> emit) async {
emit(WallLightSwitchLoading());
try {
final status =
await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus =
WallLightStatusModel.fromJson(event.deviceId, status.status);
emit(WallLightSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(WallLightSwitchError(e.toString()));
}
}
FutureOr<void> _onControl(
WallLightSwitchControl event, Emitter<WallLightSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(WallLightSwitchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceId,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: false,
);
}
Future<void> _runDebounce({
required dynamic deviceId,
required String code,
required bool value,
required bool oldValue,
required Emitter<WallLightSwitchState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(milliseconds: 500), () async {
try {
late bool response;
if (isBatch) {
response = await DevicesManagementApi()
.deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
_revertValueAndEmit(id, code, oldValue, emit);
}
} catch (e) {
_revertValueAndEmit(id, code, oldValue, emit);
}
});
}
void _revertValueAndEmit(String deviceId, String code, bool oldValue,
Emitter<WallLightSwitchState> emit) {
_updateLocalValue(code, oldValue);
emit(WallLightSwitchStatusLoaded(deviceStatus));
}
void _updateLocalValue(String code, bool value) {
if (code == 'switch_1') {
deviceStatus = deviceStatus.copyWith(switch1: value);
}
}
bool _getValueByCode(String code) {
switch (code) {
case 'switch_1':
return deviceStatus.switch1;
default:
return false;
}
}
Future<void> _onFetchBatchStatus(WallLightSwitchFetchBatchEvent event,
Emitter<WallLightSwitchState> emit) async {
emit(WallLightSwitchLoading());
try {
final status =
await DevicesManagementApi().getBatchStatus(event.devicesIds);
deviceStatus =
WallLightStatusModel.fromJson(event.devicesIds.first, status.status);
emit(WallLightSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(WallLightSwitchError(e.toString()));
}
}
@override
Future<void> close() {
_timer?.cancel();
return super.close();
}
FutureOr<void> _onBatchControl(WallLightSwitchBatchControl event,
Emitter<WallLightSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(WallLightSwitchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.devicesIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: true,
);
}
FutureOr<void> _onFactoryReset(
WallLightFactoryReset event, Emitter<WallLightSwitchState> emit) async {
emit(WallLightSwitchLoading());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.deviceId,
);
if (!response) {
emit(WallLightSwitchError('Failed'));
} else {
emit(WallLightSwitchStatusLoaded(deviceStatus));
}
} catch (e) {
emit(WallLightSwitchError(e.toString()));
}
}
}

View File

@ -0,0 +1,59 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
class WallLightSwitchEvent extends Equatable {
@override
List<Object?> get props => [];
}
class WallLightSwitchFetchDeviceEvent extends WallLightSwitchEvent {
final String deviceId;
WallLightSwitchFetchDeviceEvent(this.deviceId);
@override
List<Object> get props => [deviceId];
}
class WallLightSwitchControl extends WallLightSwitchEvent {
final String deviceId;
final String code;
final bool value;
WallLightSwitchControl(
{required this.deviceId, required this.code, required this.value});
@override
List<Object> get props => [deviceId, code, value];
}
class WallLightSwitchFetchBatchEvent extends WallLightSwitchEvent {
final List<String> devicesIds;
WallLightSwitchFetchBatchEvent(this.devicesIds);
@override
List<Object> get props => [devicesIds];
}
class WallLightSwitchBatchControl extends WallLightSwitchEvent {
final List<String> devicesIds;
final String code;
final bool value;
WallLightSwitchBatchControl(
{required this.devicesIds, required this.code, required this.value});
@override
List<Object> get props => [devicesIds, code, value];
}
class WallLightFactoryReset extends WallLightSwitchEvent {
final String deviceId;
final FactoryResetModel factoryReset;
WallLightFactoryReset({required this.deviceId, required this.factoryReset});
@override
List<Object> get props => [deviceId, factoryReset];
}

View File

@ -0,0 +1,56 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/models/wall_light_status_model.dart';
class WallLightSwitchState extends Equatable {
@override
List<Object?> get props => [];
}
class WallLightSwitchInitial extends WallLightSwitchState {}
class WallLightSwitchLoading extends WallLightSwitchState {}
class WallLightSwitchStatusLoaded extends WallLightSwitchState {
final WallLightStatusModel status;
WallLightSwitchStatusLoaded(this.status);
@override
List<Object> get props => [status];
}
class WallLightSwitchError extends WallLightSwitchState {
final String message;
WallLightSwitchError(this.message);
@override
List<Object> get props => [message];
}
class WallLightSwitchControlError extends WallLightSwitchState {
final String message;
WallLightSwitchControlError(this.message);
@override
List<Object> get props => [message];
}
class WallLightSwitchBatchControlError extends WallLightSwitchState {
final String message;
WallLightSwitchBatchControlError(this.message);
@override
List<Object> get props => [message];
}
class WallLightSwitchBatchStatusLoaded extends WallLightSwitchState {
final List<String> status;
WallLightSwitchBatchStatusLoaded(this.status);
@override
List<Object> get props => [status];
}

View File

@ -0,0 +1,47 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
class WallLightStatusModel {
final String uuid;
final bool switch1;
final int countDown;
WallLightStatusModel({
required this.uuid,
required this.switch1,
required this.countDown,
});
factory WallLightStatusModel.fromJson(String id, List<Status> jsonList) {
late bool switch1;
late int countDown;
for (var status in jsonList) {
switch (status.code) {
case 'switch_1':
switch1 = status.value ?? false;
break;
case 'countdown_1':
countDown = status.value ?? 0;
break;
}
}
return WallLightStatusModel(
uuid: id,
switch1: switch1,
countDown: countDown,
);
}
WallLightStatusModel copyWith({
String? uuid,
bool? switch1,
int? countDown,
}) {
return WallLightStatusModel(
uuid: uuid ?? this.uuid,
switch1: switch1 ?? this.switch1,
countDown: countDown ?? this.countDown,
);
}
}

View File

@ -0,0 +1,92 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_event.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_state.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/models/wall_light_status_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class WallLightBatchControlView extends StatelessWidget
with HelperResponsiveLayout {
const WallLightBatchControlView({super.key, required this.deviceIds});
final List<String> deviceIds;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => WallLightSwitchBloc(deviceId: deviceIds.first)
..add(WallLightSwitchFetchBatchEvent(deviceIds)),
child: BlocBuilder<WallLightSwitchBloc, WallLightSwitchState>(
builder: (context, state) {
if (state is WallLightSwitchLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is WallLightSwitchStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is WallLightSwitchError ||
state is WallLightSwitchControlError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(
BuildContext context, WallLightStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return SizedBox(
child: GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceIds.first,
label: 'Wall Light',
onChange: (value) {
context.read<WallLightSwitchBloc>().add(
WallLightSwitchBatchControl(
devicesIds: deviceIds,
code: 'switch_1',
value: value,
),
);
},
),
FirmwareUpdateWidget(
deviceId: deviceIds.first,
version: 12,
),
FactoryResetWidget(
callFactoryReset: () {
context.read<WallLightSwitchBloc>().add(WallLightFactoryReset(
deviceId: status.uuid,
factoryReset: FactoryResetModel(devicesUuid: deviceIds)));
},
),
],
),
);
}
}

View File

@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_bloc.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_event.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/bloc/wall_light_switch_state.dart';
import 'package:syncrow_web/pages/device_managment/one_gang_switch/models/wall_light_status_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class WallLightDeviceControl extends StatelessWidget
with HelperResponsiveLayout {
final String deviceId;
const WallLightDeviceControl({super.key, required this.deviceId});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => WallLightSwitchBloc(deviceId: deviceId)
..add(WallLightSwitchFetchDeviceEvent(deviceId)),
child: BlocBuilder<WallLightSwitchBloc, WallLightSwitchState>(
builder: (context, state) {
if (state is WallLightSwitchLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is WallLightSwitchStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is WallLightSwitchError ||
state is WallLightSwitchControlError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(
BuildContext context, WallLightStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
const SizedBox(),
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Light',
onChange: (value) {
context.read<WallLightSwitchBloc>().add(WallLightSwitchControl(
deviceId: deviceId,
code: 'switch_1',
value: value,
));
},
),
const SizedBox(),
],
);
}
}

View File

@ -0,0 +1,119 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.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';
class FactoryResetWidget extends StatefulWidget {
const FactoryResetWidget({super.key, required this.callFactoryReset});
final Function() callFactoryReset;
@override
State<FactoryResetWidget> createState() => _FactoryResetWidgetState();
}
class _FactoryResetWidgetState extends State<FactoryResetWidget> {
bool _showConfirmation = false;
void _toggleConfirmation() {
setState(() {
_showConfirmation = !_showConfirmation;
});
}
@override
Widget build(BuildContext context) {
return DeviceControlsContainer(
child: _showConfirmation
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Factory Reset',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.bold,
color: ColorsManager.blackColor,
),
),
Text(
'Are you sure?',
style: context.textTheme.bodySmall!.copyWith(
color: ColorsManager.grayColor,
),
),
const SizedBox(height: 16),
Row(
children: [
Flexible(
child: DefaultButton(
height: 20,
elevation: 0,
onPressed: _toggleConfirmation,
backgroundColor: ColorsManager.greyColor,
child: Text(
'Cancel',
style: context.textTheme.bodyMedium!.copyWith(
color: ColorsManager.blackColor,
fontWeight: FontWeight.w400,
fontSize: 12,
),
),
),
),
const SizedBox(width: 8),
Flexible(
child: DefaultButton(
height: 20,
elevation: 0,
onPressed: widget.callFactoryReset,
backgroundColor: ColorsManager.red,
child: Text(
'Reset',
style: context.textTheme.bodyMedium!.copyWith(
color: ColorsManager.whiteColors,
fontWeight: FontWeight.w400,
fontSize: 12),
),
),
),
],
),
],
)
: GestureDetector(
onTap: _toggleConfirmation,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClipOval(
child: Container(
color: ColorsManager.whiteColors,
height: 60,
width: 60,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: SvgPicture.asset(
Assets.factoryReset,
fit: BoxFit.cover,
),
),
),
),
Text(
'Factory Reset',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
),
);
}
}

View File

@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.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';
class FirmwareUpdateWidget extends StatelessWidget {
const FirmwareUpdateWidget(
{super.key, required String deviceId, required int version});
@override
Widget build(BuildContext context) {
return DeviceControlsContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClipOval(
child: Container(
color: ColorsManager.whiteColors,
height: 60,
width: 60,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: SvgPicture.asset(
Assets.firmware,
fit: BoxFit.cover,
),
),
)),
Text(
'Firmware Update',
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
);
}
}

View File

@ -0,0 +1,133 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class DeviceBatchControlDialog extends StatelessWidget
with RouteControlsBasedCode {
final List<AllDevicesModel> devices;
const DeviceBatchControlDialog({super.key, required this.devices});
@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: Colors.white,
insetPadding: const EdgeInsets.all(20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
child: SizedBox(
width: devices.length < 2 ? 500 : 800,
// height: context.screenHeight * 0.7,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(),
Column(
children: [
Text(
getBatchDialogName(devices.first),
style: context.textTheme.titleLarge!.copyWith(
color: ColorsManager.dialogBlueTitle,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 8,
),
Text(
"Batch Control",
style: context.textTheme.bodySmall!.copyWith(
color: ColorsManager.dialogBlueTitle,
),
),
],
),
Container(
width: 25,
decoration: BoxDecoration(
color: Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: Colors.grey,
width: 1.0,
),
),
child: IconButton(
padding: const EdgeInsets.all(1),
icon: const Icon(
Icons.close,
color: Colors.grey,
size: 18,
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
],
),
const SizedBox(height: 20),
//// BUILD DEVICE CONTROLS
///
//// ROUTE TO SPECIFIC CONTROL VIEW BASED ON DEVICE CATEGORY
routeBatchControlsWidgets(devices: devices),
],
),
),
),
),
);
}
}
String getBatchDialogName(AllDevicesModel device) {
/*
3G:
1G:
2G:
GW:
DL:
WPS:
CPS:
AC:
CUR:
WH:
*/
switch (device.productType) {
case '1G':
return "Smart Light Switch";
case '2G':
return "2Gang Light";
case '3G':
return "Living Room";
case 'GW':
return "GateWay";
case 'DL':
return "Door Lock";
case 'WPS':
return "White Presence Sensor";
case 'CPS':
return "Black Presence Sensor";
case 'CUR':
return "Smart Curtains";
case 'WH':
return "Smart Water Hater";
case 'AC':
return "Smart AC";
default:
return device.categoryName ?? 'Device Control';
}
}

View File

@ -1,11 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/format_date_time.dart';
class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
final AllDevicesModel device;
@ -22,7 +22,7 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
),
child: SizedBox(
width: 798,
height: context.screenHeight * 0.7,
// height: context.screenHeight * 0.7,
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
@ -87,13 +87,12 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
children: [
TableRow(
children: [
_buildInfoRow('Product Name:', device.categoryName ?? 'N/A'),
_buildInfoRow('Product Name:', device.productName ?? 'N/A'),
_buildInfoRow('Device ID:', device.uuid ?? ''),
],
),
TableRow(children: [
_buildInfoRow('Virtual Address:',
'Area - Street 1 - Building 1 - First Floor'),
_buildInfoRow('Virtual Address:', device.ip ?? '-'),
const SizedBox.shrink(),
]),
TableRow(
@ -104,14 +103,38 @@ class DeviceControlDialog extends StatelessWidget with RouteControlsBasedCode {
),
TableRow(
children: [
_buildInfoRow('Installation Date and Time:', '09/08/2024 13:30'),
const SizedBox.shrink(),
_buildInfoRow(
'Installation Date and Time:',
formatDateTime(
DateTime.fromMillisecondsSinceEpoch(
((device.createTime ?? 0) * 1000),
),
),
),
_buildInfoRow(
'Battery Level:',
device.batteryLevel != null
? '${device.batteryLevel ?? 0}%'
: "-",
statusColor: device.batteryLevel != null
? (device.batteryLevel! < 20
? ColorsManager.red
: ColorsManager.green)
: null,
),
],
),
TableRow(
children: [
_buildInfoRow('Status:', 'Online', statusColor: Colors.green),
_buildInfoRow('Last Offline Date and Time:', '-'),
_buildInfoRow(
'Last Offline Date and Time:',
formatDateTime(
DateTime.fromMillisecondsSinceEpoch(
((device.updateTime ?? 0) * 1000),
),
),
),
],
),
],

View File

@ -4,20 +4,25 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/device_rep
import 'package:syncrow_web/pages/device_managment/shared/table/table_cell_widget.dart';
import 'package:syncrow_web/pages/device_managment/shared/table/table_header.dart';
// ignore: must_be_immutable
class ReportsTable extends StatelessWidget {
final DeviceReport report;
final String? thirdColumnTitle;
final String? thirdColumnDescription;
final Function(int index) onRowTap;
final VoidCallback onClose;
bool? hideValueShowDescription;
bool? mainDoorSensor;
const ReportsTable({
ReportsTable({
super.key,
required this.report,
required this.onRowTap,
required this.onClose,
this.thirdColumnTitle,
this.thirdColumnDescription,
this.hideValueShowDescription,
this.mainDoorSensor,
});
@override
@ -57,10 +62,21 @@ class ReportsTable extends StatelessWidget {
children: [
TableCellWidget(value: date),
TableCellWidget(value: time),
TableCellWidget(
value: '${data.value!} ${thirdColumnDescription ?? ''}',
onTap: () => onRowTap(index),
),
hideValueShowDescription == true
? TableCellWidget(
value: (mainDoorSensor != null &&
mainDoorSensor == true)
? data.value == 'true'
? 'Open'
: 'Close'
: thirdColumnDescription ?? '',
onTap: () => onRowTap(index),
)
: TableCellWidget(
value:
'${data.value!} ${thirdColumnDescription ?? ''}',
onTap: () => onRowTap(index),
),
],
);
}),

View File

@ -0,0 +1,92 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_svg/flutter_svg.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';
class ToggleWidget extends StatelessWidget {
final bool value;
final String code;
final String deviceId;
final String label;
final String? icon;
final Widget? labelWidget;
final Function(dynamic value) onChange;
final bool showToggle;
const ToggleWidget({
super.key,
required this.value,
required this.code,
required this.deviceId,
required this.label,
required this.onChange,
this.icon,
this.labelWidget,
this.showToggle = true,
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: ColorsManager.greyColor.withOpacity(0.2),
border: Border.all(color: ColorsManager.boxDivider),
),
padding: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(right: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
icon == '-1'
? const SizedBox(
height: 60,
width: 60,
)
: ClipOval(
child: Container(
height: 60,
width: 60,
padding: const EdgeInsets.all(8),
color: ColorsManager.whiteColors,
child: SvgPicture.asset(
icon ?? Assets.lightPulp,
width: 35,
height: 35,
fit: BoxFit.contain,
),
)),
if (showToggle)
Container(
height: 20,
width: 35,
padding: const EdgeInsets.only(right: 16, top: 10),
child: CupertinoSwitch(
value: value,
activeColor: ColorsManager.dialogBlueTitle,
onChanged: onChange,
),
),
],
),
),
labelWidget ??
Text(
label,
style: context.textTheme.titleMedium!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
),
),
],
),
);
}
}

View File

@ -0,0 +1,174 @@
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/models/three_gang_glass_switch.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
part 'three_gang_glass_switch_event.dart';
part 'three_gang_glass_switch_state.dart';
class ThreeGangGlassSwitchBloc extends Bloc<ThreeGangGlassSwitchEvent, ThreeGangGlassSwitchState> {
ThreeGangGlassStatusModel deviceStatus;
Timer? _timer;
ThreeGangGlassSwitchBloc({required String deviceId})
: deviceStatus = ThreeGangGlassStatusModel(
uuid: deviceId,
switch1: false,
countDown1: 0,
switch2: false,
countDown2: 0,
switch3: false,
countDown3: 0),
super(ThreeGangGlassSwitchInitial()) {
on<ThreeGangGlassSwitchFetchDeviceEvent>(_onFetchDeviceStatus);
on<ThreeGangGlassSwitchControl>(_onControl);
on<ThreeGangGlassSwitchBatchControl>(_onBatchControl);
on<ThreeGangGlassSwitchFetchBatchStatusEvent>(_onFetchBatchStatus);
on<ThreeGangGlassFactoryReset>(_onFactoryReset);
}
Future<void> _onFetchDeviceStatus(
ThreeGangGlassSwitchFetchDeviceEvent event, Emitter<ThreeGangGlassSwitchState> emit) async {
emit(ThreeGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = ThreeGangGlassStatusModel.fromJson(event.deviceId, status.status);
emit(ThreeGangGlassSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(ThreeGangGlassSwitchError(e.toString()));
}
}
Future<void> _onControl(ThreeGangGlassSwitchControl event, Emitter<ThreeGangGlassSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(ThreeGangGlassSwitchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceId,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: false,
);
}
Future<void> _onBatchControl(ThreeGangGlassSwitchBatchControl event, Emitter<ThreeGangGlassSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(ThreeGangGlassSwitchBatchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: true,
);
}
Future<void> _onFetchBatchStatus(
ThreeGangGlassSwitchFetchBatchStatusEvent event, Emitter<ThreeGangGlassSwitchState> emit) async {
emit(ThreeGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getBatchStatus(event.deviceIds);
deviceStatus = ThreeGangGlassStatusModel.fromJson(event.deviceIds.first, status.status);
emit(ThreeGangGlassSwitchBatchStatusLoaded(deviceStatus));
} catch (e) {
emit(ThreeGangGlassSwitchError(e.toString()));
}
}
Future<void> _onFactoryReset(ThreeGangGlassFactoryReset event, Emitter<ThreeGangGlassSwitchState> emit) async {
emit(ThreeGangGlassSwitchLoading());
try {
final response = await DevicesManagementApi().factoryReset(event.factoryReset, event.deviceId);
if (!response) {
emit(ThreeGangGlassSwitchError('Failed'));
} else {
emit(ThreeGangGlassSwitchStatusLoaded(deviceStatus));
}
} catch (e) {
emit(ThreeGangGlassSwitchError(e.toString()));
}
}
Future<void> _runDebounce({
required dynamic deviceId,
required String code,
required bool value,
required bool oldValue,
required Emitter<ThreeGangGlassSwitchState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(milliseconds: 500), () async {
try {
late bool response;
if (isBatch) {
response = await DevicesManagementApi().deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi().deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
_revertValueAndEmit(id, code, oldValue, emit);
}
} catch (e) {
_revertValueAndEmit(id, code, oldValue, emit);
}
});
}
void _revertValueAndEmit(String deviceId, String code, bool oldValue, Emitter<ThreeGangGlassSwitchState> emit) {
_updateLocalValue(code, oldValue);
emit(ThreeGangGlassSwitchStatusLoaded(deviceStatus));
}
void _updateLocalValue(String code, bool value) {
if (code == 'switch_1') {
deviceStatus = deviceStatus.copyWith(switch1: value);
} else if (code == 'switch_2') {
deviceStatus = deviceStatus.copyWith(switch2: value);
} else if (code == 'switch_3') {
deviceStatus = deviceStatus.copyWith(switch3: value);
}
}
bool _getValueByCode(String code) {
switch (code) {
case 'switch_1':
return deviceStatus.switch1;
case 'switch_2':
return deviceStatus.switch2;
case 'switch_3':
return deviceStatus.switch3;
default:
return false;
}
}
@override
Future<void> close() {
_timer?.cancel();
return super.close();
}
}

View File

@ -0,0 +1,50 @@
part of 'three_gang_glass_switch_bloc.dart';
@immutable
abstract class ThreeGangGlassSwitchEvent {}
class ThreeGangGlassSwitchFetchDeviceEvent extends ThreeGangGlassSwitchEvent {
final String deviceId;
ThreeGangGlassSwitchFetchDeviceEvent(this.deviceId);
}
class ThreeGangGlassSwitchControl extends ThreeGangGlassSwitchEvent {
final String deviceId;
final String code;
final bool value;
ThreeGangGlassSwitchControl({
required this.deviceId,
required this.code,
required this.value,
});
}
class ThreeGangGlassSwitchBatchControl extends ThreeGangGlassSwitchEvent {
final List<String> deviceIds;
final String code;
final bool value;
ThreeGangGlassSwitchBatchControl({
required this.deviceIds,
required this.code,
required this.value,
});
}
class ThreeGangGlassSwitchFetchBatchStatusEvent extends ThreeGangGlassSwitchEvent {
final List<String> deviceIds;
ThreeGangGlassSwitchFetchBatchStatusEvent(this.deviceIds);
}
class ThreeGangGlassFactoryReset extends ThreeGangGlassSwitchEvent {
final String deviceId;
final FactoryResetModel factoryReset;
ThreeGangGlassFactoryReset({
required this.deviceId,
required this.factoryReset,
});
}

View File

@ -0,0 +1,32 @@
part of 'three_gang_glass_switch_bloc.dart';
@immutable
abstract class ThreeGangGlassSwitchState {}
class ThreeGangGlassSwitchInitial extends ThreeGangGlassSwitchState {}
class ThreeGangGlassSwitchLoading extends ThreeGangGlassSwitchState {}
class ThreeGangGlassSwitchStatusLoaded extends ThreeGangGlassSwitchState {
final ThreeGangGlassStatusModel status;
ThreeGangGlassSwitchStatusLoaded(this.status);
}
class ThreeGangGlassSwitchError extends ThreeGangGlassSwitchState {
final String message;
ThreeGangGlassSwitchError(this.message);
}
class ThreeGangGlassSwitchBatchStatusLoaded extends ThreeGangGlassSwitchState {
final ThreeGangGlassStatusModel status;
ThreeGangGlassSwitchBatchStatusLoaded(this.status);
}
class ThreeGangGlassSwitchBatchControlError extends ThreeGangGlassSwitchState {
final String message;
ThreeGangGlassSwitchBatchControlError(this.message);
}

View File

@ -0,0 +1,87 @@
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
class ThreeGangGlassStatusModel {
final String uuid;
final bool switch1;
final int countDown1;
final bool switch2;
final int countDown2;
final bool switch3;
final int countDown3;
ThreeGangGlassStatusModel({
required this.uuid,
required this.switch1,
required this.countDown1,
required this.switch2,
required this.countDown2,
required this.switch3,
required this.countDown3,
});
factory ThreeGangGlassStatusModel.fromJson(String id, List<Status> jsonList) {
late bool switch1;
late int countDown1;
late bool switch2;
late int countDown2;
late bool switch3;
late int countDown3;
for (var status in jsonList) {
switch (status.code) {
case 'switch_1':
switch1 = status.value ?? false;
break;
case 'countdown_1':
countDown1 = status.value ?? 0;
break;
case 'switch_2':
switch2 = status.value ?? false;
break;
case 'countdown_2':
countDown2 = status.value ?? 0;
break;
case 'switch_3':
switch3 = status.value ?? false;
break;
case 'countdown_3':
countDown3 = status.value ?? 0;
break;
}
}
return ThreeGangGlassStatusModel(
uuid: id,
switch1: switch1,
countDown1: countDown1,
switch2: switch2,
countDown2: countDown2,
switch3: switch3,
countDown3: countDown3,
);
}
ThreeGangGlassStatusModel copyWith({
String? uuid,
bool? switch1,
int? countDown1,
bool? switch2,
int? countDown2,
bool? switch3,
int? countDown3,
}) {
return ThreeGangGlassStatusModel(
uuid: uuid ?? this.uuid,
switch1: switch1 ?? this.switch1,
countDown1: countDown1 ?? this.countDown1,
switch2: switch2 ?? this.switch2,
countDown2: countDown2 ?? this.countDown2,
switch3: switch3 ?? this.switch3,
countDown3: countDown3 ?? this.countDown3,
);
}
@override
String toString() =>
'ThreeGangGlassStatusModel(uuid: $uuid, switch1: $switch1, countDown1: $countDown1, switch2: $switch2, countDown2: $countDown2, switch3: $switch3, countDown3: $countDown3)';
}

View File

@ -0,0 +1,118 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/bloc/three_gang_glass_switch_bloc.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/models/three_gang_glass_switch.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class ThreeGangGlassSwitchBatchControlView extends StatelessWidget with HelperResponsiveLayout {
final List<String> deviceIds;
const ThreeGangGlassSwitchBatchControlView({required this.deviceIds, super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => ThreeGangGlassSwitchBloc(deviceId: deviceIds.first)
..add(ThreeGangGlassSwitchFetchBatchStatusEvent(deviceIds)),
child: BlocBuilder<ThreeGangGlassSwitchBloc, ThreeGangGlassSwitchState>(
builder: (context, state) {
if (state is ThreeGangGlassSwitchLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is ThreeGangGlassSwitchBatchStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is ThreeGangGlassSwitchError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(BuildContext context, ThreeGangGlassStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceIds.first,
label: 'Glass Switch 1',
onChange: (value) {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassSwitchBatchControl(
deviceIds: deviceIds,
code: 'switch_1',
value: value,
),
);
},
),
ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceIds.first,
label: 'Glass Switch 2',
onChange: (value) {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassSwitchBatchControl(
deviceIds: deviceIds,
code: 'switch_2',
value: value,
),
);
},
),
ToggleWidget(
value: status.switch3,
code: 'switch_3',
deviceId: deviceIds.first,
label: 'Glass Switch 3',
onChange: (value) {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassSwitchBatchControl(
deviceIds: deviceIds,
code: 'switch_3',
value: value,
),
);
},
),
FirmwareUpdateWidget(
deviceId: deviceIds.first,
version: 12, // adjust the version according to your requirement
),
FactoryResetWidget(
callFactoryReset: () {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassFactoryReset(
deviceId: status.uuid,
factoryReset: FactoryResetModel(devicesUuid: deviceIds),
),
);
},
),
],
);
}
}

View File

@ -0,0 +1,121 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/pages/device_managment/three_g_glass_switch/bloc/three_gang_glass_switch_bloc.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
import '../models/three_gang_glass_switch.dart';
class ThreeGangGlassSwitchControlView extends StatelessWidget with HelperResponsiveLayout {
final String deviceId;
const ThreeGangGlassSwitchControlView({required this.deviceId, super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) =>
ThreeGangGlassSwitchBloc(deviceId: deviceId)..add(ThreeGangGlassSwitchFetchDeviceEvent(deviceId)),
child: BlocBuilder<ThreeGangGlassSwitchBloc, ThreeGangGlassSwitchState>(
builder: (context, state) {
if (state is ThreeGangGlassSwitchLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is ThreeGangGlassSwitchStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is ThreeGangGlassSwitchError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(BuildContext context, ThreeGangGlassStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Light',
onChange: (value) {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassSwitchControl(
deviceId: deviceId,
code: 'switch_1',
value: value,
),
);
},
),
ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceId,
label: 'Ceiling Light',
onChange: (value) {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassSwitchControl(
deviceId: deviceId,
code: 'switch_2',
value: value,
),
);
},
),
ToggleWidget(
value: status.switch3,
code: 'switch_3',
deviceId: deviceId,
label: 'SpotLight',
onChange: (value) {
context.read<ThreeGangGlassSwitchBloc>().add(
ThreeGangGlassSwitchControl(
deviceId: deviceId,
code: 'switch_3',
value: value,
),
);
},
),
ToggleWidget(
value: false,
code: '',
deviceId: deviceId,
label: 'Preferences',
icon: Assets.preferences,
onChange: (value) {},
showToggle: false,
),
ToggleWidget(
value: false,
code: '',
deviceId: deviceId,
label: 'Scheduling',
icon: Assets.scheduling,
onChange: (value) {},
showToggle: false,
),
],
);
}
}

View File

@ -4,6 +4,7 @@ import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/models/living_room_model.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
@ -16,23 +17,29 @@ class LivingRoomBloc extends Bloc<LivingRoomEvent, LivingRoomState> {
Timer? _timer;
LivingRoomBloc({required this.deviceId}) : super(LivingRoomInitial()) {
on<LivingRoomFetchDeviceStatus>(_onFetchDeviceStatus);
on<LivingRoomFetchDeviceStatusEvent>(_onFetchDeviceStatus);
on<LivingRoomControl>(_livingRoomControl);
on<LivingRoomBatchControl>(_livingRoomBatchControl);
on<LivingRoomFetchBatchEvent>(_livingRoomFetchBatchControl);
on<LivingRoomFactoryResetEvent>(_livingRoomFactoryReset);
}
FutureOr<void> _onFetchDeviceStatus(
LivingRoomFetchDeviceStatus event, Emitter<LivingRoomState> emit) async {
FutureOr<void> _onFetchDeviceStatus(LivingRoomFetchDeviceStatusEvent event,
Emitter<LivingRoomState> emit) async {
emit(LivingRoomDeviceStatusLoading());
try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = LivingRoomStatusModel.fromJson(event.deviceId, status.status);
final status =
await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus =
LivingRoomStatusModel.fromJson(event.deviceId, status.status);
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
} catch (e) {
emit(LivingRoomDeviceManagementError(e.toString()));
}
}
FutureOr<void> _livingRoomControl(LivingRoomControl event, Emitter<LivingRoomState> emit) async {
FutureOr<void> _livingRoomControl(
LivingRoomControl event, Emitter<LivingRoomState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
@ -45,37 +52,52 @@ class LivingRoomBloc extends Bloc<LivingRoomEvent, LivingRoomState> {
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: false,
);
}
Future<void> _runDebounce({
required String deviceId,
required dynamic deviceId,
required String code,
required dynamic value,
required dynamic oldValue,
required Emitter<LivingRoomState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(seconds: 1), () async {
try {
final response =
await DevicesManagementApi().deviceControl(deviceId, Status(code: code, value: value));
late bool response;
if (isBatch) {
response = await DevicesManagementApi()
.deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi()
.deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
_revertValueAndEmit(deviceId, code, oldValue, emit);
_revertValueAndEmit(id, code, oldValue, emit);
}
} catch (e) {
_revertValueAndEmit(deviceId, code, oldValue, emit);
_revertValueAndEmit(id, code, oldValue, emit);
}
});
}
void _revertValueAndEmit(
String deviceId, String code, dynamic oldValue, Emitter<LivingRoomState> emit) {
void _revertValueAndEmit(String deviceId, String code, dynamic oldValue,
Emitter<LivingRoomState> emit) {
_updateLocalValue(code, oldValue);
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
emit(const LivingRoomControlError('Failed to control the device.'));
}
void _updateLocalValue(String code, dynamic value) {
@ -113,4 +135,54 @@ class LivingRoomBloc extends Bloc<LivingRoomEvent, LivingRoomState> {
return null;
}
}
FutureOr<void> _livingRoomFetchBatchControl(
LivingRoomFetchBatchEvent event, Emitter<LivingRoomState> emit) async {
emit(LivingRoomDeviceStatusLoading());
try {
final status =
await DevicesManagementApi().getBatchStatus(event.devicesIds);
deviceStatus =
LivingRoomStatusModel.fromJson(event.devicesIds.first, status.status);
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
} catch (e) {
emit(LivingRoomDeviceManagementError(e.toString()));
}
}
FutureOr<void> _livingRoomBatchControl(
LivingRoomBatchControl event, Emitter<LivingRoomState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.devicesIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: true,
);
}
FutureOr<void> _livingRoomFactoryReset(
LivingRoomFactoryResetEvent event, Emitter<LivingRoomState> emit) async {
emit(LivingRoomDeviceStatusLoading());
try {
final response = await DevicesManagementApi().factoryReset(
event.factoryReset,
event.uuid,
);
if (!response) {
emit(const LivingRoomDeviceManagementError('Failed'));
} else {
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
}
} catch (e) {
emit(LivingRoomDeviceManagementError(e.toString()));
}
}
}

View File

@ -7,15 +7,25 @@ sealed class LivingRoomEvent extends Equatable {
List<Object> get props => [];
}
class LivingRoomFetchDeviceStatus extends LivingRoomEvent {
class LivingRoomFetchDeviceStatusEvent extends LivingRoomEvent {
final String deviceId;
const LivingRoomFetchDeviceStatus(this.deviceId);
const LivingRoomFetchDeviceStatusEvent(this.deviceId);
@override
List<Object> get props => [deviceId];
}
//LivingRoomFetchBatchStatus
class LivingRoomFetchBatchEvent extends LivingRoomEvent {
final List<String> devicesIds;
const LivingRoomFetchBatchEvent(this.devicesIds);
@override
List<Object> get props => [devicesIds];
}
class LivingRoomControl extends LivingRoomEvent {
final String deviceId;
final String code;
@ -27,3 +37,24 @@ class LivingRoomControl extends LivingRoomEvent {
@override
List<Object> get props => [deviceId, code, value];
}
class LivingRoomBatchControl extends LivingRoomEvent {
final List<String> devicesIds;
final String code;
final bool value;
const LivingRoomBatchControl(
{required this.devicesIds, required this.code, required this.value});
@override
List<Object> get props => [devicesIds, code, value];
}
class LivingRoomFactoryResetEvent extends LivingRoomEvent {
final String uuid;
final FactoryResetModel factoryReset;
const LivingRoomFactoryResetEvent(this.uuid, this.factoryReset);
@override
List<Object> get props => [uuid, factoryReset];
}

View File

@ -0,0 +1,121 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/models/living_room_model.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class LivingRoomBatchControlsView extends StatelessWidget
with HelperResponsiveLayout {
const LivingRoomBatchControlsView({super.key, required this.deviceIds});
final List<String> deviceIds;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => LivingRoomBloc(deviceId: deviceIds.first)
..add(LivingRoomFetchBatchEvent(deviceIds)),
child: BlocBuilder<LivingRoomBloc, LivingRoomState>(
builder: (context, state) {
if (state is LivingRoomDeviceStatusLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is LivingRoomDeviceStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is LivingRoomDeviceManagementError ||
state is LivingRoomControlError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
}
},
),
);
}
Widget _buildStatusControls(
BuildContext context, LivingRoomStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return SizedBox(
child: GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceIds.first,
label: 'Wall Light',
onChange: (value) {
context.read<LivingRoomBloc>().add(
LivingRoomBatchControl(
devicesIds: deviceIds,
code: 'switch_1',
value: value,
),
);
},
),
ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceIds.first,
label: 'Ceiling Light',
onChange: (value) {
context.read<LivingRoomBloc>().add(
LivingRoomBatchControl(
devicesIds: deviceIds,
code: 'switch_2',
value: value,
),
);
},
),
ToggleWidget(
value: status.switch3,
code: 'switch_2',
deviceId: deviceIds.first,
label: 'Spotlight',
onChange: (value) {
context.read<LivingRoomBloc>().add(
LivingRoomBatchControl(
devicesIds: deviceIds,
code: 'switch_3',
value: value,
),
);
},
),
FirmwareUpdateWidget(
deviceId: deviceIds.first,
version: 12,
),
FactoryResetWidget(callFactoryReset: () {
context.read<LivingRoomBloc>().add(
LivingRoomFactoryResetEvent(
status.uuid,
FactoryResetModel(devicesUuid: deviceIds),
),
);
}),
],
),
);
}
}

View File

@ -2,26 +2,28 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/models/living_room_model.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/widgets/living_toggle_widget.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class LivingRoomDeviceControl extends StatelessWidget with HelperResponsiveLayout {
class LivingRoomDeviceControlsView extends StatelessWidget
with HelperResponsiveLayout {
final String deviceId;
const LivingRoomDeviceControl({super.key, required this.deviceId});
const LivingRoomDeviceControlsView({super.key, required this.deviceId});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) =>
LivingRoomBloc(deviceId: deviceId)..add(LivingRoomFetchDeviceStatus(deviceId)),
create: (context) => LivingRoomBloc(deviceId: deviceId)
..add(LivingRoomFetchDeviceStatusEvent(deviceId)),
child: BlocBuilder<LivingRoomBloc, LivingRoomState>(
builder: (context, state) {
if (state is LivingRoomDeviceStatusLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state is LivingRoomDeviceStatusLoaded) {
return _buildStatusControls(context, state.status);
} else if (state is LivingRoomDeviceManagementError || state is LivingRoomControlError) {
} else if (state is LivingRoomDeviceManagementError ||
state is LivingRoomControlError) {
return const Center(child: Text('Error fetching status'));
} else {
return const Center(child: CircularProgressIndicator());
@ -31,46 +33,63 @@ class LivingRoomDeviceControl extends StatelessWidget with HelperResponsiveLayou
);
}
Widget _buildStatusControls(BuildContext context, LivingRoomStatusModel status) {
Widget _buildStatusControls(
BuildContext context, LivingRoomStatusModel status) {
final isExtraLarge = isExtraLargeScreenSize(context);
final isLarge = isLargeScreenSize(context);
final isMedium = isMediumScreenSize(context);
return Container(
child: GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Light',
),
ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceId,
label: 'Ceiling Light',
),
ToggleWidget(
value: status.switch3,
code: 'switch_3',
deviceId: deviceId,
label: 'Spotlight',
),
],
return GridView(
padding: const EdgeInsets.symmetric(horizontal: 50),
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: isLarge || isExtraLarge
? 3
: isMedium
? 2
: 1,
mainAxisExtent: 140,
crossAxisSpacing: 12,
mainAxisSpacing: 12,
),
children: [
ToggleWidget(
value: status.switch1,
code: 'switch_1',
deviceId: deviceId,
label: 'Wall Light',
onChange: (value) {
context.read<LivingRoomBloc>().add(
LivingRoomControl(
deviceId: deviceId, code: 'switch_1', value: value),
);
},
),
ToggleWidget(
value: status.switch2,
code: 'switch_2',
deviceId: deviceId,
label: 'Ceiling Light',
onChange: (value) {
context.read<LivingRoomBloc>().add(
LivingRoomControl(
deviceId: deviceId, code: 'switch_2', value: value),
);
},
),
ToggleWidget(
value: status.switch3,
code: 'switch_3',
deviceId: deviceId,
label: 'Spotlight',
onChange: (value) {
context.read<LivingRoomBloc>().add(
LivingRoomControl(
deviceId: deviceId, code: 'switch_3', value: value),
);
},
),
],
);
}
}

View File

@ -1,80 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class ToggleWidget extends StatelessWidget {
final bool value;
final String code;
final String deviceId;
final String label;
const ToggleWidget({
super.key,
required this.value,
required this.code,
required this.deviceId,
required this.label,
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: ColorsManager.greyColor.withOpacity(0.2),
border: Border.all(color: ColorsManager.boxDivider),
),
padding: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ClipOval(
child: Container(
color: ColorsManager.whiteColors,
child: SvgPicture.asset(
Assets.lightPulp,
width: 60,
height: 60,
fit: BoxFit.cover,
),
)),
SizedBox(
height: 20,
width: 35,
child: CupertinoSwitch(
value: value,
activeColor: ColorsManager.dialogBlueTitle,
onChanged: (newValue) {
context.read<LivingRoomBloc>().add(
LivingRoomControl(
deviceId: deviceId,
code: code,
value: newValue,
),
);
},
),
),
],
),
const Spacer(),
Text(
label,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
],
),
);
}
}

View File

@ -0,0 +1,164 @@
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/two_g_glass_switch/models/two_gang_glass_status_model.dart';
import 'package:syncrow_web/services/devices_mang_api.dart';
part 'two_gang_glass_switch_event.dart';
part 'two_gang_glass_switch_state.dart';
class TwoGangGlassSwitchBloc extends Bloc<TwoGangGlassSwitchEvent, TwoGangGlassSwitchState> {
TwoGangGlassStatusModel deviceStatus;
Timer? _timer;
TwoGangGlassSwitchBloc({required String deviceId})
: deviceStatus =
TwoGangGlassStatusModel(uuid: deviceId, switch1: false, countDown1: 0, switch2: false, countDown2: 0),
super(TwoGangGlassSwitchInitial()) {
on<TwoGangGlassSwitchFetchDeviceEvent>(_onFetchDeviceStatus);
on<TwoGangGlassSwitchControl>(_onControl);
on<TwoGangGlassSwitchBatchControl>(_onBatchControl);
on<TwoGangGlassSwitchFetchBatchStatusEvent>(_onFetchBatchStatus);
on<TwoGangGlassFactoryReset>(_onFactoryReset);
}
Future<void> _onFetchDeviceStatus(
TwoGangGlassSwitchFetchDeviceEvent event, Emitter<TwoGangGlassSwitchState> emit) async {
emit(TwoGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
deviceStatus = TwoGangGlassStatusModel.fromJson(event.deviceId, status.status);
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
}
}
Future<void> _onControl(TwoGangGlassSwitchControl event, Emitter<TwoGangGlassSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceId,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: false,
);
}
Future<void> _onBatchControl(TwoGangGlassSwitchBatchControl event, Emitter<TwoGangGlassSwitchState> emit) async {
final oldValue = _getValueByCode(event.code);
_updateLocalValue(event.code, event.value);
emit(TwoGangGlassSwitchBatchStatusLoaded(deviceStatus));
await _runDebounce(
deviceId: event.deviceIds,
code: event.code,
value: event.value,
oldValue: oldValue,
emit: emit,
isBatch: true,
);
}
Future<void> _onFetchBatchStatus(
TwoGangGlassSwitchFetchBatchStatusEvent event, Emitter<TwoGangGlassSwitchState> emit) async {
emit(TwoGangGlassSwitchLoading());
try {
final status = await DevicesManagementApi().getBatchStatus(event.deviceIds);
deviceStatus = TwoGangGlassStatusModel.fromJson(event.deviceIds.first, status.status);
emit(TwoGangGlassSwitchBatchStatusLoaded(deviceStatus));
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
}
}
Future<void> _onFactoryReset(TwoGangGlassFactoryReset event, Emitter<TwoGangGlassSwitchState> emit) async {
emit(TwoGangGlassSwitchLoading());
try {
final response = await DevicesManagementApi().factoryReset(event.factoryReset, event.deviceId);
if (!response) {
emit(TwoGangGlassSwitchError('Failed'));
} else {
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
}
} catch (e) {
emit(TwoGangGlassSwitchError(e.toString()));
}
}
Future<void> _runDebounce({
required dynamic deviceId,
required String code,
required bool value,
required bool oldValue,
required Emitter<TwoGangGlassSwitchState> emit,
required bool isBatch,
}) async {
late String id;
if (deviceId is List) {
id = deviceId.first;
} else {
id = deviceId;
}
if (_timer != null) {
_timer!.cancel();
}
_timer = Timer(const Duration(milliseconds: 500), () async {
try {
late bool response;
if (isBatch) {
response = await DevicesManagementApi().deviceBatchControl(deviceId, code, value);
} else {
response = await DevicesManagementApi().deviceControl(deviceId, Status(code: code, value: value));
}
if (!response) {
_revertValueAndEmit(id, code, oldValue, emit);
}
} catch (e) {
_revertValueAndEmit(id, code, oldValue, emit);
}
});
}
void _revertValueAndEmit(String deviceId, String code, bool oldValue, Emitter<TwoGangGlassSwitchState> emit) {
_updateLocalValue(code, oldValue);
emit(TwoGangGlassSwitchStatusLoaded(deviceStatus));
}
void _updateLocalValue(String code, bool value) {
if (code == 'switch_1') {
deviceStatus = deviceStatus.copyWith(switch1: value);
} else if (code == 'switch_2') {
deviceStatus = deviceStatus.copyWith(switch2: value);
}
}
bool _getValueByCode(String code) {
switch (code) {
case 'switch_1':
return deviceStatus.switch1;
case 'switch_2':
return deviceStatus.switch2;
default:
return false;
}
}
@override
Future<void> close() {
_timer?.cancel();
return super.close();
}
}

Some files were not shown because too many files have changed in this diff Show More