Commit 9d27e20
authored
feat: iLife798接水功能 (#125)
* feat: add dorm water card and empty dorm water page
- add `DormWaterCard` to homepage small-function grid
- add `DormWaterWindow` as placeholder page
- add i18n key for dorm water card title
* feat(dorm-water): add login form UI skeleton
* feat(dorm-water): add captcha image loading and refresh
* feat(dorm-water): SMS sending
* feat(dorm-water): complete login flow with token persistence
* feat(dorm-water): login flow and device list UI
* feat(dorm_water): water dispensing control and state sync
Add complete water dispensing control flow with robust state synchronization:
Features:
- Start/end water dispensing via API with user feedback
- Real-time device status polling (1-second interval, max 60 seconds)
- Consecutive status detection (requires 3x status==99) to prevent
network fluctuations from causing false "device ready" signals
- Direct play/stop icon toggle on device card for better UX
- Automatic state cleanup and counter reset on water operations
UI/UX Improvements:
- Remove modal dialog approach, now using inline card button control
- Play icon → Stop icon during water dispensing
- Real-time status feedback via toast notifications
- Support for 3 languages with 9 new i18n strings
Robustness:
- Handles network interruptions gracefully (retries polling)
- Mounted widget checks to prevent setState after unmount
- Timeout protection (60 seconds max polling duration)
- Proper state synchronization between UI and backend device status
* fix(dorm_water): correct button text when device list loading fails
* refactor(dorm-water): use teacup icon
* refactor(dorm-water): generate numeric-only session ID for captcha
* refactor(dorm_water): add platform-specific user agents for API requests
Implement platform detection and custom User-Agent headers for all dorm water
API requests to comply with backend requirements.
Changes:
- Add platform detection via dart:io Platform
- Implement _getUserAgent() method with platform-specific UA strings:
- iOS captcha: iLife798/3.1.1 (iPhone; iOS 26.2; Scale/3.00)
- iOS others: iOS_ilife798_3.1.1
- Android all: Android_ilife798_2.0.11
- Other platforms: default to iOS UA
- Add User-Agent header to all 6 API requests:
- getCaptcha() - uses special captcha UA
- sendSmsCode(), login(), getDeviceList()
- startWater(), endWater(), checkDeviceStatus()
* refactor(dorm-water): complete captcha request headers
* refactor(dorm-water): complete login request headers
* refactor(dorm-water): complete getDeviceList request headers
* refactor(dorm-water): perfect startWater request query
* refactor(dorm-water): complete startWater request headers
* refactor(dorm-water): complete sendSmsCode request headers
* refactor(dorm-water): complete endWater request headers
* feat: add toggleDeviceFavorite method for device favorites management
* feat(dorm-water): implement QR code scanning and device favorites management
- Integrate mobile_scanner for native QR code scanning
- Implement toggleDeviceFavorite() API method in DormWaterSession
- Create _QrCodeScannerPage with camera and torch toggle
- Extract device ID from QR code URL format (https://i.hnkzy.com/q/1/{did})
- Add scan QR code button in AppBar (qrcode_line icon left of logout)
- Auto-add scanned devices to favorites and refresh device list
- Add i18n strings: scan_qr_code, device_id, add_device_failed
- Support zh_CN, en_US, zh_TW languages
- Lower mobile_scanner version to resolve MLKit pod conflicts
* feat(dorm-water): add unfavorite functionality to star icon
* fix(dorm-water): prevent page navigation when removing device from favorites
- Change _loadDevices() call to setState with removeWhere
- Only remove the unfavorited device from list instead of full refresh
- Keep user on the dorm water page after unfavoriting
- Improve UX by avoiding unnecessary navigation
* refactor(dorm-water): replace mobile_scanner with qr_code_dart_scan
* refactor(dorm-water): regenerate platform lock/registrant files
* refactor(dorm-water): fix lifecycle usage and add QR domain validation
- Move `_loadCaptcha` from `initState` to `didChangeDependencies` to follow lifecycle best practices.
- Add domain validation for `hnkzy.com` in QR code scanner to prevent processing invalid links.1 parent a5f64f9 commit 9d27e20
12 files changed
Lines changed: 1607 additions & 64 deletions
File tree
- assets/flutter_i18n
- ios
- lib
- page
- dorm_water
- homepage
- toolbox
- repository
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
420 | 421 | | |
421 | 422 | | |
422 | 423 | | |
| |||
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
435 | 477 | | |
436 | 478 | | |
437 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| 411 | + | |
411 | 412 | | |
412 | 413 | | |
413 | 414 | | |
| |||
423 | 424 | | |
424 | 425 | | |
425 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
426 | 469 | | |
427 | 470 | | |
428 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
| |||
394 | 395 | | |
395 | 396 | | |
396 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
397 | 440 | | |
398 | 441 | | |
399 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
6 | 44 | | |
7 | 45 | | |
8 | 46 | | |
9 | 47 | | |
10 | 48 | | |
| 49 | + | |
| 50 | + | |
11 | 51 | | |
12 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
13 | 57 | | |
14 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
15 | 73 | | |
16 | 74 | | |
17 | 75 | | |
| |||
34 | 92 | | |
35 | 93 | | |
36 | 94 | | |
| 95 | + | |
| 96 | + | |
37 | 97 | | |
38 | 98 | | |
| 99 | + | |
39 | 100 | | |
40 | 101 | | |
| 102 | + | |
| 103 | + | |
41 | 104 | | |
42 | 105 | | |
43 | 106 | | |
| 107 | + | |
44 | 108 | | |
| 109 | + | |
| 110 | + | |
45 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
46 | 116 | | |
| 117 | + | |
47 | 118 | | |
48 | 119 | | |
49 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
50 | 125 | | |
51 | 126 | | |
52 | 127 | | |
53 | 128 | | |
| 129 | + | |
| 130 | + | |
54 | 131 | | |
55 | 132 | | |
56 | 133 | | |
57 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
58 | 139 | | |
59 | 140 | | |
60 | 141 | | |
61 | 142 | | |
62 | 143 | | |
63 | 144 | | |
| 145 | + | |
| 146 | + | |
64 | 147 | | |
65 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
66 | 153 | | |
67 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
68 | 163 | | |
69 | 164 | | |
| 165 | + | |
| 166 | + | |
70 | 167 | | |
71 | 168 | | |
| 169 | + | |
72 | 170 | | |
73 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
74 | 176 | | |
75 | 177 | | |
76 | 178 | | |
| 179 | + | |
77 | 180 | | |
| 181 | + | |
| 182 | + | |
78 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
79 | 190 | | |
80 | 191 | | |
81 | 192 | | |
| 193 | + | |
82 | 194 | | |
83 | 195 | | |
84 | 196 | | |
| |||
0 commit comments