mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-11 15:47:44 +00:00
Compare commits
79 Commits
SP-1279
...
fix-timer-
Author | SHA1 | Date | |
---|---|---|---|
db84a9aa5e | |||
140f4ff5e2 | |||
cbaeecc968 | |||
2a95720cb0 | |||
4fae2d6be0 | |||
5b84076572 | |||
9bf37243a6 | |||
acad0e8c9c | |||
79f5ef7871 | |||
6493f02bcc | |||
c7c8898763 | |||
62ee9a72d6 | |||
55695ca5db | |||
c2f5a8df10 | |||
cd9821679e | |||
bfd3d4542e | |||
35a99ccda7 | |||
978934399e | |||
bc32fe7941 | |||
cb6d50d367 | |||
97eb1c152b | |||
c23176706f | |||
387ef99728 | |||
694a5a7dda | |||
c90b9a1912 | |||
7860292276 | |||
550acc4953 | |||
fd6b737556 | |||
3d5825adca | |||
9c97e2879a | |||
fda96025e9 | |||
92aa574944 | |||
d08ab8caac | |||
774f21a55b | |||
9b69ec31e9 | |||
a242377ea6 | |||
3a0c8edf86 | |||
970f7ed16f | |||
006bd4c8ae | |||
b6752683fd | |||
b0846b2fef | |||
8a244dcd23 | |||
9d4395e204 | |||
46f318734a | |||
7accf1d4c8 | |||
c2476b9719 | |||
a56f4e488e | |||
6bd9fb7e4e | |||
d264409d29 | |||
ca44f3bf55 | |||
9949a0a0bf | |||
8dc4081a89 | |||
52498f4e6b | |||
37440f288c | |||
973ae82bec | |||
8c4dec4483 | |||
ad922577da | |||
64f61a6c3d | |||
ab3f268f29 | |||
b345822366 | |||
76793a3c0b | |||
c330f11206 | |||
9cb62795a6 | |||
a034202d76 | |||
869799f08e | |||
573e7b42ed | |||
22935f7007 | |||
5bf5120883 | |||
f307aaff9d | |||
aea18fb293 | |||
835dfe8785 | |||
f670ae78aa | |||
d3128a9c9c | |||
b65f172f9d | |||
dad18b77de | |||
77a9aa2f19 | |||
de5030d9f0 | |||
8c15fffd42 | |||
3750fa8329 |
21
assets/icons/active_bell.svg
Normal file
21
assets/icons/active_bell.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_7572_5102)">
|
||||
<path d="M11.255 22.5148H11.2389C9.82071 22.5148 8.66699 21.361 8.66699 19.9429V19.3419C8.66699 18.9913 8.95123 18.707 9.30183 18.707H13.1921C13.5427 18.707 13.8269 18.9913 13.8269 19.3419V19.9429C13.8269 21.3611 12.6731 22.5148 11.255 22.5148Z" fill="#FFA81C"/>
|
||||
<path d="M13.1912 18.707H11.2461V22.5148H11.2542C12.6723 22.5148 13.826 21.361 13.826 19.9429V19.3419C13.826 18.9912 13.5418 18.707 13.1912 18.707Z" fill="#FF9300"/>
|
||||
<path d="M12.5157 4.81334H9.97762C9.62701 4.81334 9.34277 4.5291 9.34277 4.1785V2.74955C9.34277 1.69974 10.1968 0.845703 11.2466 0.845703C12.2964 0.845703 13.1505 1.69978 13.1505 2.74955V4.1785C13.1505 4.5291 12.8663 4.81334 12.5157 4.81334Z" fill="#FFA81C"/>
|
||||
<path d="M12.5151 4.81334C12.8657 4.81334 13.1499 4.5291 13.1499 4.1785V2.74955C13.1499 1.69974 12.2959 0.845703 11.2461 0.845703V4.81334H12.5151Z" fill="#FF9300"/>
|
||||
<path d="M17.9733 19.9777H4.51899C3.96952 19.9777 3.52246 19.5306 3.52246 18.9811V18.0735C3.52246 17.0793 3.88851 16.1245 4.55319 15.3852C5.00799 14.8792 5.25846 14.226 5.25846 13.5457V9.43293C5.25846 6.13133 7.94448 3.44531 11.2461 3.44531C14.5477 3.44531 17.2337 6.13133 17.2337 9.43293V13.5457C17.2337 14.226 17.4842 14.8792 17.939 15.3851C18.6037 16.1245 18.9697 17.0792 18.9697 18.0734V18.9811C18.9698 19.5306 18.5228 19.9777 17.9733 19.9777Z" fill="#FFCF2C"/>
|
||||
<path d="M17.9732 19.9776C18.5227 19.9776 18.9698 19.5306 18.9698 18.9811V18.0734C18.9698 17.0792 18.6037 16.1245 17.939 15.3851C17.4842 14.8792 17.2337 14.226 17.2337 13.5457V9.43293C17.2337 6.13133 14.5477 3.44531 11.2461 3.44531V19.9776H17.9732Z" fill="#FFC12E"/>
|
||||
<path d="M3.52246 18.0734V18.9811C3.52246 19.5306 3.96952 19.9776 4.51899 19.9776H17.9732C18.5227 19.9776 18.9698 19.5306 18.9698 18.9811V18.0734C18.9698 17.638 18.8995 17.2102 18.7648 16.8047H3.72747C3.59272 17.2102 3.52246 17.638 3.52246 18.0734Z" fill="#FFF566"/>
|
||||
<path d="M11.2461 16.8047V19.9776H17.9732C18.5227 19.9776 18.9698 19.5306 18.9698 18.9811V18.0734C18.9698 17.638 18.8995 17.2102 18.7647 16.8047H11.2461V16.8047Z" fill="#FFE645"/>
|
||||
<path d="M1.04282 7.85721C0.998428 7.85721 0.953397 7.85255 0.908238 7.84278C0.565508 7.7688 0.347673 7.43097 0.421653 7.08824C0.930035 4.73345 2.22744 2.57028 4.07483 0.997187C4.3418 0.769872 4.74247 0.802079 4.96975 1.06897C5.19706 1.33594 5.16494 1.73657 4.89797 1.96388C3.2616 3.35728 2.11262 5.2723 1.66273 7.35619C1.59852 7.65376 1.33536 7.85721 1.04282 7.85721Z" fill="#FF8B6E"/>
|
||||
<path d="M21.4417 7.85717C21.1491 7.85717 20.886 7.65377 20.8218 7.35619C20.3719 5.2723 19.2229 3.35728 17.5866 1.96393C17.3196 1.73661 17.2875 1.33594 17.5148 1.06901C17.7421 0.80204 18.1427 0.769875 18.4097 0.997233C20.2571 2.57024 21.5545 4.73345 22.0628 7.08825C22.1368 7.43098 21.919 7.7688 21.5763 7.84278C21.5311 7.85247 21.4861 7.85717 21.4417 7.85717Z" fill="#FF674F"/>
|
||||
<path d="M3.48329 8.6005C3.4444 8.6005 3.40495 8.5969 3.36534 8.58945C3.02075 8.5247 2.79394 8.19284 2.85869 7.84829C3.20714 5.99413 4.18429 4.28141 5.61006 3.02565C5.87314 2.79385 6.27431 2.81937 6.50603 3.08245C6.73779 3.34557 6.71231 3.74671 6.44923 3.97842C5.23495 5.04796 4.40293 6.50556 4.1065 8.08276C4.04919 8.38778 3.78268 8.6005 3.48329 8.6005Z" fill="#FF8B6E"/>
|
||||
<path d="M19.0004 8.60042C18.701 8.60042 18.4345 8.38771 18.3772 8.08273C18.0808 6.50557 17.2489 5.04793 16.0346 3.97843C15.7715 3.74667 15.7461 3.34554 15.9778 3.08241C16.2095 2.81934 16.6107 2.7939 16.8738 3.02562C18.2995 4.28138 19.2766 5.99405 19.625 7.84817C19.6898 8.19277 19.4629 8.52458 19.1183 8.58933C19.0788 8.59682 19.0393 8.60042 19.0004 8.60042Z" fill="#FF674F"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_7572_5102">
|
||||
<rect width="21.67" height="21.67" fill="white" transform="translate(0.407227 0.845703)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 3.8 KiB |
3
assets/icons/gear.svg
Normal file
3
assets/icons/gear.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="22" height="23" viewBox="0 0 22 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M21.412 9.9034L18.9398 9.28324C18.788 8.81496 18.5981 8.35938 18.3703 7.92902C18.7373 7.30886 19.522 6.00531 19.522 6.00531C19.6613 5.75219 19.6233 5.43578 19.4208 5.23324L17.6362 3.43609C17.4338 3.23364 17.1047 3.19563 16.8642 3.3475L14.9404 4.49922C14.4975 4.27141 14.0419 4.08152 13.5862 3.92969L12.9661 1.45754C12.9028 1.17902 12.6496 0.976562 12.3586 0.976562H9.82734C9.53629 0.976562 9.28312 1.17902 9.21989 1.4575C9.21989 1.4575 8.78953 3.18293 8.59973 3.92965C8.10614 4.09418 7.62516 4.29663 7.16957 4.5498L5.16984 3.34746C4.91672 3.19558 4.60031 3.23359 4.39781 3.43605L2.61328 5.23324C2.39817 5.43578 2.36016 5.75219 2.51199 6.00531L3.75234 8.06828C3.5498 8.46063 3.38527 8.86563 3.24609 9.28324L0.773948 9.9034C0.495427 9.96672 0.292969 10.2198 0.292969 10.5109V13.0422C0.292969 13.3332 0.495427 13.5864 0.773906 13.6496L3.24609 14.2698C3.39797 14.7381 3.60051 15.2064 3.82832 15.6494L2.72723 17.4845C2.57535 17.7376 2.61328 18.054 2.82844 18.2692L4.61301 20.0537C4.81547 20.2563 5.13188 20.2942 5.38504 20.1423C5.38504 20.1423 6.62531 19.4082 7.2329 19.0412C7.67578 19.2817 8.13136 19.4715 8.59973 19.6234L9.21989 22.0956C9.28317 22.374 9.53629 22.5765 9.82734 22.5765H12.3586C12.6496 22.5765 12.9028 22.374 12.9661 22.0956L13.5862 19.6234C14.0671 19.4715 14.5354 19.269 14.9911 19.0286C15.6112 19.3955 16.8642 20.1423 16.8642 20.1423C17.1046 20.2942 17.4337 20.2563 17.6362 20.0537L19.4208 18.2692C19.6232 18.054 19.6613 17.7376 19.522 17.4845L18.383 15.5987C18.6108 15.1684 18.788 14.7254 18.9398 14.2698L21.412 13.6496C21.6905 13.5864 21.8929 13.3332 21.8929 13.0422V10.5109C21.893 10.2198 21.6905 9.96672 21.412 9.9034ZM11.093 16.2063C8.65031 16.2063 6.66328 14.2192 6.66328 11.7766C6.66328 9.33391 8.65031 7.34688 11.093 7.34688C13.5356 7.34688 15.5227 9.33391 15.5227 11.7766C15.5227 14.2192 13.5356 16.2063 11.093 16.2063Z" fill="#A1A7B3"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/icons/scenesPlayIcon.png
Normal file
BIN
assets/icons/scenesPlayIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
@ -1,17 +0,0 @@
|
||||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_6675_32326)">
|
||||
<path d="M18 3C9.71584 3 3 9.71572 3 18C3 26.2843 9.71584 33 18 33C26.2842 33 33 26.2843 33 18C33 9.71572 26.2842 3 18 3ZM23.1844 18.7951L15.6844 23.4826C15.5326 23.5774 15.3601 23.625 15.1875 23.625C15.0312 23.625 14.8746 23.5861 14.7329 23.5073C14.4349 23.3421 14.25 23.0285 14.25 22.6875V13.3125C14.25 12.9715 14.4349 12.6579 14.7329 12.4927C15.0309 12.3265 15.3953 12.3366 15.6844 12.5174L23.1844 17.2049C23.4584 17.3766 23.625 17.6769 23.625 18C23.625 18.3231 23.4584 18.6235 23.1844 18.7951Z" fill="#F4F4F4"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_6675_32326" x="0" y="0" width="36" height="36" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="1.5"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6675_32326"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6675_32326" result="shape"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.3 KiB |
BIN
assets/icons/scenesPlayIconCheck.png
Normal file
BIN
assets/icons/scenesPlayIconCheck.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -1,30 +0,0 @@
|
||||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g filter="url(#filter0_d_7280_5211)">
|
||||
<circle cx="18" cy="18" r="15" fill="#F4F4F4"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_i_7280_5211)">
|
||||
<path d="M25.1663 13.187C24.8231 12.8439 24.2666 12.8439 23.9234 13.1871L16.1621 20.9484L12.0766 16.8628C11.7334 16.5196 11.1768 16.5196 10.8336 16.8628C10.4904 17.206 10.4904 17.7625 10.8336 18.1057L15.5406 22.8127C15.7122 22.9844 15.9372 23.0701 16.1621 23.0701C16.3869 23.0701 16.6119 22.9843 16.7835 22.8127L25.1663 14.43C25.5095 14.0868 25.5095 13.5303 25.1663 13.187Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_d_7280_5211" x="0" y="0" width="36" height="36" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="1.5"/>
|
||||
<feComposite in2="hardAlpha" operator="out"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0"/>
|
||||
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_7280_5211"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_7280_5211" result="shape"/>
|
||||
</filter>
|
||||
<filter id="filter1_i_7280_5211" x="10.5762" y="12.9297" width="14.8475" height="10.1406" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
|
||||
<feOffset/>
|
||||
<feGaussianBlur stdDeviation="1.5"/>
|
||||
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
|
||||
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0"/>
|
||||
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_7280_5211"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.0 KiB |
@ -201,20 +201,17 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
||||
!state.isButtonEnabled &&
|
||||
state.remainingTime != 1
|
||||
? null
|
||||
: () {
|
||||
:
|
||||
() {
|
||||
if (forgetBloc
|
||||
.forgetEmailKey.currentState!
|
||||
.validate() ||
|
||||
forgetBloc
|
||||
.forgetRegionKey.currentState!
|
||||
.forgetEmailKey
|
||||
.currentState!
|
||||
.validate()) {
|
||||
if (forgetBloc
|
||||
.forgetRegionKey.currentState!
|
||||
.validate()) {
|
||||
forgetBloc.add(StartTimerEvent());
|
||||
}
|
||||
forgetBloc.add(
|
||||
StartTimerEvent());
|
||||
}
|
||||
},
|
||||
|
||||
child: Text(
|
||||
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
||||
style: TextStyle(
|
||||
|
@ -13,6 +13,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
late AcStatusModel deviceStatus;
|
||||
final String deviceId;
|
||||
Timer? _timer;
|
||||
Timer? _countdownTimer;
|
||||
|
||||
AcBloc({required this.deviceId}) : super(AcsInitialState()) {
|
||||
on<AcFetchDeviceStatusEvent>(_onFetchAcStatus);
|
||||
@ -21,7 +22,16 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
on<AcBatchControlEvent>(_onAcBatchControl);
|
||||
on<AcFactoryResetEvent>(_onFactoryReset);
|
||||
on<AcStatusUpdated>(_onAcStatusUpdated);
|
||||
on<OnClose>(_onClose);
|
||||
on<IncreaseTimeEvent>(_handleIncreaseTime);
|
||||
on<DecreaseTimeEvent>(_handleDecreaseTime);
|
||||
on<UpdateTimerEvent>(_handleUpdateTimer);
|
||||
on<ToggleScheduleEvent>(_handleToggleTimer);
|
||||
on<ApiCountdownValueEvent>(_handleApiCountdownValue);
|
||||
}
|
||||
bool timerActive = false;
|
||||
int scheduledHours = 0;
|
||||
int scheduledMinutes = 0;
|
||||
|
||||
FutureOr<void> _onFetchAcStatus(
|
||||
AcFetchDeviceStatusEvent event, Emitter<AcsState> emit) async {
|
||||
@ -30,8 +40,23 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
final status =
|
||||
await DevicesManagementApi().getDeviceStatus(event.deviceId);
|
||||
deviceStatus = AcStatusModel.fromJson(event.deviceId, status.status);
|
||||
if (deviceStatus.countdown1 != 0) {
|
||||
// Convert API value to minutes
|
||||
final totalMinutes = deviceStatus.countdown1 * 6;
|
||||
scheduledHours = totalMinutes ~/ 60;
|
||||
scheduledMinutes = totalMinutes % 60;
|
||||
timerActive = true;
|
||||
_startCountdownTimer(emit);
|
||||
}
|
||||
|
||||
emit(ACStatusLoaded(
|
||||
status: deviceStatus,
|
||||
scheduledHours: scheduledHours,
|
||||
scheduledMinutes: scheduledMinutes,
|
||||
isTimerActive: timerActive,
|
||||
));
|
||||
|
||||
_listenToChanges(event.deviceId);
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
} catch (e) {
|
||||
emit(AcsFailedState(error: e.toString()));
|
||||
}
|
||||
@ -70,31 +95,16 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
|
||||
void _onAcStatusUpdated(AcStatusUpdated event, Emitter<AcsState> emit) {
|
||||
deviceStatus = event.deviceStatus;
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
emit(ACStatusLoaded(status: deviceStatus));
|
||||
}
|
||||
|
||||
// Future<void> testFirebaseConnection() async {
|
||||
// // Reference to a test node in your database
|
||||
// final testRef = FirebaseDatabase.instance.ref("test");
|
||||
|
||||
// // Write a test value
|
||||
// await testRef.set("Hello, Firebase!");
|
||||
|
||||
// // Listen for changes on the test node
|
||||
// testRef.onValue.listen((DatabaseEvent event) {
|
||||
// final data = event.snapshot.value;
|
||||
// print("Data from Firebase: $data");
|
||||
// // If you see "Hello, Firebase!" printed in your console, it means the connection works.
|
||||
// });
|
||||
// }
|
||||
|
||||
FutureOr<void> _onAcControl(
|
||||
AcControlEvent event, Emitter<AcsState> emit) async {
|
||||
final oldValue = _getValueByCode(event.code);
|
||||
|
||||
_updateLocalValue(event.code, event.value, emit);
|
||||
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
emit(ACStatusLoaded(status: deviceStatus));
|
||||
|
||||
await _runDebounce(
|
||||
isBatch: false,
|
||||
@ -151,7 +161,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
void _revertValueAndEmit(
|
||||
String deviceId, String code, dynamic oldValue, Emitter<AcsState> emit) {
|
||||
_updateLocalValue(code, oldValue, emit);
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
emit(ACStatusLoaded(status: deviceStatus));
|
||||
}
|
||||
|
||||
void _updateLocalValue(String code, dynamic value, Emitter<AcsState> emit) {
|
||||
@ -184,11 +194,16 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
if (value is bool) {
|
||||
deviceStatus = deviceStatus.copyWith(childLock: value);
|
||||
}
|
||||
|
||||
case 'countdown_time':
|
||||
if (value is int) {
|
||||
deviceStatus = deviceStatus.copyWith(countdown1: value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
emit(ACStatusLoaded(status: deviceStatus));
|
||||
}
|
||||
|
||||
dynamic _getValueByCode(String code) {
|
||||
@ -203,6 +218,8 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
return deviceStatus.fanSpeedsString;
|
||||
case 'child_lock':
|
||||
return deviceStatus.childLock;
|
||||
case 'countdown_time':
|
||||
return deviceStatus.countdown1;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -216,7 +233,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
await DevicesManagementApi().getBatchStatus(event.devicesIds);
|
||||
deviceStatus =
|
||||
AcStatusModel.fromJson(event.devicesIds.first, status.status);
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
emit(ACStatusLoaded(status: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(AcsFailedState(error: e.toString()));
|
||||
}
|
||||
@ -228,7 +245,7 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
|
||||
_updateLocalValue(event.code, event.value, emit);
|
||||
|
||||
emit(ACStatusLoaded(deviceStatus));
|
||||
emit(ACStatusLoaded(status: deviceStatus));
|
||||
|
||||
await _runDebounce(
|
||||
isBatch: true,
|
||||
@ -257,4 +274,144 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
emit(AcsFailedState(error: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void _onClose(OnClose event, Emitter<AcsState> emit) {
|
||||
_countdownTimer?.cancel();
|
||||
_timer?.cancel();
|
||||
}
|
||||
|
||||
void _handleIncreaseTime(IncreaseTimeEvent event, Emitter<AcsState> emit) {
|
||||
if (state is! ACStatusLoaded) return;
|
||||
final currentState = state as ACStatusLoaded;
|
||||
int newHours = scheduledHours;
|
||||
int newMinutes = scheduledMinutes + 30;
|
||||
newHours += newMinutes ~/ 60;
|
||||
newMinutes = newMinutes % 60;
|
||||
if (newHours > 23) {
|
||||
newHours = 23;
|
||||
newMinutes = 59;
|
||||
}
|
||||
scheduledHours = newHours;
|
||||
scheduledMinutes = newMinutes;
|
||||
|
||||
emit(currentState.copyWith(
|
||||
scheduledHours: scheduledHours,
|
||||
scheduledMinutes: scheduledMinutes,
|
||||
));
|
||||
}
|
||||
|
||||
void _handleDecreaseTime(DecreaseTimeEvent event, Emitter<AcsState> emit) {
|
||||
if (state is! ACStatusLoaded) return;
|
||||
final currentState = state as ACStatusLoaded;
|
||||
int totalMinutes = (scheduledHours * 60) + scheduledMinutes;
|
||||
totalMinutes = (totalMinutes - 30).clamp(0, 1440);
|
||||
scheduledHours = totalMinutes ~/ 60;
|
||||
scheduledMinutes = totalMinutes % 60;
|
||||
|
||||
emit(currentState.copyWith(
|
||||
scheduledHours: scheduledHours,
|
||||
scheduledMinutes: scheduledMinutes,
|
||||
));
|
||||
}
|
||||
|
||||
Future<void> _handleToggleTimer(
|
||||
ToggleScheduleEvent event, Emitter<AcsState> emit) async {
|
||||
if (state is! ACStatusLoaded) return;
|
||||
final currentState = state as ACStatusLoaded;
|
||||
|
||||
timerActive = !timerActive;
|
||||
|
||||
if (timerActive) {
|
||||
final totalMinutes = scheduledHours * 60 + scheduledMinutes;
|
||||
if (totalMinutes <= 0) {
|
||||
timerActive = false;
|
||||
emit(currentState.copyWith(isTimerActive: timerActive));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final scaledValue = totalMinutes ~/ 6;
|
||||
await _runDebounce(
|
||||
isBatch: false,
|
||||
deviceId: deviceId,
|
||||
code: 'countdown_time',
|
||||
value: scaledValue,
|
||||
oldValue: scaledValue,
|
||||
emit: emit,
|
||||
);
|
||||
_startCountdownTimer(emit);
|
||||
emit(currentState.copyWith(isTimerActive: timerActive));
|
||||
} catch (e) {
|
||||
timerActive = false;
|
||||
emit(AcsFailedState(error: e.toString()));
|
||||
}
|
||||
} else {
|
||||
await _runDebounce(
|
||||
isBatch: false,
|
||||
deviceId: deviceId,
|
||||
code: 'countdown_time',
|
||||
value: 0,
|
||||
oldValue: 0,
|
||||
emit: emit,
|
||||
);
|
||||
_countdownTimer?.cancel();
|
||||
scheduledHours = 0;
|
||||
scheduledMinutes = 0;
|
||||
emit(currentState.copyWith(
|
||||
isTimerActive: timerActive,
|
||||
scheduledHours: 0,
|
||||
scheduledMinutes: 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void _startCountdownTimer(Emitter<AcsState> emit) {
|
||||
_countdownTimer?.cancel();
|
||||
int totalSeconds = (scheduledHours * 3600) + (scheduledMinutes * 60);
|
||||
|
||||
_countdownTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||
if (totalSeconds > 0) {
|
||||
totalSeconds--;
|
||||
scheduledHours = totalSeconds ~/ 3600;
|
||||
scheduledMinutes = (totalSeconds % 3600) ~/ 60;
|
||||
add(UpdateTimerEvent());
|
||||
} else {
|
||||
_countdownTimer?.cancel();
|
||||
timerActive = false;
|
||||
scheduledHours = 0;
|
||||
scheduledMinutes = 0;
|
||||
add(TimerCompletedEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _handleUpdateTimer(UpdateTimerEvent event, Emitter<AcsState> emit) {
|
||||
if (state is ACStatusLoaded) {
|
||||
final currentState = state as ACStatusLoaded;
|
||||
emit(currentState.copyWith(
|
||||
scheduledHours: scheduledHours,
|
||||
scheduledMinutes: scheduledMinutes,
|
||||
isTimerActive: timerActive,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void _handleApiCountdownValue(
|
||||
ApiCountdownValueEvent event, Emitter<AcsState> emit) {
|
||||
if (state is ACStatusLoaded) {
|
||||
final totalMinutes = event.apiValue * 6;
|
||||
final scheduledHours = totalMinutes ~/ 60;
|
||||
scheduledMinutes = totalMinutes % 60;
|
||||
_startCountdownTimer(
|
||||
emit,
|
||||
);
|
||||
add(UpdateTimerEvent());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
add(OnClose());
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ sealed class AcsEvent extends Equatable {
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class AcUpdated extends AcsEvent {}
|
||||
|
||||
class AcFetchDeviceStatusEvent extends AcsEvent {
|
||||
@ -18,10 +19,12 @@ class AcFetchDeviceStatusEvent extends AcsEvent {
|
||||
@override
|
||||
List<Object> get props => [deviceId];
|
||||
}
|
||||
|
||||
class AcStatusUpdated extends AcsEvent {
|
||||
final AcStatusModel deviceStatus;
|
||||
AcStatusUpdated(this.deviceStatus);
|
||||
}
|
||||
|
||||
class AcFetchBatchStatusEvent extends AcsEvent {
|
||||
final List<String> devicesIds;
|
||||
|
||||
@ -73,3 +76,30 @@ class AcFactoryResetEvent extends AcsEvent {
|
||||
@override
|
||||
List<Object> get props => [deviceId, factoryResetModel];
|
||||
}
|
||||
|
||||
|
||||
|
||||
class OnClose extends AcsEvent {}
|
||||
|
||||
class IncreaseTimeEvent extends AcsEvent {
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class DecreaseTimeEvent extends AcsEvent {
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ToggleScheduleEvent extends AcsEvent {}
|
||||
|
||||
class TimerCompletedEvent extends AcsEvent {}
|
||||
|
||||
class UpdateTimerEvent extends AcsEvent {
|
||||
}
|
||||
|
||||
class ApiCountdownValueEvent extends AcsEvent {
|
||||
final int apiValue;
|
||||
|
||||
const ApiCountdownValueEvent(this.apiValue);
|
||||
}
|
||||
|
@ -2,8 +2,9 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
||||
|
||||
abstract class AcsState extends Equatable {
|
||||
const AcsState();
|
||||
final bool isTimerActive;
|
||||
|
||||
const AcsState({this.isTimerActive = false});
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
@ -15,8 +16,30 @@ class AcsLoadingState extends AcsState {}
|
||||
class ACStatusLoaded extends AcsState {
|
||||
final AcStatusModel status;
|
||||
final DateTime timestamp;
|
||||
final int scheduledHours;
|
||||
final int scheduledMinutes;
|
||||
final bool isTimerActive;
|
||||
|
||||
ACStatusLoaded(this.status) : timestamp = DateTime.now();
|
||||
ACStatusLoaded({
|
||||
required this.status,
|
||||
this.scheduledHours = 0,
|
||||
this.scheduledMinutes = 0,
|
||||
this.isTimerActive = false,
|
||||
}) : timestamp = DateTime.now();
|
||||
ACStatusLoaded copyWith({
|
||||
AcStatusModel? status,
|
||||
int? scheduledHours,
|
||||
int? scheduledMinutes,
|
||||
bool? isTimerActive,
|
||||
int? remainingTime,
|
||||
}) {
|
||||
return ACStatusLoaded(
|
||||
status: status ?? this.status,
|
||||
scheduledHours: scheduledHours ?? this.scheduledHours,
|
||||
scheduledMinutes: scheduledMinutes ?? this.scheduledMinutes,
|
||||
isTimerActive: isTimerActive ?? this.isTimerActive,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object> get props => [status, timestamp];
|
||||
@ -40,3 +63,14 @@ class AcsFailedState extends AcsState {
|
||||
@override
|
||||
List<Object> get props => [error];
|
||||
}
|
||||
|
||||
class TimerRunInProgress extends AcsState {
|
||||
final int remainingTime;
|
||||
|
||||
const TimerRunInProgress(this.remainingTime);
|
||||
|
||||
@override
|
||||
List<Object> get props => [remainingTime];
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@ class AcStatusModel {
|
||||
final bool childLock;
|
||||
final TempModes acMode;
|
||||
final FanSpeeds acFanSpeed;
|
||||
final int countdown1;
|
||||
|
||||
AcStatusModel({
|
||||
required this.uuid,
|
||||
@ -18,6 +19,7 @@ class AcStatusModel {
|
||||
required this.modeString,
|
||||
required this.tempSet,
|
||||
required this.currentTemp,
|
||||
required this.countdown1,
|
||||
required this.fanSpeedsString,
|
||||
required this.childLock,
|
||||
}) : acMode = getACMode(modeString),
|
||||
@ -30,6 +32,7 @@ class AcStatusModel {
|
||||
late int currentTemp;
|
||||
late String fanSpeeds;
|
||||
late bool childLock;
|
||||
late int _countdown1 = 0;
|
||||
|
||||
for (var status in jsonList) {
|
||||
switch (status.code) {
|
||||
@ -51,6 +54,9 @@ class AcStatusModel {
|
||||
case 'child_lock':
|
||||
childLock = status.value ?? false;
|
||||
break;
|
||||
case 'countdown_time':
|
||||
_countdown1 = status.value ?? 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +68,7 @@ class AcStatusModel {
|
||||
currentTemp: currentTemp,
|
||||
fanSpeedsString: fanSpeeds,
|
||||
childLock: childLock,
|
||||
countdown1: _countdown1,
|
||||
);
|
||||
}
|
||||
|
||||
@ -73,6 +80,7 @@ class AcStatusModel {
|
||||
int? currentTemp,
|
||||
String? fanSpeedsString,
|
||||
bool? childLock,
|
||||
int? countdown1,
|
||||
}) {
|
||||
return AcStatusModel(
|
||||
uuid: uuid ?? this.uuid,
|
||||
@ -82,6 +90,7 @@ class AcStatusModel {
|
||||
currentTemp: currentTemp ?? this.currentTemp,
|
||||
fanSpeedsString: fanSpeedsString ?? this.fanSpeedsString,
|
||||
childLock: childLock ?? this.childLock,
|
||||
countdown1: countdown1 ?? this.countdown1,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
||||
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 AcDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
|
||||
@ -23,11 +22,13 @@ class AcDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
|
||||
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) => AcBloc(deviceId: device.uuid!)
|
||||
..add(AcFetchDeviceStatusEvent(device.uuid!)),
|
||||
child: BlocBuilder<AcBloc, AcsState>(
|
||||
builder: (context, state) {
|
||||
final acBloc = BlocProvider.of<AcBloc>(context);
|
||||
if (state is ACStatusLoaded) {
|
||||
return GridView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
@ -78,56 +79,101 @@ class AcDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
|
||||
),
|
||||
ToggleWidget(
|
||||
label: '',
|
||||
labelWidget: Row(
|
||||
labelWidget: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: const ShapeDecoration(
|
||||
color: ColorsManager.primaryColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: SizedBox(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
IconButton(
|
||||
padding: const EdgeInsets.all(0),
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.remove,
|
||||
size: 28,
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
onPressed: () {
|
||||
if (acBloc.timerActive == false) {
|
||||
context
|
||||
.read<AcBloc>()
|
||||
.add(DecreaseTimeEvent());
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.remove,
|
||||
color: ColorsManager.greyColor),
|
||||
),
|
||||
Text(
|
||||
'06',
|
||||
style: context.textTheme.titleLarge!.copyWith(
|
||||
acBloc.scheduledHours
|
||||
.toString()
|
||||
.padLeft(2, '0'),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge!
|
||||
.copyWith(
|
||||
color: ColorsManager.dialogBlueTitle,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'h',
|
||||
style: context.textTheme.bodySmall!
|
||||
.copyWith(color: ColorsManager.blackColor),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'30',
|
||||
style: context.textTheme.titleLarge!.copyWith(
|
||||
acBloc.scheduledMinutes
|
||||
.toString()
|
||||
.padLeft(2, '0'),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleLarge!
|
||||
.copyWith(
|
||||
color: ColorsManager.dialogBlueTitle,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text('m',
|
||||
style: context.textTheme.bodySmall!
|
||||
.copyWith(color: ColorsManager.blackColor)),
|
||||
Text(
|
||||
'm',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
padding: const EdgeInsets.all(0),
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
size: 28,
|
||||
color: ColorsManager.greyColor,
|
||||
onPressed: () {
|
||||
if (acBloc.timerActive == false) {
|
||||
context
|
||||
.read<AcBloc>()
|
||||
.add(IncreaseTimeEvent());
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.add,
|
||||
color: ColorsManager.greyColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
value: false,
|
||||
value: acBloc.timerActive,
|
||||
code: 'ac_schedule',
|
||||
deviceId: device.uuid!,
|
||||
icon: Assets.acSchedule,
|
||||
onChange: (value) {},
|
||||
onChange: (value) {
|
||||
context.read<AcBloc>().add(ToggleScheduleEvent());
|
||||
},
|
||||
),
|
||||
ToggleWidget(
|
||||
deviceId: device.uuid!,
|
||||
|
@ -8,6 +8,7 @@ import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/three_gang_switch/three_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/two_gang_switch/two_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gateway.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_functions.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/enum/device_types.dart';
|
||||
@ -247,12 +248,18 @@ SOS
|
||||
switch (productType) {
|
||||
case 'AC':
|
||||
return [
|
||||
SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
SwitchFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ModeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
TempSetFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
CurrentTempFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
LevelFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ChildLockFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
];
|
||||
|
||||
case '1G':
|
||||
@ -275,44 +282,60 @@ SOS
|
||||
case '3G':
|
||||
return [
|
||||
ThreeGangSwitch1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangSwitch2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangSwitch3Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangCountdown1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangCountdown2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangCountdown3Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
];
|
||||
case 'WPS':
|
||||
return [
|
||||
//IF Functions
|
||||
PresenceStateFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
CurrentDistanceFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
IlluminanceValueFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
PresenceTimeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
|
||||
//THEN Functions
|
||||
FarDetectionFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
MotionSensitivityFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
MotionLessSensitivityFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
IndicatorFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
NoOneTimeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
|
||||
// FarDetectionSliderFunction(
|
||||
// deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN')
|
||||
];
|
||||
case 'GW':
|
||||
return [
|
||||
GatewaySwitchAlarmSound(
|
||||
deviceId: uuid ?? '',
|
||||
deviceName: name ?? '',
|
||||
type: 'BOTH',
|
||||
),
|
||||
GatewayMasterState(
|
||||
deviceId: uuid ?? '',
|
||||
deviceName: name ?? '',
|
||||
type: 'BOTH',
|
||||
),
|
||||
GatewayFactoryReset(
|
||||
deviceId: uuid ?? '',
|
||||
deviceName: name ?? '',
|
||||
type: 'BOTH',
|
||||
),
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
|
@ -2,14 +2,17 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class FactoryResetModel {
|
||||
final List<String> devicesUuid;
|
||||
final String operationType;
|
||||
|
||||
FactoryResetModel({
|
||||
required this.devicesUuid,
|
||||
this.operationType = "RESET",
|
||||
});
|
||||
|
||||
factory FactoryResetModel.fromJson(Map<String, dynamic> json) {
|
||||
return FactoryResetModel(
|
||||
devicesUuid: List<String>.from(json['devicesUuid']),
|
||||
operationType: "RESET",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,77 +12,68 @@ class DeviceSearchFilters extends StatefulWidget {
|
||||
State<DeviceSearchFilters> createState() => _DeviceSearchFiltersState();
|
||||
}
|
||||
|
||||
class _DeviceSearchFiltersState extends State<DeviceSearchFilters> with HelperResponsiveLayout {
|
||||
final TextEditingController communityController = TextEditingController();
|
||||
final TextEditingController unitNameController = TextEditingController();
|
||||
final TextEditingController productNameController = TextEditingController();
|
||||
class _DeviceSearchFiltersState extends State<DeviceSearchFilters>
|
||||
with HelperResponsiveLayout {
|
||||
final _unitNameController = TextEditingController();
|
||||
final _productNameController = TextEditingController();
|
||||
|
||||
List<Widget> get _widgets => [
|
||||
_buildSearchField("Space Name", _unitNameController, 200),
|
||||
_buildSearchField("Device Name / Product Name", _productNameController, 300),
|
||||
_buildSearchResetButtons(),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isExtraLargeScreenSize(context)
|
||||
? Row(
|
||||
children: [
|
||||
_buildSearchField("Community", communityController, 200),
|
||||
const SizedBox(width: 20),
|
||||
_buildSearchField("Space Name", unitNameController, 200),
|
||||
const SizedBox(width: 20),
|
||||
_buildSearchField("Device Name / Product Name", productNameController, 300),
|
||||
const SizedBox(width: 20),
|
||||
_buildSearchResetButtons(),
|
||||
],
|
||||
)
|
||||
: Wrap(
|
||||
spacing: 20,
|
||||
runSpacing: 10,
|
||||
children: [
|
||||
_buildSearchField(
|
||||
"Community",
|
||||
communityController,
|
||||
200,
|
||||
),
|
||||
_buildSearchField("Space Name", unitNameController, 200),
|
||||
_buildSearchField(
|
||||
"Device Name / Product Name",
|
||||
productNameController,
|
||||
300,
|
||||
),
|
||||
_buildSearchResetButtons(),
|
||||
],
|
||||
if (isExtraLargeScreenSize(context)) {
|
||||
return Row(
|
||||
children: _widgets
|
||||
.map((e) => Padding(padding: const EdgeInsets.all(10), child: e))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchField(String title, TextEditingController controller, double width) {
|
||||
return Container(
|
||||
child: StatefulTextField(
|
||||
return Wrap(
|
||||
spacing: 20,
|
||||
runSpacing: 10,
|
||||
children: _widgets,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchField(
|
||||
String title,
|
||||
TextEditingController controller,
|
||||
double width,
|
||||
) {
|
||||
return StatefulTextField(
|
||||
title: title,
|
||||
width: width,
|
||||
elevation: 2,
|
||||
controller: controller,
|
||||
onSubmitted: () {
|
||||
context.read<DeviceManagementBloc>().add(SearchDevices(
|
||||
productName: productNameController.text,
|
||||
unitName: unitNameController.text,
|
||||
community: communityController.text,
|
||||
searchField: true));
|
||||
final searchDevicesEvent = SearchDevices(
|
||||
productName: _productNameController.text,
|
||||
unitName: _unitNameController.text,
|
||||
searchField: true,
|
||||
);
|
||||
context.read<DeviceManagementBloc>().add(searchDevicesEvent);
|
||||
},
|
||||
onChanged: (p0) {},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSearchResetButtons() {
|
||||
return SearchResetButtons(
|
||||
onSearch: () {
|
||||
context.read<DeviceManagementBloc>().add(SearchDevices(
|
||||
community: communityController.text,
|
||||
unitName: unitNameController.text,
|
||||
productName: productNameController.text,
|
||||
searchField: true));
|
||||
},
|
||||
onSearch: () => context.read<DeviceManagementBloc>().add(
|
||||
SearchDevices(
|
||||
unitName: _unitNameController.text,
|
||||
productName: _productNameController.text,
|
||||
searchField: true,
|
||||
),
|
||||
),
|
||||
onReset: () {
|
||||
communityController.clear();
|
||||
unitNameController.clear();
|
||||
productNameController.clear();
|
||||
_unitNameController.clear();
|
||||
_productNameController.clear();
|
||||
context.read<DeviceManagementBloc>()
|
||||
..add(ResetFilters())
|
||||
..add(FetchDevices(context));
|
||||
|
49
lib/pages/device_managment/gateway/model/gateway_model.dart
Normal file
49
lib/pages/device_managment/gateway/model/gateway_model.dart
Normal file
@ -0,0 +1,49 @@
|
||||
class GatewayModel {
|
||||
final String uuid;
|
||||
final bool switchAlarmSound;
|
||||
final String masterState;
|
||||
final bool factoryReset;
|
||||
final String alarmActive;
|
||||
|
||||
GatewayModel({
|
||||
required this.uuid,
|
||||
required this.switchAlarmSound,
|
||||
required this.masterState,
|
||||
required this.factoryReset,
|
||||
required this.alarmActive,
|
||||
});
|
||||
|
||||
factory GatewayModel.fromJson(Map<String, dynamic> json) {
|
||||
final status = json['status'] as List<dynamic>? ?? <dynamic>[];
|
||||
|
||||
bool? switchAlarmSound;
|
||||
String? masterState;
|
||||
bool? factoryReset;
|
||||
String? alarmActive;
|
||||
|
||||
for (final item in status) {
|
||||
switch (item['code']) {
|
||||
case 'switch_alarm_sound':
|
||||
switchAlarmSound = item['value'] as bool;
|
||||
break;
|
||||
case 'master_state':
|
||||
masterState = item['value'] as String;
|
||||
break;
|
||||
case 'factory_reset':
|
||||
factoryReset = item['value'] as bool;
|
||||
break;
|
||||
case 'alarm_active':
|
||||
alarmActive = item['value'] as String;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return GatewayModel(
|
||||
uuid: json['uuid'] as String? ?? '',
|
||||
switchAlarmSound: switchAlarmSound ?? false,
|
||||
masterState: masterState ?? '',
|
||||
factoryReset: factoryReset ?? false,
|
||||
alarmActive: alarmActive ?? '',
|
||||
);
|
||||
}
|
||||
}
|
@ -62,9 +62,6 @@ class ToggleWidget extends StatelessWidget {
|
||||
)),
|
||||
if (showToggle)
|
||||
Container(
|
||||
height: 20,
|
||||
width: 35,
|
||||
padding: const EdgeInsets.only(right: 16, top: 10),
|
||||
child: CupertinoSwitch(
|
||||
value: value,
|
||||
activeColor: ColorsManager.dialogBlueTitle,
|
||||
|
@ -13,7 +13,8 @@ import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_la
|
||||
|
||||
import '../models/sos_status_model.dart';
|
||||
|
||||
class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout {
|
||||
class SosDeviceControlsView extends StatelessWidget
|
||||
with HelperResponsiveLayout {
|
||||
const SosDeviceControlsView({
|
||||
super.key,
|
||||
required this.device,
|
||||
@ -24,7 +25,8 @@ class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => SosDeviceBloc()..add(GetDeviceStatus(device.uuid!)),
|
||||
create: (context) =>
|
||||
SosDeviceBloc()..add(GetDeviceStatus(device.uuid!)),
|
||||
child: BlocBuilder<SosDeviceBloc, SosDeviceState>(
|
||||
builder: (context, state) {
|
||||
if (state is SosDeviceLoadingState) {
|
||||
@ -63,7 +65,8 @@ class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildStatusControls(BuildContext context, SosStatusModel deviceStatus) {
|
||||
Widget _buildStatusControls(
|
||||
BuildContext context, SosStatusModel deviceStatus) {
|
||||
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||
final isLarge = isLargeScreenSize(context);
|
||||
final isMedium = isMediumScreenSize(context);
|
||||
@ -85,7 +88,7 @@ class SosDeviceControlsView extends StatelessWidget with HelperResponsiveLayout
|
||||
IconNameStatusContainer(
|
||||
isFullIcon: false,
|
||||
name: deviceStatus.sosStatus == 'sos' ? 'SOS' : 'Normal',
|
||||
icon: deviceStatus.sosStatus == 'sos' ? Assets.sos : Assets.sosNormal,
|
||||
icon: deviceStatus.sosStatus == 'sos' ? Assets.sosNormal : Assets.sos,
|
||||
onTap: () {},
|
||||
status: false,
|
||||
textColor: ColorsManager.blackColor,
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
|
||||
@ -10,11 +11,12 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
||||
on<SpaceOnlyWithDevicesEvent>(_fetchSpaceOnlyWithDevices);
|
||||
on<SaveCommunityIdAndSpaceIdEvent>(saveSpaceIdCommunityId);
|
||||
on<ResetSelectedEvent>(resetSelected);
|
||||
on<FetchCommunityEvent>(_fetchCommunity);
|
||||
}
|
||||
|
||||
String selectedSpaceId = '';
|
||||
String selectedCommunityId = '';
|
||||
|
||||
List<CommunityModel> communities = [];
|
||||
List<SpaceModel> spacesOnlyWithDevices = [];
|
||||
|
||||
Future<void> _fetchSpaceOnlyWithDevices(
|
||||
@ -30,7 +32,7 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
||||
|
||||
emit(SpaceWithDeviceLoadedState(spacesOnlyWithDevices));
|
||||
} catch (e) {
|
||||
emit(SpaceTreeErrorState('Error loading communities and spaces: $e'));
|
||||
emit(SpaceTreeErrorState('Error loading spaces: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,4 +50,18 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
||||
selectedCommunityId = '';
|
||||
emit(const ResetSelectedState());
|
||||
}
|
||||
|
||||
Future<void> _fetchCommunity(
|
||||
FetchCommunityEvent event, Emitter<CreateRoutineState> emit) async {
|
||||
emit(const CommunitiesLoadingState());
|
||||
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
communities =
|
||||
await CommunitySpaceManagementApi().fetchCommunities(projectUuid);
|
||||
emit(const CommunityLoadedState());
|
||||
} catch (e) {
|
||||
emit(SpaceTreeErrorState('Error loading communities $e'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,3 +41,11 @@ class ResetSelectedEvent extends CreateRoutineEvent {
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
|
||||
class FetchCommunityEvent extends CreateRoutineEvent {
|
||||
const FetchCommunityEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
@ -44,3 +44,10 @@ class ResetSelectedState extends CreateRoutineState {
|
||||
const ResetSelectedState();
|
||||
}
|
||||
|
||||
class CommunityLoadedState extends CreateRoutineState {
|
||||
const CommunityLoadedState();
|
||||
}
|
||||
|
||||
class CommunitiesLoadingState extends CreateRoutineState {
|
||||
const CommunitiesLoadingState();
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class CommunityDropdown extends StatelessWidget {
|
||||
final String? selectedValue;
|
||||
final List<CommunityModel> communities;
|
||||
final Function(String?) onChanged;
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
|
||||
const CommunityDropdown({
|
||||
CommunityDropdown({
|
||||
Key? key,
|
||||
required this.selectedValue,
|
||||
required this.onChanged,
|
||||
required this.communities,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -32,27 +32,28 @@ class CommunityDropdown extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
||||
builder: (context, state) {
|
||||
List<CommunityModel> communities = state.isSearching
|
||||
? state.filteredCommunity
|
||||
: state.communityList;
|
||||
|
||||
return SizedBox(
|
||||
child: DropdownButtonFormField<String>(
|
||||
dropdownColor: ColorsManager.whiteColors,
|
||||
SizedBox(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: DropdownButton2<String>(
|
||||
underline: const SizedBox(),
|
||||
value: selectedValue,
|
||||
items: communities.map((community) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: community.uuid,
|
||||
child: Text(' ${community.name}'),
|
||||
child: Text(
|
||||
' ${community.name}',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: onChanged,
|
||||
icon: const SizedBox.shrink(),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
hint: Padding(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
" Please Select",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
@ -60,35 +61,94 @@ class CommunityDropdown extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
decoration: inputTextFormDeco().copyWith(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
suffixIcon: Container(
|
||||
padding: EdgeInsets.zero,
|
||||
width: 70,
|
||||
customButton: Container(
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: ColorsManager.textGray, width: 1.0),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
selectedValue != null
|
||||
? " ${communities.firstWhere((element) => element.uuid == selectedValue).name}"
|
||||
: ' Please Select',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: selectedValue != null
|
||||
? Colors.black
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomRight: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
bottomRight: Radius.circular(10),
|
||||
),
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
height: 45,
|
||||
child: const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
dropdownStyleData: DropdownStyleData(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.4,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
dropdownSearchData: DropdownSearchData(
|
||||
searchController: _searchController,
|
||||
searchInnerWidgetHeight: 50,
|
||||
searchInnerWidget: Container(
|
||||
height: 50,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: TextFormField(
|
||||
style: const TextStyle(color: Colors.black),
|
||||
controller: _searchController,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 12,
|
||||
),
|
||||
hintText: 'Search for community...',
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
searchMatchFn: (item, searchValue) {
|
||||
final communityName =
|
||||
(item.child as Text).data?.toLowerCase() ?? '';
|
||||
return communityName
|
||||
.contains(searchValue.toLowerCase().trim());
|
||||
},
|
||||
),
|
||||
onMenuStateChange: (isOpen) {
|
||||
if (!isOpen) {
|
||||
_searchController.clear();
|
||||
}
|
||||
},
|
||||
menuItemStyleData: const MenuItemStyleData(
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -5,11 +5,10 @@ import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routi
|
||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/create_new_routines/commu_dropdown.dart';
|
||||
import 'package:syncrow_web/pages/routines/create_new_routines/space_dropdown.dart';
|
||||
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class CreateNewRoutinesDialog extends StatefulWidget {
|
||||
const CreateNewRoutinesDialog({Key? key}) : super(key: key);
|
||||
const CreateNewRoutinesDialog({super.key});
|
||||
|
||||
@override
|
||||
State<CreateNewRoutinesDialog> createState() =>
|
||||
@ -19,24 +18,21 @@ class CreateNewRoutinesDialog extends StatefulWidget {
|
||||
class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
String? _selectedCommunity;
|
||||
String? _selectedSpace;
|
||||
void _fetchSpaces(String communityId) {
|
||||
context
|
||||
.read<CreateRoutineBloc>()
|
||||
.add(SpaceOnlyWithDevicesEvent(communityId));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<CreateRoutineBloc, CreateRoutineState>(
|
||||
return BlocProvider(
|
||||
create: (BuildContext context) =>
|
||||
CreateRoutineBloc()..add(const FetchCommunityEvent()),
|
||||
child: BlocBuilder<CreateRoutineBloc, CreateRoutineState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
||||
final spaces = _bloc.spacesOnlyWithDevices;
|
||||
final isLoading = state is SpaceWithDeviceLoadingState;
|
||||
|
||||
final isLoadingCommunities = state is CommunitiesLoadingState;
|
||||
final isLoadingSpaces = state is SpaceWithDeviceLoadingState;
|
||||
String spaceHint = 'Select a community first';
|
||||
|
||||
if (_selectedCommunity != null) {
|
||||
if (isLoading) {
|
||||
if (isLoadingSpaces) {
|
||||
spaceHint = 'Loading spaces...';
|
||||
} else if (spaces.isEmpty) {
|
||||
spaceHint = 'No spaces available';
|
||||
@ -49,8 +45,8 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
backgroundColor: Colors.white,
|
||||
insetPadding: EdgeInsets.zero,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
title: Text(
|
||||
'Create New Routines',
|
||||
textAlign: TextAlign.center,
|
||||
@ -58,11 +54,16 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
color: ColorsManager.primaryColor,
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
content: Stack(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Divider(),
|
||||
CommunityDropdown(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: CommunityDropdown(
|
||||
communities: _bloc.communities,
|
||||
selectedValue: _selectedCommunity,
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
@ -70,12 +71,15 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
_selectedSpace = null;
|
||||
});
|
||||
if (newValue != null) {
|
||||
_fetchSpaces(newValue);
|
||||
_bloc.add(SpaceOnlyWithDevicesEvent(newValue));
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SpaceDropdown(
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: SpaceDropdown(
|
||||
hintMessage: spaceHint,
|
||||
spaces: spaces,
|
||||
selectedValue: _selectedSpace,
|
||||
@ -85,6 +89,7 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
@ -96,12 +101,14 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
color: ColorsManager.blackColor,
|
||||
@ -115,8 +122,8 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
right: 20,
|
||||
),
|
||||
child: TextButton(
|
||||
onPressed:
|
||||
_selectedCommunity != null && _selectedSpace != null
|
||||
onPressed: _selectedCommunity != null &&
|
||||
_selectedSpace != null
|
||||
? () {
|
||||
Navigator.of(context).pop({
|
||||
'community': _selectedCommunity,
|
||||
@ -126,7 +133,10 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
: null,
|
||||
child: Text(
|
||||
'Next',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium!
|
||||
.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 14,
|
||||
color: _selectedCommunity != null &&
|
||||
@ -139,10 +149,29 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
if (isLoadingCommunities)
|
||||
const SizedBox(
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: ColorsManager.primaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
|
||||
class SpaceDropdown extends StatelessWidget {
|
||||
final List<SpaceModel> spaces;
|
||||
@ -33,7 +34,13 @@ class SpaceDropdown extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
DropdownButtonFormField<String>(
|
||||
SizedBox(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: DropdownButton2<String>(
|
||||
underline: const SizedBox(),
|
||||
value: selectedValue,
|
||||
items: spaces.map((space) {
|
||||
return DropdownMenuItem<String>(
|
||||
@ -44,23 +51,25 @@ class SpaceDropdown extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
' ${space.name}',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 12,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
' ${space.lastThreeParents}',
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: onChanged,
|
||||
icon: const SizedBox.shrink(),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
style: TextStyle(color: Colors.black),
|
||||
hint: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
@ -70,28 +79,66 @@ class SpaceDropdown extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
decoration: inputTextFormDeco().copyWith(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
suffixIcon: Container(
|
||||
width: 70,
|
||||
customButton: Container(
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
border:
|
||||
Border.all(color: ColorsManager.textGray, width: 1.0),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
selectedValue != null
|
||||
? spaces
|
||||
.firstWhere((e) => e.uuid == selectedValue)
|
||||
.name
|
||||
: hintMessage,
|
||||
style:
|
||||
Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: selectedValue != null
|
||||
? Colors.black
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomRight: Radius.circular(10),
|
||||
topRight: Radius.circular(10),
|
||||
),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
bottomRight: Radius.circular(10),
|
||||
),
|
||||
),
|
||||
height: 45,
|
||||
child: const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
dropdownStyleData: DropdownStyleData(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.4,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
menuItemStyleData: const MenuItemStyleData(
|
||||
height: 60,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_helper.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
||||
|
||||
class DeviceDialogHelper {
|
||||
@ -49,45 +50,45 @@ class DeviceDialogHelper {
|
||||
final deviceSelectedFunctions =
|
||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||
|
||||
if (removeComparetors && data['productType'] != 'WPS') {
|
||||
//remove the current temp function in the 'if container'
|
||||
functions.removeAt(3);
|
||||
}
|
||||
|
||||
switch (productType) {
|
||||
case 'AC':
|
||||
return ACHelper.showACFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors,
|
||||
dialogType: dialogType,
|
||||
);
|
||||
|
||||
case '1G':
|
||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case '2G':
|
||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case '3G':
|
||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case 'WPS':
|
||||
return WallPresenceSensor.showWPSFunctionsDialog(
|
||||
dialogType: dialogType,
|
||||
@ -97,6 +98,15 @@ class DeviceDialogHelper {
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case 'GW':
|
||||
return GatewayHelper.showGatewayFunctionsDialog(
|
||||
context: context,
|
||||
functions: functions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
device: data['device'],
|
||||
);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -5,23 +5,28 @@ import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
||||
final String type;
|
||||
|
||||
ACFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.code,
|
||||
required super.operationName,
|
||||
required super.icon,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
List<ACOperationalValue> getOperationalValues();
|
||||
}
|
||||
|
||||
class SwitchFunction extends ACFunction {
|
||||
SwitchFunction({required super.deviceId, required super.deviceName})
|
||||
SwitchFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
code: 'switch',
|
||||
operationName: 'Power',
|
||||
icon: Assets.assetsAcPower,
|
||||
type: type,
|
||||
);
|
||||
|
||||
@override
|
||||
@ -40,11 +45,13 @@ class SwitchFunction extends ACFunction {
|
||||
}
|
||||
|
||||
class ModeFunction extends ACFunction {
|
||||
ModeFunction({required super.deviceId, required super.deviceName})
|
||||
ModeFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
code: 'mode',
|
||||
operationName: 'Mode',
|
||||
icon: Assets.assetsFreezing,
|
||||
type: type,
|
||||
);
|
||||
|
||||
@override
|
||||
@ -72,7 +79,8 @@ class TempSetFunction extends ACFunction {
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
TempSetFunction({required super.deviceId, required super.deviceName})
|
||||
TempSetFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 160,
|
||||
max = 300,
|
||||
step = 1,
|
||||
@ -80,6 +88,7 @@ class TempSetFunction extends ACFunction {
|
||||
code: 'temp_set',
|
||||
operationName: 'Set Temperature',
|
||||
icon: Assets.assetsTempreture,
|
||||
type: type,
|
||||
);
|
||||
|
||||
@override
|
||||
@ -97,8 +106,10 @@ class TempSetFunction extends ACFunction {
|
||||
}
|
||||
|
||||
class LevelFunction extends ACFunction {
|
||||
LevelFunction({required super.deviceId, required super.deviceName})
|
||||
LevelFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
type: type,
|
||||
code: 'level',
|
||||
operationName: 'Fan Speed',
|
||||
icon: Assets.assetsFanSpeed,
|
||||
@ -130,8 +141,10 @@ class LevelFunction extends ACFunction {
|
||||
}
|
||||
|
||||
class ChildLockFunction extends ACFunction {
|
||||
ChildLockFunction({required super.deviceId, required super.deviceName})
|
||||
ChildLockFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
type: type,
|
||||
code: 'child_lock',
|
||||
operationName: 'Child Lock',
|
||||
icon: Assets.assetsChildLock,
|
||||
@ -157,11 +170,13 @@ class CurrentTempFunction extends ACFunction {
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
CurrentTempFunction({required super.deviceId, required super.deviceName})
|
||||
CurrentTempFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = -100,
|
||||
max = 990,
|
||||
step = 1,
|
||||
super(
|
||||
type: type,
|
||||
code: 'temp_current',
|
||||
operationName: 'Current Temperature',
|
||||
icon: Assets.currentTemp,
|
||||
|
@ -3,7 +3,7 @@ import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operation
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'switch_1',
|
||||
operationName: 'Light 1 Switch',
|
||||
@ -26,7 +26,7 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'countdown_1',
|
||||
operationName: 'Light 1 Countdown',
|
||||
@ -47,7 +47,7 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
||||
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
code: 'switch_2',
|
||||
operationName: 'Light 2 Switch',
|
||||
@ -70,7 +70,7 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'countdown_2',
|
||||
operationName: 'Light 2 Countdown',
|
||||
@ -91,7 +91,7 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
||||
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'switch_3',
|
||||
operationName: 'Light 3 Switch',
|
||||
@ -114,7 +114,7 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'countdown_3',
|
||||
operationName: 'Light 3 Countdown',
|
||||
|
111
lib/pages/routines/models/gateway.dart
Normal file
111
lib/pages/routines/models/gateway.dart
Normal file
@ -0,0 +1,111 @@
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class GatewayOperationalValue {
|
||||
final String icon;
|
||||
final String description;
|
||||
final dynamic value;
|
||||
|
||||
GatewayOperationalValue({
|
||||
required this.icon,
|
||||
required this.description,
|
||||
required this.value,
|
||||
});
|
||||
}
|
||||
|
||||
abstract class GatewayFunctions extends DeviceFunction<GatewayOperationalValue> {
|
||||
final String type;
|
||||
|
||||
GatewayFunctions({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.code,
|
||||
required super.operationName,
|
||||
required super.icon,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
List<GatewayOperationalValue> getOperationalValues();
|
||||
}
|
||||
|
||||
final class GatewaySwitchAlarmSound extends GatewayFunctions {
|
||||
GatewaySwitchAlarmSound({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'switch_alarm_sound',
|
||||
operationName: 'Switch Alarm Sound',
|
||||
icon: Assets.activeBell,
|
||||
);
|
||||
|
||||
@override
|
||||
List<GatewayOperationalValue> getOperationalValues() => [
|
||||
GatewayOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "ON",
|
||||
value: true,
|
||||
),
|
||||
GatewayOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
final class GatewayMasterState extends GatewayFunctions {
|
||||
GatewayMasterState({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'master_state',
|
||||
operationName: 'Master State',
|
||||
icon: Assets.gear,
|
||||
);
|
||||
|
||||
@override
|
||||
List<GatewayOperationalValue> getOperationalValues() {
|
||||
return [
|
||||
GatewayOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "Normal",
|
||||
value: 'normal',
|
||||
),
|
||||
GatewayOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "Alarm",
|
||||
value: 'alarm',
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
final class GatewayFactoryReset extends GatewayFunctions {
|
||||
GatewayFactoryReset({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.type,
|
||||
}) : super(
|
||||
code: 'factory_reset',
|
||||
operationName: 'Factory Reset',
|
||||
icon: Assets.factoryReset,
|
||||
);
|
||||
|
||||
@override
|
||||
List<GatewayOperationalValue> getOperationalValues() {
|
||||
return [
|
||||
GatewayOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "ON",
|
||||
value: true,
|
||||
),
|
||||
GatewayOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/model/wall_sensor_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/wps/wps_operational_value.dart';
|
||||
@ -216,12 +214,12 @@ class PresenceStateFunction extends WpsFunctions {
|
||||
WpsOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "None",
|
||||
value: true,
|
||||
value: 'none',
|
||||
),
|
||||
WpsOperationalValue(
|
||||
icon: Assets.presenceStateIcon,
|
||||
description: "Presence",
|
||||
value: false,
|
||||
value: 'presence',
|
||||
),
|
||||
];
|
||||
}
|
||||
@ -238,7 +236,7 @@ class CurrentDistanceFunction extends WpsFunctions {
|
||||
step = 1,
|
||||
super(
|
||||
type: type,
|
||||
code: 'current_distance',
|
||||
code: 'dis_current',
|
||||
operationName: 'Current Distance',
|
||||
icon: Assets.currentDistanceIcon,
|
||||
);
|
||||
@ -246,11 +244,12 @@ class CurrentDistanceFunction extends WpsFunctions {
|
||||
@override
|
||||
List<WpsOperationalValue> getOperationalValues() {
|
||||
List<WpsOperationalValue> values = [];
|
||||
for (int temp = min; temp <= max; temp += step) {
|
||||
for (int cm = min; cm <= max; cm += step) {
|
||||
values.add(WpsOperationalValue(
|
||||
icon: Assets.assetsTempreture,
|
||||
description: "${temp}CM",
|
||||
value: temp,
|
||||
description: "${cm}CM",
|
||||
|
||||
value: cm,
|
||||
));
|
||||
}
|
||||
return values;
|
||||
|
@ -33,8 +33,6 @@ class _RoutinesViewState extends State<RoutinesView> {
|
||||
communityID: communityId, spaceID: spaceId));
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
||||
await Future.delayed(const Duration(milliseconds:500));
|
||||
_bloc.add(const ResetSelectedEvent());
|
||||
}
|
||||
|
||||
@override
|
||||
@ -92,6 +90,7 @@ class _RoutinesViewState extends State<RoutinesView> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 50),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
@ -72,6 +72,7 @@ class IfContainer extends StatelessWidget {
|
||||
'2G',
|
||||
'3G',
|
||||
'WPS'
|
||||
'GW',
|
||||
].contains(
|
||||
state.ifItems[index]['productType'])) {
|
||||
context.read<RoutineBloc>().add(
|
||||
@ -105,9 +106,7 @@ class IfContainer extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
onAcceptWithDetails: (data) async {
|
||||
print('data.data=${data.data}');
|
||||
final uniqueCustomId = const Uuid().v4();
|
||||
|
||||
final mutableData = Map<String, dynamic>.from(data.data);
|
||||
mutableData['uniqueCustomId'] = uniqueCustomId;
|
||||
|
||||
@ -131,7 +130,7 @@ class IfContainer extends StatelessWidget {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
.add(AddToIfContainer(mutableData, false));
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW']
|
||||
.contains(mutableData['productType'])) {
|
||||
context
|
||||
.read<RoutineBloc>()
|
||||
|
@ -31,7 +31,8 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Padding(
|
||||
: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -46,20 +47,17 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (state.scenes.isEmpty)
|
||||
Expanded(
|
||||
child: Text(
|
||||
Text(
|
||||
"No scenes found",
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.scenes.isNotEmpty)
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: isSmallScreenSize(context) ? 190 : 200,
|
||||
maxWidth: MediaQuery.sizeOf(context).width * 0.8),
|
||||
SizedBox(
|
||||
height: 200,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.scenes.length,
|
||||
itemBuilder: (context, index) {
|
||||
@ -69,9 +67,12 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
right:
|
||||
isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
child: Column(
|
||||
children: [
|
||||
RoutineViewCard(
|
||||
isLoading: isLoading,
|
||||
sceneOnTap: () {
|
||||
context.read<RoutineBloc>().add(
|
||||
@ -81,20 +82,25 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
},
|
||||
status: state.scenes[index].status,
|
||||
communityId:
|
||||
state.scenes[index].communityId ?? '',
|
||||
state.scenes[index].communityId ??
|
||||
'',
|
||||
spaceId: state.scenes[index].spaceId,
|
||||
sceneId: state.scenes[index].sceneTuyaId!,
|
||||
sceneId:
|
||||
state.scenes[index].sceneTuyaId!,
|
||||
automationId: state.scenes[index].id,
|
||||
cardType: 'scenes',
|
||||
spaceName: state.scenes[index].spaceName,
|
||||
spaceName:
|
||||
state.scenes[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
BlocProvider.of<RoutineBloc>(context)
|
||||
.add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetSceneDetails(
|
||||
sceneId: state.scenes[index].id,
|
||||
sceneId:
|
||||
state.scenes[index].id,
|
||||
isTabToRun: true,
|
||||
isUpdate: true,
|
||||
),
|
||||
@ -104,7 +110,10 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
icon: state.scenes[index].icon ??
|
||||
Assets.logoHorizontal,
|
||||
isFromScenes: true,
|
||||
iconInBytes: state.scenes[index].iconInBytes,
|
||||
iconInBytes:
|
||||
state.scenes[index].iconInBytes,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
@ -117,80 +126,91 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
const SizedBox(height: 3),
|
||||
if (state.automations.isEmpty)
|
||||
Expanded(
|
||||
child: Text(
|
||||
Text(
|
||||
"No automations found",
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state.automations.isNotEmpty)
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: isSmallScreenSize(context) ? 185 : 192,
|
||||
maxWidth: MediaQuery.sizeOf(context).width * 0.7),
|
||||
SizedBox(
|
||||
height: 200,
|
||||
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.automations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final isLoading = state.automations!
|
||||
.contains(state.automations[index].id);
|
||||
|
||||
return Padding(
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||
right: isSmallScreenSize(context)
|
||||
? 4.0
|
||||
: 8.0,
|
||||
),
|
||||
child: RoutineViewCard(
|
||||
isLoading: isLoading,
|
||||
onChanged: (v) {
|
||||
// BlocProvider.of<RoutineBloc>(context)
|
||||
context.read<RoutineBloc>().add(
|
||||
UpdateAutomationStatus(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
automationId: state
|
||||
.automations[index].id,
|
||||
automationStatusUpdate:
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: state
|
||||
.automations[index]
|
||||
.automations[
|
||||
index]
|
||||
.spaceId,
|
||||
isEnable: v),
|
||||
communityId: state
|
||||
.automations[index].communityId,
|
||||
.automations[index]
|
||||
.communityId,
|
||||
),
|
||||
);
|
||||
},
|
||||
status: state.automations[index].status,
|
||||
communityId: '',
|
||||
spaceId: state.automations[index].spaceId,
|
||||
spaceId:
|
||||
state.automations[index].spaceId,
|
||||
sceneId: '',
|
||||
automationId: state.automations[index].id,
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
cardType: 'automations',
|
||||
spaceName: state.scenes[index].spaceName,
|
||||
spaceName:
|
||||
state.automations[index].spaceName,
|
||||
onTap: () {
|
||||
BlocProvider.of<RoutineBloc>(context).add(
|
||||
BlocProvider.of<RoutineBloc>(context)
|
||||
.add(
|
||||
const CreateNewRoutineViewEvent(
|
||||
createRoutineView: true),
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetAutomationDetails(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
automationId: state
|
||||
.automations[index].id,
|
||||
isAutomation: true,
|
||||
isUpdate: true),
|
||||
);
|
||||
},
|
||||
textString: state.automations[index].name,
|
||||
textString:
|
||||
state.automations[index].name,
|
||||
icon: state.automations[index].icon ??
|
||||
Assets.automation,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -106,10 +106,10 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
if (widget.isFromScenes ?? false)
|
||||
InkWell(
|
||||
onTap: _handleSceneTap,
|
||||
child: SvgPicture.asset(
|
||||
child: Image.asset(
|
||||
_showTemporaryCheck
|
||||
? Assets.scenesPlayIconCheck
|
||||
: Assets.scenesPlayIcon,
|
||||
? Assets.scenesPlayIcon
|
||||
: Assets.scenesPlayIconCheck,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
)
|
||||
@ -177,6 +177,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
||||
: (widget.icon is String &&
|
||||
widget.icon.endsWith('.svg'))
|
||||
? SvgPicture.asset(
|
||||
height: iconSize,
|
||||
width: iconSize,
|
||||
widget.icon,
|
||||
fit: BoxFit.contain,
|
||||
)
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
||||
|
||||
@ -18,6 +17,8 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
||||
context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
||||
}
|
||||
|
||||
static const _allowedProductTypes = {'AC', '1G', '2G', '3G', 'WPS', 'GW'};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||
@ -32,13 +33,8 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
||||
}
|
||||
});
|
||||
|
||||
List<AllDevicesModel> deviceList = state.devices
|
||||
.where((device) =>
|
||||
device.productType == 'AC' ||
|
||||
device.productType == '1G' ||
|
||||
device.productType == '2G' ||
|
||||
device.productType == '3G' ||
|
||||
device.productType == 'WPS')
|
||||
final deviceList = state.devices
|
||||
.where((device) => _allowedProductTypes.contains(device.productType))
|
||||
.toList();
|
||||
|
||||
return Wrap(
|
||||
@ -46,37 +42,32 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
||||
runSpacing: 10,
|
||||
children: deviceList.asMap().entries.map((entry) {
|
||||
final device = entry.value;
|
||||
|
||||
final deviceData = {
|
||||
'device': device,
|
||||
'imagePath': device.getDefaultIcon(device.productType),
|
||||
'title': device.name ?? '',
|
||||
'deviceId': device.uuid,
|
||||
'productType': device.productType,
|
||||
'functions': device.functions,
|
||||
'uniqueCustomId': '',
|
||||
};
|
||||
|
||||
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
||||
return device.name!
|
||||
.toLowerCase()
|
||||
.contains(state.searchText!.toLowerCase())
|
||||
? DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
deviceData: {
|
||||
'device': device,
|
||||
'imagePath': device.getDefaultIcon(device.productType),
|
||||
'title': device.name ?? '',
|
||||
'deviceId': device.uuid,
|
||||
'productType': device.productType,
|
||||
'functions': device.functions,
|
||||
'uniqueCustomId': '',
|
||||
},
|
||||
imagePath: deviceData['imagePath'] as String,
|
||||
title: deviceData['title'] as String,
|
||||
deviceData: deviceData,
|
||||
)
|
||||
: Container();
|
||||
: const SizedBox.shrink();
|
||||
} else {
|
||||
return DraggableCard(
|
||||
imagePath: device.getDefaultIcon(device.productType),
|
||||
title: device.name ?? '',
|
||||
deviceData: {
|
||||
'device': device,
|
||||
'imagePath': device.getDefaultIcon(device.productType),
|
||||
'title': device.name ?? '',
|
||||
'deviceId': device.uuid,
|
||||
'productType': device.productType,
|
||||
'functions': device.functions,
|
||||
'uniqueCustomId': '',
|
||||
},
|
||||
imagePath: deviceData['imagePath'] as String,
|
||||
title: deviceData['title'] as String,
|
||||
deviceData: deviceData,
|
||||
);
|
||||
}
|
||||
}).toList(),
|
||||
|
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class RoutineDialogFunctionListTile extends StatelessWidget {
|
||||
const RoutineDialogFunctionListTile({
|
||||
super.key,
|
||||
required this.iconPath,
|
||||
required this.operationName,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final String iconPath;
|
||||
final String operationName;
|
||||
final void Function() onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
iconPath,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (context) => const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
operationName,
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class RoutineDialogSelectionListTile extends StatelessWidget {
|
||||
const RoutineDialogSelectionListTile({
|
||||
required this.iconPath,
|
||||
required this.description,
|
||||
required this.isSelected,
|
||||
required this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final bool isSelected;
|
||||
final String iconPath;
|
||||
final String description;
|
||||
final void Function() onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
iconPath,
|
||||
width: 24,
|
||||
height: 24,
|
||||
placeholderBuilder: (context) => Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
description,
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
@ -13,29 +13,38 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
|
||||
class ACHelper {
|
||||
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool? removeComparetors,
|
||||
) async {
|
||||
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required bool? removeComparetors,
|
||||
required String dialogType,
|
||||
}) async {
|
||||
List<ACFunction> acFunctions =
|
||||
functions.whereType<ACFunction>().where((function) {
|
||||
if (dialogType == 'THEN') {
|
||||
return function.type == 'THEN' || function.type == 'BOTH';
|
||||
}
|
||||
return function.type == 'IF' || function.type == 'BOTH';
|
||||
}).toList();
|
||||
// List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -65,8 +74,10 @@ class ACHelper {
|
||||
child: _buildFunctionsList(
|
||||
context: context,
|
||||
acFunctions: acFunctions,
|
||||
onFunctionSelected: (functionCode, operationName) =>
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
onFunctionSelected:
|
||||
(functionCode, operationName) => context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: functionCode,
|
||||
operationName: operationName,
|
||||
)),
|
||||
@ -194,7 +205,8 @@ class ACHelper {
|
||||
);
|
||||
}
|
||||
|
||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final selectedFn =
|
||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -290,7 +302,8 @@ class ACHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -384,9 +397,13 @@ class ACHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -398,7 +415,8 @@ class ACHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -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/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gateway.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_dialog_value_selector.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_functions_list.dart';
|
||||
|
||||
class GatewayDialog extends StatefulWidget {
|
||||
const GatewayDialog({
|
||||
required this.uniqueCustomId,
|
||||
required this.functions,
|
||||
required this.deviceSelectedFunctions,
|
||||
required this.device,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String? uniqueCustomId;
|
||||
final List<DeviceFunction> functions;
|
||||
final List<DeviceFunctionData> deviceSelectedFunctions;
|
||||
final AllDevicesModel? device;
|
||||
|
||||
@override
|
||||
State<GatewayDialog> createState() => _GatewayDialogState();
|
||||
}
|
||||
|
||||
class _GatewayDialogState extends State<GatewayDialog> {
|
||||
late final List<GatewayFunctions> _gatewayFunctions;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_gatewayFunctions = widget.functions.whereType<GatewayFunctions>().toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
return Container(
|
||||
width: selectedFunction != null ? 600 : 360,
|
||||
height: 450,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const DialogHeader('Gateway Conditions'),
|
||||
Expanded(child: _buildMainContent(context, state)),
|
||||
_buildDialogFooter(context, state),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainContent(BuildContext context, FunctionBlocState state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData = state.addedFunctions.firstWhere(
|
||||
(f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
operationName: '',
|
||||
value: null,
|
||||
),
|
||||
);
|
||||
final selectedGatewayFunctions = _gatewayFunctions.firstWhere(
|
||||
(f) => f.code == selectedFunction,
|
||||
orElse: () => GatewaySwitchAlarmSound(
|
||||
deviceId: '',
|
||||
deviceName: '',
|
||||
type: '',
|
||||
),
|
||||
);
|
||||
final operations = selectedGatewayFunctions.getOperationalValues();
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
GatewayFunctionsList(gatewayFunctions: _gatewayFunctions),
|
||||
if (state.selectedFunction != null)
|
||||
Expanded(
|
||||
child: GatewayDialogValueSelector(
|
||||
operations: operations,
|
||||
selectedFunction: selectedFunction ?? '',
|
||||
selectedFunctionData: selectedFunctionData,
|
||||
gatewayFunctions: _gatewayFunctions,
|
||||
operationName: selectedOperationName ?? '',
|
||||
device: widget.device,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDialogFooter(BuildContext context, FunctionBlocState state) {
|
||||
return DialogFooter(
|
||||
onCancel: () => Navigator.pop(context),
|
||||
onConfirm: state.addedFunctions.isNotEmpty
|
||||
? () {
|
||||
context.read<RoutineBloc>().add(
|
||||
AddFunctionToRoutine(
|
||||
state.addedFunctions,
|
||||
widget.uniqueCustomId ?? '-1',
|
||||
),
|
||||
);
|
||||
Navigator.pop(
|
||||
context,
|
||||
{'deviceId': widget.functions.firstOrNull?.deviceId},
|
||||
);
|
||||
}
|
||||
: null,
|
||||
isConfirmEnabled: state.selectedFunction != null,
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gateway.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialog_selection_list_tile.dart';
|
||||
|
||||
class GatewayDialogValueSelector extends StatelessWidget {
|
||||
const GatewayDialogValueSelector({
|
||||
required this.operations,
|
||||
required this.selectedFunction,
|
||||
required this.selectedFunctionData,
|
||||
required this.gatewayFunctions,
|
||||
required this.device,
|
||||
required this.operationName,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final List<GatewayOperationalValue> operations;
|
||||
final String selectedFunction;
|
||||
final DeviceFunctionData? selectedFunctionData;
|
||||
final List<GatewayFunctions> gatewayFunctions;
|
||||
final AllDevicesModel? device;
|
||||
final String operationName;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
itemCount: operations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final operation = operations[index];
|
||||
final isSelected = selectedFunctionData?.value == operation.value;
|
||||
return RoutineDialogSelectionListTile(
|
||||
iconPath: operation.icon,
|
||||
description: operation.description,
|
||||
isSelected: isSelected,
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
context.read<FunctionBloc>().add(
|
||||
AddFunction(
|
||||
functionData: DeviceFunctionData(
|
||||
entityId: device?.uuid ?? '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: operationName,
|
||||
value: operation.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gateway.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialog_function_list_tile.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class GatewayFunctionsList extends StatelessWidget {
|
||||
const GatewayFunctionsList({
|
||||
required this.gatewayFunctions,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final List<GatewayFunctions> gatewayFunctions;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 360,
|
||||
child: ListView.separated(
|
||||
shrinkWrap: false,
|
||||
itemCount: gatewayFunctions.length,
|
||||
separatorBuilder: (context, index) => const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 40.0),
|
||||
child: Divider(color: ColorsManager.dividerColor),
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final function = gatewayFunctions[index];
|
||||
return RoutineDialogFunctionListTile(
|
||||
iconPath: function.icon,
|
||||
operationName: function.operationName,
|
||||
onTap: () => context.read<FunctionBloc>().add(
|
||||
SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_dialog.dart';
|
||||
|
||||
abstract final class GatewayHelper {
|
||||
const GatewayHelper._();
|
||||
|
||||
static Future<Map<String, dynamic>?> showGatewayFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required String? uniqueCustomId,
|
||||
required List<DeviceFunctionData> deviceSelectedFunctions,
|
||||
required AllDevicesModel? device,
|
||||
}) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => BlocProvider<FunctionBloc>(
|
||||
create: (context) => FunctionBloc()
|
||||
..add(
|
||||
InitializeFunctions(deviceSelectedFunctions),
|
||||
),
|
||||
child: GatewayDialog(
|
||||
uniqueCustomId: uniqueCustomId,
|
||||
functions: functions,
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
device: device,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -5,8 +5,10 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||
@ -14,29 +16,32 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class OneGangSwitchHelper {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
List<BaseSwitchFunction> acFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||
required String dialogType,
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required bool removeComparetors,
|
||||
}) async {
|
||||
List<BaseSwitchFunction> oneGangFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -61,12 +66,12 @@ class OneGangSwitchHelper {
|
||||
// Left side: Function list
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: acFunctions.length,
|
||||
itemCount: oneGangFunctions.length,
|
||||
separatorBuilder: (_, __) => const Divider(
|
||||
color: ColorsManager.dividerColor,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
final function = acFunctions[index];
|
||||
final function = oneGangFunctions[index];
|
||||
return ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
function.icon,
|
||||
@ -83,9 +88,12 @@ class OneGangSwitchHelper {
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
operationName:
|
||||
function.operationName,
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -99,7 +107,7 @@ class OneGangSwitchHelper {
|
||||
context: context,
|
||||
selectedFunction: selectedFunction,
|
||||
selectedFunctionData: selectedFunctionData,
|
||||
acFunctions: acFunctions,
|
||||
acFunctions: oneGangFunctions,
|
||||
device: device,
|
||||
operationName: selectedOperationName ?? '',
|
||||
removeComparetors: removeComparetors,
|
||||
@ -174,8 +182,14 @@ class OneGangSwitchHelper {
|
||||
removeComparetors: removeComparetors,
|
||||
);
|
||||
}
|
||||
final selectedFn = acFunctions.firstWhere(
|
||||
(f) => f.code == selectedFunction,
|
||||
orElse: () => OneGangSwitchFunction(
|
||||
deviceId: '',
|
||||
deviceName: '',
|
||||
),
|
||||
);
|
||||
|
||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -212,11 +226,11 @@ class OneGangSwitchHelper {
|
||||
selectedFunctionData,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownDisplay(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownSlider(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -257,7 +271,8 @@ class OneGangSwitchHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -305,7 +320,8 @@ class OneGangSwitchHelper {
|
||||
value: (initialValue ?? 0).toDouble(),
|
||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||
divisions: (((operationalValues.maxValue ?? 0) -
|
||||
(operationalValues.minValue ?? 0)) /
|
||||
(operationalValues.stepValue ?? 1))
|
||||
.round(),
|
||||
onChanged: (value) {
|
||||
@ -357,9 +373,13 @@ class OneGangSwitchHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -371,7 +391,8 @@ class OneGangSwitchHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -14,14 +14,15 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class ThreeGangSwitchHelper {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required String dialogType,
|
||||
required bool removeComparetors,
|
||||
}) async {
|
||||
List<BaseSwitchFunction> switchFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
|
@ -14,29 +14,32 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class TwoGangSwitchHelper {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required bool removeComparetors,
|
||||
required String dialogType,
|
||||
}) async {
|
||||
List<BaseSwitchFunction> switchFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -83,9 +86,12 @@ class TwoGangSwitchHelper {
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
operationName:
|
||||
function.operationName,
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -161,7 +167,8 @@ class TwoGangSwitchHelper {
|
||||
required String operationName,
|
||||
required bool removeComparetors,
|
||||
}) {
|
||||
if (selectedFunction == 'countdown_1' || selectedFunction == 'countdown_2') {
|
||||
if (selectedFunction == 'countdown_1' ||
|
||||
selectedFunction == 'countdown_2') {
|
||||
final initialValue = selectedFunctionData?.value ?? 200;
|
||||
return _buildTemperatureSelector(
|
||||
context: context,
|
||||
@ -175,7 +182,8 @@ class TwoGangSwitchHelper {
|
||||
);
|
||||
}
|
||||
|
||||
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final selectedFn =
|
||||
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -212,11 +220,11 @@ class TwoGangSwitchHelper {
|
||||
selectedFunctionData,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownDisplay(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownSlider(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -257,7 +265,8 @@ class TwoGangSwitchHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -305,7 +314,8 @@ class TwoGangSwitchHelper {
|
||||
value: (initialValue ?? 0).toDouble(),
|
||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||
divisions: (((operationalValues.maxValue ?? 0) -
|
||||
(operationalValues.minValue ?? 0)) /
|
||||
(operationalValues.stepValue ?? 1))
|
||||
.round(),
|
||||
onChanged: (value) {
|
||||
@ -357,9 +367,13 @@ class TwoGangSwitchHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -371,7 +385,8 @@ class TwoGangSwitchHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
@ -28,9 +27,12 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_hoursController = FixedExtentScrollController(initialItem: widget.initialHours);
|
||||
_minutesController = FixedExtentScrollController(initialItem: widget.initialMinutes);
|
||||
_secondsController = FixedExtentScrollController(initialItem: widget.initialSeconds);
|
||||
_hoursController =
|
||||
FixedExtentScrollController(initialItem: widget.initialHours);
|
||||
_minutesController =
|
||||
FixedExtentScrollController(initialItem: widget.initialMinutes);
|
||||
_secondsController =
|
||||
FixedExtentScrollController(initialItem: widget.initialSeconds);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -47,6 +49,8 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_hoursController.dispose();
|
||||
@ -63,24 +67,26 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
|
||||
_buildPickerColumn(
|
||||
label: 'h',
|
||||
controller: _hoursController,
|
||||
itemCount: 24,
|
||||
onChanged: (value) => _handleTimeChange(
|
||||
itemCount: 3,
|
||||
onChanged: (value) {
|
||||
_handleTimeChange(
|
||||
value,
|
||||
_minutesController.selectedItem,
|
||||
_secondsController.selectedItem,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
const SizedBox(width: 5),
|
||||
_buildPickerColumn(
|
||||
label: 'm',
|
||||
controller: _minutesController,
|
||||
itemCount: 60,
|
||||
onChanged: (value) => _handleTimeChange(
|
||||
onChanged: (value) {
|
||||
_handleTimeChange(
|
||||
_hoursController.selectedItem,
|
||||
value,
|
||||
_secondsController.selectedItem,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
const SizedBox(width: 5),
|
||||
_buildPickerColumn(
|
||||
label: 's',
|
||||
@ -97,6 +103,19 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
|
||||
}
|
||||
|
||||
void _handleTimeChange(int hours, int minutes, int seconds) {
|
||||
int total = hours * 3600 + minutes * 60 + seconds;
|
||||
if (total > 10000) {
|
||||
hours = 2;
|
||||
minutes = 46;
|
||||
seconds = 40;
|
||||
total = 10000;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_hoursController.jumpToItem(hours);
|
||||
_minutesController.jumpToItem(minutes);
|
||||
_secondsController.jumpToItem(seconds);
|
||||
});
|
||||
}
|
||||
|
||||
widget.onTimeChanged(hours, minutes, seconds);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
|
||||
|
||||
class WallPresenceSensor extends StatefulWidget {
|
||||
final List<DeviceFunction> functions;
|
||||
final AllDevicesModel? device;
|
||||
@ -171,7 +170,7 @@ class _WallPresenceSensorState extends State<WallPresenceSensor> {
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction,
|
||||
operationName: '',
|
||||
operationName: state.selectedOperationName ?? '',
|
||||
value: null,
|
||||
),
|
||||
);
|
||||
@ -251,11 +250,8 @@ class _ValueSelector extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
bool _isSliderFunction(String function) => [
|
||||
'current_distance',
|
||||
'presence_time',
|
||||
'illuminance_value'
|
||||
].contains(function);
|
||||
bool _isSliderFunction(String function) =>
|
||||
['dis_current', 'presence_time', 'illuminance_value'].contains(function);
|
||||
}
|
||||
|
||||
class _SliderValueSelector extends StatelessWidget {
|
||||
@ -382,7 +378,7 @@ class _ValueDisplay extends StatelessWidget {
|
||||
switch (functionCode) {
|
||||
case 'presence_time':
|
||||
return '$intValue Min';
|
||||
case 'current_distance':
|
||||
case 'dis_current':
|
||||
return '$intValue CM';
|
||||
case 'illuminance_value':
|
||||
return '$intValue Lux';
|
||||
@ -421,7 +417,7 @@ class _FunctionSlider extends StatelessWidget {
|
||||
switch (functionCode) {
|
||||
case 'presence_time':
|
||||
return (0, 65535);
|
||||
case 'current_distance':
|
||||
case 'dis_current':
|
||||
return (1, 600);
|
||||
case 'illuminance_value':
|
||||
return (0, 10000);
|
||||
|
@ -113,7 +113,8 @@ class ThenContainer extends StatelessWidget {
|
||||
'1G',
|
||||
'2G',
|
||||
'3G',
|
||||
'WPS'
|
||||
'WPS',
|
||||
"GW",
|
||||
].contains(state.thenItems[index]
|
||||
['productType'])) {
|
||||
context.read<RoutineBloc>().add(
|
||||
@ -229,7 +230,7 @@ class ThenContainer extends StatelessWidget {
|
||||
dialogType: "THEN");
|
||||
if (result != null) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
||||
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW']
|
||||
.contains(mutableData['productType'])) {
|
||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
@ -18,7 +21,10 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
on<ClearCachedData>(_clearCachedData);
|
||||
on<OnCommunityAdded>(_onCommunityAdded);
|
||||
on<OnCommunityUpdated>(_onCommunityUpdate);
|
||||
on<PaginationEvent>(_fetchPaginationSpaces);
|
||||
on<DebouncedSearchEvent>(_onDebouncedSearch);
|
||||
}
|
||||
Timer _timer = Timer(const Duration(microseconds: 0), () {});
|
||||
|
||||
void _onCommunityUpdate(
|
||||
OnCommunityUpdated event,
|
||||
@ -28,17 +34,16 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
|
||||
try {
|
||||
final updatedCommunity = event.updatedCommunity;
|
||||
final updatedCommunities =
|
||||
List<CommunityModel>.from(state.communityList);
|
||||
final updatedCommunities = List<CommunityModel>.from(state.communityList);
|
||||
|
||||
final index = updatedCommunities
|
||||
.indexWhere((community) => community.uuid == updatedCommunity.uuid);
|
||||
final index =
|
||||
updatedCommunities.indexWhere((community) => community.uuid == updatedCommunity.uuid);
|
||||
|
||||
if (index != -1) {
|
||||
updatedCommunities[index] = updatedCommunity;
|
||||
emit(state.copyWith(communitiesList: updatedCommunities));
|
||||
} else {
|
||||
emit(SpaceTreeErrorState('Community not found in the list.'));
|
||||
emit(const SpaceTreeErrorState('Community not found in the list.'));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(SpaceTreeErrorState('Error updating community: $e'));
|
||||
@ -50,48 +55,68 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
List<CommunityModel> communities =
|
||||
await CommunitySpaceManagementApi().fetchCommunities(projectUuid);
|
||||
PaginationModel paginationModel = await CommunitySpaceManagementApi()
|
||||
.fetchCommunitiesAndSpaces(projectId: projectUuid, page: 1);
|
||||
|
||||
List<CommunityModel> updatedCommunities = await Future.wait(
|
||||
communities.map((community) async {
|
||||
List<SpaceModel> spaces = await CommunitySpaceManagementApi()
|
||||
.getSpaceHierarchy(community.uuid, projectUuid);
|
||||
// List<CommunityModel> updatedCommunities = await Future.wait(
|
||||
// communities.map((community) async {
|
||||
// List<SpaceModel> spaces =
|
||||
// await CommunitySpaceManagementApi().getSpaceHierarchy(community.uuid, projectUuid);
|
||||
|
||||
return CommunityModel(
|
||||
uuid: community.uuid,
|
||||
createdAt: community.createdAt,
|
||||
updatedAt: community.updatedAt,
|
||||
name: community.name,
|
||||
description: community.description,
|
||||
spaces: spaces,
|
||||
region: community.region,
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
// return CommunityModel(
|
||||
// uuid: community.uuid,
|
||||
// createdAt: community.createdAt,
|
||||
// updatedAt: community.updatedAt,
|
||||
// name: community.name,
|
||||
// description: community.description,
|
||||
// spaces: spaces,
|
||||
// region: community.region,
|
||||
// );
|
||||
// }).toList(),
|
||||
// );
|
||||
|
||||
emit(state.copyWith(
|
||||
communitiesList: updatedCommunities,
|
||||
communitiesList: paginationModel.communities,
|
||||
expandedCommunity: [],
|
||||
expandedSpaces: []));
|
||||
expandedSpaces: [],
|
||||
paginationModel: paginationModel));
|
||||
} catch (e) {
|
||||
emit(SpaceTreeErrorState('Error loading communities and spaces: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
void _onCommunityAdded(
|
||||
OnCommunityAdded event, Emitter<SpaceTreeState> emit) async {
|
||||
_fetchPaginationSpaces(PaginationEvent event, Emitter<SpaceTreeState> emit) async {
|
||||
emit(state.copyWith(paginationIsLoading: true));
|
||||
PaginationModel paginationModel = event.paginationModel;
|
||||
List<CommunityModel> communities = List<CommunityModel>.from(event.communities);
|
||||
try {
|
||||
if (paginationModel.hasNext && state.searchQuery.isEmpty) {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
paginationModel = await CommunitySpaceManagementApi().fetchCommunitiesAndSpaces(
|
||||
projectId: projectUuid, page: paginationModel.pageNum, search: state.searchQuery);
|
||||
|
||||
communities.addAll(paginationModel.communities);
|
||||
}
|
||||
} catch (e) {
|
||||
emit(SpaceTreeErrorState('Error loading communities and spaces: $e'));
|
||||
}
|
||||
emit(state.copyWith(
|
||||
communitiesList: communities,
|
||||
paginationModel: paginationModel,
|
||||
paginationIsLoading: false));
|
||||
}
|
||||
|
||||
void _onCommunityAdded(OnCommunityAdded event, Emitter<SpaceTreeState> emit) async {
|
||||
final updatedCommunities = List<CommunityModel>.from(state.communityList);
|
||||
updatedCommunities.add(event.newCommunity);
|
||||
|
||||
emit(state.copyWith(communitiesList: updatedCommunities));
|
||||
}
|
||||
|
||||
_onCommunityExpanded(
|
||||
OnCommunityExpanded event, Emitter<SpaceTreeState> emit) async {
|
||||
_onCommunityExpanded(OnCommunityExpanded event, Emitter<SpaceTreeState> emit) async {
|
||||
try {
|
||||
List<String> updatedExpandedCommunityList =
|
||||
List.from(state.expandedCommunities);
|
||||
List<String> updatedExpandedCommunityList = List.from(state.expandedCommunities);
|
||||
|
||||
if (updatedExpandedCommunityList.contains(event.communityId)) {
|
||||
updatedExpandedCommunityList.remove(event.communityId);
|
||||
@ -123,19 +148,14 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
}
|
||||
}
|
||||
|
||||
_onCommunitySelected(
|
||||
OnCommunitySelected event, Emitter<SpaceTreeState> emit) async {
|
||||
_onCommunitySelected(OnCommunitySelected event, Emitter<SpaceTreeState> emit) async {
|
||||
try {
|
||||
List<String> updatedSelectedCommunities =
|
||||
List.from(state.selectedCommunities.toSet().toList());
|
||||
List<String> updatedSelectedSpaces =
|
||||
List.from(state.selectedSpaces.toSet().toList());
|
||||
List<String> updatedSoldChecks =
|
||||
List.from(state.soldCheck.toSet().toList());
|
||||
Map<String, List<String>> communityAndSpaces =
|
||||
Map.from(state.selectedCommunityAndSpaces);
|
||||
List<String> selectedSpacesInCommunity =
|
||||
communityAndSpaces[event.communityId] ?? [];
|
||||
List<String> updatedSelectedSpaces = List.from(state.selectedSpaces.toSet().toList());
|
||||
List<String> updatedSoldChecks = List.from(state.soldCheck.toSet().toList());
|
||||
Map<String, List<String>> communityAndSpaces = Map.from(state.selectedCommunityAndSpaces);
|
||||
List<String> selectedSpacesInCommunity = communityAndSpaces[event.communityId] ?? [];
|
||||
|
||||
List<String> childrenIds = _getAllChildIds(event.children);
|
||||
|
||||
@ -168,15 +188,11 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
try {
|
||||
List<String> updatedSelectedCommunities =
|
||||
List.from(state.selectedCommunities.toSet().toList());
|
||||
List<String> updatedSelectedSpaces =
|
||||
List.from(state.selectedSpaces.toSet().toList());
|
||||
List<String> updatedSoldChecks =
|
||||
List.from(state.soldCheck.toSet().toList());
|
||||
Map<String, List<String>> communityAndSpaces =
|
||||
Map.from(state.selectedCommunityAndSpaces);
|
||||
List<String> updatedSelectedSpaces = List.from(state.selectedSpaces.toSet().toList());
|
||||
List<String> updatedSoldChecks = List.from(state.soldCheck.toSet().toList());
|
||||
Map<String, List<String>> communityAndSpaces = Map.from(state.selectedCommunityAndSpaces);
|
||||
|
||||
List<String> selectedSpacesInCommunity =
|
||||
communityAndSpaces[event.communityModel.uuid] ?? [];
|
||||
List<String> selectedSpacesInCommunity = communityAndSpaces[event.communityModel.uuid] ?? [];
|
||||
|
||||
List<String> childrenIds = _getAllChildIds(event.children);
|
||||
bool isChildSelected = false;
|
||||
@ -199,11 +215,9 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
selectedSpacesInCommunity.addAll(childrenIds);
|
||||
}
|
||||
|
||||
List<String> spaces =
|
||||
_getThePathToChild(event.communityModel.uuid, event.spaceId);
|
||||
List<String> spaces = _getThePathToChild(event.communityModel.uuid, event.spaceId);
|
||||
for (String space in spaces) {
|
||||
if (!updatedSelectedSpaces.contains(space) &&
|
||||
!updatedSoldChecks.contains(space)) {
|
||||
if (!updatedSelectedSpaces.contains(space) && !updatedSoldChecks.contains(space)) {
|
||||
updatedSoldChecks.add(space);
|
||||
}
|
||||
}
|
||||
@ -226,9 +240,7 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
updatedSoldChecks.remove(event.spaceId);
|
||||
|
||||
List<String> parents =
|
||||
_getThePathToChild(event.communityModel.uuid, event.spaceId)
|
||||
.toSet()
|
||||
.toList();
|
||||
_getThePathToChild(event.communityModel.uuid, event.spaceId).toSet().toList();
|
||||
|
||||
if (updatedSelectedSpaces.isEmpty) {
|
||||
updatedSoldChecks.removeWhere(parents.contains);
|
||||
@ -236,8 +248,7 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
} else {
|
||||
// Check if any parent has selected children
|
||||
for (String space in parents) {
|
||||
if (!_noChildrenSelected(
|
||||
event.communityModel, space, updatedSelectedSpaces, parents)) {
|
||||
if (!_noChildrenSelected(event.communityModel, space, updatedSelectedSpaces, parents)) {
|
||||
updatedSoldChecks.remove(space);
|
||||
}
|
||||
}
|
||||
@ -262,8 +273,8 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
}
|
||||
}
|
||||
|
||||
_noChildrenSelected(CommunityModel community, String spaceId,
|
||||
List<String> selectedSpaces, List<String> parents) {
|
||||
_noChildrenSelected(
|
||||
CommunityModel community, String spaceId, List<String> selectedSpaces, List<String> parents) {
|
||||
if (selectedSpaces.contains(spaceId)) {
|
||||
return true;
|
||||
}
|
||||
@ -285,29 +296,52 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
|
||||
_onSearch(SearchQueryEvent event, Emitter<SpaceTreeState> emit) async {
|
||||
try {
|
||||
List<CommunityModel> communities = List.from(state.communityList);
|
||||
List<CommunityModel> filteredCommunity = [];
|
||||
const duration = Duration(seconds: 1);
|
||||
if (_timer.isActive) {
|
||||
_timer.cancel(); // clear timer
|
||||
}
|
||||
_timer = Timer(duration, () async => add(DebouncedSearchEvent(event.searchQuery)));
|
||||
|
||||
// List<CommunityModel> communities = List.from(state.communityList);
|
||||
// List<CommunityModel> filteredCommunity = [];
|
||||
|
||||
// Filter communities and expand only those that match the query
|
||||
filteredCommunity = communities.where((community) {
|
||||
final containsQueryInCommunity = community.name
|
||||
.toLowerCase()
|
||||
.contains(event.searchQuery.toLowerCase());
|
||||
final containsQueryInSpaces = community.spaces.any(
|
||||
(space) => _containsQuery(space, event.searchQuery.toLowerCase()));
|
||||
// filteredCommunity = communities.where((community) {
|
||||
// final containsQueryInCommunity =
|
||||
// community.name.toLowerCase().contains(event.searchQuery.toLowerCase());
|
||||
// final containsQueryInSpaces =
|
||||
// community.spaces.any((space) => _containsQuery(space, event.searchQuery.toLowerCase()));
|
||||
|
||||
return containsQueryInCommunity || containsQueryInSpaces;
|
||||
}).toList();
|
||||
// return containsQueryInCommunity || containsQueryInSpaces;
|
||||
// }).toList();
|
||||
|
||||
emit(state.copyWith(
|
||||
filteredCommunity: filteredCommunity,
|
||||
isSearching: event.searchQuery.isNotEmpty,
|
||||
searchQuery: event.searchQuery));
|
||||
// emit(state.copyWith(
|
||||
// filteredCommunity: filteredCommunity,
|
||||
// isSearching: event.searchQuery.isNotEmpty,
|
||||
// searchQuery: event.searchQuery));
|
||||
} catch (e) {
|
||||
emit(const SpaceTreeErrorState('Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
_onDebouncedSearch(DebouncedSearchEvent event, Emitter<SpaceTreeState> emit) async {
|
||||
emit(state.copyWith(
|
||||
isSearching: true,
|
||||
));
|
||||
PaginationModel paginationModel = const PaginationModel.emptyConstructor();
|
||||
try {
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
paginationModel = await CommunitySpaceManagementApi()
|
||||
.fetchCommunitiesAndSpaces(projectId: projectUuid, page: 1, search: event.searchQuery);
|
||||
} catch (_) {}
|
||||
|
||||
emit(state.copyWith(
|
||||
filteredCommunity: paginationModel.communities,
|
||||
isSearching: false,
|
||||
searchQuery: event.searchQuery));
|
||||
}
|
||||
|
||||
_clearAllData(ClearAllData event, Emitter<SpaceTreeState> emit) async {
|
||||
try {
|
||||
emit(state.copyWith(
|
||||
@ -345,13 +379,13 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
}
|
||||
|
||||
// Helper function to determine if any space or its children match the search query
|
||||
bool _containsQuery(SpaceModel space, String query) {
|
||||
final matchesSpace = space.name.toLowerCase().contains(query);
|
||||
final matchesChildren = space.children.any((child) =>
|
||||
_containsQuery(child, query)); // Recursive check for children
|
||||
// bool _containsQuery(SpaceModel space, String query) {
|
||||
// final matchesSpace = space.name.toLowerCase().contains(query);
|
||||
// final matchesChildren =
|
||||
// space.children.any((child) => _containsQuery(child, query)); // Recursive check for children
|
||||
|
||||
return matchesSpace || matchesChildren;
|
||||
}
|
||||
// return matchesSpace || matchesChildren;
|
||||
// }
|
||||
|
||||
List<String> _getAllChildIds(List<SpaceModel> spaces) {
|
||||
List<String> ids = [];
|
||||
@ -371,8 +405,8 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
return children;
|
||||
}
|
||||
|
||||
bool _anySpacesSelectedInCommunity(CommunityModel community,
|
||||
List<String> selectedSpaces, List<String> partialCheckedList) {
|
||||
bool _anySpacesSelectedInCommunity(
|
||||
CommunityModel community, List<String> selectedSpaces, List<String> partialCheckedList) {
|
||||
bool result = false;
|
||||
List<String> ids = _getAllChildIds(community.spaces);
|
||||
for (var id in ids) {
|
||||
@ -401,8 +435,7 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
return ids;
|
||||
}
|
||||
|
||||
List<String> _getAllParentsIds(
|
||||
SpaceModel child, String spaceId, List<String> listIds) {
|
||||
List<String> _getAllParentsIds(SpaceModel child, String spaceId, List<String> listIds) {
|
||||
List<String> ids = listIds;
|
||||
|
||||
ids.add(child.uuid ?? '');
|
||||
@ -426,6 +459,7 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
|
||||
@override
|
||||
Future<void> close() async {
|
||||
_timer.cancel();
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
@ -11,6 +12,16 @@ class SpaceTreeEvent extends Equatable {
|
||||
|
||||
class InitialEvent extends SpaceTreeEvent {}
|
||||
|
||||
class PaginationEvent extends SpaceTreeEvent {
|
||||
final PaginationModel paginationModel;
|
||||
final List<CommunityModel> communities;
|
||||
|
||||
const PaginationEvent(this.paginationModel, this.communities);
|
||||
|
||||
@override
|
||||
List<Object> get props => [paginationModel, communities];
|
||||
}
|
||||
|
||||
class SearchForSpace extends SpaceTreeEvent {
|
||||
final String searchQuery;
|
||||
|
||||
@ -69,6 +80,15 @@ class SearchQueryEvent extends SpaceTreeEvent {
|
||||
List<Object> get props => [searchQuery];
|
||||
}
|
||||
|
||||
class DebouncedSearchEvent extends SpaceTreeEvent {
|
||||
final String searchQuery;
|
||||
|
||||
const DebouncedSearchEvent(this.searchQuery);
|
||||
|
||||
@override
|
||||
List<Object> get props => [searchQuery];
|
||||
}
|
||||
|
||||
class OnCommunityAdded extends SpaceTreeEvent {
|
||||
final CommunityModel newCommunity;
|
||||
const OnCommunityAdded(this.newCommunity);
|
||||
@ -85,7 +105,6 @@ class OnCommunityUpdated extends SpaceTreeEvent {
|
||||
List<Object> get props => [updatedCommunity];
|
||||
}
|
||||
|
||||
|
||||
class ClearAllData extends SpaceTreeEvent {}
|
||||
|
||||
class ClearCachedData extends SpaceTreeEvent {}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
|
||||
class SpaceTreeState extends Equatable {
|
||||
@ -12,6 +13,8 @@ class SpaceTreeState extends Equatable {
|
||||
final List<String> soldCheck;
|
||||
final bool isSearching;
|
||||
final String searchQuery;
|
||||
final PaginationModel paginationModel;
|
||||
final bool paginationIsLoading;
|
||||
|
||||
const SpaceTreeState(
|
||||
{this.communityList = const [],
|
||||
@ -23,7 +26,9 @@ class SpaceTreeState extends Equatable {
|
||||
this.soldCheck = const [],
|
||||
this.isSearching = false,
|
||||
this.selectedCommunityAndSpaces = const {},
|
||||
this.searchQuery = ''});
|
||||
this.searchQuery = '',
|
||||
this.paginationModel = const PaginationModel.emptyConstructor(),
|
||||
this.paginationIsLoading = false});
|
||||
|
||||
SpaceTreeState copyWith(
|
||||
{List<CommunityModel>? communitiesList,
|
||||
@ -35,7 +40,9 @@ class SpaceTreeState extends Equatable {
|
||||
List<String>? soldCheck,
|
||||
bool? isSearching,
|
||||
Map<String, List<String>>? selectedCommunityAndSpaces,
|
||||
String? searchQuery}) {
|
||||
String? searchQuery,
|
||||
PaginationModel? paginationModel,
|
||||
bool? paginationIsLoading}) {
|
||||
return SpaceTreeState(
|
||||
communityList: communitiesList ?? this.communityList,
|
||||
filteredCommunity: filteredCommunity ?? this.filteredCommunity,
|
||||
@ -46,7 +53,9 @@ class SpaceTreeState extends Equatable {
|
||||
soldCheck: soldCheck ?? this.soldCheck,
|
||||
isSearching: isSearching ?? this.isSearching,
|
||||
selectedCommunityAndSpaces: selectedCommunityAndSpaces ?? this.selectedCommunityAndSpaces,
|
||||
searchQuery: searchQuery ?? this.searchQuery);
|
||||
searchQuery: searchQuery ?? this.searchQuery,
|
||||
paginationModel: paginationModel ?? this.paginationModel,
|
||||
paginationIsLoading: paginationIsLoading ?? this.paginationIsLoading);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -60,7 +69,9 @@ class SpaceTreeState extends Equatable {
|
||||
soldCheck,
|
||||
isSearching,
|
||||
selectedCommunityAndSpaces,
|
||||
searchQuery
|
||||
searchQuery,
|
||||
paginationModel,
|
||||
paginationIsLoading
|
||||
];
|
||||
}
|
||||
|
||||
|
20
lib/pages/space_tree/model/pagination_model.dart
Normal file
20
lib/pages/space_tree/model/pagination_model.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
|
||||
class PaginationModel {
|
||||
final int pageNum;
|
||||
final bool hasNext;
|
||||
final int size;
|
||||
final List<CommunityModel> communities;
|
||||
|
||||
const PaginationModel(
|
||||
{required this.pageNum,
|
||||
required this.hasNext,
|
||||
required this.size,
|
||||
required this.communities});
|
||||
|
||||
const PaginationModel.emptyConstructor()
|
||||
: pageNum = 1,
|
||||
hasNext = true,
|
||||
size = 10,
|
||||
communities = const [];
|
||||
}
|
@ -34,7 +34,8 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
||||
List<CommunityModel> list = state.isSearching ? state.filteredCommunity : state.communityList;
|
||||
List<CommunityModel> list =
|
||||
state.searchQuery.isNotEmpty ? state.filteredCommunity : state.communityList;
|
||||
return Container(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
decoration: widget.isSide == true
|
||||
@ -61,7 +62,8 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
border: Border.all(color: ColorsManager.grayBorder)),
|
||||
child: TextFormField(
|
||||
style: const TextStyle(color: Colors.black),
|
||||
style: context.textTheme.bodyMedium
|
||||
?.copyWith(color: ColorsManager.blackColor),
|
||||
onChanged: (value) {
|
||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(value));
|
||||
},
|
||||
@ -94,7 +96,9 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
child: state.isSearching
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
@ -115,59 +119,70 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
scrollbarOrientation: ScrollbarOrientation.left,
|
||||
thumbVisibility: true,
|
||||
controller: _scrollController,
|
||||
child: NotificationListener(
|
||||
onNotification: (notification) {
|
||||
if (notification is ScrollEndNotification &&
|
||||
notification.metrics.extentAfter == 0) {
|
||||
// If the user has reached the end of the list Load more data
|
||||
context.read<SpaceTreeBloc>().add(PaginationEvent(
|
||||
state.paginationModel, state.communityList));
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: ListView(
|
||||
controller: _scrollController,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
children: list
|
||||
.map(
|
||||
(community) => CustomExpansionTileSpaceTree(
|
||||
title: community.name,
|
||||
itemCount: list.length,
|
||||
controller: _scrollController,
|
||||
itemBuilder: (context, index) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
title: list[index].name,
|
||||
isSelected: state.selectedCommunities
|
||||
.contains(community.uuid),
|
||||
.contains(list[index].uuid),
|
||||
isSoldCheck: state.selectedCommunities
|
||||
.contains(community.uuid),
|
||||
.contains(list[index].uuid),
|
||||
onExpansionChanged: () {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(OnCommunityExpanded(community.uuid));
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunityExpanded(list[index].uuid));
|
||||
},
|
||||
isExpanded: state.expandedCommunities
|
||||
.contains(community.uuid),
|
||||
.contains(list[index].uuid),
|
||||
onItemSelected: () {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunitySelected(
|
||||
community.uuid, community.spaces));
|
||||
OnCommunitySelected(list[index].uuid,
|
||||
list[index].spaces));
|
||||
widget.onSelect();
|
||||
},
|
||||
children: community.spaces.map((space) {
|
||||
children: list[index].spaces.map((space) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
title: space.name,
|
||||
isExpanded:
|
||||
state.expandedSpaces.contains(space.uuid),
|
||||
isExpanded: state.expandedSpaces
|
||||
.contains(space.uuid),
|
||||
onItemSelected: () {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceSelected(community, space.uuid ?? '',
|
||||
OnSpaceSelected(
|
||||
list[index],
|
||||
space.uuid ?? '',
|
||||
space.children));
|
||||
widget.onSelect();
|
||||
},
|
||||
onExpansionChanged: () {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceExpanded(
|
||||
community.uuid, space.uuid ?? ''));
|
||||
OnSpaceExpanded(list[index].uuid,
|
||||
space.uuid ?? ''));
|
||||
},
|
||||
isSelected:
|
||||
state.selectedSpaces.contains(space.uuid) ||
|
||||
isSelected: state.selectedSpaces
|
||||
.contains(space.uuid) ||
|
||||
state.soldCheck.contains(space.uuid),
|
||||
isSoldCheck:
|
||||
state.soldCheck.contains(space.uuid),
|
||||
isSoldCheck: state.soldCheck.contains(space.uuid),
|
||||
children: _buildNestedSpaces(
|
||||
context, state, space, community),
|
||||
context, state, space, list[index]),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -175,7 +190,7 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
if (state.paginationIsLoading) const CircularProgressIndicator(),
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
|
@ -22,11 +22,11 @@ class CommunityModel {
|
||||
|
||||
factory CommunityModel.fromJson(Map<String, dynamic> json) {
|
||||
return CommunityModel(
|
||||
uuid: json['uuid'],
|
||||
createdAt: DateTime.parse(json['createdAt']),
|
||||
updatedAt: DateTime.parse(json['updatedAt']),
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
uuid: json['uuid'] ?? '',
|
||||
createdAt: DateTime.parse(json['createdAt'] ?? ''),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] ?? ''),
|
||||
name: json['name'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
region: json['region'] != null ? RegionModel.fromJson(json['region']) : null,
|
||||
spaces: json['spaces'] != null
|
||||
? (json['spaces'] as List).map((space) => SpaceModel.fromJson(space)).toList()
|
||||
|
@ -301,11 +301,18 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
SpaceTemplateModel? spaceModel, List<SubspaceModel>? subspaces, List<Tag>? tags) {
|
||||
setState(() {
|
||||
// Set the first space in the center or use passed position
|
||||
Offset centerPosition = position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
Offset newPosition;
|
||||
if (parentIndex != null) {
|
||||
newPosition =
|
||||
getBalancedChildPosition(spaces[parentIndex]); // Ensure balanced position
|
||||
} else {
|
||||
newPosition = position ?? ConnectionHelper.getCenterPosition(screenSize);
|
||||
}
|
||||
|
||||
SpaceModel newSpace = SpaceModel(
|
||||
name: name,
|
||||
icon: icon,
|
||||
position: centerPosition,
|
||||
position: newPosition,
|
||||
isPrivate: false,
|
||||
children: [],
|
||||
status: SpaceStatus.newSpace,
|
||||
@ -425,7 +432,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
Connection(
|
||||
startSpace: parent,
|
||||
endSpace: child,
|
||||
direction: child.incomingConnection?.direction ?? "down",
|
||||
direction: "down",
|
||||
),
|
||||
);
|
||||
|
||||
@ -522,6 +529,38 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
);
|
||||
}
|
||||
|
||||
Offset getBalancedChildPosition(SpaceModel parent) {
|
||||
int totalSiblings = parent.children.length + 1;
|
||||
double totalWidth = (totalSiblings - 1) * 250; // Horizontal spacing
|
||||
double startX = parent.position.dx - (totalWidth / 2);
|
||||
|
||||
Offset position = Offset(startX + (parent.children.length * 250), parent.position.dy + 180);
|
||||
|
||||
// Check for overlaps & adjust
|
||||
while (spaces.any((s) => (s.position - position).distance < 250)) {
|
||||
position = Offset(position.dx + 250, position.dy);
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void realignTree() {
|
||||
void updatePositions(SpaceModel node, double x, double y) {
|
||||
node.position = Offset(x, y);
|
||||
|
||||
int numChildren = node.children.length;
|
||||
double childStartX = x - ((numChildren - 1) * 250) / 2;
|
||||
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
updatePositions(node.children[i], childStartX + (i * 250), y + 180);
|
||||
}
|
||||
}
|
||||
|
||||
if (spaces.isNotEmpty) {
|
||||
updatePositions(spaces.first, spaces.first.position.dx, spaces.first.position.dy);
|
||||
}
|
||||
}
|
||||
|
||||
void _onDuplicate(BuildContext parentContext) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
@ -604,29 +643,57 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
|
||||
void _duplicateSpace(SpaceModel space) {
|
||||
final Map<SpaceModel, SpaceModel> originalToDuplicate = {};
|
||||
const double horizontalGap = 200.0;
|
||||
const double verticalGap = 100.0;
|
||||
double horizontalGap = 250.0; // Increased spacing
|
||||
double verticalGap = 180.0; // Adjusted for better visualization
|
||||
|
||||
SpaceModel duplicateRecursive(
|
||||
SpaceModel original, Offset parentPosition, SpaceModel? duplicatedParent) {
|
||||
Offset newPosition = Offset(parentPosition.dx + horizontalGap, original.position.dy);
|
||||
print("🟢 Duplicating: ${space.name}");
|
||||
|
||||
while (spaces.any((s) =>
|
||||
(s.position - newPosition).distance < horizontalGap && s.status != SpaceStatus.deleted)) {
|
||||
newPosition += Offset(horizontalGap, 0);
|
||||
/// **Find a new position ensuring no overlap**
|
||||
Offset getBalancedChildPosition(SpaceModel parent) {
|
||||
int totalSiblings = parent.children.length + 1;
|
||||
double totalWidth = (totalSiblings - 1) * horizontalGap;
|
||||
double startX = parent.position.dx - (totalWidth / 2);
|
||||
Offset position = Offset(
|
||||
startX + (parent.children.length * horizontalGap), parent.position.dy + verticalGap);
|
||||
|
||||
// **Check for overlaps & adjust**
|
||||
while (spaces.any((s) => (s.position - position).distance < horizontalGap)) {
|
||||
position = Offset(position.dx + horizontalGap, position.dy);
|
||||
}
|
||||
|
||||
print("🔹 New position for ${parent.name}: (${position.dx}, ${position.dy})");
|
||||
return position;
|
||||
}
|
||||
|
||||
/// **Realign the entire tree after duplication**
|
||||
void realignTree() {
|
||||
void updatePositions(SpaceModel node, double x, double y) {
|
||||
node.position = Offset(x, y);
|
||||
print("✅ Adjusted ${node.name} to (${x}, ${y})");
|
||||
|
||||
int numChildren = node.children.length;
|
||||
double childStartX = x - ((numChildren - 1) * horizontalGap) / 2;
|
||||
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
updatePositions(node.children[i], childStartX + (i * horizontalGap), y + verticalGap);
|
||||
}
|
||||
}
|
||||
|
||||
if (spaces.isNotEmpty) {
|
||||
print("🔄 Realigning tree...");
|
||||
updatePositions(spaces.first, spaces.first.position.dx, spaces.first.position.dy);
|
||||
}
|
||||
}
|
||||
|
||||
/// **Recursive duplication logic**
|
||||
SpaceModel duplicateRecursive(SpaceModel original, SpaceModel? duplicatedParent) {
|
||||
Offset newPosition = duplicatedParent == null
|
||||
? Offset(original.position.dx + horizontalGap, original.position.dy)
|
||||
: getBalancedChildPosition(duplicatedParent);
|
||||
|
||||
final duplicatedName = SpaceHelper.generateUniqueSpaceName(original.name, spaces);
|
||||
|
||||
final List<SubspaceModel>? duplicatedSubspaces;
|
||||
final List<Tag>? duplicatedTags;
|
||||
if (original.spaceModel != null) {
|
||||
duplicatedTags = [];
|
||||
duplicatedSubspaces = [];
|
||||
} else {
|
||||
duplicatedTags = original.tags;
|
||||
duplicatedSubspaces = original.subspaces;
|
||||
}
|
||||
print(
|
||||
"🟡 Duplicating ${original.name} → ${duplicatedName} at (${newPosition.dx}, ${newPosition.dy})");
|
||||
|
||||
final duplicated = SpaceModel(
|
||||
name: duplicatedName,
|
||||
@ -637,12 +704,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
status: SpaceStatus.newSpace,
|
||||
parent: duplicatedParent,
|
||||
spaceModel: original.spaceModel,
|
||||
subspaces: duplicatedSubspaces,
|
||||
tags: duplicatedTags,
|
||||
subspaces: original.subspaces,
|
||||
tags: original.tags,
|
||||
);
|
||||
|
||||
originalToDuplicate[original] = duplicated;
|
||||
|
||||
setState(() {
|
||||
spaces.add(duplicated);
|
||||
_updateNodePosition(duplicated, duplicated.position);
|
||||
@ -651,60 +716,42 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
final newConnection = Connection(
|
||||
startSpace: duplicatedParent,
|
||||
endSpace: duplicated,
|
||||
direction: original.incomingConnection?.direction ?? 'down',
|
||||
direction: "down",
|
||||
);
|
||||
connections.add(newConnection);
|
||||
duplicated.incomingConnection = newConnection;
|
||||
duplicatedParent.addOutgoingConnection(newConnection);
|
||||
duplicatedParent.children.add(duplicated);
|
||||
print("🔗 Created connection: ${duplicatedParent.name} → ${duplicated.name}");
|
||||
}
|
||||
|
||||
if (original.parent != null && duplicatedParent == null) {
|
||||
final originalParent = original.parent!;
|
||||
final duplicatedParent = originalToDuplicate[originalParent] ?? originalParent;
|
||||
|
||||
final parentConnection = Connection(
|
||||
startSpace: duplicatedParent,
|
||||
endSpace: duplicated,
|
||||
direction: original.incomingConnection?.direction ?? "down",
|
||||
);
|
||||
|
||||
connections.add(parentConnection);
|
||||
duplicated.incomingConnection = parentConnection;
|
||||
duplicatedParent.addOutgoingConnection(parentConnection);
|
||||
}
|
||||
// **Recalculate the whole tree to avoid overlaps**
|
||||
realignTree();
|
||||
});
|
||||
|
||||
final childrenWithDownDirection = original.children
|
||||
.where((child) =>
|
||||
child.incomingConnection?.direction == "down" && child.status != SpaceStatus.deleted)
|
||||
.toList();
|
||||
|
||||
Offset childStartPosition = childrenWithDownDirection.length == 1
|
||||
? duplicated.position
|
||||
: newPosition + Offset(0, verticalGap);
|
||||
|
||||
for (final child in original.children) {
|
||||
final isDownDirection = child.incomingConnection?.direction == "down" ?? false;
|
||||
|
||||
if (isDownDirection && childrenWithDownDirection.length == 1) {
|
||||
childStartPosition = duplicated.position + Offset(0, verticalGap);
|
||||
} else if (!isDownDirection) {
|
||||
childStartPosition = duplicated.position + Offset(horizontalGap, 0);
|
||||
}
|
||||
|
||||
final duplicatedChild = duplicateRecursive(child, childStartPosition, duplicated);
|
||||
duplicated.children.add(duplicatedChild);
|
||||
childStartPosition += Offset(0, verticalGap);
|
||||
// Recursively duplicate children
|
||||
for (var child in original.children) {
|
||||
duplicateRecursive(child, duplicated);
|
||||
}
|
||||
|
||||
return duplicated;
|
||||
}
|
||||
|
||||
/// **Handle root duplication**
|
||||
if (space.parent == null) {
|
||||
duplicateRecursive(space, space.position, null);
|
||||
print("🟠 Duplicating root node: ${space.name}");
|
||||
SpaceModel duplicatedRoot = duplicateRecursive(space, null);
|
||||
|
||||
setState(() {
|
||||
spaces.add(duplicatedRoot);
|
||||
realignTree();
|
||||
});
|
||||
|
||||
print("✅ Root duplication successful: ${duplicatedRoot.name}");
|
||||
} else {
|
||||
final duplicatedParent = originalToDuplicate[space.parent!] ?? space.parent!;
|
||||
duplicateRecursive(space, space.position, duplicatedParent);
|
||||
}
|
||||
duplicateRecursive(space, space.parent);
|
||||
}
|
||||
|
||||
print("🟢 Finished duplication process for: ${space.name}");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/create_community/view/create_community_dialog.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class SidebarAddCommunityButton extends StatelessWidget {
|
||||
const SidebarAddCommunityButton({
|
||||
required this.existingCommunityNames,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final List<String> existingCommunityNames;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.square(
|
||||
dimension: 30,
|
||||
child: IconButton(
|
||||
style: IconButton.styleFrom(
|
||||
iconSize: 20,
|
||||
backgroundColor: ColorsManager.circleImageBackground,
|
||||
shape: const CircleBorder(
|
||||
side: BorderSide(
|
||||
color: ColorsManager.lightGrayBorderColor,
|
||||
width: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: () => _showCreateCommunityDialog(context),
|
||||
icon: SvgPicture.asset(Assets.addIcon),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showCreateCommunityDialog(BuildContext context) => showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => CreateCommunityDialog(
|
||||
isEditMode: false,
|
||||
existingCommunityNames: existingCommunityNames,
|
||||
onCreateCommunity: (name, description) {
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
CreateCommunityEvent(name, description, context),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/sidebar_add_community_button.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class SidebarHeader extends StatelessWidget {
|
||||
const SidebarHeader({required this.existingCommunityNames, super.key});
|
||||
|
||||
final List<String> existingCommunityNames;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: subSectionContainerDecoration,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Communities',
|
||||
style: context.textTheme.titleMedium?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
SidebarAddCommunityButton(existingCommunityNames: existingCommunityNames),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,17 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/common/widgets/search_bar.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_tile.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/sidebar_header.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class SidebarWidget extends StatefulWidget {
|
||||
@ -19,62 +17,59 @@ class SidebarWidget extends StatefulWidget {
|
||||
final String? selectedSpaceUuid;
|
||||
|
||||
const SidebarWidget({
|
||||
super.key,
|
||||
required this.communities,
|
||||
this.selectedSpaceUuid,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
_SidebarWidgetState createState() => _SidebarWidgetState();
|
||||
State<SidebarWidget> createState() => _SidebarWidgetState();
|
||||
}
|
||||
|
||||
class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
String _searchQuery = ''; // Track search query
|
||||
String _searchQuery = '';
|
||||
String? _selectedSpaceUuid;
|
||||
String? _selectedId;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_selectedId = widget.selectedSpaceUuid;
|
||||
super.initState();
|
||||
_selectedId = widget.selectedSpaceUuid; // Initialize with the passed selected space UUID
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant SidebarWidget oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.selectedSpaceUuid != oldWidget.selectedSpaceUuid) {
|
||||
setState(() {
|
||||
_selectedId = widget.selectedSpaceUuid;
|
||||
});
|
||||
setState(() => _selectedId = widget.selectedSpaceUuid);
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
// Function to filter communities based on the search query
|
||||
List<CommunityModel> _filterCommunities() {
|
||||
List<CommunityModel> _filteredCommunities() {
|
||||
if (_searchQuery.isEmpty) {
|
||||
// Reset the selected community and space UUIDs if there's no query
|
||||
_selectedSpaceUuid = null;
|
||||
return widget.communities;
|
||||
}
|
||||
|
||||
// Filter communities and expand only those that match the query
|
||||
return widget.communities.where((community) {
|
||||
final containsQueryInCommunity =
|
||||
community.name.toLowerCase().contains(_searchQuery.toLowerCase());
|
||||
final containsQueryInSpaces =
|
||||
community.spaces.any((space) => _containsQuery(space, _searchQuery.toLowerCase()));
|
||||
final containsQueryInSpaces = community.spaces.any((space) =>
|
||||
_containsQuery(space: space, query: _searchQuery.toLowerCase()));
|
||||
|
||||
return containsQueryInCommunity || containsQueryInSpaces;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// Helper function to determine if any space or its children match the search query
|
||||
bool _containsQuery(SpaceModel space, String query) {
|
||||
bool _containsQuery({
|
||||
required SpaceModel space,
|
||||
required String query,
|
||||
}) {
|
||||
final matchesSpace = space.name.toLowerCase().contains(query);
|
||||
final matchesChildren =
|
||||
space.children.any((child) => _containsQuery(child, query)); // Recursive check for children
|
||||
final matchesChildren = space.children.any(
|
||||
(child) => _containsQuery(space: child, query: query),
|
||||
);
|
||||
|
||||
// If the space or any of its children match the query, expand this space
|
||||
if (matchesSpace || matchesChildren) {
|
||||
_selectedSpaceUuid = space.uuid;
|
||||
}
|
||||
@ -83,79 +78,35 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
}
|
||||
|
||||
bool _isSpaceOrChildSelected(SpaceModel space) {
|
||||
// Return true if the current space or any of its child spaces is selected
|
||||
if (_selectedSpaceUuid == space.uuid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Recursively check if any child spaces match the query
|
||||
for (var child in space.children) {
|
||||
if (_isSpaceOrChildSelected(child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
final isSpaceSelected = _selectedSpaceUuid == space.uuid;
|
||||
final anySubSpaceIsSelected = space.children.any(_isSpaceOrChildSelected);
|
||||
return isSpaceSelected || anySubSpaceIsSelected;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final filteredCommunities = _filterCommunities();
|
||||
final filteredCommunities = _filteredCommunities();
|
||||
|
||||
return Container(
|
||||
width: 300,
|
||||
decoration: subSectionContainerDecoration,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min, // Ensures the Column only takes necessary height
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Communities title with the add button
|
||||
Container(
|
||||
decoration: subSectionContainerDecoration,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('Communities',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
)),
|
||||
GestureDetector(
|
||||
onTap: () => _navigateToBlank(context),
|
||||
child: Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: const BoxDecoration(
|
||||
color: ColorsManager.whiteColors,
|
||||
shape: BoxShape.circle,
|
||||
SidebarHeader(
|
||||
existingCommunityNames:
|
||||
widget.communities.map((community) => community.name).toList(),
|
||||
),
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.roundedAddIcon,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Search bar
|
||||
CustomSearchBar(
|
||||
onSearchChanged: (query) {
|
||||
setState(() {
|
||||
_searchQuery = query;
|
||||
});
|
||||
},
|
||||
onSearchChanged: (query) => setState(() => _searchQuery = query),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Community list
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: filteredCommunities.map((community) {
|
||||
return _buildCommunityTile(context, community);
|
||||
}).toList(),
|
||||
children: filteredCommunities
|
||||
.map((community) => _buildCommunityTile(context, community))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -163,18 +114,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
void _navigateToBlank(BuildContext context) {
|
||||
setState(() {
|
||||
_selectedId = '';
|
||||
});
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
NewCommunityEvent(communities: widget.communities),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCommunityTile(BuildContext context, CommunityModel community) {
|
||||
bool hasChildren = community.spaces.isNotEmpty;
|
||||
|
||||
return CommunityTile(
|
||||
title: community.name,
|
||||
key: ValueKey(community.uuid),
|
||||
@ -183,7 +123,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
onItemSelected: () {
|
||||
setState(() {
|
||||
_selectedId = community.uuid;
|
||||
_selectedSpaceUuid = null; // Update the selected community
|
||||
_selectedSpaceUuid = null;
|
||||
});
|
||||
|
||||
context.read<CenterBodyBloc>().add(CommunitySelectedEvent());
|
||||
@ -192,31 +132,32 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
SelectCommunityEvent(selectedCommunity: community),
|
||||
);
|
||||
},
|
||||
onExpansionChanged: (String title, bool expanded) {
|
||||
_handleExpansionChange(community.uuid, expanded);
|
||||
},
|
||||
children: hasChildren
|
||||
? community.spaces
|
||||
.where((space) => (space.status != SpaceStatus.deleted ||
|
||||
space.status != SpaceStatus.parentDeleted))
|
||||
.map((space) => _buildSpaceTile(space, community))
|
||||
.toList()
|
||||
: null,
|
||||
onExpansionChanged: (title, expanded) {},
|
||||
children: community.spaces
|
||||
.where((space) {
|
||||
final isDeleted = space.status != SpaceStatus.deleted;
|
||||
final isParentDeleted = space.status != SpaceStatus.parentDeleted;
|
||||
return (isDeleted || isParentDeleted);
|
||||
})
|
||||
.map((space) => _buildSpaceTile(space: space, community: community))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) {
|
||||
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
||||
Widget _buildSpaceTile({
|
||||
required SpaceModel space,
|
||||
required CommunityModel community,
|
||||
}) {
|
||||
final spaceIsExpanded = _isSpaceOrChildSelected(space);
|
||||
final isSelected = _selectedId == space.uuid;
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(left: depth * 16.0),
|
||||
padding: const EdgeInsetsDirectional.only(start: 16.0),
|
||||
child: SpaceTile(
|
||||
title: space.name,
|
||||
key: ValueKey(space.uuid),
|
||||
isSelected: _selectedId == space.uuid,
|
||||
initiallyExpanded: isExpandedSpace,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
_handleExpansionChange(space.uuid ?? '', expanded);
|
||||
},
|
||||
isSelected: isSelected,
|
||||
initiallyExpanded: spaceIsExpanded,
|
||||
onExpansionChanged: (expanded) {},
|
||||
onItemSelected: () {
|
||||
setState(() {
|
||||
_selectedId = space.uuid;
|
||||
@ -227,11 +168,15 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
SelectSpaceEvent(selectedCommunity: community, selectedSpace: space),
|
||||
);
|
||||
},
|
||||
children: space.children.isNotEmpty
|
||||
? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()
|
||||
: [], // Recursively render child spaces if available
|
||||
));
|
||||
children: space.children
|
||||
.map(
|
||||
(childSpace) => _buildSpaceTile(
|
||||
space: childSpace,
|
||||
community: community,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleExpansionChange(String uuid, bool expanded) {}
|
||||
}
|
||||
|
@ -47,18 +47,6 @@ class SpaceCardWidget extends StatelessWidget {
|
||||
children: [
|
||||
buildSpaceContainer(index), // Build the space container
|
||||
if (isHovered) ...[
|
||||
PlusButtonWidget(
|
||||
index: index,
|
||||
direction: 'left',
|
||||
offset: const Offset(-21, 20),
|
||||
onButtonTap: onButtonTap,
|
||||
),
|
||||
PlusButtonWidget(
|
||||
index: index,
|
||||
direction: 'right',
|
||||
offset: const Offset(140, 20),
|
||||
onButtonTap: onButtonTap,
|
||||
),
|
||||
PlusButtonWidget(
|
||||
index: index,
|
||||
direction: 'down',
|
||||
|
@ -2,8 +2,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_m
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
|
||||
class SpaceHelper {
|
||||
static SpaceModel? findSpaceByUuid(
|
||||
String? uuid, List<CommunityModel> communities) {
|
||||
static SpaceModel? findSpaceByUuid(String? uuid, List<CommunityModel> communities) {
|
||||
for (var community in communities) {
|
||||
for (var space in community.spaces) {
|
||||
if (space.uuid == uuid) return space;
|
||||
@ -12,8 +11,7 @@ class SpaceHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
static SpaceModel? findSpaceByInternalId(
|
||||
String? internalId, List<SpaceModel> spaces) {
|
||||
static SpaceModel? findSpaceByInternalId(String? internalId, List<SpaceModel> spaces) {
|
||||
if (internalId != null) {
|
||||
for (var space in spaces) {
|
||||
if (space.internalId == internalId) return space;
|
||||
@ -23,8 +21,7 @@ class SpaceHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
static String generateUniqueSpaceName(
|
||||
String originalName, List<SpaceModel> spaces) {
|
||||
static String generateUniqueSpaceName(String originalName, List<SpaceModel> spaces) {
|
||||
final baseName = originalName.replaceAll(RegExp(r'\(\d+\)$'), '').trim();
|
||||
int maxNumber = 0;
|
||||
|
||||
@ -54,13 +51,10 @@ class SpaceHelper {
|
||||
|
||||
return space == selectedSpace ||
|
||||
selectedSpace.parent?.internalId == space.internalId ||
|
||||
selectedSpace.children
|
||||
?.any((child) => child.internalId == space.internalId) ==
|
||||
true;
|
||||
selectedSpace.children?.any((child) => child.internalId == space.internalId) == true;
|
||||
}
|
||||
|
||||
static bool isNameConflict(
|
||||
String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
|
||||
static bool isNameConflict(String value, SpaceModel? parentSpace, SpaceModel? editSpace) {
|
||||
final siblings = parentSpace?.children
|
||||
.where((child) => child.internalId != editSpace?.internalId)
|
||||
.toList() ??
|
||||
@ -71,19 +65,17 @@ class SpaceHelper {
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
final editSiblingConflict =
|
||||
editSiblings.any((child) => child.name == value);
|
||||
final editSiblingConflict = editSiblings.any((child) => child.name == value);
|
||||
|
||||
final siblingConflict = siblings.any((child) => child.name == value);
|
||||
|
||||
final parentConflict = parentSpace?.name == value &&
|
||||
parentSpace?.internalId != editSpace?.internalId;
|
||||
final parentConflict =
|
||||
parentSpace?.name == value && parentSpace?.internalId != editSpace?.internalId;
|
||||
|
||||
final parentOfEditSpaceConflict = editSpace?.parent?.name == value &&
|
||||
editSpace?.parent?.internalId != editSpace?.internalId;
|
||||
final parentOfEditSpaceConflict =
|
||||
editSpace?.parent?.name == value && editSpace?.parent?.internalId != editSpace?.internalId;
|
||||
|
||||
final childConflict =
|
||||
editSpace?.children.any((child) => child.name == value) ?? false;
|
||||
final childConflict = editSpace?.children.any((child) => child.name == value) ?? false;
|
||||
|
||||
return siblingConflict ||
|
||||
parentConflict ||
|
||||
|
@ -194,9 +194,10 @@ class VisitorPasswordBloc
|
||||
emit(DeviceLoaded());
|
||||
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||
|
||||
data = await AccessMangApi().fetchDevices(projectUuid);
|
||||
data = await AccessMangApi().fetchDoorLockDeviceList(projectUuid);
|
||||
emit(TableLoaded(data));
|
||||
} catch (e) {
|
||||
print("error: $e");
|
||||
emit(FailedState(e.toString()));
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,23 @@ import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
class AccessMangApi {
|
||||
AccessMangApi() {
|
||||
_validateEndpoints();
|
||||
}
|
||||
|
||||
void _validateEndpoints() {
|
||||
if (!ApiEndpoints.getDevices.contains('{projectId}')) {
|
||||
throw Exception("Endpoint 'getDevices' must contain '{projectId}' placeholder.");
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<PasswordModel>> fetchVisitorPassword(String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.visitorPassword.replaceAll('{projectId}', projectId),
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
List<dynamic> jsonData = json['data'] ?? [];
|
||||
List<PasswordModel> passwordList = jsonData.map((jsonItem) {
|
||||
return PasswordModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -25,17 +35,22 @@ class AccessMangApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future fetchDevices(String projectId) async {
|
||||
Future fetchDoorLockDeviceList(String projectId) async {
|
||||
try {
|
||||
// The endpoint structure is already validated during initialization.
|
||||
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDevices.replaceAll('{projectId}', projectId),
|
||||
queryParameters: {
|
||||
'deviceType': 'DOOR_LOCK',
|
||||
},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
List<DeviceModel> passwordList = jsonData.map((jsonItem) {
|
||||
List<dynamic> jsonData = json['data'] ?? [];
|
||||
List<DeviceModel> deviceList = jsonData.map((jsonItem) {
|
||||
return DeviceModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
return passwordList;
|
||||
return deviceList;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -52,14 +67,15 @@ class AccessMangApi {
|
||||
String? invalidTime,
|
||||
List<String>? devicesUuid}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOnlineOneTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode({
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"password": password,
|
||||
"devicesUuid": devicesUuid,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime
|
||||
"invalidTime": invalidTime,
|
||||
"operationType": "ONLINE_ONE_TIME",
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
@ -84,13 +100,13 @@ class AccessMangApi {
|
||||
"password": password,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime,
|
||||
"operationType": "ONLINE_MULTIPLE_TIME",
|
||||
};
|
||||
if (scheduleList != null) {
|
||||
body["scheduleList"] =
|
||||
scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOnlineMultipleTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode(body),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
@ -105,8 +121,9 @@ class AccessMangApi {
|
||||
Future postOffLineOneTime(
|
||||
{String? email, String? passwordName, List<String>? devicesUuid}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOffLineOneTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode({
|
||||
"operationType": "OFFLINE_ONE_TIME",
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"devicesUuid": devicesUuid
|
||||
@ -126,13 +143,14 @@ class AccessMangApi {
|
||||
String? invalidTime,
|
||||
List<String>? devicesUuid}) async {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOffLineMultipleTime,
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
body: jsonEncode({
|
||||
"email": email,
|
||||
"devicesUuid": devicesUuid,
|
||||
"passwordName": passwordName,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime,
|
||||
"operationType": "OFFLINE_MULTIPLE_TIME",
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
|
@ -23,9 +23,7 @@ class DevicesManagementApi {
|
||||
: ApiEndpoints.getAllDevices.replaceAll('{projectId}', projectId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = communityId.isNotEmpty && spaceId.isNotEmpty
|
||||
? json['data']
|
||||
: json;
|
||||
List<dynamic> jsonData = json['data'];
|
||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||
return AllDevicesModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -34,7 +32,7 @@ class DevicesManagementApi {
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('fetchDevices Error fetching $e');
|
||||
debugPrint('Error fetching device $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -45,7 +43,7 @@ class DevicesManagementApi {
|
||||
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json);
|
||||
return DeviceStatus.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -62,7 +60,7 @@ class DevicesManagementApi {
|
||||
Future getPowerClampInfo(String deviceId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
|
||||
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', deviceId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -93,13 +91,13 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deviceBatchControl(
|
||||
List<String> uuids, String code, dynamic value) async {
|
||||
Future<bool> deviceBatchControl(List<String> uuids, String code, dynamic value) async {
|
||||
try {
|
||||
final body = {
|
||||
'devicesUuid': uuids,
|
||||
'code': code,
|
||||
'value': value,
|
||||
'operationType': 'COMMAND',
|
||||
};
|
||||
|
||||
final response = await HTTPService().post(
|
||||
@ -107,7 +105,7 @@ class DevicesManagementApi {
|
||||
body: body,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return (json['successResults'] as List).isNotEmpty;
|
||||
return json['success'] ?? false;
|
||||
},
|
||||
);
|
||||
|
||||
@ -118,8 +116,7 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
@ -128,7 +125,7 @@ class DevicesManagementApi {
|
||||
if (json == null || json.isEmpty || json == []) {
|
||||
return devices;
|
||||
}
|
||||
for (var device in json['devices']) {
|
||||
for (var device in json['data']['devices']) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
return devices;
|
||||
@ -153,12 +150,10 @@ class DevicesManagementApi {
|
||||
String code,
|
||||
) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDeviceLogs
|
||||
.replaceAll('{uuid}', uuid)
|
||||
.replaceAll('{code}', code),
|
||||
path: ApiEndpoints.getDeviceLogs.replaceAll('{uuid}', uuid).replaceAll('{code}', code),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
return DeviceReport.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -174,7 +169,7 @@ class DevicesManagementApi {
|
||||
.replaceAll('{endTime}', to ?? ''),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
return DeviceReport.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -190,7 +185,7 @@ class DevicesManagementApi {
|
||||
queryParameters: queryParameters,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json['status']);
|
||||
return DeviceStatus.fromJson(json['data']['status']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -228,8 +223,7 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> addScheduleRecord(
|
||||
ScheduleEntry sendSchedule, String uuid) async {
|
||||
Future<bool> addScheduleRecord(ScheduleEntry sendSchedule, String uuid) async {
|
||||
try {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
||||
@ -246,8 +240,7 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<ScheduleModel>> getDeviceSchedules(
|
||||
String uuid, String category) async {
|
||||
Future<List<ScheduleModel>> getDeviceSchedules(String uuid, String category) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getScheduleByDeviceId
|
||||
@ -270,9 +263,7 @@ class DevicesManagementApi {
|
||||
}
|
||||
|
||||
Future<bool> updateScheduleRecord(
|
||||
{required bool enable,
|
||||
required String uuid,
|
||||
required String scheduleId}) async {
|
||||
{required bool enable, required String uuid, required String scheduleId}) async {
|
||||
try {
|
||||
final response = await HTTPService().put(
|
||||
path: ApiEndpoints.updateScheduleByDeviceId
|
||||
@ -293,8 +284,7 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> editScheduleRecord(
|
||||
String uuid, ScheduleEntry newSchedule) async {
|
||||
Future<bool> editScheduleRecord(String uuid, ScheduleEntry newSchedule) async {
|
||||
try {
|
||||
final response = await HTTPService().put(
|
||||
path: ApiEndpoints.scheduleByDeviceId.replaceAll('{deviceUuid}', uuid),
|
||||
|
@ -1,29 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/create_subspace_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/space_template_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_body_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_update_model.dart';
|
||||
import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
import 'package:syncrow_web/utils/constants/temp_const.dart';
|
||||
|
||||
class CommunitySpaceManagementApi {
|
||||
// Community Management APIs
|
||||
Future<List<CommunityModel>> fetchCommunities(String projectId,
|
||||
{int page = 1}) async {
|
||||
Future<List<CommunityModel>> fetchCommunities(String projectId, {int page = 1}) async {
|
||||
try {
|
||||
List<CommunityModel> allCommunities = [];
|
||||
bool hasNext = true;
|
||||
|
||||
while (hasNext) {
|
||||
await HTTPService().get(
|
||||
path: ApiEndpoints.getCommunityList
|
||||
.replaceAll('{projectId}', projectId),
|
||||
queryParameters: {'page': page},
|
||||
path: ApiEndpoints.getCommunityList.replaceAll('{projectId}', projectId),
|
||||
queryParameters: {
|
||||
'page': page,
|
||||
},
|
||||
expectedResponseModel: (json) {
|
||||
try {
|
||||
List<dynamic> jsonData = json['data'] ?? [];
|
||||
@ -49,11 +48,42 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<PaginationModel> fetchCommunitiesAndSpaces(
|
||||
{required String projectId, int page = 1, String search = ''}) async {
|
||||
PaginationModel paginationModel = const PaginationModel.emptyConstructor();
|
||||
|
||||
try {
|
||||
bool hasNext = false;
|
||||
await HTTPService().get(
|
||||
path: ApiEndpoints.getCommunityList.replaceAll('{projectId}', projectId),
|
||||
queryParameters: {'page': page, 'includeSpaces': true, 'size': 25, 'search': search},
|
||||
expectedResponseModel: (json) {
|
||||
try {
|
||||
List<dynamic> jsonData = json['data'] ?? [];
|
||||
hasNext = json['hasNext'] ?? false;
|
||||
int currentPage = json['page'] ?? 1;
|
||||
List<CommunityModel> communityList = jsonData.map((jsonItem) {
|
||||
return CommunityModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
|
||||
page = currentPage + 1;
|
||||
paginationModel = PaginationModel(
|
||||
pageNum: page, hasNext: hasNext, size: 25, communities: communityList);
|
||||
return paginationModel;
|
||||
} catch (_) {
|
||||
hasNext = false;
|
||||
return [];
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (_) {}
|
||||
return paginationModel;
|
||||
}
|
||||
|
||||
Future<CommunityModel?> getCommunityById(String communityId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getCommunityById
|
||||
.replaceAll('{communityId}', communityId),
|
||||
path: ApiEndpoints.getCommunityById.replaceAll('{communityId}', communityId),
|
||||
expectedResponseModel: (json) {
|
||||
return CommunityModel.fromJson(json['data']);
|
||||
},
|
||||
@ -65,8 +95,7 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<CommunityModel?> createCommunity(
|
||||
String name, String description, String projectId) async {
|
||||
Future<CommunityModel?> createCommunity(String name, String description, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.createCommunity.replaceAll('{projectId}', projectId),
|
||||
@ -85,8 +114,7 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> updateCommunity(
|
||||
String communityId, String name, String projectId) async {
|
||||
Future<bool> updateCommunity(String communityId, String name, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().put(
|
||||
path: ApiEndpoints.updateCommunity
|
||||
@ -123,8 +151,7 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<SpacesResponse> fetchSpaces(
|
||||
String communityId, String projectId) async {
|
||||
Future<SpacesResponse> fetchSpaces(String communityId, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.listSpaces
|
||||
@ -150,8 +177,7 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<SpaceModel?> getSpace(
|
||||
String communityId, String spaceId, String projectId) async {
|
||||
Future<SpaceModel?> getSpace(String communityId, String spaceId, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getSpace
|
||||
@ -262,8 +288,7 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deleteSpace(
|
||||
String communityId, String spaceId, String projectId) async {
|
||||
Future<bool> deleteSpace(String communityId, String spaceId, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().delete(
|
||||
path: ApiEndpoints.deleteSpace
|
||||
@ -281,17 +306,15 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<SpaceModel>> getSpaceHierarchy(
|
||||
String communityId, String projectId) async {
|
||||
Future<List<SpaceModel>> getSpaceHierarchy(String communityId, String projectId) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getSpaceHierarchy
|
||||
.replaceAll('{communityId}', communityId)
|
||||
.replaceAll('{projectId}', projectId),
|
||||
expectedResponseModel: (json) {
|
||||
final spaceModels = (json['data'] as List)
|
||||
.map((spaceJson) => SpaceModel.fromJson(spaceJson))
|
||||
.toList();
|
||||
final spaceModels =
|
||||
(json['data'] as List).map((spaceJson) => SpaceModel.fromJson(spaceJson)).toList();
|
||||
|
||||
return spaceModels;
|
||||
},
|
||||
@ -302,17 +325,16 @@ class CommunitySpaceManagementApi {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Future<List<SpaceModel>> getSpaceOnlyWithDevices(
|
||||
{String? communityId, String? projectId}) async {
|
||||
|
||||
Future<List<SpaceModel>> getSpaceOnlyWithDevices({String? communityId, String? projectId}) async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.spaceOnlyWithDevices
|
||||
.replaceAll('{communityId}', communityId!)
|
||||
.replaceAll('{projectId}', projectId!),
|
||||
expectedResponseModel: (json) {
|
||||
final spaceModels = (json['data'] as List)
|
||||
.map((spaceJson) => SpaceModel.fromJson(spaceJson))
|
||||
.toList();
|
||||
final spaceModels =
|
||||
(json['data'] as List).map((spaceJson) => SpaceModel.fromJson(spaceJson)).toList();
|
||||
return spaceModels;
|
||||
},
|
||||
);
|
||||
|
@ -9,21 +9,8 @@ abstract class ApiEndpoints {
|
||||
static const String sendOtp = '/authentication/user/send-otp';
|
||||
static const String verifyOtp = '/authentication/user/verify-otp';
|
||||
static const String getRegion = '/region';
|
||||
static const String visitorPassword =
|
||||
'/projects/{projectId}/visitor-password';
|
||||
static const String getDevices =
|
||||
'/projects/{projectId}/visitor-password/devices';
|
||||
|
||||
static const String sendOnlineOneTime =
|
||||
'/visitor-password/temporary-password/online/one-time';
|
||||
static const String sendOnlineMultipleTime =
|
||||
'/visitor-password/temporary-password/online/multiple-time';
|
||||
|
||||
//offline Password
|
||||
static const String sendOffLineOneTime =
|
||||
'/visitor-password/temporary-password/offline/one-time';
|
||||
static const String sendOffLineMultipleTime =
|
||||
'/visitor-password/temporary-password/offline/multiple-time';
|
||||
static const String visitorPassword = '/visitor-passwords';
|
||||
static const String getDevices = '/projects/{projectId}/devices';
|
||||
|
||||
static const String getUser = '/user/{userUuid}';
|
||||
|
||||
@ -32,15 +19,15 @@ abstract class ApiEndpoints {
|
||||
static const String getAllDevices = '/projects/{projectId}/devices';
|
||||
static const String getSpaceDevices =
|
||||
'/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/devices';
|
||||
static const String getDeviceStatus = '/device/{uuid}/functions/status';
|
||||
static const String getBatchStatus = '/device/status/batch';
|
||||
static const String getDeviceStatus = '/devices/{uuid}/functions/status';
|
||||
static const String getBatchStatus = '/devices/batch';
|
||||
|
||||
static const String deviceControl = '/device/{uuid}/control';
|
||||
static const String deviceBatchControl = '/device/control/batch';
|
||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
||||
static const String deviceControl = '/devices/{uuid}/command';
|
||||
static const String deviceBatchControl = '/devices/batch';
|
||||
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||
|
||||
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
||||
static const String getDeviceLogs = '/devices/{uuid}/report-logs?code={code}';
|
||||
|
||||
// Space Module
|
||||
static const String createSpace =
|
||||
@ -70,18 +57,13 @@ abstract class ApiEndpoints {
|
||||
static const String createUserCommunity =
|
||||
'/projects/{projectId}/communities/user';
|
||||
static const String getDeviceLogsByDate =
|
||||
'/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||
'/devices/{uuid}/report-logs?code={code}&startTime={startTime}&endTime={endTime}';
|
||||
|
||||
static const String scheduleByDeviceId = '/schedule/{deviceUuid}';
|
||||
static const String getScheduleByDeviceId =
|
||||
'/schedule/{deviceUuid}?category={category}';
|
||||
static const String deleteScheduleByDeviceId =
|
||||
'/schedule/{deviceUuid}/{scheduleUuid}';
|
||||
static const String updateScheduleByDeviceId =
|
||||
'/schedule/enable/{deviceUuid}';
|
||||
static const String factoryReset = '/device/factory/reset/{deviceUuid}';
|
||||
static const String powerClamp =
|
||||
'/device/{powerClampUuid}/power-clamp/status';
|
||||
static const String getScheduleByDeviceId = '/schedule/{deviceUuid}?category={category}';
|
||||
static const String deleteScheduleByDeviceId = '/schedule/{deviceUuid}/{scheduleUuid}';
|
||||
static const String updateScheduleByDeviceId = '/schedule/enable/{deviceUuid}';
|
||||
static const String factoryReset = '/devices/batch';
|
||||
|
||||
//product
|
||||
static const String listProducts = '/products';
|
||||
|
@ -408,9 +408,9 @@ class Assets {
|
||||
static const String spaceLinkIcon = 'assets/icons/space_link_icon.svg';
|
||||
static const String successIcon = 'assets/icons/success_icon.svg';
|
||||
static const String spaceLocationIcon = 'assets/icons/spaseLocationIcon.svg';
|
||||
static const String scenesPlayIcon = 'assets/icons/scenesPlayIcon.svg';
|
||||
static const String scenesPlayIcon = 'assets/icons/scenesPlayIcon.png';
|
||||
static const String scenesPlayIconCheck =
|
||||
'assets/icons/scenesPlayIconCheck.svg';
|
||||
'assets/icons/scenesPlayIconCheck.png';
|
||||
static const String presenceStateIcon = 'assets/icons/presence_state.svg';
|
||||
static const String currentDistanceIcon =
|
||||
'assets/icons/current_distance_icon.svg';
|
||||
@ -426,6 +426,8 @@ class Assets {
|
||||
static const String motionDetectionSensitivityValueIcon = 'assets/icons/motion_detection_sensitivity_value_icon.svg';
|
||||
static const String presenceTimeIcon = 'assets/icons/presence_time_icon.svg';
|
||||
static const String IlluminanceIcon = 'assets/icons/Illuminance_icon.svg';
|
||||
static const String gear = 'assets/icons/gear.svg';
|
||||
static const String activeBell='assets/icons/active_bell.svg';
|
||||
|
||||
|
||||
//Illuminance_icon
|
||||
}
|
||||
|
Reference in New Issue
Block a user