mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 08:51:44 +00:00
Compare commits
29 Commits
SP-1285-FE
...
Fix-Save-D
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f49a18130 | |||
| a51c4d9679 | |||
| caeed8e73f | |||
| dc5ac9be5b | |||
| 5c9b30895f | |||
| 06b14a3964 | |||
| 3c92ea3047 | |||
| cb79627038 | |||
| 9e84048f81 | |||
| 99adb1c286 | |||
| f2412aa867 | |||
| e4768c95aa | |||
| f25b4dbf6d | |||
| 9eff9ab371 | |||
| a2e68d6194 | |||
| 94c94b170f | |||
| 253cf15559 | |||
| 443eea9421 | |||
| 87a2c08f64 | |||
| dd66e7c747 | |||
| 7af61d2f65 | |||
| f37eacb0ee | |||
| c7dcc297aa | |||
| aefe5ad081 | |||
| 8d9af8519d | |||
| b1d52937c9 | |||
| 5fedf37421 | |||
| 4c8f2c72df | |||
| fb867e5df3 |
2
.env.dev
2
.env.dev
@ -1,3 +1,5 @@
|
|||||||
ENV_NAME=development
|
ENV_NAME=development
|
||||||
BASE_URL=https://syncrow-dev.azurewebsites.net
|
BASE_URL=https://syncrow-dev.azurewebsites.net
|
||||||
PROJECT_ID=0e62577c-06fa-41b9-8a92-99a21fbaf51c
|
PROJECT_ID=0e62577c-06fa-41b9-8a92-99a21fbaf51c
|
||||||
|
CLIENT_ID=c024573d191a327ce74db7d4502fdc29
|
||||||
|
CLIENT_SECRET=fec6ccbc33664f94a3b84a45c7cceef3f3ebd1613ef4307db8946ede530cd1ed
|
||||||
10
assets/icons/cancel_icon.svg
Normal file
10
assets/icons/cancel_icon.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_7302_4118)">
|
||||||
|
<path d="M11.1049 10.0001L19.7712 1.33381C20.0763 1.02869 20.0763 0.534007 19.7712 0.228929C19.4661 -0.0761485 18.9714 -0.0761876 18.6663 0.228929L9.99999 8.89524L1.33372 0.228929C1.0286 -0.0761876 0.533915 -0.0761876 0.228837 0.228929C-0.0762401 0.534046 -0.0762792 1.02873 0.228837 1.33381L8.89511 10.0001L0.228837 18.6664C-0.0762792 18.9715 -0.0762792 19.4662 0.228837 19.7713C0.381376 19.9238 0.581337 20.0001 0.781297 20.0001C0.981258 20.0001 1.18118 19.9238 1.33376 19.7713L9.99999 11.105L18.6663 19.7713C18.8188 19.9238 19.0188 20.0001 19.2187 20.0001C19.4187 20.0001 19.6186 19.9238 19.7712 19.7713C20.0763 19.4662 20.0763 18.9715 19.7712 18.6664L11.1049 10.0001Z" fill="#999999"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_7302_4118">
|
||||||
|
<rect width="20" height="20" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 939 B |
10
assets/icons/save_routines_icon.svg
Normal file
10
assets/icons/save_routines_icon.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_7302_4149)">
|
||||||
|
<path d="M19.9969 4.94279C19.986 4.83232 19.943 4.72146 19.8674 4.62924C19.8382 4.59358 20.1367 4.89431 15.4141 0.17176C15.3015 0.0591838 15.1487 8.30277e-05 14.9996 0.00012209C14.6443 0.00012209 2.11177 0.00012209 1.75779 0.00012209C0.788544 0.00012209 0 0.788666 0 1.75791V18.2421C0 19.2113 0.788544 19.9998 1.75779 19.9998H18.2419C19.2112 19.9998 19.9997 19.2113 19.9997 18.2421C19.9998 4.01624 20.0013 4.98771 19.9969 4.94279ZM13.4764 1.17198V5.00005C13.4764 5.32314 13.2136 5.58598 12.8905 5.58598H12.1483V1.17198H13.4764ZM10.9765 1.17198V5.58598H5.54684C5.22376 5.58598 4.96091 5.32314 4.96091 5.00005V1.17198H10.9765ZM13.4764 12.539H4.96091V11.7968C4.96091 11.4738 5.22376 11.2109 5.54684 11.2109H12.8905C13.2136 11.2109 13.4764 11.4738 13.4764 11.7968V12.539ZM4.96091 18.828V13.7109H13.4764V18.828H4.96091ZM18.8279 18.2421C18.8279 18.5651 18.5651 18.828 18.242 18.828H14.6483C14.6483 18.0641 14.6483 12.6676 14.6483 11.7968C14.6483 10.8276 13.8597 10.039 12.8905 10.039H5.54684C4.57759 10.039 3.78905 10.8276 3.78905 11.7968V18.828H1.75783C1.43475 18.828 1.1719 18.5651 1.1719 18.2421V1.75791C1.1719 1.43483 1.43475 1.17198 1.75783 1.17198H3.78905V5.00005C3.78905 5.9693 4.57759 6.75784 5.54684 6.75784H12.8905C13.8597 6.75784 14.6483 5.9693 14.6483 5.00005V1.17198H14.7571L18.8279 5.24278V18.2421Z" fill="#023DFE" fill-opacity="0.6"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_7302_4149">
|
||||||
|
<rect width="20" height="20" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.6 KiB |
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
import 'package:syncrow_app/features/auth/model/login_with_email_model.dart';
|
||||||
import 'package:syncrow_app/features/auth/model/signup_model.dart';
|
import 'package:syncrow_app/features/auth/model/signup_model.dart';
|
||||||
@ -217,9 +218,22 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
signUp() async {
|
signUp() async {
|
||||||
emit(AuthLoginLoading());
|
emit(AuthLoginLoading());
|
||||||
final response;
|
final response;
|
||||||
|
|
||||||
|
final clientId = dotenv.env['CLIENT_ID'] ?? '';
|
||||||
|
final clientSecret = dotenv.env['CLIENT_SECRET'] ?? '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<String> userFullName = fullName.split(' ');
|
List<String> userFullName = fullName.split(' ');
|
||||||
|
|
||||||
|
final clientToken = await AuthenticationAPI.fetchClientToken(
|
||||||
|
clientId: clientId,
|
||||||
|
clientSecret: clientSecret,
|
||||||
|
);
|
||||||
|
|
||||||
|
final accessToken = clientToken['accessToken'];
|
||||||
|
|
||||||
response = await AuthenticationAPI.signUp(
|
response = await AuthenticationAPI.signUp(
|
||||||
|
accessToken: accessToken,
|
||||||
model: SignUpModel(
|
model: SignUpModel(
|
||||||
hasAcceptedAppAgreement: true,
|
hasAcceptedAppAgreement: true,
|
||||||
email: email.toLowerCase(),
|
email: email.toLowerCase(),
|
||||||
|
|||||||
@ -178,6 +178,7 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
|
|||||||
DeviceType.CeilingSensor,
|
DeviceType.CeilingSensor,
|
||||||
DeviceType.ThreeGang,
|
DeviceType.ThreeGang,
|
||||||
DeviceType.OneGang,
|
DeviceType.OneGang,
|
||||||
|
DeviceType.TwoGang
|
||||||
};
|
};
|
||||||
|
|
||||||
return devices
|
return devices
|
||||||
|
|||||||
@ -76,21 +76,38 @@ class RoomPageSwitch extends StatelessWidget {
|
|||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Flexible(
|
LayoutBuilder(
|
||||||
child: FittedBox(
|
builder: (context, constraints) {
|
||||||
child: Column(
|
final text = device.name ?? "";
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
final textPainter = TextPainter(
|
||||||
children: [
|
text: TextSpan(
|
||||||
Text(
|
text: text,
|
||||||
device.name ?? "",
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 2,
|
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
);
|
||||||
|
|
||||||
|
textPainter.layout(maxWidth: constraints.maxWidth);
|
||||||
|
|
||||||
|
final exceeded = textPainter.didExceedMaxLines;
|
||||||
|
|
||||||
|
return Text(
|
||||||
|
exceeded ? '${text.substring(0, 10)}...' : text,
|
||||||
|
style: context.bodyLarge.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 20,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.clip,
|
||||||
|
maxLines: 1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
device.subspace!.subspaceName ?? '',
|
device.subspace!.subspaceName ?? '',
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@ -103,10 +120,6 @@ class RoomPageSwitch extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +132,6 @@ Future<void> showDeviceInterface(
|
|||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required isAllDevices,
|
required isAllDevices,
|
||||||
List<DeviceModel>? allDevices}) async {
|
List<DeviceModel>? allDevices}) async {
|
||||||
print('object-----${device.uuid} ${device.name}');
|
|
||||||
|
|
||||||
final devicesCubit = context.read<DevicesCubit>();
|
final devicesCubit = context.read<DevicesCubit>();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_event.dart';
|
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_event.dart';
|
||||||
@ -7,19 +5,31 @@ import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_event.dart
|
|||||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart';
|
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart';
|
||||||
|
|
||||||
class TabBarBloc extends Bloc<TabBarEvent, TabBarState> {
|
class TabBarBloc extends Bloc<TabBarEvent, TabBarState> {
|
||||||
final DeviceManagerBloc deviceManagerBloc;
|
TabBarBloc(this.deviceManagerBloc) : super(const TabBarInitialState()) {
|
||||||
TabBarBloc(this.deviceManagerBloc) : super(const Initial()) {
|
on<TabBarTabChangedEvent>(_onTabBarTabChangedEvent);
|
||||||
on<TabChanged>(_handleTabChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _handleTabChanged(
|
final DeviceManagerBloc deviceManagerBloc;
|
||||||
TabChanged event, Emitter<TabBarState> emit) {
|
|
||||||
|
void _onTabBarTabChangedEvent(
|
||||||
|
TabBarTabChangedEvent event,
|
||||||
|
Emitter<TabBarState> emit,
|
||||||
|
) {
|
||||||
|
_getDevices(event);
|
||||||
|
|
||||||
|
emit(
|
||||||
|
TabBarTabSelectedState(
|
||||||
|
roomId: event.roomId,
|
||||||
|
selectedTabIndex: event.selectedIndex,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _getDevices(TabBarTabChangedEvent event) {
|
||||||
if (event.roomId == "-1") {
|
if (event.roomId == "-1") {
|
||||||
deviceManagerBloc.add(FetchAllDevices());
|
deviceManagerBloc.add(FetchAllDevices());
|
||||||
} else {
|
} else {
|
||||||
deviceManagerBloc.add(FetchDevicesByRoomId(event.roomId,event.unit));
|
deviceManagerBloc.add(FetchDevicesByRoomId(event.roomId, event.unit));
|
||||||
}
|
}
|
||||||
emit(TabSelected(
|
|
||||||
roomId: event.roomId, selectedTabIndex: event.selectedIndex));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,14 @@ abstract class TabBarEvent {
|
|||||||
const TabBarEvent();
|
const TabBarEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabChanged extends TabBarEvent {
|
class TabBarTabChangedEvent extends TabBarEvent {
|
||||||
|
const TabBarTabChangedEvent({
|
||||||
|
required this.selectedIndex,
|
||||||
|
required this.roomId,
|
||||||
|
required this.unit,
|
||||||
|
});
|
||||||
|
|
||||||
final int selectedIndex;
|
final int selectedIndex;
|
||||||
final String roomId;
|
final String roomId;
|
||||||
final SpaceModel unit;
|
final SpaceModel unit;
|
||||||
const TabChanged(
|
|
||||||
{required this.selectedIndex, required this.roomId, required this.unit});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,12 +2,16 @@ abstract class TabBarState {
|
|||||||
const TabBarState();
|
const TabBarState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Initial extends TabBarState {
|
class TabBarInitialState extends TabBarState {
|
||||||
const Initial();
|
const TabBarInitialState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabSelected extends TabBarState {
|
class TabBarTabSelectedState extends TabBarState {
|
||||||
|
const TabBarTabSelectedState({
|
||||||
|
required this.roomId,
|
||||||
|
required this.selectedTabIndex,
|
||||||
|
});
|
||||||
|
|
||||||
final int selectedTabIndex;
|
final int selectedTabIndex;
|
||||||
final String roomId;
|
final String roomId;
|
||||||
const TabSelected({required this.roomId, required this.selectedTabIndex});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class ThreeGangHelperFunctions {
|
|||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 1 Switch',
|
operationName: 'L - Light Switch',
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
@ -21,11 +21,23 @@ class ThreeGangHelperFunctions {
|
|||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsLightCountdown,
|
||||||
|
operationName: 'L - Light Countdown',
|
||||||
|
code: 'countdown_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.countdown,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
|
],
|
||||||
|
),
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 2 Switch',
|
operationName: 'M - Light Switch',
|
||||||
code: 'switch_2',
|
code: 'switch_2',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
@ -36,11 +48,23 @@ class ThreeGangHelperFunctions {
|
|||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsLightCountdown,
|
||||||
|
operationName: 'M - Light Countdown',
|
||||||
|
code: 'countdown_2',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.countdown,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
|
],
|
||||||
|
),
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 3 Switch',
|
operationName: 'R - Light Switch',
|
||||||
code: 'switch_3',
|
code: 'switch_3',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
@ -55,31 +79,7 @@ class ThreeGangHelperFunctions {
|
|||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 1 CountDown',
|
operationName: 'R - Light Countdown',
|
||||||
code: 'countdown_1',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.countdown,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsLightCountdown,
|
|
||||||
operationName: 'Light 2 CountDown',
|
|
||||||
code: 'countdown_2',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.countdown,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsLightCountdown,
|
|
||||||
operationName: 'Light 3 CountDown',
|
|
||||||
code: 'countdown_3',
|
code: 'countdown_3',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.countdown,
|
operationDialogType: OperationDialogType.countdown,
|
||||||
@ -97,7 +97,7 @@ class ThreeGangHelperFunctions {
|
|||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 1 Switch',
|
operationName: 'L - Light Switch',
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
@ -108,41 +108,11 @@ class ThreeGangHelperFunctions {
|
|||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsAcPower,
|
|
||||||
operationName: 'Light 2 Switch',
|
|
||||||
code: 'switch_2',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.onOff,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
icon: Assets.assetsAcPower,
|
|
||||||
operationName: 'Light 3 Switch',
|
|
||||||
code: 'switch_3',
|
|
||||||
functionValue: functionValue,
|
|
||||||
operationDialogType: OperationDialogType.onOff,
|
|
||||||
operationalValues: [
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
|
||||||
SceneOperationalValue(
|
|
||||||
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 1 CountDown',
|
operationName: 'L - Light Countdown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.integerSteps,
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
@ -157,11 +127,26 @@ class ThreeGangHelperFunctions {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: 'M - Light Switch',
|
||||||
|
code: 'switch_2',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.onOff,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
|
],
|
||||||
|
),
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 2 CountDown',
|
operationName: 'M - Light Countdown',
|
||||||
code: 'countdown_2',
|
code: 'countdown_2',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.integerSteps,
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
@ -176,11 +161,26 @@ class ThreeGangHelperFunctions {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: 'R - Light Switch',
|
||||||
|
code: 'switch_3',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.onOff,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
|
],
|
||||||
|
),
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 3 CountDown',
|
operationName: 'R - Light Countdown',
|
||||||
code: 'countdown_3',
|
code: 'countdown_3',
|
||||||
functionValue: functionValue,
|
functionValue: functionValue,
|
||||||
operationDialogType: OperationDialogType.integerSteps,
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
|
|||||||
@ -0,0 +1,139 @@
|
|||||||
|
import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||||
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
|
|
||||||
|
class TowGangHelperFunctions {
|
||||||
|
static List<SceneStaticFunction> towGangHelperFunctions(
|
||||||
|
String deviceId, String deviceName, functionValue) {
|
||||||
|
return [
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: 'L - Light Switch',
|
||||||
|
code: 'switch_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.onOff,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsLightCountdown,
|
||||||
|
operationName: 'L - Light CountDown',
|
||||||
|
code: 'countdown_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.countdown,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: 'R - Light Switch',
|
||||||
|
code: 'switch_2',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.onOff,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsLightCountdown,
|
||||||
|
operationName: 'R - Light CountDown',
|
||||||
|
code: 'countdown_2',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.countdown,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<SceneStaticFunction> towGangAutomationFunctions(
|
||||||
|
String deviceId, String deviceName, functionValue) {
|
||||||
|
return [
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: 'L - Light Switch',
|
||||||
|
code: 'switch_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.onOff,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsLightCountdown,
|
||||||
|
operationName: 'R - Light CountDown',
|
||||||
|
code: 'countdown_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: '',
|
||||||
|
description: "sec",
|
||||||
|
value: 0.0,
|
||||||
|
minValue: 0,
|
||||||
|
maxValue: 43200,
|
||||||
|
stepValue: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: 'R - Light Switch',
|
||||||
|
code: 'switch_2',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.onOff,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: Assets.assetsAcPowerOFF, description: "OFF", value: false),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsLightCountdown,
|
||||||
|
operationName: 'R - Light CountDown',
|
||||||
|
code: 'countdown_2',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: '',
|
||||||
|
description: "sec",
|
||||||
|
value: 0.0,
|
||||||
|
minValue: 0,
|
||||||
|
maxValue: 43200,
|
||||||
|
stepValue: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ import 'package:syncrow_app/features/scene/helper/functions_per_device/human_pre
|
|||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/one_gang_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/one_gang_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/presence_sensor.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/presence_sensor.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/three_gang_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/three_gang_functions.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/tow_gang_helper_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
@ -27,6 +28,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
DeviceType.ThreeGang: threeGangFunctions,
|
DeviceType.ThreeGang: threeGangFunctions,
|
||||||
DeviceType.Gateway: gatewayFunctions,
|
DeviceType.Gateway: gatewayFunctions,
|
||||||
DeviceType.OneGang: oneGangFunctions,
|
DeviceType.OneGang: oneGangFunctions,
|
||||||
|
DeviceType.TwoGang: towGangFunctions,
|
||||||
};
|
};
|
||||||
|
|
||||||
final Map<DeviceType, String> _titleMap = {
|
final Map<DeviceType, String> _titleMap = {
|
||||||
@ -39,8 +41,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
DeviceType.ThreeGang: '3G Light Switch Functions',
|
DeviceType.ThreeGang: '3G Light Switch Functions',
|
||||||
DeviceType.Gateway: 'Gateway Functions',
|
DeviceType.Gateway: 'Gateway Functions',
|
||||||
DeviceType.OneGang: '1G Light Switch Conditions',
|
DeviceType.OneGang: '1G Light Switch Conditions',
|
||||||
|
DeviceType.TwoGang: '2G Light Switch Conditions',
|
||||||
};
|
};
|
||||||
static String _productTypeCache = '';
|
|
||||||
|
|
||||||
//one gang functions
|
//one gang functions
|
||||||
static List<SceneStaticFunction> oneGangFunctions(
|
static List<SceneStaticFunction> oneGangFunctions(
|
||||||
@ -57,6 +59,20 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static List<SceneStaticFunction> towGangFunctions(
|
||||||
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
|
if (isAutomation) {
|
||||||
|
return TowGangHelperFunctions.towGangAutomationFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
|
}
|
||||||
|
return TowGangHelperFunctions.towGangHelperFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> getFunctionsWithIcons({
|
List<SceneStaticFunction> getFunctionsWithIcons({
|
||||||
DeviceType? type,
|
DeviceType? type,
|
||||||
required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
@ -243,6 +259,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
for (var condition in conditions) {
|
for (var condition in conditions) {
|
||||||
// Create a dummy Action from Condition to reuse _mapExecutorPropertyToSceneFunction
|
// Create a dummy Action from Condition to reuse _mapExecutorPropertyToSceneFunction
|
||||||
Action dummyAction = Action(
|
Action dummyAction = Action(
|
||||||
|
productType: condition.productType,
|
||||||
actionExecutor: 'device_report',
|
actionExecutor: 'device_report',
|
||||||
entityId: condition.entityId,
|
entityId: condition.entityId,
|
||||||
executorProperty: ExecutorProperty(
|
executorProperty: ExecutorProperty(
|
||||||
@ -830,6 +847,72 @@ mixin SceneOperationsDataHelper {
|
|||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
|
case "2G":
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'2 Gang Button Switch L-L',
|
||||||
|
Assets.twoGang,
|
||||||
|
'Light 1 Switch',
|
||||||
|
OperationDialogType.onOff,
|
||||||
|
_createOnOffOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
case "1G":
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'1 Gang Button Switch L-L',
|
||||||
|
Assets.oneGang,
|
||||||
|
'Light 1 Switch',
|
||||||
|
OperationDialogType.onOff,
|
||||||
|
_createOnOffOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'None',
|
||||||
|
Assets.assetsRemoteUnlockReq,
|
||||||
|
'None',
|
||||||
|
OperationDialogType.onOff,
|
||||||
|
_createOnOffOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SceneStaticFunction _createSwitch2Function(Action action, bool isAutomation,
|
||||||
|
String? comparator, String? uniqueCustomId) {
|
||||||
|
switch (action.productType) {
|
||||||
|
case "3G":
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'3 Gang Button Switch L-L',
|
||||||
|
Assets.assetsIcons3GangSwitch,
|
||||||
|
'Light 2 Switch',
|
||||||
|
OperationDialogType.onOff,
|
||||||
|
_createOnOffOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
case "2G":
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'2 Gang Button Switch L-L',
|
||||||
|
Assets.twoGang,
|
||||||
|
'Light 2 Switch',
|
||||||
|
OperationDialogType.onOff,
|
||||||
|
_createOnOffOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
@ -845,21 +928,6 @@ mixin SceneOperationsDataHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch2Function(Action action, bool isAutomation,
|
|
||||||
String? comparator, String? uniqueCustomId) {
|
|
||||||
return _createSceneFunction(
|
|
||||||
action,
|
|
||||||
'3 Gang Button Switch L-L',
|
|
||||||
Assets.assetsIcons3GangSwitch,
|
|
||||||
'Light 2 Switch',
|
|
||||||
OperationDialogType.onOff,
|
|
||||||
_createOnOffOptions(),
|
|
||||||
isAutomation,
|
|
||||||
comparator,
|
|
||||||
uniqueCustomId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch3Function(Action action, bool isAutomation,
|
SceneStaticFunction _createSwitch3Function(Action action, bool isAutomation,
|
||||||
String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
@ -894,6 +962,22 @@ mixin SceneOperationsDataHelper {
|
|||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
|
case "2G":
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'2 Gang Button Switch L-L',
|
||||||
|
Assets.twoGang,
|
||||||
|
'Light 1 CountDown',
|
||||||
|
isAutomation
|
||||||
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.countdown,
|
||||||
|
isAutomation
|
||||||
|
? _createAutomationCountDownOptions()
|
||||||
|
: _createCountdownOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
@ -915,6 +999,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
|
|
||||||
SceneStaticFunction _createCountdown2Function(Action action,
|
SceneStaticFunction _createCountdown2Function(Action action,
|
||||||
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
|
switch (action.productType) {
|
||||||
|
case "3G":
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -930,6 +1016,39 @@ mixin SceneOperationsDataHelper {
|
|||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
|
case "2G":
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'2 Gang Button Switch L-L',
|
||||||
|
Assets.twoGang,
|
||||||
|
'Light 2 CountDown',
|
||||||
|
isAutomation
|
||||||
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.countdown,
|
||||||
|
isAutomation
|
||||||
|
? _createAutomationCountDownOptions()
|
||||||
|
: _createCountdownOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'1 Gang Button Switch L-L',
|
||||||
|
Assets.oneGang,
|
||||||
|
'Light CountDown',
|
||||||
|
isAutomation
|
||||||
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.countdown,
|
||||||
|
isAutomation
|
||||||
|
? _createAutomationCountDownOptions()
|
||||||
|
: _createCountdownOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown3Function(Action action,
|
SceneStaticFunction _createCountdown3Function(Action action,
|
||||||
@ -1328,6 +1447,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
return [
|
return [
|
||||||
_mapExecutorPropertyToSceneFunction(
|
_mapExecutorPropertyToSceneFunction(
|
||||||
Action(
|
Action(
|
||||||
|
productType: '',
|
||||||
entityId: deviceId,
|
entityId: deviceId,
|
||||||
executorProperty: ExecutorProperty(
|
executorProperty: ExecutorProperty(
|
||||||
functionCode: taskItem.code,
|
functionCode: taskItem.code,
|
||||||
|
|||||||
@ -74,7 +74,7 @@ class Action {
|
|||||||
ExecutorProperty? executorProperty;
|
ExecutorProperty? executorProperty;
|
||||||
String? name;
|
String? name;
|
||||||
String? type;
|
String? type;
|
||||||
String? productType;
|
final String productType;
|
||||||
|
|
||||||
Action({
|
Action({
|
||||||
required this.actionExecutor,
|
required this.actionExecutor,
|
||||||
@ -82,7 +82,7 @@ class Action {
|
|||||||
this.executorProperty,
|
this.executorProperty,
|
||||||
this.name,
|
this.name,
|
||||||
this.type,
|
this.type,
|
||||||
this.productType,
|
required this.productType,
|
||||||
});
|
});
|
||||||
|
|
||||||
String toRawJson() => json.encode(toJson());
|
String toRawJson() => json.encode(toJson());
|
||||||
@ -94,7 +94,7 @@ class Action {
|
|||||||
entityId: json["entityId"] as String,
|
entityId: json["entityId"] as String,
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
type: json['type'] as String?,
|
type: json['type'] as String?,
|
||||||
productType: json['productType'] as String?,
|
productType: json['productType'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (json["executorProperty"] == null) {
|
if (json["executorProperty"] == null) {
|
||||||
@ -105,7 +105,7 @@ class Action {
|
|||||||
actionExecutor: json["actionExecutor"] as String,
|
actionExecutor: json["actionExecutor"] as String,
|
||||||
entityId: json["entityId"] as String,
|
entityId: json["entityId"] as String,
|
||||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||||
productType: json['productType'] as String?,
|
productType: json['productType'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,12 +146,14 @@ class Condition {
|
|||||||
final String entityId;
|
final String entityId;
|
||||||
final String entityType;
|
final String entityType;
|
||||||
final Expr expr;
|
final Expr expr;
|
||||||
|
final String productType;
|
||||||
|
|
||||||
Condition({
|
Condition({
|
||||||
required this.code,
|
required this.code,
|
||||||
required this.entityId,
|
required this.entityId,
|
||||||
required this.entityType,
|
required this.entityType,
|
||||||
required this.expr,
|
required this.expr,
|
||||||
|
required this.productType,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Condition.fromRawJson(String str) =>
|
factory Condition.fromRawJson(String str) =>
|
||||||
@ -164,6 +166,7 @@ class Condition {
|
|||||||
entityId: json["entityId"],
|
entityId: json["entityId"],
|
||||||
entityType: json["entityType"],
|
entityType: json["entityType"],
|
||||||
expr: Expr.fromJson(json["expr"]),
|
expr: Expr.fromJson(json["expr"]),
|
||||||
|
productType: json['productType'] as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||||
@ -12,6 +13,7 @@ import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
|||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/light_divider.dart';
|
import 'package:syncrow_app/features/shared_widgets/light_divider.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
import 'package:syncrow_app/navigation/navigate_to_route.dart';
|
||||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
@ -51,22 +53,14 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
.add(AddTaskEvent(isAutomation: isAutomation));
|
.add(AddTaskEvent(isAutomation: isAutomation));
|
||||||
navigateToRoute(context, Routes.sceneTasksRoute);
|
navigateToRoute(context, Routes.sceneTasksRoute);
|
||||||
},
|
},
|
||||||
child: BodyMedium(
|
child: SvgPicture.asset(Assets.saveRoutinesIcon),
|
||||||
text: 'Save',
|
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
fontColor: ColorsManager.secondaryColor.withOpacity(0.6),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
leading: TextButton(
|
leading: TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_cancelOperation(context, device, isAutomation);
|
_cancelOperation(context, device, isAutomation);
|
||||||
},
|
},
|
||||||
child: BodyMedium(
|
child: SvgPicture.asset(Assets.cancelIcon),
|
||||||
text: 'Cancel',
|
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
fontColor: ColorsManager.textPrimaryColor.withOpacity(0.6),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
leadingWidth: 80,
|
leadingWidth: 80,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@ -75,21 +69,27 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
itemCount: functions.length,
|
itemCount: functions.length,
|
||||||
padding: const EdgeInsets.only(top: 24.0),
|
padding: const EdgeInsets.only(top: 24.0),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return DefaultContainer(
|
final bool isFirstInPair = index % 2 == 0;
|
||||||
padding: index == 0
|
final bool isLastInPair =
|
||||||
? const EdgeInsets.only(top: 8)
|
index % 2 == 1 || index == functions.length - 1;
|
||||||
: index == functions.length - 1
|
final bool isLastItem = index == functions.length - 1;
|
||||||
? const EdgeInsets.only(bottom: 8)
|
|
||||||
: EdgeInsets.zero,
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (isFirstInPair && index != 0) const SizedBox(height: 16),
|
||||||
|
DefaultContainer(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: isFirstInPair ? 8 : 0,
|
||||||
|
bottom: isLastInPair ? 8 : 0,
|
||||||
|
),
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
borderRadius: index == 0
|
borderRadius: BorderRadius.only(
|
||||||
? const BorderRadius.only(
|
topLeft: Radius.circular(isFirstInPair ? 20 : 0),
|
||||||
topLeft: Radius.circular(20), topRight: Radius.circular(20))
|
topRight: Radius.circular(isFirstInPair ? 20 : 0),
|
||||||
: index == functions.length - 1
|
bottomLeft: Radius.circular(isLastInPair ? 20 : 0),
|
||||||
? const BorderRadius.only(
|
bottomRight: Radius.circular(isLastInPair ? 20 : 0),
|
||||||
bottomLeft: Radius.circular(20),
|
),
|
||||||
bottomRight: Radius.circular(20))
|
|
||||||
: BorderRadius.zero,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@ -100,40 +100,32 @@ class DeviceFunctionsView extends StatelessWidget
|
|||||||
minLeadingWidth: 20,
|
minLeadingWidth: 20,
|
||||||
assetPath: functions[index].icon,
|
assetPath: functions[index].icon,
|
||||||
titleString: functions[index].operationName,
|
titleString: functions[index].operationName,
|
||||||
trailingWidget: const Row(
|
trailingWidget: const Icon(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.arrow_forward_ios_rounded,
|
Icons.arrow_forward_ios_rounded,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
_showAutomationDialog(
|
_showAutomationDialog(
|
||||||
context,
|
context, functions[index], device);
|
||||||
functions[index],
|
|
||||||
device,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
_showTabToRunDialog(
|
_showTabToRunDialog(
|
||||||
context,
|
context, functions[index], device);
|
||||||
functions[index],
|
|
||||||
device,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
index != functions.length - 1
|
if (isFirstInPair && !isLastItem)
|
||||||
? SizedBox(
|
SizedBox(
|
||||||
width: context.width * 0.8, child: const LightDivider())
|
width: context.width * 0.8,
|
||||||
: const SizedBox(),
|
child: const LightDivider(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -20,82 +20,69 @@ class SceneRoomsTabBarDevicesView extends StatefulWidget {
|
|||||||
_SceneRoomsTabBarDevicesViewState();
|
_SceneRoomsTabBarDevicesViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SceneRoomsTabBarDevicesViewState
|
class _SceneRoomsTabBarDevicesViewState extends State<SceneRoomsTabBarDevicesView>
|
||||||
extends State<SceneRoomsTabBarDevicesView>
|
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
late final TabController _tabController;
|
late final TabController _tabController;
|
||||||
List<SubSpaceModel>? rooms = [];
|
|
||||||
late final SpaceModel selectedSpace;
|
late final SpaceModel selectedSpace;
|
||||||
|
var rooms = <SubSpaceModel>[];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
||||||
|
|
||||||
rooms = List.from(selectedSpace.subspaces ?? []);
|
rooms = List.from(selectedSpace.subspaces);
|
||||||
|
final defaultSubSpaceModel = SubSpaceModel(
|
||||||
if (rooms != null && rooms!.isNotEmpty) {
|
|
||||||
if (rooms![0].id != '-1') {
|
|
||||||
rooms?.insert(
|
|
||||||
0,
|
|
||||||
SubSpaceModel(
|
|
||||||
name: 'All Devices',
|
name: 'All Devices',
|
||||||
devices: context.read<DevicesCubit>().allDevices,
|
devices: context.read<DevicesCubit>().allDevices,
|
||||||
id: '-1',
|
id: '-1',
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (rooms.isNotEmpty) {
|
||||||
|
final isFirstRoomIdValid = rooms[0].id != '-1';
|
||||||
|
if (isFirstRoomIdValid) {
|
||||||
|
rooms.insert(0, defaultSubSpaceModel);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rooms = [
|
rooms = [defaultSubSpaceModel];
|
||||||
SubSpaceModel(
|
|
||||||
name: 'All Devices',
|
|
||||||
devices: context.read<DevicesCubit>().allDevices,
|
|
||||||
id: '-1',
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_tabController = TabController(length: rooms!.length, vsync: this);
|
_tabController = TabController(length: rooms.length, vsync: this);
|
||||||
_tabController.addListener(_handleTabSwitched);
|
_tabController.addListener(_handleTabSwitched);
|
||||||
setState(() {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleTabSwitched() {
|
|
||||||
if (_tabController.indexIsChanging) {
|
|
||||||
final value = _tabController.index;
|
|
||||||
|
|
||||||
/// select tab
|
|
||||||
context.read<TabBarBloc>().add(TabChanged(
|
|
||||||
selectedIndex: value,
|
|
||||||
roomId: rooms?[value].id ?? '',
|
|
||||||
unit: selectedSpace));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_tabController.dispose();
|
|
||||||
_tabController.removeListener(() {});
|
_tabController.removeListener(() {});
|
||||||
|
_tabController.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleTabSwitched() {
|
||||||
|
if (_tabController.indexIsChanging) {
|
||||||
|
final index = _tabController.index;
|
||||||
|
|
||||||
|
context.read<TabBarBloc>().add(
|
||||||
|
TabBarTabChangedEvent(
|
||||||
|
selectedIndex: index,
|
||||||
|
roomId: rooms[index].id ?? '',
|
||||||
|
unit: selectedSpace,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: StringsManager.createScene,
|
padding: EdgeInsetsDirectional.zero,
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
onPressed: () {
|
onPressed: () => navigateToRoute(context, Routes.sceneTasksRoute),
|
||||||
navigateToRoute(context, Routes.sceneTasksRoute);
|
icon: const Icon(Icons.arrow_back_ios),
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.arrow_back_ios,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
title: StringsManager.createScene,
|
||||||
child: SceneDevicesBody(tabController: _tabController, rooms: rooms),
|
child: SceneDevicesBody(tabController: _tabController, rooms: rooms),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
|
||||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart';
|
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_state.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||||
@ -8,60 +7,44 @@ import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart'
|
|||||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart';
|
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_state.dart';
|
||||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
import 'package:syncrow_app/features/scene/widgets/scene_devices/scene_devices_body_tab_bar.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/scene/widgets/scene_devices/scene_devices_list.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/app_loading_indicator.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
|
||||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|
||||||
|
|
||||||
class SceneDevicesBody extends StatelessWidget {
|
class SceneDevicesBody extends StatelessWidget {
|
||||||
const SceneDevicesBody({
|
const SceneDevicesBody({
|
||||||
super.key,
|
required this.tabController,
|
||||||
required TabController tabController,
|
|
||||||
required this.rooms,
|
required this.rooms,
|
||||||
}) : _tabController = tabController;
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final TabController _tabController;
|
final TabController tabController;
|
||||||
final List<SubSpaceModel>? rooms;
|
final List<SubSpaceModel> rooms;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isAutomationDeviceStatus =
|
|
||||||
((ModalRoute.of(context)?.settings.arguments as SceneSettingsRouteArguments?)?.sceneType ==
|
|
||||||
CreateSceneEnum.deviceStatusChanges.name);
|
|
||||||
return BlocBuilder<TabBarBloc, TabBarState>(
|
return BlocBuilder<TabBarBloc, TabBarState>(
|
||||||
builder: (context, tabState) {
|
builder: (context, state) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
TabBar(
|
SceneDevicesBodyTabBar(
|
||||||
controller: _tabController,
|
tabController: tabController,
|
||||||
dividerColor: Colors.transparent,
|
rooms: rooms,
|
||||||
indicatorColor: Colors.transparent,
|
selectedRoomId: state is TabBarTabSelectedState ? state.roomId : '-1',
|
||||||
tabs: [
|
|
||||||
...rooms!.map((e) => Tab(
|
|
||||||
child: BodyLarge(
|
|
||||||
text: e.name ?? '',
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
style: context.bodyLarge.copyWith(
|
|
||||||
color: (tabState is TabSelected) && tabState.roomId == e.id
|
|
||||||
? ColorsManager.textPrimaryColor
|
|
||||||
: ColorsManager.textPrimaryColor.withOpacity(0.2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
isScrollable: true,
|
|
||||||
tabAlignment: TabAlignment.start,
|
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: _tabController,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
children:
|
controller: tabController,
|
||||||
rooms!.map((e) => _buildRoomTab(e, context, isAutomationDeviceStatus)).toList(),
|
children: rooms
|
||||||
|
.map(
|
||||||
|
(room) => _buildRoomTab(
|
||||||
|
room,
|
||||||
|
_isAutomationDeviceStatus(context),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -70,52 +53,46 @@ class SceneDevicesBody extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRoomTab(SubSpaceModel room, BuildContext context, bool isAutomationDeviceStatus) {
|
bool _isAutomationDeviceStatus(BuildContext context) {
|
||||||
|
final routeArguments =
|
||||||
|
ModalRoute.of(context)?.settings.arguments as SceneSettingsRouteArguments?;
|
||||||
|
final deviceStatusChangesScene = CreateSceneEnum.deviceStatusChanges.name;
|
||||||
|
final sceneType = routeArguments?.sceneType;
|
||||||
|
|
||||||
|
return sceneType == deviceStatusChangesScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRoomTab(
|
||||||
|
SubSpaceModel room,
|
||||||
|
bool isAutomationDeviceStatus,
|
||||||
|
) {
|
||||||
return BlocBuilder<DeviceManagerBloc, DeviceManagerState>(
|
return BlocBuilder<DeviceManagerBloc, DeviceManagerState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state.loading && state.devices == null) {
|
final isLoading = state.loading && state.devices == null;
|
||||||
return const Center(child: CircularProgressIndicator());
|
final hasData =
|
||||||
} else if (state.devices != null && state.devices!.isNotEmpty) {
|
state.devices != null && (state.devices?.isNotEmpty ?? false);
|
||||||
return ListView.builder(
|
final hasError = state.error != null;
|
||||||
itemCount: state.devices!.length,
|
|
||||||
itemBuilder: (context, index) {
|
final widgets = <bool, Widget>{
|
||||||
final device = state.devices![index];
|
isLoading: const AppLoadingIndicator(),
|
||||||
return DefaultContainer(
|
hasError: Center(child: Text('${state.error}')),
|
||||||
child: SceneListTile(
|
hasData: SceneDevicesList(
|
||||||
minLeadingWidth: 40,
|
devices: state.devices ?? [],
|
||||||
leadingWidget: SvgPicture.asset(device.icon ?? ''),
|
isAutomationDeviceStatus: isAutomationDeviceStatus,
|
||||||
titleWidget: BodyMedium(
|
|
||||||
text: device.name ?? '',
|
|
||||||
style: context.titleSmall.copyWith(
|
|
||||||
color: ColorsManager.secondaryTextColor,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
),
|
||||||
),
|
};
|
||||||
trailingWidget: const Icon(
|
|
||||||
Icons.arrow_forward_ios_rounded,
|
final invalidWidgetEntry = MapEntry(
|
||||||
color: ColorsManager.greyColor,
|
true,
|
||||||
size: 16,
|
Center(child: Text('This subspace has no devices')),
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pushNamed(
|
|
||||||
context,
|
|
||||||
Routes.deviceFunctionsRoute,
|
|
||||||
arguments: {
|
|
||||||
"device": device,
|
|
||||||
"isAutomationDeviceStatus": isAutomationDeviceStatus
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
|
||||||
),
|
final validWidgetEntry = widgets.entries.firstWhere(
|
||||||
|
(entry) => entry.key == true,
|
||||||
|
orElse: () => invalidWidgetEntry,
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
return validWidgetEntry.value;
|
||||||
} else if (state.error != null) {
|
|
||||||
return const Center(child: Text('Something went wrong'));
|
|
||||||
} else {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
|
class SceneDevicesBodyTabBar extends StatelessWidget {
|
||||||
|
const SceneDevicesBodyTabBar({
|
||||||
|
required this.tabController,
|
||||||
|
required this.rooms,
|
||||||
|
required this.selectedRoomId,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String selectedRoomId;
|
||||||
|
|
||||||
|
final TabController tabController;
|
||||||
|
final List<SubSpaceModel> rooms;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TabBar(
|
||||||
|
controller: tabController,
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
indicatorColor: Colors.transparent,
|
||||||
|
isScrollable: true,
|
||||||
|
tabAlignment: TabAlignment.start,
|
||||||
|
tabs: rooms.map((e) {
|
||||||
|
final isSelected = selectedRoomId == e.id;
|
||||||
|
return Tab(
|
||||||
|
child: BodyLarge(
|
||||||
|
text: e.name ?? '',
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
style: context.bodyLarge.copyWith(
|
||||||
|
color: isSelected
|
||||||
|
? ColorsManager.textPrimaryColor
|
||||||
|
: ColorsManager.textPrimaryColor.withValues(
|
||||||
|
alpha: 0.2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
|
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||||
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
|
class SceneDevicesList extends StatelessWidget {
|
||||||
|
const SceneDevicesList({
|
||||||
|
required this.isAutomationDeviceStatus,
|
||||||
|
required this.devices,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
final List<DeviceModel> devices;
|
||||||
|
final bool isAutomationDeviceStatus;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: devices.length,
|
||||||
|
itemBuilder: (context, index) => _buildDeviceTile(context, devices[index]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDeviceTile(
|
||||||
|
BuildContext context,
|
||||||
|
DeviceModel device,
|
||||||
|
) {
|
||||||
|
return DefaultContainer(
|
||||||
|
child: SceneListTile(
|
||||||
|
minLeadingWidth: 40,
|
||||||
|
leadingWidget: SvgPicture.asset(device.icon ?? ''),
|
||||||
|
titleWidget: BodyMedium(
|
||||||
|
text: device.name ?? '',
|
||||||
|
style: context.titleSmall.copyWith(
|
||||||
|
color: ColorsManager.secondaryTextColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailingWidget: const Icon(
|
||||||
|
Icons.arrow_forward_ios_rounded,
|
||||||
|
color: ColorsManager.greyColor,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
onPressed: () => _navigateToDeviceFunctions(context, device),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToDeviceFunctions(
|
||||||
|
BuildContext context,
|
||||||
|
DeviceModel device,
|
||||||
|
) {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
Routes.deviceFunctionsRoute,
|
||||||
|
arguments: {
|
||||||
|
"device": device,
|
||||||
|
"isAutomationDeviceStatus": isAutomationDeviceStatus,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1142,5 +1142,9 @@ class Assets {
|
|||||||
|
|
||||||
static const String toggleSwitchSmall = 'assets/icons/toggleSwitchSmall.svg';
|
static const String toggleSwitchSmall = 'assets/icons/toggleSwitchSmall.svg';
|
||||||
static const String offToggleSwitchSmall = 'assets/icons/offToggleSwitchSmall.svg';
|
static const String offToggleSwitchSmall = 'assets/icons/offToggleSwitchSmall.svg';
|
||||||
|
static const String saveRoutinesIcon = 'assets/icons/save_routines_icon.svg';
|
||||||
|
static const String cancelIcon = 'assets/icons/cancel_icon.svg';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_app/features/app_layout/model/community_model.dart';
|
import 'package:syncrow_app/features/app_layout/model/community_model.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/view/app_layout.dart';
|
import 'package:syncrow_app/features/app_layout/view/app_layout.dart';
|
||||||
import 'package:syncrow_app/features/auth/view/otp_view.dart';
|
|
||||||
import 'package:syncrow_app/features/auth/view/login_view.dart';
|
import 'package:syncrow_app/features/auth/view/login_view.dart';
|
||||||
|
import 'package:syncrow_app/features/auth/view/otp_view.dart';
|
||||||
import 'package:syncrow_app/features/auth/view/sign_up_view.dart';
|
import 'package:syncrow_app/features/auth/view/sign_up_view.dart';
|
||||||
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
import 'package:syncrow_app/features/dashboard/view/dashboard_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
import 'package:syncrow_app/features/devices/bloc/device_manager_bloc/device_manager_bloc.dart';
|
||||||
@ -17,11 +17,12 @@ import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_bloc.dart'
|
|||||||
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_event.dart';
|
import 'package:syncrow_app/features/scene/bloc/tab_change/tab_change_event.dart';
|
||||||
import 'package:syncrow_app/features/scene/view/device_functions_view.dart';
|
import 'package:syncrow_app/features/scene/view/device_functions_view.dart';
|
||||||
import 'package:syncrow_app/features/scene/view/scene_auto_settings.dart';
|
import 'package:syncrow_app/features/scene/view/scene_auto_settings.dart';
|
||||||
import 'package:syncrow_app/features/scene/view/scene_tasks_view.dart';
|
|
||||||
import 'package:syncrow_app/features/scene/view/scene_rooms_tabbar.dart';
|
import 'package:syncrow_app/features/scene/view/scene_rooms_tabbar.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/view/scene_tasks_view.dart';
|
||||||
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
import 'package:syncrow_app/features/scene/view/scene_view.dart';
|
||||||
import 'package:syncrow_app/features/scene/view/smart_automation_select_route.dart';
|
import 'package:syncrow_app/features/scene/view/smart_automation_select_route.dart';
|
||||||
import 'package:syncrow_app/features/splash/view/splash_view.dart';
|
import 'package:syncrow_app/features/splash/view/splash_view.dart';
|
||||||
|
|
||||||
import 'routing_constants.dart';
|
import 'routing_constants.dart';
|
||||||
|
|
||||||
class Router {
|
class Router {
|
||||||
@ -88,7 +89,7 @@ class Router {
|
|||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (BuildContext context) =>
|
create: (BuildContext context) =>
|
||||||
TabBarBloc(context.read<DeviceManagerBloc>())
|
TabBarBloc(context.read<DeviceManagerBloc>())
|
||||||
..add(TabChanged(
|
..add(TabBarTabChangedEvent(
|
||||||
selectedIndex: 0,
|
selectedIndex: 0,
|
||||||
roomId: '-1',
|
roomId: '-1',
|
||||||
unit: SpaceModel(
|
unit: SpaceModel(
|
||||||
|
|||||||
@ -11,7 +11,7 @@ abstract class ApiEndpoints {
|
|||||||
static const String sendOtp = '/authentication/user/send-otp';
|
static const String sendOtp = '/authentication/user/send-otp';
|
||||||
static const String verifyOtp = '/authentication/user/verify-otp';
|
static const String verifyOtp = '/authentication/user/verify-otp';
|
||||||
static const String forgetPassword = '/authentication/user/forget-password';
|
static const String forgetPassword = '/authentication/user/forget-password';
|
||||||
|
static const String clientLogin = '/client/token';
|
||||||
////////////////////////////////////// Spaces ///////////////////////////////////////
|
////////////////////////////////////// Spaces ///////////////////////////////////////
|
||||||
|
|
||||||
///Community Module
|
///Community Module
|
||||||
@ -111,9 +111,9 @@ abstract class ApiEndpoints {
|
|||||||
//POST
|
//POST
|
||||||
static const String addDeviceToRoom = '/device/room';
|
static const String addDeviceToRoom = '/device/room';
|
||||||
static const String addDeviceToGroup = '/device/group';
|
static const String addDeviceToGroup = '/device/group';
|
||||||
static const String controlDevice = '/device/{deviceUuid}/control';
|
static const String controlDevice = '/devices/{deviceUuid}/command';
|
||||||
static const String firmwareDevice =
|
static const String firmwareDevice =
|
||||||
'/device/{deviceUuid}/firmware/{firmwareVersion}';
|
'/devices/{deviceUuid}/firmware/{firmwareVersion}';
|
||||||
static const String getDevicesByUserId = '/device/user/{userId}';
|
static const String getDevicesByUserId = '/device/user/{userId}';
|
||||||
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
||||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||||
@ -121,13 +121,13 @@ abstract class ApiEndpoints {
|
|||||||
//GET
|
//GET
|
||||||
static const String deviceByRoom =
|
static const String deviceByRoom =
|
||||||
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
|
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
|
||||||
static const String deviceByUuid = '/device/{deviceUuid}';
|
static const String deviceByUuid = '/devices/{deviceUuid}';
|
||||||
static const String deviceFunctions = '/device/{deviceUuid}/functions';
|
static const String deviceFunctions = '/devices/{deviceUuid}/functions';
|
||||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
||||||
static const String deviceFunctionsStatus =
|
static const String deviceFunctionsStatus =
|
||||||
'/device/{deviceUuid}/functions/status';
|
'/devices/{deviceUuid}/functions/status';
|
||||||
static const String powerClamp =
|
static const String powerClamp =
|
||||||
'/device/{powerClampUuid}/power-clamp/status';
|
'/devices/{deviceUuid}/functions/status';
|
||||||
|
|
||||||
///Device Permission Module
|
///Device Permission Module
|
||||||
//POST
|
//POST
|
||||||
@ -153,7 +153,8 @@ abstract class ApiEndpoints {
|
|||||||
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
static const String getScene = '/scene/tap-to-run/{sceneId}';
|
||||||
static const String getIconScene = '/scene/icon';
|
static const String getIconScene = '/scene/icon';
|
||||||
|
|
||||||
static const String getUnitAutomation = '/projects/{projectId}/communities/{communityId}/spaces/{unitUuid}/automations';
|
static const String getUnitAutomation =
|
||||||
|
'/projects/{projectId}/communities/{communityId}/spaces/{unitUuid}/automations';
|
||||||
|
|
||||||
static const String getAutomationDetails =
|
static const String getAutomationDetails =
|
||||||
'/projects/{projectId}/automations/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
@ -161,7 +162,8 @@ abstract class ApiEndpoints {
|
|||||||
/// PUT
|
/// PUT
|
||||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String updateAutomation = '/projects/{projectId}/automations/{automationId}';
|
static const String updateAutomation =
|
||||||
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
static const String updateAutomationStatus =
|
static const String updateAutomationStatus =
|
||||||
'/projects/{projectId}/automations/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
@ -169,7 +171,8 @@ abstract class ApiEndpoints {
|
|||||||
/// DELETE
|
/// DELETE
|
||||||
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
|
static const String deleteAutomation =
|
||||||
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
//////////////////////Door Lock //////////////////////
|
//////////////////////Door Lock //////////////////////
|
||||||
//online
|
//online
|
||||||
@ -213,18 +216,18 @@ abstract class ApiEndpoints {
|
|||||||
static const String changeSchedule = '/schedule/enable/{deviceUuid}';
|
static const String changeSchedule = '/schedule/enable/{deviceUuid}';
|
||||||
static const String deleteSchedule = '/schedule/{deviceUuid}/{scheduleId}';
|
static const String deleteSchedule = '/schedule/{deviceUuid}/{scheduleId}';
|
||||||
static const String reportLogs =
|
static const String reportLogs =
|
||||||
'/device/report-logs/{deviceUuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
'/devices/report-logs/{deviceUuid}?code={code}&startTime={startTime}&endTime={endTime}';
|
||||||
static const String controlBatch = '/device/control/batch';
|
static const String controlBatch = '/devices/batch';
|
||||||
static const String statusBatch = '/device/status/batch';
|
static const String statusBatch = '/devices/batch';
|
||||||
static const String deviceScene = '/device/{deviceUuid}/scenes';
|
static const String deviceScene = '/devices/{deviceUuid}/scenes';
|
||||||
|
|
||||||
static const String fourSceneByName =
|
static const String fourSceneByName =
|
||||||
'/device/{deviceUuid}/scenes?switchName={switchName}';
|
'/devices/{deviceUuid}/scenes?switchName={switchName}';
|
||||||
|
|
||||||
static const String resetDevice = '/factory/reset/{deviceUuid}';
|
static const String resetDevice = '/factory/reset/{deviceUuid}';
|
||||||
static const String unAssignScenesDevice =
|
static const String unAssignScenesDevice =
|
||||||
'/device/{deviceUuid}/scenes?switchName={switchName}';
|
'/devices/{deviceUuid}/scenes?switchName={switchName}';
|
||||||
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
|
static const String getDeviceLogs = '/devices/report-logs/{uuid}?code={code}';
|
||||||
static const String terms = '/terms';
|
static const String terms = '/terms';
|
||||||
static const String policy = '/policy';
|
static const String policy = '/policy';
|
||||||
static const String getPermission = '/permission/{roleUuid}';
|
static const String getPermission = '/permission/{roleUuid}';
|
||||||
|
|||||||
@ -25,11 +25,15 @@ class AuthenticationAPI {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<bool> signUp({required SignUpModel model}) async {
|
static Future<bool> signUp({
|
||||||
|
required SignUpModel model,
|
||||||
|
required String accessToken,
|
||||||
|
}) async {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.signUp,
|
path: ApiEndpoints.signUp,
|
||||||
body: model.toJson(),
|
body: model.toJson(),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
|
accessToken: accessToken,
|
||||||
expectedResponseModel: (json) => json['statusCode'] == 201);
|
expectedResponseModel: (json) => json['statusCode'] == 201);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -63,4 +67,20 @@ class AuthenticationAPI {
|
|||||||
expectedResponseModel: (json) => json['data']);
|
expectedResponseModel: (json) => json['data']);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>> fetchClientToken({
|
||||||
|
required String clientId,
|
||||||
|
required String clientSecret,
|
||||||
|
}) async {
|
||||||
|
final response = await HTTPService().post(
|
||||||
|
path: ApiEndpoints.clientLogin,
|
||||||
|
body: {
|
||||||
|
'clientId': clientId,
|
||||||
|
'clientSecret': clientSecret,
|
||||||
|
},
|
||||||
|
showServerMessage: false,
|
||||||
|
expectedResponseModel: (json) => json['data'],
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
|
||||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
@ -8,7 +7,6 @@ import 'package:syncrow_app/features/devices/model/device_report_model.dart';
|
|||||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||||
import 'package:syncrow_app/services/api/http_service.dart';
|
import 'package:syncrow_app/services/api/http_service.dart';
|
||||||
import 'package:syncrow_app/utils/constants/temp_const.dart';
|
|
||||||
import '../../features/devices/model/create_temporary_password_model.dart';
|
import '../../features/devices/model/create_temporary_password_model.dart';
|
||||||
|
|
||||||
class DevicesAPI {
|
class DevicesAPI {
|
||||||
@ -39,7 +37,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||||
body: {"deviceName": deviceName},
|
body: {"deviceName": deviceName},
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
@ -92,7 +90,7 @@ class DevicesAPI {
|
|||||||
.replaceAll('{deviceUuid}', deviceId),
|
.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
@ -101,7 +99,7 @@ class DevicesAPI {
|
|||||||
static Future<Map<String, dynamic>> getPowerClampStatus(
|
static Future<Map<String, dynamic>> getPowerClampStatus(
|
||||||
String deviceId) async {
|
String deviceId) async {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{powerClampUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
@ -132,7 +130,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
final functions = FunctionModel.fromJson(json);
|
final functions = FunctionModel.fromJson(json['data']);
|
||||||
return functions;
|
return functions;
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
@ -188,7 +186,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -264,7 +262,7 @@ class DevicesAPI {
|
|||||||
if (json == null || json.isEmpty || json == []) {
|
if (json == null || json.isEmpty || json == []) {
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
for (var device in json['devices']) {
|
for (var device in json['data']['devices']) {
|
||||||
devices.add(DeviceModel.fromJson(device));
|
devices.add(DeviceModel.fromJson(device));
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
@ -491,7 +489,12 @@ class DevicesAPI {
|
|||||||
}) async {
|
}) async {
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.controlBatch,
|
path: ApiEndpoints.controlBatch,
|
||||||
body: {"devicesUuid": devicesUuid, "code": code, "value": value},
|
body: {
|
||||||
|
"devicesUuid": devicesUuid,
|
||||||
|
"code": code,
|
||||||
|
"value": value,
|
||||||
|
"operationType": 'COMMAND',
|
||||||
|
},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class HomeManagementAPI {
|
|||||||
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
json.forEach((value) {
|
json['data'].forEach((value) {
|
||||||
list.add(DeviceModel.fromJson(value));
|
list.add(DeviceModel.fromJson(value));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -48,13 +48,26 @@ class HTTPService {
|
|||||||
Options? options,
|
Options? options,
|
||||||
dynamic body,
|
dynamic body,
|
||||||
bool showServerMessage = true,
|
bool showServerMessage = true,
|
||||||
|
String? accessToken,
|
||||||
required T Function(dynamic) expectedResponseModel}) async {
|
required T Function(dynamic) expectedResponseModel}) async {
|
||||||
try {
|
try {
|
||||||
|
final authOptions = options ??
|
||||||
|
Options(
|
||||||
|
headers: accessToken != null
|
||||||
|
? {
|
||||||
|
'Authorization': 'Bearer $accessToken',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
final response = await client.post(
|
final response = await client.post(
|
||||||
path,
|
path,
|
||||||
data: body,
|
data: body,
|
||||||
queryParameters: queryParameters,
|
queryParameters: queryParameters,
|
||||||
options: options,
|
options: authOptions,
|
||||||
);
|
);
|
||||||
return expectedResponseModel(response.data);
|
return expectedResponseModel(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user