mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 07:51:45 +00:00
Compare commits
56 Commits
real_time_
...
Fix-Save-D
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f49a18130 | |||
| a51c4d9679 | |||
| caeed8e73f | |||
| dc5ac9be5b | |||
| 5c9b30895f | |||
| 06b14a3964 | |||
| 3c92ea3047 | |||
| 73d28a1800 | |||
| 5493ca6fb0 | |||
| 7005d8ba83 | |||
| cb79627038 | |||
| 1cff69d496 | |||
| 60df77efad | |||
| 9e84048f81 | |||
| 99adb1c286 | |||
| f2412aa867 | |||
| e4768c95aa | |||
| f25b4dbf6d | |||
| 9eff9ab371 | |||
| a2e68d6194 | |||
| 94c94b170f | |||
| 253cf15559 | |||
| 443eea9421 | |||
| 87a2c08f64 | |||
| dd66e7c747 | |||
| 7af61d2f65 | |||
| f37eacb0ee | |||
| c7dcc297aa | |||
| aefe5ad081 | |||
| 8d9af8519d | |||
| b1d52937c9 | |||
| 5fedf37421 | |||
| ccde857c29 | |||
| b2a8086e0e | |||
| 408e78962c | |||
| dcdbc02ca0 | |||
| 31025e9176 | |||
| 8219de6821 | |||
| fbdf3817ab | |||
| 17422edd0d | |||
| 4c8f2c72df | |||
| fb867e5df3 | |||
| 9472390284 | |||
| 731ba0f3d6 | |||
| 56407c6426 | |||
| 02d61ca0bb | |||
| 99ee4b9878 | |||
| 19edd0a275 | |||
| ef5e7c3154 | |||
| 80dd0f696f | |||
| a64a41548f | |||
| 0d50aa68fa | |||
| 88aac86b10 | |||
| 0673548745 | |||
| c2fc8fa0ae | |||
| cbf10bbf78 |
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
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
/android/app/.cxx/
|
||||||
|
|||||||
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(),
|
||||||
|
|||||||
@ -169,18 +169,20 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_getOnlyImplementedDevices(List<DeviceModel> devices) {
|
List<DeviceModel> _getOnlyImplementedDevices(List<DeviceModel> devices) {
|
||||||
List<DeviceModel> implementedDevices = [];
|
const allowedDeviceTypes = {
|
||||||
for (int i = 0; i < devices.length; i++) {
|
DeviceType.AC,
|
||||||
if (devices[i].productType == DeviceType.AC ||
|
DeviceType.DoorLock,
|
||||||
devices[i].productType == DeviceType.DoorLock ||
|
DeviceType.Gateway,
|
||||||
devices[i].productType == DeviceType.Gateway ||
|
DeviceType.WallSensor,
|
||||||
devices[i].productType == DeviceType.WallSensor ||
|
DeviceType.CeilingSensor,
|
||||||
devices[i].productType == DeviceType.CeilingSensor ||
|
DeviceType.ThreeGang,
|
||||||
devices[i].productType == DeviceType.ThreeGang) {
|
DeviceType.OneGang,
|
||||||
implementedDevices.add(devices[i]);
|
DeviceType.TwoGang
|
||||||
}
|
};
|
||||||
}
|
|
||||||
return implementedDevices;
|
return devices
|
||||||
|
.where((device) => allowedDeviceTypes.contains(device.productType))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
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:smooth_page_indicator/smooth_page_indicator.dart';
|
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
||||||
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/all_devices.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/all_devices.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/room_page.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/room_page.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/rooms_slider.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/rooms_slider.dart';
|
||||||
@ -15,7 +15,7 @@ import 'package:syncrow_app/utils/context_extension.dart';
|
|||||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||||
|
|
||||||
class DevicesViewBody extends StatelessWidget {
|
class DevicesViewBody extends StatelessWidget {
|
||||||
const DevicesViewBody({Key? key}) : super(key: key);
|
const DevicesViewBody({super.key});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<HomeCubit, HomeState>(
|
return BlocBuilder<HomeCubit, HomeState>(
|
||||||
@ -80,10 +80,7 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
const SceneView(pageType: true),
|
||||||
height: MediaQuery.of(context).size.height * 0.1,
|
|
||||||
child: const SceneView(pageType: true),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
const RoomsSlider(),
|
const RoomsSlider(),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
|||||||
@ -8,8 +8,7 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
class GarageList extends StatelessWidget {
|
class GarageList extends StatelessWidget {
|
||||||
const GarageList(
|
const GarageList({super.key, required this.garageList, required this.allSwitches});
|
||||||
{super.key, required this.garageList, required this.allSwitches});
|
|
||||||
|
|
||||||
final List<GroupGarageModel> garageList;
|
final List<GroupGarageModel> garageList;
|
||||||
final bool allSwitches;
|
final bool allSwitches;
|
||||||
@ -23,43 +22,42 @@ class GarageList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Garages'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'Close',
|
||||||
on: 'ON',
|
on: 'Open',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () => BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
BlocProvider.of<GarageDoorBloc>(context)
|
GroupAllOnEvent(),
|
||||||
.add(GroupAllOnEvent());
|
),
|
||||||
},
|
secondAction: () => BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
secondAction: () {
|
GroupAllOffEvent(),
|
||||||
BlocProvider.of<GarageDoorBloc>(context)
|
),
|
||||||
.add(GroupAllOffEvent());
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: EdgeInsetsDirectional.zero,
|
||||||
itemCount: garageList.length,
|
itemCount: garageList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
final garageDoor = garageList[index];
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: garageList[index].deviceName),
|
BodySmall(text: garageDoor.deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'Close',
|
||||||
on: 'ON',
|
on: 'Open',
|
||||||
switchValue: garageList[index].firstSwitch,
|
switchValue: garageDoor.firstSwitch,
|
||||||
action: () {
|
action: () => BlocProvider.of<GarageDoorBloc>(context).add(
|
||||||
BlocProvider.of<GarageDoorBloc>(context).add(
|
ChangeFirstWizardSwitchStatusEvent(
|
||||||
ChangeFirstWizardSwitchStatusEvent(
|
value: garageDoor.firstSwitch,
|
||||||
value: garageList[index].firstSwitch,
|
deviceId: garageDoor.deviceId,
|
||||||
deviceId: garageList[index].deviceId));
|
),
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -76,32 +76,45 @@ 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 ?? "",
|
style: context.bodyLarge.copyWith(
|
||||||
overflow: TextOverflow.ellipsis,
|
fontWeight: FontWeight.bold,
|
||||||
maxLines: 2,
|
fontSize: 20,
|
||||||
style: context.bodyLarge.copyWith(
|
color: Colors.grey,
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Text(
|
),
|
||||||
device.subspace!.subspaceName ?? '',
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
textDirection: TextDirection.ltr,
|
||||||
style: context.bodySmall.copyWith(
|
);
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 10,
|
textPainter.layout(maxWidth: constraints.maxWidth);
|
||||||
color: Colors.grey,
|
|
||||||
),
|
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(
|
||||||
|
device.subspace!.subspaceName ?? '',
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: context.bodySmall.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 10,
|
||||||
|
color: Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -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>();
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,11 @@ import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart'
|
|||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
|
|
||||||
class WHList extends StatelessWidget {
|
class WHList extends StatelessWidget {
|
||||||
const WHList({super.key, required this.whList, required this.allSwitches});
|
const WHList({
|
||||||
|
required this.whList,
|
||||||
|
required this.allSwitches,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final List<GroupWHModel> whList;
|
final List<GroupWHModel> whList;
|
||||||
final bool allSwitches;
|
final bool allSwitches;
|
||||||
@ -22,43 +26,42 @@ class WHList extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const BodySmall(text: 'All Lights'),
|
const BodySmall(text: 'All Water Heaters'),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'OFF',
|
||||||
on: 'ON',
|
on: 'ON',
|
||||||
switchValue: allSwitches,
|
switchValue: allSwitches,
|
||||||
action: () {
|
action: () => context.read<WaterHeaterBloc>().add(
|
||||||
BlocProvider.of<WaterHeaterBloc>(context)
|
GroupAllOnEvent(),
|
||||||
.add(GroupAllOnEvent());
|
),
|
||||||
},
|
secondAction: () => context.read<WaterHeaterBloc>().add(
|
||||||
secondAction: () {
|
GroupAllOffEvent(),
|
||||||
BlocProvider.of<WaterHeaterBloc>(context)
|
),
|
||||||
.add(GroupAllOffEvent());
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
padding: EdgeInsetsDirectional.zero,
|
||||||
itemCount: whList.length,
|
itemCount: whList.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
final waterHeater = whList[index];
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
BodySmall(text: whList[index].deviceName),
|
BodySmall(text: waterHeater.deviceName),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
off: 'OFF',
|
off: 'OFF',
|
||||||
on: 'ON',
|
on: 'ON',
|
||||||
switchValue: whList[index].firstSwitch,
|
switchValue: waterHeater.firstSwitch,
|
||||||
action: () {
|
action: () => context.read<WaterHeaterBloc>().add(
|
||||||
BlocProvider.of<WaterHeaterBloc>(context).add(
|
|
||||||
ChangeFirstWizardSwitchStatusEvent(
|
ChangeFirstWizardSwitchStatusEvent(
|
||||||
value: whList[index].firstSwitch,
|
value: waterHeater.firstSwitch,
|
||||||
deviceId: whList[index].deviceId));
|
deviceId: waterHeater.deviceId,
|
||||||
},
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/auth/model/project_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/scene/bloc/effective_period/effect_period_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_app/features/scene/bloc/effective_period/effect_period_event.dart';
|
||||||
@ -348,15 +350,18 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
try {
|
try {
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
if (event.createSceneModel != null) {
|
if (event.createSceneModel != null) {
|
||||||
response = event.updateScene
|
response = event.updateScene
|
||||||
? await SceneApi.updateScene(event.createSceneModel!, event.sceneId)
|
? await SceneApi.updateScene(event.createSceneModel!, event.sceneId)
|
||||||
: await SceneApi.createScene(event.createSceneModel!);
|
: await SceneApi.createScene(event.createSceneModel!);
|
||||||
} else if (event.createAutomationModel != null) {
|
} else if (event.createAutomationModel != null) {
|
||||||
response = event.updateScene
|
response = event.updateScene
|
||||||
? await SceneApi.updateAutomation(
|
? await SceneApi.updateAutomation(event.createAutomationModel!,
|
||||||
event.createAutomationModel!, event.sceneId)
|
event.sceneId, project?.uuid ?? '')
|
||||||
: await SceneApi.createAutomation(event.createAutomationModel!);
|
: await SceneApi.createAutomation(
|
||||||
|
event.createAutomationModel!, project?.uuid ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response['success'] == true) {
|
if (response['success'] == true) {
|
||||||
@ -421,6 +426,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(CreateSceneLoading());
|
emit(CreateSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
tasksList.clear();
|
tasksList.clear();
|
||||||
tempTasksList.clear();
|
tempTasksList.clear();
|
||||||
selectedValues.clear();
|
selectedValues.clear();
|
||||||
@ -436,7 +443,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
conditionRule = 'or';
|
conditionRule = 'or';
|
||||||
|
|
||||||
final response = event.isAutomation
|
final response = event.isAutomation
|
||||||
? await SceneApi.getAutomationDetails(event.sceneId)
|
? await SceneApi.getAutomationDetails(
|
||||||
|
event.sceneId, project?.uuid ?? '')
|
||||||
: await SceneApi.getSceneDetails(event.sceneId);
|
: await SceneApi.getSceneDetails(event.sceneId);
|
||||||
if (response.id.isNotEmpty) {
|
if (response.id.isNotEmpty) {
|
||||||
if (event.isAutomation) {
|
if (event.isAutomation) {
|
||||||
@ -605,10 +613,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
|||||||
emit(DeleteSceneLoading());
|
emit(DeleteSceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
final response =
|
final response =
|
||||||
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
||||||
? await SceneApi.deleteAutomation(
|
? await SceneApi.deleteAutomation(
|
||||||
automationId: event.sceneId, unitUuid: event.unitUuid)
|
automationId: event.sceneId,
|
||||||
|
unitUuid: event.unitUuid,
|
||||||
|
projectId: project?.uuid ?? '')
|
||||||
: await SceneApi.deleteScene(
|
: await SceneApi.deleteScene(
|
||||||
sceneId: event.sceneId,
|
sceneId: event.sceneId,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -46,8 +46,11 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
|||||||
emit(SceneLoading());
|
emit(SceneLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
if (event.unitId.isNotEmpty) {
|
if (event.unitId.isNotEmpty) {
|
||||||
automationList = await SceneApi.getAutomationByUnitId(event.unitId);
|
automationList = await SceneApi.getAutomationByUnitId(
|
||||||
|
event.unitId, event.communityId, project?.uuid ?? '');
|
||||||
emit(SceneLoaded(scenes, automationList));
|
emit(SceneLoaded(scenes, automationList));
|
||||||
} else {
|
} else {
|
||||||
emit(const SceneError(message: 'Unit ID is empty'));
|
emit(const SceneError(message: 'Unit ID is empty'));
|
||||||
@ -96,11 +99,17 @@ class SceneBloc extends Bloc<SceneEvent, SceneState> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Project? project = HomeCubit.getInstance().project;
|
||||||
|
|
||||||
final success = await SceneApi.updateAutomationStatus(
|
final success = await SceneApi.updateAutomationStatus(
|
||||||
event.automationId, event.automationStatusUpdate);
|
event.automationId,
|
||||||
|
event.automationStatusUpdate,
|
||||||
|
project?.uuid ?? '');
|
||||||
if (success) {
|
if (success) {
|
||||||
automationList = await SceneApi.getAutomationByUnitId(
|
automationList = await SceneApi.getAutomationByUnitId(
|
||||||
event.automationStatusUpdate.spaceUuid);
|
event.automationStatusUpdate.spaceUuid,
|
||||||
|
event.communityId,
|
||||||
|
project?.uuid ?? '');
|
||||||
newLoadingStates[event.automationId] = false;
|
newLoadingStates[event.automationId] = false;
|
||||||
emit(SceneLoaded(
|
emit(SceneLoaded(
|
||||||
currentState.scenes,
|
currentState.scenes,
|
||||||
|
|||||||
@ -22,11 +22,13 @@ class LoadScenes extends SceneEvent {
|
|||||||
|
|
||||||
class LoadAutomation extends SceneEvent {
|
class LoadAutomation extends SceneEvent {
|
||||||
final String unitId;
|
final String unitId;
|
||||||
|
final String communityId;
|
||||||
|
|
||||||
const LoadAutomation(this.unitId);
|
|
||||||
|
const LoadAutomation(this.unitId, this.communityId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [unitId];
|
List<Object> get props => [unitId, communityId];
|
||||||
}
|
}
|
||||||
|
|
||||||
class SceneTrigger extends SceneEvent {
|
class SceneTrigger extends SceneEvent {
|
||||||
@ -43,8 +45,9 @@ class SceneTrigger extends SceneEvent {
|
|||||||
class UpdateAutomationStatus extends SceneEvent {
|
class UpdateAutomationStatus extends SceneEvent {
|
||||||
final String automationId;
|
final String automationId;
|
||||||
final AutomationStatusUpdate automationStatusUpdate;
|
final AutomationStatusUpdate automationStatusUpdate;
|
||||||
|
final String communityId;
|
||||||
|
|
||||||
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId});
|
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId, required this.communityId});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [automationStatusUpdate];
|
List<Object> get props => [automationStatusUpdate];
|
||||||
|
|||||||
@ -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});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,78 @@
|
|||||||
|
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 OneGangHelperFunctions {
|
||||||
|
static List<SceneStaticFunction> oneGangHelperFunctions(
|
||||||
|
String deviceId, String deviceName, functionValue) {
|
||||||
|
return [
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: '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: 'Light CountDown',
|
||||||
|
code: 'countdown_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.countdown,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<SceneStaticFunction> oneGangAutomationFunctions(
|
||||||
|
String deviceId, String deviceName, functionValue) {
|
||||||
|
return [
|
||||||
|
SceneStaticFunction(
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
icon: Assets.assetsAcPower,
|
||||||
|
operationName: '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: 'Light CountDown',
|
||||||
|
code: 'countdown_1',
|
||||||
|
functionValue: functionValue,
|
||||||
|
operationDialogType: OperationDialogType.integerSteps,
|
||||||
|
operationalValues: [
|
||||||
|
SceneOperationalValue(
|
||||||
|
icon: '',
|
||||||
|
description: "sec",
|
||||||
|
value: 0.0,
|
||||||
|
minValue: 0,
|
||||||
|
maxValue: 43200,
|
||||||
|
stepValue: 1,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
48
lib/features/scene/helper/scene_bloc_factory.dart
Normal file
48
lib/features/scene/helper/scene_bloc_factory.dart
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.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/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||||
|
|
||||||
|
abstract final class SceneBlocFactory {
|
||||||
|
static SceneBloc create({
|
||||||
|
required bool pageType,
|
||||||
|
required HomeCubit homeCubit,
|
||||||
|
}) {
|
||||||
|
final selectedSpace = homeCubit.selectedSpace;
|
||||||
|
final defaultSpace = SpaceModel(
|
||||||
|
id: '-1',
|
||||||
|
name: '',
|
||||||
|
community: Community(
|
||||||
|
uuid: '-1',
|
||||||
|
name: '',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final spaceId = selectedSpace?.id ?? defaultSpace.id;
|
||||||
|
final space = selectedSpace ?? defaultSpace;
|
||||||
|
final communityUuid =
|
||||||
|
selectedSpace?.community.uuid ?? defaultSpace.community.uuid;
|
||||||
|
|
||||||
|
final sceneBloc = SceneBloc();
|
||||||
|
|
||||||
|
sceneBloc.add(
|
||||||
|
LoadScenes(
|
||||||
|
spaceId,
|
||||||
|
space,
|
||||||
|
showInDevice: pageType,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!pageType) {
|
||||||
|
sceneBloc.add(
|
||||||
|
LoadAutomation(
|
||||||
|
spaceId,
|
||||||
|
communityUuid,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sceneBloc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,16 +6,19 @@ import 'package:syncrow_app/features/scene/helper/functions_per_device/ac_functi
|
|||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/door_lock_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/door_lock_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/gateway_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/gateway_functions.dart';
|
||||||
import 'package:syncrow_app/features/scene/helper/functions_per_device/human_presence_functions.dart';
|
import 'package:syncrow_app/features/scene/helper/functions_per_device/human_presence_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';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
mixin SceneOperationsDataHelper {
|
mixin SceneOperationsDataHelper {
|
||||||
final Map<DeviceType, Function(List<FunctionModel>, String, String, dynamic, bool)> _functionMap =
|
final Map<DeviceType,
|
||||||
{
|
Function(List<FunctionModel>, String, String, dynamic, bool)>
|
||||||
|
_functionMap = {
|
||||||
DeviceType.LightBulb: lightBulbFunctions,
|
DeviceType.LightBulb: lightBulbFunctions,
|
||||||
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
DeviceType.CeilingSensor: ceilingSensorFunctions,
|
||||||
DeviceType.WallSensor: wallSensorFunctions,
|
DeviceType.WallSensor: wallSensorFunctions,
|
||||||
@ -24,6 +27,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
DeviceType.Curtain: curtainFunctions,
|
DeviceType.Curtain: curtainFunctions,
|
||||||
DeviceType.ThreeGang: threeGangFunctions,
|
DeviceType.ThreeGang: threeGangFunctions,
|
||||||
DeviceType.Gateway: gatewayFunctions,
|
DeviceType.Gateway: gatewayFunctions,
|
||||||
|
DeviceType.OneGang: oneGangFunctions,
|
||||||
|
DeviceType.TwoGang: towGangFunctions,
|
||||||
};
|
};
|
||||||
|
|
||||||
final Map<DeviceType, String> _titleMap = {
|
final Map<DeviceType, String> _titleMap = {
|
||||||
@ -35,8 +40,39 @@ mixin SceneOperationsDataHelper {
|
|||||||
DeviceType.Curtain: 'Curtain Functions',
|
DeviceType.Curtain: 'Curtain Functions',
|
||||||
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.TwoGang: '2G Light Switch Conditions',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//one gang functions
|
||||||
|
static List<SceneStaticFunction> oneGangFunctions(
|
||||||
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
|
if (isAutomation) {
|
||||||
|
return OneGangHelperFunctions.oneGangAutomationFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
|
}
|
||||||
|
return OneGangHelperFunctions.oneGangHelperFunctions(
|
||||||
|
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,
|
||||||
@ -45,16 +81,22 @@ mixin SceneOperationsDataHelper {
|
|||||||
required bool isAutomation,
|
required bool isAutomation,
|
||||||
}) {
|
}) {
|
||||||
final functionValue = null;
|
final functionValue = null;
|
||||||
return _functionMap[type]?.call(functions, deviceId, deviceName, functionValue, isAutomation) ??
|
return _functionMap[type]?.call(
|
||||||
lightBulbFunctions(functions, deviceId, deviceName, functionValue, isAutomation);
|
functions, deviceId, deviceName, functionValue, isAutomation) ??
|
||||||
|
lightBulbFunctions(
|
||||||
|
functions, deviceId, deviceName, functionValue, isAutomation);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getTitle({DeviceType? type}) {
|
String getTitle({DeviceType? type}) {
|
||||||
return _titleMap[type] ?? '';
|
return _titleMap[type] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> ceilingSensorFunctions(List<FunctionModel> functions,
|
static List<SceneStaticFunction> ceilingSensorFunctions(
|
||||||
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
return PresenceSensorHelperFunctions.automationPresenceSensorFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
@ -63,22 +105,35 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> curtainFunctions(List<FunctionModel> functions, String deviceId,
|
static List<SceneStaticFunction> curtainFunctions(
|
||||||
String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> doorLockFunctions(List<FunctionModel> functions, String deviceId,
|
static List<SceneStaticFunction> doorLockFunctions(
|
||||||
String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
return DoorLockHelperFunctions.doorLockAutomationFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return DoorLockHelperFunctions.doorLockTapToRunFunctions(deviceId, deviceName, functionValue);
|
return DoorLockHelperFunctions.doorLockTapToRunFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> wallSensorFunctions(List<FunctionModel> functions,
|
static List<SceneStaticFunction> wallSensorFunctions(
|
||||||
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
return HumanPresenceHelperFunctions.automationHumanPresenceFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
@ -87,31 +142,51 @@ mixin SceneOperationsDataHelper {
|
|||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> lightBulbFunctions(List<FunctionModel> functions,
|
static List<SceneStaticFunction> lightBulbFunctions(
|
||||||
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> gatewayFunctions(List<FunctionModel> functions, String deviceId,
|
static List<SceneStaticFunction> gatewayFunctions(
|
||||||
String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
return GatewayHelperFunctions.tabToRunGatewayFunctions(deviceId, deviceName, functionValue);
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
|
return GatewayHelperFunctions.tabToRunGatewayFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> threeGangFunctions(List<FunctionModel> functions,
|
static List<SceneStaticFunction> threeGangFunctions(
|
||||||
String deviceId, String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
return ThreeGangHelperFunctions.threeGangAutomationFunctions(
|
||||||
deviceId, deviceName, functionValue);
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return ThreeGangHelperFunctions.threeGangHelperFunctions(deviceId, deviceName, functionValue);
|
return ThreeGangHelperFunctions.threeGangHelperFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<SceneStaticFunction> acFunctions(List<FunctionModel> functions, String deviceId,
|
static List<SceneStaticFunction> acFunctions(
|
||||||
String deviceName, dynamic functionValue, bool isAutomation) {
|
List<FunctionModel> functions,
|
||||||
|
String deviceId,
|
||||||
|
String deviceName,
|
||||||
|
dynamic functionValue,
|
||||||
|
bool isAutomation) {
|
||||||
if (isAutomation) {
|
if (isAutomation) {
|
||||||
return ACFunctionsHelper.automationAcFunctions(deviceId, deviceName, functionValue);
|
return ACFunctionsHelper.automationAcFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
return ACFunctionsHelper.tabToRunAcFunctions(deviceId, deviceName, functionValue);
|
return ACFunctionsHelper.tabToRunAcFunctions(
|
||||||
|
deviceId, deviceName, functionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
||||||
@ -149,8 +224,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: action.entityId,
|
deviceId: action.entityId,
|
||||||
deviceName: action.name.toString(),
|
deviceName: action.name.toString(),
|
||||||
deviceIcon: action.type == 'automation' ? Assets.player : Assets.handClickIcon,
|
deviceIcon: action.type == 'automation'
|
||||||
icon: action.type == 'automation' ? Assets.player : Assets.handClickIcon,
|
? Assets.player
|
||||||
|
: Assets.handClickIcon,
|
||||||
|
icon: action.type == 'automation'
|
||||||
|
? Assets.player
|
||||||
|
: Assets.handClickIcon,
|
||||||
operationName: action.type.toString(),
|
operationName: action.type.toString(),
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
functionValue: action.actionExecutor,
|
functionValue: action.actionExecutor,
|
||||||
@ -170,7 +249,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
functions.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
functions
|
||||||
|
.add(_mapExecutorPropertyToSceneFunction(action, isAutomation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,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(
|
||||||
@ -206,7 +287,9 @@ mixin SceneOperationsDataHelper {
|
|||||||
}) {
|
}) {
|
||||||
final executorProperty = action.executorProperty;
|
final executorProperty = action.executorProperty;
|
||||||
|
|
||||||
final Map<String, SceneStaticFunction Function(Action, bool, String?, String?)> functionMap = {
|
final Map<String,
|
||||||
|
SceneStaticFunction Function(Action, bool, String?, String?)>
|
||||||
|
functionMap = {
|
||||||
'sensitivity': _createSensitivityFunction,
|
'sensitivity': _createSensitivityFunction,
|
||||||
'normal_open_switch': _createNormalOpenSwitchFunction,
|
'normal_open_switch': _createNormalOpenSwitchFunction,
|
||||||
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
'unlock_fingerprint': _createUnlockFingerprintFunction,
|
||||||
@ -282,14 +365,16 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSensitivityFunction(
|
SceneStaticFunction _createSensitivityFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Presence Sensor',
|
'Presence Sensor',
|
||||||
Assets.assetsIconsSensors,
|
Assets.assetsIconsSensors,
|
||||||
'Sensitivity',
|
'Sensitivity',
|
||||||
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.listOfOptions,
|
isAutomation
|
||||||
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.listOfOptions,
|
||||||
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
isAutomation ? _createIntegerStepsOptions() : _createSensitivityOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
@ -297,8 +382,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createNormalOpenSwitchFunction(
|
SceneStaticFunction _createNormalOpenSwitchFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -351,8 +436,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockFingerprintFunction(
|
SceneStaticFunction _createUnlockFingerprintFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -366,8 +451,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockPasswordFunction(
|
SceneStaticFunction _createUnlockPasswordFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -381,8 +466,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockCardFunction(
|
SceneStaticFunction _createUnlockCardFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -396,8 +481,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createAlarmLockFunction(
|
SceneStaticFunction _createAlarmLockFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -411,8 +496,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockRequestFunction(
|
SceneStaticFunction _createUnlockRequestFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -426,8 +511,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createResidualElectricityFunction(
|
SceneStaticFunction _createResidualElectricityFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -441,8 +526,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createReverseLockFunction(
|
SceneStaticFunction _createReverseLockFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -456,8 +541,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockAppFunction(
|
SceneStaticFunction _createUnlockAppFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -471,8 +556,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createHijackFunction(
|
SceneStaticFunction _createHijackFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -486,8 +571,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createDoorbellFunction(
|
SceneStaticFunction _createDoorbellFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -501,8 +586,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createUnlockTemporaryFunction(
|
SceneStaticFunction _createUnlockTemporaryFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'WIFI LOCK PRO',
|
'WIFI LOCK PRO',
|
||||||
@ -516,8 +601,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createFarDetectionFunction(
|
SceneStaticFunction _createFarDetectionFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -531,8 +616,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMotionSensitivityFunction(
|
SceneStaticFunction _createMotionSensitivityFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -546,8 +631,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMotionlessSensitivityFunction(
|
SceneStaticFunction _createMotionlessSensitivityFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -561,8 +646,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createIndicatorFunction(
|
SceneStaticFunction _createIndicatorFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -576,8 +661,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createPresenceTimeFunction(
|
SceneStaticFunction _createPresenceTimeFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -591,8 +676,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createPresenceStateFunction(
|
SceneStaticFunction _createPresenceStateFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -606,14 +691,16 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createDisCurrentFunction(
|
SceneStaticFunction _createDisCurrentFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
Assets.assetsIconsSensors,
|
Assets.assetsIconsSensors,
|
||||||
'Current Distance',
|
'Current Distance',
|
||||||
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
isAutomation
|
||||||
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.countdown,
|
||||||
_createCurrentDistanceOptions(),
|
_createCurrentDistanceOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
@ -621,8 +708,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createIlluminanceValueFunction(
|
SceneStaticFunction _createIlluminanceValueFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -636,8 +723,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCheckingResultFunction(
|
SceneStaticFunction _createCheckingResultFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Human Presence Sensor',
|
'Human Presence Sensor',
|
||||||
@ -651,8 +738,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitchFunction(
|
SceneStaticFunction _createSwitchFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -666,23 +753,27 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createTempSetFunction(
|
SceneStaticFunction _createTempSetFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
Assets.assetsIconsAC,
|
Assets.assetsIconsAC,
|
||||||
'Set Temperature',
|
'Set Temperature',
|
||||||
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.temperature,
|
isAutomation
|
||||||
isAutomation ? _createAutomationTemperatureOptions() : _createTemperatureOptions(),
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.temperature,
|
||||||
|
isAutomation
|
||||||
|
? _createAutomationTemperatureOptions()
|
||||||
|
: _createTemperatureOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createTempCurrentFunction(
|
SceneStaticFunction _createTempCurrentFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -696,8 +787,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createModeFunction(
|
SceneStaticFunction _createModeFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -711,8 +802,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createLevelFunction(
|
SceneStaticFunction _createLevelFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -726,8 +817,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createChildLockFunction(
|
SceneStaticFunction _createChildLockFunction(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Smart AC Thermostat - Grey - Model A',
|
'Smart AC Thermostat - Grey - Model A',
|
||||||
@ -741,38 +832,104 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch1Function(
|
SceneStaticFunction _createSwitch1Function(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
switch (action.productType) {
|
||||||
action,
|
case "3G":
|
||||||
'3 Gang Button Switch L-L',
|
return _createSceneFunction(
|
||||||
Assets.assetsIcons3GangSwitch,
|
action,
|
||||||
'Light 1 Switch',
|
'3 Gang Button Switch L-L',
|
||||||
OperationDialogType.onOff,
|
Assets.assetsIcons3GangSwitch,
|
||||||
_createOnOffOptions(),
|
'Light 1 Switch',
|
||||||
isAutomation,
|
OperationDialogType.onOff,
|
||||||
comparator,
|
_createOnOffOptions(),
|
||||||
uniqueCustomId,
|
isAutomation,
|
||||||
);
|
comparator,
|
||||||
|
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(
|
SceneStaticFunction _createSwitch2Function(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
switch (action.productType) {
|
||||||
action,
|
case "3G":
|
||||||
'3 Gang Button Switch L-L',
|
return _createSceneFunction(
|
||||||
Assets.assetsIcons3GangSwitch,
|
action,
|
||||||
'Light 2 Switch',
|
'3 Gang Button Switch L-L',
|
||||||
OperationDialogType.onOff,
|
Assets.assetsIcons3GangSwitch,
|
||||||
_createOnOffOptions(),
|
'Light 2 Switch',
|
||||||
isAutomation,
|
OperationDialogType.onOff,
|
||||||
comparator,
|
_createOnOffOptions(),
|
||||||
uniqueCustomId,
|
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:
|
||||||
|
return _createSceneFunction(
|
||||||
|
action,
|
||||||
|
'1 Gang Button Switch L-L',
|
||||||
|
Assets.oneGang,
|
||||||
|
'Light Switch',
|
||||||
|
OperationDialogType.onOff,
|
||||||
|
_createOnOffOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
uniqueCustomId,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitch3Function(
|
SceneStaticFunction _createSwitch3Function(Action action, bool isAutomation,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
@ -786,53 +943,135 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createCountdown1Function(
|
SceneStaticFunction _createCountdown1Function(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
switch (action.productType) {
|
||||||
action,
|
case "3G":
|
||||||
'3 Gang Button Switch L-L',
|
return _createSceneFunction(
|
||||||
Assets.assetsIcons3GangSwitch,
|
action,
|
||||||
'Light 1 CountDown',
|
'3 Gang Button Switch L-L',
|
||||||
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
Assets.assetsIcons3GangSwitch,
|
||||||
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
'Light 1 CountDown',
|
||||||
isAutomation,
|
isAutomation
|
||||||
comparator,
|
? OperationDialogType.integerSteps
|
||||||
uniqueCustomId,
|
: OperationDialogType.countdown,
|
||||||
);
|
isAutomation
|
||||||
|
? _createAutomationCountDownOptions()
|
||||||
|
: _createCountdownOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
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:
|
||||||
|
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 _createCountdown2Function(
|
SceneStaticFunction _createCountdown2Function(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
switch (action.productType) {
|
||||||
action,
|
case "3G":
|
||||||
'3 Gang Button Switch L-L',
|
return _createSceneFunction(
|
||||||
Assets.assetsIcons3GangSwitch,
|
action,
|
||||||
'Light 2 CountDown',
|
'3 Gang Button Switch L-L',
|
||||||
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
Assets.assetsIcons3GangSwitch,
|
||||||
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
'Light 2 CountDown',
|
||||||
isAutomation,
|
isAutomation
|
||||||
comparator,
|
? OperationDialogType.integerSteps
|
||||||
uniqueCustomId,
|
: OperationDialogType.countdown,
|
||||||
);
|
isAutomation
|
||||||
|
? _createAutomationCountDownOptions()
|
||||||
|
: _createCountdownOptions(),
|
||||||
|
isAutomation,
|
||||||
|
comparator,
|
||||||
|
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(
|
SceneStaticFunction _createCountdown3Function(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'3 Gang Button Switch L-L',
|
'3 Gang Button Switch L-L',
|
||||||
Assets.assetsIcons3GangSwitch,
|
Assets.assetsIcons3GangSwitch,
|
||||||
'Light 3 CountDown',
|
'Light 3 CountDown',
|
||||||
isAutomation ? OperationDialogType.integerSteps : OperationDialogType.countdown,
|
isAutomation
|
||||||
isAutomation ? _createAutomationCountDownOptions() : _createCountdownOptions(),
|
? OperationDialogType.integerSteps
|
||||||
|
: OperationDialogType.countdown,
|
||||||
|
isAutomation
|
||||||
|
? _createAutomationCountDownOptions()
|
||||||
|
: _createCountdownOptions(),
|
||||||
isAutomation,
|
isAutomation,
|
||||||
comparator,
|
comparator,
|
||||||
uniqueCustomId,
|
uniqueCustomId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createSwitchAlarmSoundFunction(
|
SceneStaticFunction _createSwitchAlarmSoundFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -846,8 +1085,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createMasterStateFunction(
|
SceneStaticFunction _createMasterStateFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -861,8 +1100,8 @@ mixin SceneOperationsDataHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStaticFunction _createFactoryResetFunction(
|
SceneStaticFunction _createFactoryResetFunction(Action action,
|
||||||
Action action, bool isAutomation, String? comparator, String? uniqueCustomId) {
|
bool isAutomation, String? comparator, String? uniqueCustomId) {
|
||||||
return _createSceneFunction(
|
return _createSceneFunction(
|
||||||
action,
|
action,
|
||||||
'Gateway',
|
'Gateway',
|
||||||
@ -1180,8 +1419,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
uniqueCustomId: taskItem.uniqueCustomId,
|
uniqueCustomId: taskItem.uniqueCustomId,
|
||||||
deviceId: taskItem.deviceId,
|
deviceId: taskItem.deviceId,
|
||||||
deviceName: taskItem.deviceName.toString(),
|
deviceName: taskItem.deviceName.toString(),
|
||||||
deviceIcon: taskItem.operationName == 'automation' ? Assets.player : Assets.handClickIcon,
|
deviceIcon: taskItem.operationName == 'automation'
|
||||||
icon: taskItem.operationName == 'automation' ? Assets.player : Assets.handClickIcon,
|
? Assets.player
|
||||||
|
: Assets.handClickIcon,
|
||||||
|
icon: taskItem.operationName == 'automation'
|
||||||
|
? Assets.player
|
||||||
|
: Assets.handClickIcon,
|
||||||
operationName: taskItem.operationName,
|
operationName: taskItem.operationName,
|
||||||
operationDialogType: OperationDialogType.onOff,
|
operationDialogType: OperationDialogType.onOff,
|
||||||
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
functionValue: taskItem.functionValue == 'rule_enable' ? true : false,
|
||||||
@ -1204,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,6 +74,7 @@ class Action {
|
|||||||
ExecutorProperty? executorProperty;
|
ExecutorProperty? executorProperty;
|
||||||
String? name;
|
String? name;
|
||||||
String? type;
|
String? type;
|
||||||
|
final String productType;
|
||||||
|
|
||||||
Action({
|
Action({
|
||||||
required this.actionExecutor,
|
required this.actionExecutor,
|
||||||
@ -81,6 +82,7 @@ class Action {
|
|||||||
this.executorProperty,
|
this.executorProperty,
|
||||||
this.name,
|
this.name,
|
||||||
this.type,
|
this.type,
|
||||||
|
required this.productType,
|
||||||
});
|
});
|
||||||
|
|
||||||
String toRawJson() => json.encode(toJson());
|
String toRawJson() => json.encode(toJson());
|
||||||
@ -88,10 +90,11 @@ class Action {
|
|||||||
static Action? fromJson(Map<String, dynamic> json) {
|
static Action? fromJson(Map<String, dynamic> json) {
|
||||||
if (json['name'] != null && json['type'] != null) {
|
if (json['name'] != null && json['type'] != null) {
|
||||||
return Action(
|
return Action(
|
||||||
actionExecutor: json["actionExecutor"],
|
actionExecutor: json["actionExecutor"] as String,
|
||||||
entityId: json["entityId"],
|
entityId: json["entityId"] as String,
|
||||||
name: json['name'],
|
name: json['name'] as String?,
|
||||||
type: json['type'],
|
type: json['type'] as String?,
|
||||||
|
productType: json['productType'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (json["executorProperty"] == null) {
|
if (json["executorProperty"] == null) {
|
||||||
@ -99,9 +102,10 @@ class Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Action(
|
return Action(
|
||||||
actionExecutor: json["actionExecutor"],
|
actionExecutor: json["actionExecutor"] as String,
|
||||||
entityId: json["entityId"],
|
entityId: json["entityId"] as String,
|
||||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||||
|
productType: json['productType'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,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) =>
|
||||||
@ -160,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,65 +69,63 @@ 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(
|
||||||
margin: EdgeInsets.zero,
|
mainAxisSize: MainAxisSize.min,
|
||||||
borderRadius: index == 0
|
children: [
|
||||||
? const BorderRadius.only(
|
if (isFirstInPair && index != 0) const SizedBox(height: 16),
|
||||||
topLeft: Radius.circular(20), topRight: Radius.circular(20))
|
DefaultContainer(
|
||||||
: index == functions.length - 1
|
padding: EdgeInsets.only(
|
||||||
? const BorderRadius.only(
|
top: isFirstInPair ? 8 : 0,
|
||||||
bottomLeft: Radius.circular(20),
|
bottom: isLastInPair ? 8 : 0,
|
||||||
bottomRight: Radius.circular(20))
|
),
|
||||||
: BorderRadius.zero,
|
margin: EdgeInsets.zero,
|
||||||
child: Column(
|
borderRadius: BorderRadius.only(
|
||||||
mainAxisSize: MainAxisSize.min,
|
topLeft: Radius.circular(isFirstInPair ? 20 : 0),
|
||||||
children: [
|
topRight: Radius.circular(isFirstInPair ? 20 : 0),
|
||||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
bottomLeft: Radius.circular(isLastInPair ? 20 : 0),
|
||||||
builder: (context, state) {
|
bottomRight: Radius.circular(isLastInPair ? 20 : 0),
|
||||||
return SceneListTile(
|
),
|
||||||
iconsSize: 22,
|
child: Column(
|
||||||
minLeadingWidth: 20,
|
mainAxisSize: MainAxisSize.min,
|
||||||
assetPath: functions[index].icon,
|
children: [
|
||||||
titleString: functions[index].operationName,
|
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||||
trailingWidget: const Row(
|
builder: (context, state) {
|
||||||
mainAxisSize: MainAxisSize.min,
|
return SceneListTile(
|
||||||
children: [
|
iconsSize: 22,
|
||||||
Icon(
|
minLeadingWidth: 20,
|
||||||
|
assetPath: functions[index].icon,
|
||||||
|
titleString: functions[index].operationName,
|
||||||
|
trailingWidget: const Icon(
|
||||||
Icons.arrow_forward_ios_rounded,
|
Icons.arrow_forward_ios_rounded,
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
],
|
onPressed: () {
|
||||||
),
|
if (isAutomation) {
|
||||||
onPressed: () {
|
_showAutomationDialog(
|
||||||
if (isAutomation) {
|
context, functions[index], device);
|
||||||
_showAutomationDialog(
|
} else {
|
||||||
context,
|
_showTabToRunDialog(
|
||||||
functions[index],
|
context, functions[index], device);
|
||||||
device,
|
}
|
||||||
);
|
},
|
||||||
} else {
|
);
|
||||||
_showTabToRunDialog(
|
|
||||||
context,
|
|
||||||
functions[index],
|
|
||||||
device,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
},
|
if (isFirstInPair && !isLastItem)
|
||||||
|
SizedBox(
|
||||||
|
width: context.width * 0.8,
|
||||||
|
child: const LightDivider(),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
index != functions.length - 1
|
),
|
||||||
? SizedBox(
|
],
|
||||||
width: context.width * 0.8, child: const LightDivider())
|
|
||||||
: const SizedBox(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -20,69 +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() {
|
||||||
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
|
||||||
rooms = List.from(HomeCubit.getInstance().selectedSpace?.subspaces ?? []);
|
|
||||||
if (rooms != null) {
|
|
||||||
if (rooms![0].id != '-1') {
|
|
||||||
rooms?.insert(
|
|
||||||
0,
|
|
||||||
SubSpaceModel(
|
|
||||||
name: 'All Devices',
|
|
||||||
devices: context.read<DevicesCubit>().allDevices,
|
|
||||||
id: '-1',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_tabController =
|
|
||||||
TabController(length: rooms!.length, vsync: this, initialIndex: 0);
|
|
||||||
_tabController.addListener(_handleTabSwitched);
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
|
||||||
|
|
||||||
void _handleTabSwitched() {
|
selectedSpace = HomeCubit.getInstance().selectedSpace!;
|
||||||
if (_tabController.indexIsChanging) {
|
|
||||||
final value = _tabController.index;
|
|
||||||
|
|
||||||
/// select tab
|
rooms = List.from(selectedSpace.subspaces);
|
||||||
context.read<TabBarBloc>().add(TabChanged(
|
final defaultSubSpaceModel = SubSpaceModel(
|
||||||
selectedIndex: value,
|
name: 'All Devices',
|
||||||
roomId: rooms?[value].id ?? '',
|
devices: context.read<DevicesCubit>().allDevices,
|
||||||
unit: selectedSpace));
|
id: '-1',
|
||||||
return;
|
);
|
||||||
|
|
||||||
|
if (rooms.isNotEmpty) {
|
||||||
|
final isFirstRoomIdValid = rooms[0].id != '-1';
|
||||||
|
if (isFirstRoomIdValid) {
|
||||||
|
rooms.insert(0, defaultSubSpaceModel);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rooms = [defaultSubSpaceModel];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tabController = TabController(length: rooms.length, vsync: this);
|
||||||
|
_tabController.addListener(_handleTabSwitched);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,75 +1,45 @@
|
|||||||
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:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.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/devices/view/widgets/scene_listview.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/scene_listview.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';
|
||||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/smart_scene/smart_scene_select_dart_bloc.dart';
|
import 'package:syncrow_app/features/scene/bloc/smart_scene/smart_scene_select_dart_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/helper/scene_bloc_factory.dart';
|
||||||
|
import 'package:syncrow_app/features/scene/widgets/empty_devices_widget.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
|
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_header.dart';
|
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_header.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/create_unit.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/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class SceneView extends StatelessWidget {
|
class SceneView extends StatelessWidget {
|
||||||
|
const SceneView({
|
||||||
|
this.pageType = false,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final bool pageType;
|
final bool pageType;
|
||||||
const SceneView({super.key, this.pageType = false});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (BuildContext context) {
|
create: (context) => SceneBlocFactory.create(
|
||||||
if (pageType) {
|
pageType: pageType,
|
||||||
return SceneBloc()
|
homeCubit: HomeCubit.getInstance(),
|
||||||
..add(LoadScenes(
|
),
|
||||||
HomeCubit.getInstance().selectedSpace?.id ?? '',
|
|
||||||
HomeCubit.getInstance().selectedSpace ??
|
|
||||||
SpaceModel(
|
|
||||||
id: '-1',
|
|
||||||
name: '',
|
|
||||||
community: Community(
|
|
||||||
uuid: '-1',
|
|
||||||
name: '',
|
|
||||||
)),
|
|
||||||
showInDevice: pageType));
|
|
||||||
} else {
|
|
||||||
return SceneBloc()
|
|
||||||
..add(LoadScenes(
|
|
||||||
HomeCubit.getInstance().selectedSpace?.id ?? '',
|
|
||||||
HomeCubit.getInstance().selectedSpace ??
|
|
||||||
SpaceModel(
|
|
||||||
id: '-1',
|
|
||||||
name: '',
|
|
||||||
community: Community(
|
|
||||||
uuid: '-1',
|
|
||||||
name: '',
|
|
||||||
)),
|
|
||||||
showInDevice: pageType))
|
|
||||||
..add(LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? ''));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
final selectedSpace = HomeCubit.getInstance().selectedSpace;
|
||||||
if (state is DeleteSceneSuccess) {
|
if (state is DeleteSceneSuccess) {
|
||||||
if (state.success) {
|
if (state.success) _loadScenesAndAutomations(context, selectedSpace);
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
|
||||||
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!,
|
|
||||||
showInDevice: pageType));
|
|
||||||
BlocProvider.of<SceneBloc>(context)
|
|
||||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (state is CreateSceneWithTasks) {
|
if (state is CreateSceneWithTasks) {
|
||||||
if (state.success == true) {
|
if (state.success) {
|
||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
_loadScenesAndAutomations(context, selectedSpace);
|
||||||
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!,
|
|
||||||
showInDevice: pageType));
|
|
||||||
BlocProvider.of<SceneBloc>(context)
|
|
||||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
|
|
||||||
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,23 +47,24 @@ class SceneView extends StatelessWidget {
|
|||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is SceneTriggerSuccess) {
|
if (state is SceneTriggerSuccess) {
|
||||||
context.showCustomSnackbar(
|
context.showCustomSnackbar(
|
||||||
message: 'Scene ${state.sceneName} triggered successfully!');
|
message: 'Scene ${state.sceneName} triggered successfully!',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: HomeCubit.getInstance().spaces?.isEmpty ?? true
|
child: HomeCubit.getInstance().spaces.isEmpty
|
||||||
? const CreateUnitWidget()
|
? const EmptyDevicesWidget()
|
||||||
: Column(
|
: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
if (pageType == false) const SceneHeader(),
|
if (!pageType) ...[
|
||||||
if (pageType == false) const SizedBox(height: 8),
|
const SceneHeader(),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
BlocBuilder<SceneBloc, SceneState>(
|
BlocBuilder<SceneBloc, SceneState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is SceneLoading) {
|
if (state is SceneLoading) {
|
||||||
return const Center(
|
return const AppLoadingIndicator();
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (state is SceneError) {
|
if (state is SceneError) {
|
||||||
return Center(
|
return Center(
|
||||||
@ -103,80 +74,83 @@ class SceneView extends StatelessWidget {
|
|||||||
if (state is SceneLoaded) {
|
if (state is SceneLoaded) {
|
||||||
final scenes = state.scenes;
|
final scenes = state.scenes;
|
||||||
final automationList = state.automationList;
|
final automationList = state.automationList;
|
||||||
|
if (scenes.isEmpty) return const EmptyDevicesWidget();
|
||||||
|
|
||||||
return pageType
|
if (pageType) {
|
||||||
? Expanded(
|
return SizedBox(
|
||||||
child: SceneListview(
|
height: context.height * 0.1,
|
||||||
scenes: scenes,
|
child: SceneListview(
|
||||||
loadingSceneId: state.loadingSceneId,
|
scenes: scenes,
|
||||||
))
|
loadingSceneId: state.loadingSceneId,
|
||||||
: Expanded(
|
),
|
||||||
child: ListView(
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Theme(
|
||||||
|
data: Theme.of(context).copyWith(
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
ExpansionTile(
|
||||||
|
tilePadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6,
|
||||||
|
),
|
||||||
|
initiallyExpanded: true,
|
||||||
|
iconColor: ColorsManager.grayColor,
|
||||||
|
title: const BodyMedium(
|
||||||
|
text: 'Tap to run routines',
|
||||||
|
),
|
||||||
children: [
|
children: [
|
||||||
Theme(
|
if (scenes.isNotEmpty)
|
||||||
data: ThemeData()
|
SceneGrid(
|
||||||
.copyWith(dividerColor: Colors.transparent),
|
scenes: scenes,
|
||||||
child: ExpansionTile(
|
loadingSceneId: state.loadingSceneId,
|
||||||
tilePadding: const EdgeInsets.symmetric(horizontal: 6),
|
disablePlayButton: false,
|
||||||
initiallyExpanded: true,
|
loadingStates: state.loadingStates,
|
||||||
iconColor: ColorsManager.grayColor,
|
)
|
||||||
title: const BodyMedium(text: 'Tap to run routines'),
|
else
|
||||||
children: [
|
const Center(
|
||||||
scenes.isNotEmpty
|
child: BodyMedium(
|
||||||
? SceneGrid(
|
text: 'No scenes have been added yet',
|
||||||
scenes: scenes,
|
),
|
||||||
loadingSceneId: state.loadingSceneId,
|
|
||||||
disablePlayButton: false,
|
|
||||||
loadingStates:
|
|
||||||
state.loadingStates, // Add this line
|
|
||||||
)
|
|
||||||
: const Center(
|
|
||||||
child: BodyMedium(
|
|
||||||
text: 'No scenes have been added yet',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
Theme(
|
|
||||||
data: ThemeData()
|
|
||||||
.copyWith(dividerColor: Colors.transparent),
|
|
||||||
child: ExpansionTile(
|
|
||||||
initiallyExpanded: true,
|
|
||||||
iconColor: ColorsManager.grayColor,
|
|
||||||
tilePadding: const EdgeInsets.symmetric(horizontal: 6),
|
|
||||||
title: const BodyMedium(text: 'Automation'),
|
|
||||||
children: [
|
|
||||||
automationList.isNotEmpty
|
|
||||||
? SceneGrid(
|
|
||||||
scenes: automationList,
|
|
||||||
loadingSceneId: state.loadingSceneId,
|
|
||||||
disablePlayButton: true,
|
|
||||||
loadingStates:
|
|
||||||
state.loadingStates, // Add this line
|
|
||||||
)
|
|
||||||
: const Center(
|
|
||||||
child: BodyMedium(
|
|
||||||
text: 'No automations have been added yet',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 15,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
ExpansionTile(
|
||||||
|
initiallyExpanded: true,
|
||||||
|
iconColor: ColorsManager.grayColor,
|
||||||
|
tilePadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 6,
|
||||||
|
),
|
||||||
|
title: const BodyMedium(text: 'Automation'),
|
||||||
|
children: [
|
||||||
|
if (automationList.isNotEmpty)
|
||||||
|
SceneGrid(
|
||||||
|
scenes: automationList,
|
||||||
|
loadingSceneId: state.loadingSceneId,
|
||||||
|
disablePlayButton: true,
|
||||||
|
loadingStates: state.loadingStates,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
const Center(
|
||||||
|
child: BodyMedium(
|
||||||
|
text:
|
||||||
|
'No automations have been added yet',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox();
|
return const SizedBox.shrink();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -186,4 +160,21 @@ class SceneView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _loadScenesAndAutomations(BuildContext context, SpaceModel? selectedSpace) {
|
||||||
|
BlocProvider.of<SceneBloc>(context)
|
||||||
|
..add(
|
||||||
|
LoadScenes(
|
||||||
|
selectedSpace!.id,
|
||||||
|
selectedSpace,
|
||||||
|
showInDevice: pageType,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
..add(
|
||||||
|
LoadAutomation(
|
||||||
|
selectedSpace.id,
|
||||||
|
selectedSpace.community.uuid,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class DeleteRoutineButton extends StatelessWidget {
|
|||||||
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
BlocProvider.of<SceneBloc>(context).add(LoadScenes(
|
||||||
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!));
|
HomeCubit.getInstance().selectedSpace!.id, HomeCubit.getInstance().selectedSpace!));
|
||||||
BlocProvider.of<SceneBloc>(context)
|
BlocProvider.of<SceneBloc>(context)
|
||||||
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id));
|
.add(LoadAutomation(HomeCubit.getInstance().selectedSpace!.id,HomeCubit.getInstance().selectedSpace!.community.uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
22
lib/features/scene/widgets/empty_devices_widget.dart
Normal file
22
lib/features/scene/widgets/empty_devices_widget.dart
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
|
class EmptyDevicesWidget extends StatelessWidget {
|
||||||
|
const EmptyDevicesWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 48),
|
||||||
|
child: Text(
|
||||||
|
"No routines.\nEnable 'Show on Home Screen' to add routines",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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,
|
final invalidWidgetEntry = MapEntry(
|
||||||
fontWeight: FontWeight.w400,
|
true,
|
||||||
fontSize: 20,
|
Center(child: Text('This subspace has no devices')),
|
||||||
),
|
);
|
||||||
),
|
|
||||||
trailingWidget: const Icon(
|
final validWidgetEntry = widgets.entries.firstWhere(
|
||||||
Icons.arrow_forward_ios_rounded,
|
(entry) => entry.key == true,
|
||||||
color: ColorsManager.greyColor,
|
orElse: () => invalidWidgetEntry,
|
||||||
size: 16,
|
);
|
||||||
),
|
|
||||||
onPressed: () {
|
return validWidgetEntry.value;
|
||||||
Navigator.pushNamed(
|
|
||||||
context,
|
|
||||||
Routes.deviceFunctionsRoute,
|
|
||||||
arguments: {
|
|
||||||
"device": device,
|
|
||||||
"isAutomationDeviceStatus": isAutomationDeviceStatus
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} 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,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -132,6 +132,10 @@ class SceneItem extends StatelessWidget {
|
|||||||
spaceUuid: HomeCubit.getInstance()
|
spaceUuid: HomeCubit.getInstance()
|
||||||
.selectedSpace!
|
.selectedSpace!
|
||||||
.id),
|
.id),
|
||||||
|
communityId: HomeCubit.getInstance()
|
||||||
|
.selectedSpace!
|
||||||
|
.community
|
||||||
|
.uuid,
|
||||||
automationId: scene.id));
|
automationId: scene.id));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class SmartEnableAutomation extends StatelessWidget {
|
|||||||
child: BlocBuilder<SceneBloc, SceneState>(
|
child: BlocBuilder<SceneBloc, SceneState>(
|
||||||
bloc: context.read<SceneBloc>()
|
bloc: context.read<SceneBloc>()
|
||||||
..add(
|
..add(
|
||||||
LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '')),
|
LoadAutomation(HomeCubit.getInstance().selectedSpace?.id ?? '',HomeCubit.getInstance().selectedSpace?.community.uuid ?? '')),
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is SceneLoading) {
|
if (state is SceneLoading) {
|
||||||
return const Align(
|
return const Align(
|
||||||
|
|||||||
12
lib/features/shared_widgets/app_loading_indicator.dart
Normal file
12
lib/features/shared_widgets/app_loading_indicator.dart
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppLoadingIndicator extends StatelessWidget {
|
||||||
|
const AppLoadingIndicator({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator.adaptive(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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
|
||||||
@ -144,7 +144,7 @@ abstract class ApiEndpoints {
|
|||||||
/// POST
|
/// POST
|
||||||
static const String createScene = '/scene/tap-to-run';
|
static const String createScene = '/scene/tap-to-run';
|
||||||
static const String triggerScene = '/scene/tap-to-run/{sceneId}/trigger';
|
static const String triggerScene = '/scene/tap-to-run/{sceneId}/trigger';
|
||||||
static const String createAutomation = '/automation';
|
static const String createAutomation = '/projects/{projectId}/automations';
|
||||||
|
|
||||||
/// GET
|
/// GET
|
||||||
static const String getUnitScenes =
|
static const String getUnitScenes =
|
||||||
@ -153,23 +153,26 @@ 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 = '/automation/{unitUuid}';
|
static const String getUnitAutomation =
|
||||||
|
'/projects/{projectId}/communities/{communityId}/spaces/{unitUuid}/automations';
|
||||||
|
|
||||||
static const String getAutomationDetails =
|
static const String getAutomationDetails =
|
||||||
'/automation/details/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
/// PUT
|
/// PUT
|
||||||
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
static const String updateScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String updateAutomation = '/automation/{automationId}';
|
static const String updateAutomation =
|
||||||
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
static const String updateAutomationStatus =
|
static const String updateAutomationStatus =
|
||||||
'/automation/status/{automationId}';
|
'/projects/{projectId}/automations/{automationId}';
|
||||||
|
|
||||||
/// DELETE
|
/// DELETE
|
||||||
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
static const String deleteScene = '/scene/tap-to-run/{sceneId}';
|
||||||
|
|
||||||
static const String deleteAutomation = '/automation/{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) {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
|||||||
import 'package:syncrow_app/features/scene/model/update_automation.dart';
|
import 'package:syncrow_app/features/scene/model/update_automation.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';
|
|
||||||
|
|
||||||
class SceneApi {
|
class SceneApi {
|
||||||
static final HTTPService _httpService = HTTPService();
|
static final HTTPService _httpService = HTTPService();
|
||||||
@ -31,10 +30,11 @@ class SceneApi {
|
|||||||
|
|
||||||
// create automation
|
// create automation
|
||||||
static Future<Map<String, dynamic>> createAutomation(
|
static Future<Map<String, dynamic>> createAutomation(
|
||||||
CreateAutomationModel createAutomationModel) async {
|
CreateAutomationModel createAutomationModel, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.createAutomation,
|
path:
|
||||||
|
ApiEndpoints.createAutomation.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationModel.toMap(),
|
body: createAutomationModel.toMap(),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
@ -78,10 +78,17 @@ class SceneApi {
|
|||||||
|
|
||||||
//getAutomation
|
//getAutomation
|
||||||
|
|
||||||
static Future<List<ScenesModel>> getAutomationByUnitId(String unitId) async {
|
static Future<List<ScenesModel>> getAutomationByUnitId(
|
||||||
|
String unitId,
|
||||||
|
String communityId,
|
||||||
|
String projectId,
|
||||||
|
) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.getUnitAutomation.replaceAll('{unitUuid}', unitId),
|
path: ApiEndpoints.getUnitAutomation
|
||||||
|
.replaceAll('{unitUuid}', unitId)
|
||||||
|
.replaceAll('{communityId}', communityId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<ScenesModel> scenes = [];
|
List<ScenesModel> scenes = [];
|
||||||
@ -112,11 +119,12 @@ class SceneApi {
|
|||||||
|
|
||||||
//automation details
|
//automation details
|
||||||
static Future<SceneDetailsModel> getAutomationDetails(
|
static Future<SceneDetailsModel> getAutomationDetails(
|
||||||
String automationId) async {
|
String automationId, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.getAutomationDetails
|
path: ApiEndpoints.getAutomationDetails
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
||||||
);
|
);
|
||||||
@ -128,11 +136,12 @@ class SceneApi {
|
|||||||
|
|
||||||
//updateAutomationStatus
|
//updateAutomationStatus
|
||||||
static Future<bool> updateAutomationStatus(String automationId,
|
static Future<bool> updateAutomationStatus(String automationId,
|
||||||
AutomationStatusUpdate createAutomationEnable) async {
|
AutomationStatusUpdate createAutomationEnable, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.patch(
|
||||||
path: ApiEndpoints.updateAutomationStatus
|
path: ApiEndpoints.updateAutomationStatus
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationEnable.toMap(),
|
body: createAutomationEnable.toMap(),
|
||||||
expectedResponseModel: (json) => json['success'],
|
expectedResponseModel: (json) => json['success'],
|
||||||
);
|
);
|
||||||
@ -194,12 +203,13 @@ class SceneApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//update automation
|
//update automation
|
||||||
static updateAutomation(
|
static updateAutomation(CreateAutomationModel createAutomationModel,
|
||||||
CreateAutomationModel createAutomationModel, String automationId) async {
|
String automationId, String projectId) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.put(
|
final response = await _httpService.put(
|
||||||
path: ApiEndpoints.updateAutomation
|
path: ApiEndpoints.updateAutomation
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
body: createAutomationModel
|
body: createAutomationModel
|
||||||
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
.toJson(automationId.isNotEmpty == true ? automationId : null),
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
@ -229,11 +239,14 @@ class SceneApi {
|
|||||||
|
|
||||||
// delete automation
|
// delete automation
|
||||||
static Future<bool> deleteAutomation(
|
static Future<bool> deleteAutomation(
|
||||||
{required String unitUuid, required String automationId}) async {
|
{required String unitUuid,
|
||||||
|
required String automationId,
|
||||||
|
required String projectId}) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.delete(
|
final response = await _httpService.delete(
|
||||||
path: ApiEndpoints.deleteAutomation
|
path: ApiEndpoints.deleteAutomation
|
||||||
.replaceAll('{automationId}', automationId),
|
.replaceAll('{automationId}', automationId)
|
||||||
|
.replaceAll('{projectId}', projectId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => json['statusCode'] == 200,
|
expectedResponseModel: (json) => json['statusCode'] == 200,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user