mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 00:54:56 +00:00
Compare commits
12 Commits
routine_ui
...
SP-1277-FE
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c691d4b3c | |||
| 550acc4953 | |||
| fd6b737556 | |||
| d08ab8caac | |||
| c2476b9719 | |||
| a56f4e488e | |||
| 6bd9fb7e4e | |||
| d264409d29 | |||
| ca44f3bf55 | |||
| 9949a0a0bf | |||
| 8dc4081a89 | |||
| 52498f4e6b |
@ -247,12 +247,18 @@ SOS
|
|||||||
switch (productType) {
|
switch (productType) {
|
||||||
case 'AC':
|
case 'AC':
|
||||||
return [
|
return [
|
||||||
SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
SwitchFunction(
|
||||||
ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
ModeFunction(
|
||||||
CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
TempSetFunction(
|
||||||
ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
|
CurrentTempFunction(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||||
|
LevelFunction(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
|
ChildLockFunction(
|
||||||
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
];
|
];
|
||||||
|
|
||||||
case '1G':
|
case '1G':
|
||||||
@ -275,44 +281,42 @@ SOS
|
|||||||
case '3G':
|
case '3G':
|
||||||
return [
|
return [
|
||||||
ThreeGangSwitch1Function(
|
ThreeGangSwitch1Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
ThreeGangSwitch2Function(
|
ThreeGangSwitch2Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
ThreeGangSwitch3Function(
|
ThreeGangSwitch3Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
ThreeGangCountdown1Function(
|
ThreeGangCountdown1Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
ThreeGangCountdown2Function(
|
ThreeGangCountdown2Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
ThreeGangCountdown3Function(
|
ThreeGangCountdown3Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
];
|
];
|
||||||
case 'WPS':
|
case 'WPS':
|
||||||
return [
|
return [
|
||||||
//IF Functions
|
//IF Functions
|
||||||
PresenceStateFunction(
|
PresenceStateFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||||
CurrentDistanceFunction(
|
CurrentDistanceFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||||
IlluminanceValueFunction(
|
IlluminanceValueFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||||
PresenceTimeFunction(
|
PresenceTimeFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||||
|
|
||||||
//THEN Functions
|
//THEN Functions
|
||||||
FarDetectionFunction(
|
FarDetectionFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||||
MotionSensitivityFunction(
|
MotionSensitivityFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||||
MotionLessSensitivityFunction(
|
MotionLessSensitivityFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||||
IndicatorFunction(
|
IndicatorFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||||
NoOneTimeFunction(
|
NoOneTimeFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||||
|
|
||||||
// FarDetectionSliderFunction(
|
|
||||||
// deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN')
|
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_state.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_state.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||||
|
|
||||||
@ -10,11 +11,12 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
|||||||
on<SpaceOnlyWithDevicesEvent>(_fetchSpaceOnlyWithDevices);
|
on<SpaceOnlyWithDevicesEvent>(_fetchSpaceOnlyWithDevices);
|
||||||
on<SaveCommunityIdAndSpaceIdEvent>(saveSpaceIdCommunityId);
|
on<SaveCommunityIdAndSpaceIdEvent>(saveSpaceIdCommunityId);
|
||||||
on<ResetSelectedEvent>(resetSelected);
|
on<ResetSelectedEvent>(resetSelected);
|
||||||
|
on<FetchCommunityEvent>(_fetchCommunity);
|
||||||
}
|
}
|
||||||
|
|
||||||
String selectedSpaceId = '';
|
String selectedSpaceId = '';
|
||||||
String selectedCommunityId = '';
|
String selectedCommunityId = '';
|
||||||
|
List<CommunityModel> communities = [];
|
||||||
List<SpaceModel> spacesOnlyWithDevices = [];
|
List<SpaceModel> spacesOnlyWithDevices = [];
|
||||||
|
|
||||||
Future<void> _fetchSpaceOnlyWithDevices(
|
Future<void> _fetchSpaceOnlyWithDevices(
|
||||||
@ -30,7 +32,7 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
|||||||
|
|
||||||
emit(SpaceWithDeviceLoadedState(spacesOnlyWithDevices));
|
emit(SpaceWithDeviceLoadedState(spacesOnlyWithDevices));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(SpaceTreeErrorState('Error loading communities and spaces: $e'));
|
emit(SpaceTreeErrorState('Error loading spaces: $e'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,4 +50,18 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
|
|||||||
selectedCommunityId = '';
|
selectedCommunityId = '';
|
||||||
emit(const ResetSelectedState());
|
emit(const ResetSelectedState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchCommunity(
|
||||||
|
FetchCommunityEvent event, Emitter<CreateRoutineState> emit) async {
|
||||||
|
emit(const CommunitiesLoadingState());
|
||||||
|
|
||||||
|
try {
|
||||||
|
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
|
||||||
|
communities =
|
||||||
|
await CommunitySpaceManagementApi().fetchCommunities(projectUuid);
|
||||||
|
emit(const CommunityLoadedState());
|
||||||
|
} catch (e) {
|
||||||
|
emit(SpaceTreeErrorState('Error loading communities $e'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,3 +41,11 @@ class ResetSelectedEvent extends CreateRoutineEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class FetchCommunityEvent extends CreateRoutineEvent {
|
||||||
|
const FetchCommunityEvent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
@ -44,3 +44,10 @@ class ResetSelectedState extends CreateRoutineState {
|
|||||||
const ResetSelectedState();
|
const ResetSelectedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CommunityLoadedState extends CreateRoutineState {
|
||||||
|
const CommunityLoadedState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class CommunitiesLoadingState extends CreateRoutineState {
|
||||||
|
const CommunitiesLoadingState();
|
||||||
|
}
|
||||||
@ -1,12 +1,11 @@
|
|||||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class CommunityDropdown extends StatelessWidget {
|
class CommunityDropdown extends StatelessWidget {
|
||||||
final String? selectedValue;
|
final String? selectedValue;
|
||||||
|
final List<CommunityModel> communities;
|
||||||
final Function(String?) onChanged;
|
final Function(String?) onChanged;
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
@ -14,6 +13,7 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
Key? key,
|
Key? key,
|
||||||
required this.selectedValue,
|
required this.selectedValue,
|
||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
|
required this.communities,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -32,17 +32,15 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
BlocBuilder<SpaceTreeBloc, SpaceTreeState>(
|
SizedBox(
|
||||||
builder: (context, state) {
|
|
||||||
return SizedBox(
|
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: DropdownButton2<String>(
|
child: DropdownButton2<String>(
|
||||||
underline: SizedBox(),
|
underline: const SizedBox(),
|
||||||
value: selectedValue,
|
value: selectedValue,
|
||||||
items: state.communityList.map((community) {
|
items: communities.map((community) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: community.uuid,
|
value: community.uuid,
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -53,9 +51,9 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
style: TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
hint: Padding(
|
hint: Padding(
|
||||||
padding: EdgeInsets.only(left: 10),
|
padding: const EdgeInsets.only(left: 10),
|
||||||
child: Text(
|
child: Text(
|
||||||
" Please Select",
|
" Please Select",
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
@ -76,11 +74,12 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
flex: 5,
|
flex: 5,
|
||||||
child: Text(
|
child: Text(
|
||||||
selectedValue != null
|
selectedValue != null
|
||||||
? " ${state.communityList.firstWhere((element) => element.uuid == selectedValue).name}"
|
? " ${communities.firstWhere((element) => element.uuid == selectedValue).name}"
|
||||||
: ' Please Select',
|
: ' Please Select',
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
color:
|
color: selectedValue != null
|
||||||
selectedValue != null ? Colors.black : ColorsManager.textGray,
|
? Colors.black
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
@ -115,7 +114,8 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
searchInnerWidgetHeight: 50,
|
searchInnerWidgetHeight: 50,
|
||||||
searchInnerWidget: Container(
|
searchInnerWidget: Container(
|
||||||
height: 50,
|
height: 50,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
@ -133,8 +133,10 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
searchMatchFn: (item, searchValue) {
|
searchMatchFn: (item, searchValue) {
|
||||||
final communityName = (item.child as Text).data?.toLowerCase() ?? '';
|
final communityName =
|
||||||
return communityName.contains(searchValue.toLowerCase().trim());
|
(item.child as Text).data?.toLowerCase() ?? '';
|
||||||
|
return communityName
|
||||||
|
.contains(searchValue.toLowerCase().trim());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
onMenuStateChange: (isOpen) {
|
onMenuStateChange: (isOpen) {
|
||||||
@ -146,9 +148,7 @@ class CommunityDropdown extends StatelessWidget {
|
|||||||
height: 40,
|
height: 40,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
))
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -5,11 +5,10 @@ import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routi
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/create_new_routines/commu_dropdown.dart';
|
import 'package:syncrow_web/pages/routines/create_new_routines/commu_dropdown.dart';
|
||||||
import 'package:syncrow_web/pages/routines/create_new_routines/space_dropdown.dart';
|
import 'package:syncrow_web/pages/routines/create_new_routines/space_dropdown.dart';
|
||||||
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
class CreateNewRoutinesDialog extends StatefulWidget {
|
class CreateNewRoutinesDialog extends StatefulWidget {
|
||||||
const CreateNewRoutinesDialog({Key? key}) : super(key: key);
|
const CreateNewRoutinesDialog({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CreateNewRoutinesDialog> createState() =>
|
State<CreateNewRoutinesDialog> createState() =>
|
||||||
@ -19,24 +18,21 @@ class CreateNewRoutinesDialog extends StatefulWidget {
|
|||||||
class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
||||||
String? _selectedCommunity;
|
String? _selectedCommunity;
|
||||||
String? _selectedSpace;
|
String? _selectedSpace;
|
||||||
void _fetchSpaces(String communityId) {
|
|
||||||
context
|
|
||||||
.read<CreateRoutineBloc>()
|
|
||||||
.add(SpaceOnlyWithDevicesEvent(communityId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<CreateRoutineBloc, CreateRoutineState>(
|
return BlocProvider(
|
||||||
|
create: (BuildContext context) =>
|
||||||
|
CreateRoutineBloc()..add(const FetchCommunityEvent()),
|
||||||
|
child: BlocBuilder<CreateRoutineBloc, CreateRoutineState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
||||||
final spaces = _bloc.spacesOnlyWithDevices;
|
final spaces = _bloc.spacesOnlyWithDevices;
|
||||||
final isLoading = state is SpaceWithDeviceLoadingState;
|
final isLoadingCommunities = state is CommunitiesLoadingState;
|
||||||
|
final isLoadingSpaces = state is SpaceWithDeviceLoadingState;
|
||||||
String spaceHint = 'Select a community first';
|
String spaceHint = 'Select a community first';
|
||||||
|
|
||||||
if (_selectedCommunity != null) {
|
if (_selectedCommunity != null) {
|
||||||
if (isLoading) {
|
if (isLoadingSpaces) {
|
||||||
spaceHint = 'Loading spaces...';
|
spaceHint = 'Loading spaces...';
|
||||||
} else if (spaces.isEmpty) {
|
} else if (spaces.isEmpty) {
|
||||||
spaceHint = 'No spaces available';
|
spaceHint = 'No spaces available';
|
||||||
@ -49,8 +45,8 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
insetPadding: EdgeInsets.zero,
|
insetPadding: EdgeInsets.zero,
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
shape:
|
shape: RoundedRectangleBorder(
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
borderRadius: BorderRadius.circular(12)),
|
||||||
title: Text(
|
title: Text(
|
||||||
'Create New Routines',
|
'Create New Routines',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
@ -58,13 +54,16 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager.primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
content: Column(
|
content: Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Divider(),
|
const Divider(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||||
child: CommunityDropdown(
|
child: CommunityDropdown(
|
||||||
|
communities: _bloc.communities,
|
||||||
selectedValue: _selectedCommunity,
|
selectedValue: _selectedCommunity,
|
||||||
onChanged: (String? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -72,7 +71,7 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
_selectedSpace = null;
|
_selectedSpace = null;
|
||||||
});
|
});
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
_fetchSpaces(newValue);
|
_bloc.add(SpaceOnlyWithDevicesEvent(newValue));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -106,7 +105,10 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Cancel',
|
'Cancel',
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
@ -120,8 +122,8 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
right: 20,
|
right: 20,
|
||||||
),
|
),
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed:
|
onPressed: _selectedCommunity != null &&
|
||||||
_selectedCommunity != null && _selectedSpace != null
|
_selectedSpace != null
|
||||||
? () {
|
? () {
|
||||||
Navigator.of(context).pop({
|
Navigator.of(context).pop({
|
||||||
'community': _selectedCommunity,
|
'community': _selectedCommunity,
|
||||||
@ -131,7 +133,10 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
: null,
|
: null,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Next',
|
'Next',
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: _selectedCommunity != null &&
|
color: _selectedCommunity != null &&
|
||||||
@ -144,11 +149,29 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (isLoadingCommunities)
|
||||||
|
const SizedBox(
|
||||||
|
height: 200,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: ColorsManager.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
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_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
||||||
|
|
||||||
class DeviceDialogHelper {
|
class DeviceDialogHelper {
|
||||||
@ -49,45 +49,46 @@ class DeviceDialogHelper {
|
|||||||
final deviceSelectedFunctions =
|
final deviceSelectedFunctions =
|
||||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||||
|
|
||||||
if (removeComparetors && data['productType'] != 'WPS') {
|
|
||||||
//remove the current temp function in the 'if container'
|
|
||||||
functions.removeAt(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (productType) {
|
switch (productType) {
|
||||||
case 'AC':
|
case 'AC':
|
||||||
return ACHelper.showACFunctionsDialog(
|
return ACHelper.showACFunctionsDialog(
|
||||||
context,
|
context: context,
|
||||||
functions,
|
functions: functions,
|
||||||
data['device'],
|
device: data['device'],
|
||||||
deviceSelectedFunctions,
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
data['uniqueCustomId'],
|
uniqueCustomId: data['uniqueCustomId'],
|
||||||
removeComparetors);
|
removeComparetors: removeComparetors,
|
||||||
|
dialogType: dialogType,
|
||||||
|
);
|
||||||
|
|
||||||
case '1G':
|
case '1G':
|
||||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
context,
|
dialogType: dialogType,
|
||||||
functions,
|
context: context,
|
||||||
data['device'],
|
functions: functions,
|
||||||
deviceSelectedFunctions,
|
device: data['device'],
|
||||||
data['uniqueCustomId'],
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
removeComparetors);
|
uniqueCustomId: data['uniqueCustomId'],
|
||||||
|
removeComparetors: removeComparetors);
|
||||||
case '2G':
|
case '2G':
|
||||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
context,
|
dialogType: dialogType,
|
||||||
functions,
|
context: context,
|
||||||
data['device'],
|
functions: functions,
|
||||||
deviceSelectedFunctions,
|
device: data['device'],
|
||||||
data['uniqueCustomId'],
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
removeComparetors);
|
uniqueCustomId: data['uniqueCustomId'],
|
||||||
|
removeComparetors: removeComparetors);
|
||||||
case '3G':
|
case '3G':
|
||||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
context,
|
dialogType: dialogType,
|
||||||
functions,
|
context: context,
|
||||||
data['device'],
|
functions: functions,
|
||||||
deviceSelectedFunctions,
|
device: data['device'],
|
||||||
data['uniqueCustomId'],
|
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||||
removeComparetors);
|
uniqueCustomId: data['uniqueCustomId'],
|
||||||
|
removeComparetors: removeComparetors);
|
||||||
case 'WPS':
|
case 'WPS':
|
||||||
return WallPresenceSensor.showWPSFunctionsDialog(
|
return WallPresenceSensor.showWPSFunctionsDialog(
|
||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
|
|||||||
@ -5,23 +5,28 @@ import 'package:syncrow_web/utils/constants/app_enum.dart';
|
|||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
||||||
|
final String type;
|
||||||
|
|
||||||
ACFunction({
|
ACFunction({
|
||||||
required super.deviceId,
|
required super.deviceId,
|
||||||
required super.deviceName,
|
required super.deviceName,
|
||||||
required super.code,
|
required super.code,
|
||||||
required super.operationName,
|
required super.operationName,
|
||||||
required super.icon,
|
required super.icon,
|
||||||
|
required this.type,
|
||||||
});
|
});
|
||||||
|
|
||||||
List<ACOperationalValue> getOperationalValues();
|
List<ACOperationalValue> getOperationalValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
class SwitchFunction extends ACFunction {
|
class SwitchFunction extends ACFunction {
|
||||||
SwitchFunction({required super.deviceId, required super.deviceName})
|
SwitchFunction(
|
||||||
|
{required super.deviceId, required super.deviceName, required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch',
|
code: 'switch',
|
||||||
operationName: 'Power',
|
operationName: 'Power',
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
|
type: type,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -40,11 +45,13 @@ class SwitchFunction extends ACFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ModeFunction extends ACFunction {
|
class ModeFunction extends ACFunction {
|
||||||
ModeFunction({required super.deviceId, required super.deviceName})
|
ModeFunction(
|
||||||
|
{required super.deviceId, required super.deviceName, required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'mode',
|
code: 'mode',
|
||||||
operationName: 'Mode',
|
operationName: 'Mode',
|
||||||
icon: Assets.assetsFreezing,
|
icon: Assets.assetsFreezing,
|
||||||
|
type: type,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -72,7 +79,8 @@ class TempSetFunction extends ACFunction {
|
|||||||
final int max;
|
final int max;
|
||||||
final int step;
|
final int step;
|
||||||
|
|
||||||
TempSetFunction({required super.deviceId, required super.deviceName})
|
TempSetFunction(
|
||||||
|
{required super.deviceId, required super.deviceName, required type})
|
||||||
: min = 160,
|
: min = 160,
|
||||||
max = 300,
|
max = 300,
|
||||||
step = 1,
|
step = 1,
|
||||||
@ -80,6 +88,7 @@ class TempSetFunction extends ACFunction {
|
|||||||
code: 'temp_set',
|
code: 'temp_set',
|
||||||
operationName: 'Set Temperature',
|
operationName: 'Set Temperature',
|
||||||
icon: Assets.assetsTempreture,
|
icon: Assets.assetsTempreture,
|
||||||
|
type: type,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -97,8 +106,10 @@ class TempSetFunction extends ACFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LevelFunction extends ACFunction {
|
class LevelFunction extends ACFunction {
|
||||||
LevelFunction({required super.deviceId, required super.deviceName})
|
LevelFunction(
|
||||||
|
{required super.deviceId, required super.deviceName, required type})
|
||||||
: super(
|
: super(
|
||||||
|
type: type,
|
||||||
code: 'level',
|
code: 'level',
|
||||||
operationName: 'Fan Speed',
|
operationName: 'Fan Speed',
|
||||||
icon: Assets.assetsFanSpeed,
|
icon: Assets.assetsFanSpeed,
|
||||||
@ -130,8 +141,10 @@ class LevelFunction extends ACFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ChildLockFunction extends ACFunction {
|
class ChildLockFunction extends ACFunction {
|
||||||
ChildLockFunction({required super.deviceId, required super.deviceName})
|
ChildLockFunction(
|
||||||
|
{required super.deviceId, required super.deviceName, required type})
|
||||||
: super(
|
: super(
|
||||||
|
type: type,
|
||||||
code: 'child_lock',
|
code: 'child_lock',
|
||||||
operationName: 'Child Lock',
|
operationName: 'Child Lock',
|
||||||
icon: Assets.assetsChildLock,
|
icon: Assets.assetsChildLock,
|
||||||
@ -157,11 +170,13 @@ class CurrentTempFunction extends ACFunction {
|
|||||||
final int max;
|
final int max;
|
||||||
final int step;
|
final int step;
|
||||||
|
|
||||||
CurrentTempFunction({required super.deviceId, required super.deviceName})
|
CurrentTempFunction(
|
||||||
|
{required super.deviceId, required super.deviceName, required type})
|
||||||
: min = -100,
|
: min = -100,
|
||||||
max = 990,
|
max = 990,
|
||||||
step = 1,
|
step = 1,
|
||||||
super(
|
super(
|
||||||
|
type: type,
|
||||||
code: 'temp_current',
|
code: 'temp_current',
|
||||||
operationName: 'Current Temperature',
|
operationName: 'Current Temperature',
|
||||||
icon: Assets.currentTemp,
|
icon: Assets.currentTemp,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operation
|
|||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||||
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName})
|
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName ,required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
operationName: 'Light 1 Switch',
|
operationName: 'Light 1 Switch',
|
||||||
@ -26,7 +26,7 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName})
|
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName ,required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationName: 'Light 1 Countdown',
|
operationName: 'Light 1 Countdown',
|
||||||
@ -47,7 +47,7 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
||||||
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName})
|
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName, required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch_2',
|
code: 'switch_2',
|
||||||
operationName: 'Light 2 Switch',
|
operationName: 'Light 2 Switch',
|
||||||
@ -70,7 +70,7 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName})
|
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName ,required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_2',
|
code: 'countdown_2',
|
||||||
operationName: 'Light 2 Countdown',
|
operationName: 'Light 2 Countdown',
|
||||||
@ -91,7 +91,7 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
||||||
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName})
|
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName ,required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch_3',
|
code: 'switch_3',
|
||||||
operationName: 'Light 3 Switch',
|
operationName: 'Light 3 Switch',
|
||||||
@ -114,7 +114,7 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName})
|
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName ,required type})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_3',
|
code: 'countdown_3',
|
||||||
operationName: 'Light 3 Countdown',
|
operationName: 'Light 3 Countdown',
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/model/wall_sensor_model.dart';
|
import 'package:syncrow_web/pages/device_managment/wall_sensor/model/wall_sensor_model.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/wps/wps_operational_value.dart';
|
import 'package:syncrow_web/pages/routines/models/wps/wps_operational_value.dart';
|
||||||
@ -216,12 +214,12 @@ class PresenceStateFunction extends WpsFunctions {
|
|||||||
WpsOperationalValue(
|
WpsOperationalValue(
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
description: "None",
|
description: "None",
|
||||||
value: true,
|
value: 'none',
|
||||||
),
|
),
|
||||||
WpsOperationalValue(
|
WpsOperationalValue(
|
||||||
icon: Assets.presenceStateIcon,
|
icon: Assets.presenceStateIcon,
|
||||||
description: "Presence",
|
description: "Presence",
|
||||||
value: false,
|
value: 'presence',
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -238,7 +236,7 @@ class CurrentDistanceFunction extends WpsFunctions {
|
|||||||
step = 1,
|
step = 1,
|
||||||
super(
|
super(
|
||||||
type: type,
|
type: type,
|
||||||
code: 'current_distance',
|
code: 'dis_current',
|
||||||
operationName: 'Current Distance',
|
operationName: 'Current Distance',
|
||||||
icon: Assets.currentDistanceIcon,
|
icon: Assets.currentDistanceIcon,
|
||||||
);
|
);
|
||||||
@ -246,11 +244,12 @@ class CurrentDistanceFunction extends WpsFunctions {
|
|||||||
@override
|
@override
|
||||||
List<WpsOperationalValue> getOperationalValues() {
|
List<WpsOperationalValue> getOperationalValues() {
|
||||||
List<WpsOperationalValue> values = [];
|
List<WpsOperationalValue> values = [];
|
||||||
for (int temp = min; temp <= max; temp += step) {
|
for (int cm = min; cm <= max; cm += step) {
|
||||||
values.add(WpsOperationalValue(
|
values.add(WpsOperationalValue(
|
||||||
icon: Assets.assetsTempreture,
|
icon: Assets.assetsTempreture,
|
||||||
description: "${temp}CM",
|
description: "${cm}CM",
|
||||||
value: temp,
|
|
||||||
|
value: cm,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
|
|||||||
@ -71,7 +71,8 @@ class IfContainer extends StatelessWidget {
|
|||||||
'1G',
|
'1G',
|
||||||
'2G',
|
'2G',
|
||||||
'3G',
|
'3G',
|
||||||
'WPS'
|
'WPS',
|
||||||
|
'CPS',
|
||||||
].contains(
|
].contains(
|
||||||
state.ifItems[index]['productType'])) {
|
state.ifItems[index]['productType'])) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
@ -105,9 +106,7 @@ class IfContainer extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
onAcceptWithDetails: (data) async {
|
onAcceptWithDetails: (data) async {
|
||||||
print('data.data=${data.data}');
|
|
||||||
final uniqueCustomId = const Uuid().v4();
|
final uniqueCustomId = const Uuid().v4();
|
||||||
|
|
||||||
final mutableData = Map<String, dynamic>.from(data.data);
|
final mutableData = Map<String, dynamic>.from(data.data);
|
||||||
mutableData['uniqueCustomId'] = uniqueCustomId;
|
mutableData['uniqueCustomId'] = uniqueCustomId;
|
||||||
|
|
||||||
@ -131,7 +130,7 @@ class IfContainer extends StatelessWidget {
|
|||||||
context
|
context
|
||||||
.read<RoutineBloc>()
|
.read<RoutineBloc>()
|
||||||
.add(AddToIfContainer(mutableData, false));
|
.add(AddToIfContainer(mutableData, false));
|
||||||
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'CPS']
|
||||||
.contains(mutableData['productType'])) {
|
.contains(mutableData['productType'])) {
|
||||||
context
|
context
|
||||||
.read<RoutineBloc>()
|
.read<RoutineBloc>()
|
||||||
|
|||||||
@ -31,7 +31,8 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
? const Center(
|
? const Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
)
|
)
|
||||||
: Padding(
|
: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -46,20 +47,17 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
if (state.scenes.isEmpty)
|
if (state.scenes.isEmpty)
|
||||||
Expanded(
|
Text(
|
||||||
child: Text(
|
|
||||||
"No scenes found",
|
"No scenes found",
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (state.scenes.isNotEmpty)
|
if (state.scenes.isNotEmpty)
|
||||||
ConstrainedBox(
|
SizedBox(
|
||||||
constraints: BoxConstraints(
|
height: 200,
|
||||||
maxHeight: isSmallScreenSize(context) ? 190 : 200,
|
|
||||||
maxWidth: MediaQuery.sizeOf(context).width * 0.8),
|
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: state.scenes.length,
|
itemCount: state.scenes.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@ -69,9 +67,12 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
right:
|
||||||
|
isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
),
|
),
|
||||||
child: RoutineViewCard(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
RoutineViewCard(
|
||||||
isLoading: isLoading,
|
isLoading: isLoading,
|
||||||
sceneOnTap: () {
|
sceneOnTap: () {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
@ -81,20 +82,25 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
},
|
},
|
||||||
status: state.scenes[index].status,
|
status: state.scenes[index].status,
|
||||||
communityId:
|
communityId:
|
||||||
state.scenes[index].communityId ?? '',
|
state.scenes[index].communityId ??
|
||||||
|
'',
|
||||||
spaceId: state.scenes[index].spaceId,
|
spaceId: state.scenes[index].spaceId,
|
||||||
sceneId: state.scenes[index].sceneTuyaId!,
|
sceneId:
|
||||||
|
state.scenes[index].sceneTuyaId!,
|
||||||
automationId: state.scenes[index].id,
|
automationId: state.scenes[index].id,
|
||||||
cardType: 'scenes',
|
cardType: 'scenes',
|
||||||
spaceName: state.scenes[index].spaceName,
|
spaceName:
|
||||||
|
state.scenes[index].spaceName,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
BlocProvider.of<RoutineBloc>(context)
|
||||||
|
.add(
|
||||||
const CreateNewRoutineViewEvent(
|
const CreateNewRoutineViewEvent(
|
||||||
createRoutineView: true),
|
createRoutineView: true),
|
||||||
);
|
);
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
GetSceneDetails(
|
GetSceneDetails(
|
||||||
sceneId: state.scenes[index].id,
|
sceneId:
|
||||||
|
state.scenes[index].id,
|
||||||
isTabToRun: true,
|
isTabToRun: true,
|
||||||
isUpdate: true,
|
isUpdate: true,
|
||||||
),
|
),
|
||||||
@ -104,7 +110,10 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
icon: state.scenes[index].icon ??
|
icon: state.scenes[index].icon ??
|
||||||
Assets.logoHorizontal,
|
Assets.logoHorizontal,
|
||||||
isFromScenes: true,
|
isFromScenes: true,
|
||||||
iconInBytes: state.scenes[index].iconInBytes,
|
iconInBytes:
|
||||||
|
state.scenes[index].iconInBytes,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@ -119,78 +128,89 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 3),
|
const SizedBox(height: 3),
|
||||||
if (state.automations.isEmpty)
|
if (state.automations.isEmpty)
|
||||||
Expanded(
|
Text(
|
||||||
child: Text(
|
|
||||||
"No automations found",
|
"No automations found",
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (state.automations.isNotEmpty)
|
if (state.automations.isNotEmpty)
|
||||||
ConstrainedBox(
|
SizedBox(
|
||||||
constraints: BoxConstraints(
|
height: 200,
|
||||||
maxHeight: isSmallScreenSize(context) ? 190 : 195,
|
|
||||||
),
|
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: state.automations.length,
|
itemCount: state.automations.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final isLoading = state.automations!
|
final isLoading = state.automations!
|
||||||
.contains(state.automations[index].id);
|
.contains(state.automations[index].id);
|
||||||
|
|
||||||
return Padding(
|
return Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
right: isSmallScreenSize(context)
|
||||||
|
? 4.0
|
||||||
|
: 8.0,
|
||||||
),
|
),
|
||||||
child: RoutineViewCard(
|
child: RoutineViewCard(
|
||||||
isLoading: isLoading,
|
isLoading: isLoading,
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
// BlocProvider.of<RoutineBloc>(context)
|
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
UpdateAutomationStatus(
|
UpdateAutomationStatus(
|
||||||
automationId:
|
automationId: state
|
||||||
state.automations[index].id,
|
.automations[index].id,
|
||||||
automationStatusUpdate:
|
automationStatusUpdate:
|
||||||
AutomationStatusUpdate(
|
AutomationStatusUpdate(
|
||||||
spaceUuid: state
|
spaceUuid: state
|
||||||
.automations[index]
|
.automations[
|
||||||
|
index]
|
||||||
.spaceId,
|
.spaceId,
|
||||||
isEnable: v),
|
isEnable: v),
|
||||||
communityId: state
|
communityId: state
|
||||||
.automations[index].communityId,
|
.automations[index]
|
||||||
|
.communityId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
status: state.automations[index].status,
|
status: state.automations[index].status,
|
||||||
communityId: '',
|
communityId: '',
|
||||||
spaceId: state.automations[index].spaceId,
|
spaceId:
|
||||||
|
state.automations[index].spaceId,
|
||||||
sceneId: '',
|
sceneId: '',
|
||||||
automationId: state.automations[index].id,
|
automationId:
|
||||||
|
state.automations[index].id,
|
||||||
cardType: 'automations',
|
cardType: 'automations',
|
||||||
spaceName: state.scenes[index].spaceName,
|
spaceName:
|
||||||
|
state.scenes[index].spaceName,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
BlocProvider.of<RoutineBloc>(context)
|
||||||
|
.add(
|
||||||
const CreateNewRoutineViewEvent(
|
const CreateNewRoutineViewEvent(
|
||||||
createRoutineView: true),
|
createRoutineView: true),
|
||||||
);
|
);
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
GetAutomationDetails(
|
GetAutomationDetails(
|
||||||
automationId:
|
automationId: state
|
||||||
state.automations[index].id,
|
.automations[index].id,
|
||||||
isAutomation: true,
|
isAutomation: true,
|
||||||
isUpdate: true),
|
isUpdate: true),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
textString: state.automations[index].name,
|
textString:
|
||||||
|
state.automations[index].name,
|
||||||
icon: state.automations[index].icon ??
|
icon: state.automations[index].icon ??
|
||||||
Assets.automation,
|
Assets.automation,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -177,6 +177,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
: (widget.icon is String &&
|
: (widget.icon is String &&
|
||||||
widget.icon.endsWith('.svg'))
|
widget.icon.endsWith('.svg'))
|
||||||
? SvgPicture.asset(
|
? SvgPicture.asset(
|
||||||
|
height: iconSize,
|
||||||
|
width: iconSize,
|
||||||
widget.icon,
|
widget.icon,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -38,7 +38,8 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
|||||||
device.productType == '1G' ||
|
device.productType == '1G' ||
|
||||||
device.productType == '2G' ||
|
device.productType == '2G' ||
|
||||||
device.productType == '3G' ||
|
device.productType == '3G' ||
|
||||||
device.productType == 'WPS')
|
device.productType == 'WPS' ||
|
||||||
|
device.productType == 'CPS')
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
|
|||||||
@ -13,29 +13,38 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
|
||||||
class ACHelper {
|
class ACHelper {
|
||||||
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
List<DeviceFunction> functions,
|
required List<DeviceFunction> functions,
|
||||||
AllDevicesModel? device,
|
required AllDevicesModel? device,
|
||||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
String uniqueCustomId,
|
required String uniqueCustomId,
|
||||||
bool? removeComparetors,
|
required bool? removeComparetors,
|
||||||
) async {
|
required String dialogType,
|
||||||
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
}) async {
|
||||||
|
List<ACFunction> acFunctions =
|
||||||
|
functions.whereType<ACFunction>().where((function) {
|
||||||
|
if (dialogType == 'THEN') {
|
||||||
|
return function.type == 'THEN' || function.type == 'BOTH';
|
||||||
|
}
|
||||||
|
return function.type == 'IF' || function.type == 'BOTH';
|
||||||
|
}).toList();
|
||||||
|
// List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -65,8 +74,10 @@ class ACHelper {
|
|||||||
child: _buildFunctionsList(
|
child: _buildFunctionsList(
|
||||||
context: context,
|
context: context,
|
||||||
acFunctions: acFunctions,
|
acFunctions: acFunctions,
|
||||||
onFunctionSelected: (functionCode, operationName) =>
|
onFunctionSelected:
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
(functionCode, operationName) => context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: functionCode,
|
functionCode: functionCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
)),
|
)),
|
||||||
@ -194,7 +205,8 @@ class ACHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -290,7 +302,8 @@ class ACHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -384,9 +397,13 @@ class ACHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -398,7 +415,8 @@ class ACHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -5,8 +5,10 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||||
@ -14,29 +16,32 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class OneGangSwitchHelper {
|
class OneGangSwitchHelper {
|
||||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||||
BuildContext context,
|
required String dialogType,
|
||||||
List<DeviceFunction> functions,
|
required BuildContext context,
|
||||||
AllDevicesModel? device,
|
required List<DeviceFunction> functions,
|
||||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
required AllDevicesModel? device,
|
||||||
String uniqueCustomId,
|
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
bool removeComparetors,
|
required String uniqueCustomId,
|
||||||
) async {
|
required bool removeComparetors,
|
||||||
List<BaseSwitchFunction> acFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
}) async {
|
||||||
|
List<BaseSwitchFunction> oneGangFunctions =
|
||||||
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -61,12 +66,12 @@ class OneGangSwitchHelper {
|
|||||||
// Left side: Function list
|
// Left side: Function list
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
itemCount: acFunctions.length,
|
itemCount: oneGangFunctions.length,
|
||||||
separatorBuilder: (_, __) => const Divider(
|
separatorBuilder: (_, __) => const Divider(
|
||||||
color: ColorsManager.dividerColor,
|
color: ColorsManager.dividerColor,
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final function = acFunctions[index];
|
final function = oneGangFunctions[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: SvgPicture.asset(
|
leading: SvgPicture.asset(
|
||||||
function.icon,
|
function.icon,
|
||||||
@ -83,9 +88,12 @@ class OneGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName: function.operationName,
|
operationName:
|
||||||
|
function.operationName,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -99,7 +107,7 @@ class OneGangSwitchHelper {
|
|||||||
context: context,
|
context: context,
|
||||||
selectedFunction: selectedFunction,
|
selectedFunction: selectedFunction,
|
||||||
selectedFunctionData: selectedFunctionData,
|
selectedFunctionData: selectedFunctionData,
|
||||||
acFunctions: acFunctions,
|
acFunctions: oneGangFunctions,
|
||||||
device: device,
|
device: device,
|
||||||
operationName: selectedOperationName ?? '',
|
operationName: selectedOperationName ?? '',
|
||||||
removeComparetors: removeComparetors,
|
removeComparetors: removeComparetors,
|
||||||
@ -174,8 +182,14 @@ class OneGangSwitchHelper {
|
|||||||
removeComparetors: removeComparetors,
|
removeComparetors: removeComparetors,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
final selectedFn = acFunctions.firstWhere(
|
||||||
|
(f) => f.code == selectedFunction,
|
||||||
|
orElse: () => OneGangSwitchFunction(
|
||||||
|
deviceId: '',
|
||||||
|
deviceName: '',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -212,11 +226,11 @@ class OneGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(
|
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(
|
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -257,7 +271,8 @@ class OneGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -305,7 +320,8 @@ class OneGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
divisions: (((operationalValues.maxValue ?? 0) -
|
||||||
|
(operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -357,9 +373,13 @@ class OneGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -371,7 +391,8 @@ class OneGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -14,14 +14,15 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class ThreeGangSwitchHelper {
|
class ThreeGangSwitchHelper {
|
||||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
List<DeviceFunction> functions,
|
required List<DeviceFunction> functions,
|
||||||
AllDevicesModel? device,
|
required AllDevicesModel? device,
|
||||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
String uniqueCustomId,
|
required String uniqueCustomId,
|
||||||
bool removeComparetors,
|
required String dialogType,
|
||||||
) async {
|
required bool removeComparetors,
|
||||||
|
}) async {
|
||||||
List<BaseSwitchFunction> switchFunctions =
|
List<BaseSwitchFunction> switchFunctions =
|
||||||
functions.whereType<BaseSwitchFunction>().toList();
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
|
|||||||
@ -14,29 +14,32 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class TwoGangSwitchHelper {
|
class TwoGangSwitchHelper {
|
||||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
List<DeviceFunction> functions,
|
required List<DeviceFunction> functions,
|
||||||
AllDevicesModel? device,
|
required AllDevicesModel? device,
|
||||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
String uniqueCustomId,
|
required String uniqueCustomId,
|
||||||
bool removeComparetors,
|
required bool removeComparetors,
|
||||||
) async {
|
required String dialogType,
|
||||||
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
}) async {
|
||||||
|
List<BaseSwitchFunction> switchFunctions =
|
||||||
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
create: (_) => FunctionBloc()
|
||||||
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData =
|
final selectedFunctionData = state.addedFunctions
|
||||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -83,9 +86,12 @@ class TwoGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<FunctionBloc>().add(SelectFunction(
|
context
|
||||||
|
.read<FunctionBloc>()
|
||||||
|
.add(SelectFunction(
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName: function.operationName,
|
operationName:
|
||||||
|
function.operationName,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -161,7 +167,8 @@ class TwoGangSwitchHelper {
|
|||||||
required String operationName,
|
required String operationName,
|
||||||
required bool removeComparetors,
|
required bool removeComparetors,
|
||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1' || selectedFunction == 'countdown_2') {
|
if (selectedFunction == 'countdown_1' ||
|
||||||
|
selectedFunction == 'countdown_2') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 200;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
@ -175,7 +182,8 @@ class TwoGangSwitchHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
final selectedFn =
|
||||||
|
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -212,11 +220,11 @@ class TwoGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(
|
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(
|
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -257,7 +265,8 @@ class TwoGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -305,7 +314,8 @@ class TwoGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
divisions: (((operationalValues.maxValue ?? 0) -
|
||||||
|
(operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -357,9 +367,13 @@ class TwoGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -371,7 +385,8 @@ class TwoGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
|
||||||
|
|
||||||
class WallPresenceSensor extends StatefulWidget {
|
class WallPresenceSensor extends StatefulWidget {
|
||||||
final List<DeviceFunction> functions;
|
final List<DeviceFunction> functions;
|
||||||
final AllDevicesModel? device;
|
final AllDevicesModel? device;
|
||||||
@ -171,7 +170,7 @@ class _WallPresenceSensorState extends State<WallPresenceSensor> {
|
|||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction,
|
functionCode: selectedFunction,
|
||||||
operationName: '',
|
operationName: state.selectedOperationName ?? '',
|
||||||
value: null,
|
value: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -251,11 +250,8 @@ class _ValueSelector extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isSliderFunction(String function) => [
|
bool _isSliderFunction(String function) =>
|
||||||
'current_distance',
|
['dis_current', 'presence_time', 'illuminance_value'].contains(function);
|
||||||
'presence_time',
|
|
||||||
'illuminance_value'
|
|
||||||
].contains(function);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SliderValueSelector extends StatelessWidget {
|
class _SliderValueSelector extends StatelessWidget {
|
||||||
@ -382,7 +378,7 @@ class _ValueDisplay extends StatelessWidget {
|
|||||||
switch (functionCode) {
|
switch (functionCode) {
|
||||||
case 'presence_time':
|
case 'presence_time':
|
||||||
return '$intValue Min';
|
return '$intValue Min';
|
||||||
case 'current_distance':
|
case 'dis_current':
|
||||||
return '$intValue CM';
|
return '$intValue CM';
|
||||||
case 'illuminance_value':
|
case 'illuminance_value':
|
||||||
return '$intValue Lux';
|
return '$intValue Lux';
|
||||||
@ -421,7 +417,7 @@ class _FunctionSlider extends StatelessWidget {
|
|||||||
switch (functionCode) {
|
switch (functionCode) {
|
||||||
case 'presence_time':
|
case 'presence_time':
|
||||||
return (0, 65535);
|
return (0, 65535);
|
||||||
case 'current_distance':
|
case 'dis_current':
|
||||||
return (1, 600);
|
return (1, 600);
|
||||||
case 'illuminance_value':
|
case 'illuminance_value':
|
||||||
return (0, 10000);
|
return (0, 10000);
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
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_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/automation_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/delay_dialog.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/helper/dialog_helper/device_dialog_helper.dart';
|
import 'package:syncrow_web/pages/routines/helper/dialog_helper/device_dialog_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/automation_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/delay_dialog.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
@ -113,7 +113,8 @@ class ThenContainer extends StatelessWidget {
|
|||||||
'1G',
|
'1G',
|
||||||
'2G',
|
'2G',
|
||||||
'3G',
|
'3G',
|
||||||
'WPS'
|
'WPS',
|
||||||
|
'CPS',
|
||||||
].contains(state.thenItems[index]
|
].contains(state.thenItems[index]
|
||||||
['productType'])) {
|
['productType'])) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
@ -229,7 +230,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
dialogType: "THEN");
|
dialogType: "THEN");
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'CPS']
|
||||||
.contains(mutableData['productType'])) {
|
.contains(mutableData['productType'])) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user