Revert "formatted all files."

This reverts commit 04250ebc98.
This commit is contained in:
Faris Armoush
2025-06-12 16:04:49 +03:00
parent 218f43bacb
commit c642ba2644
473 changed files with 4335 additions and 5417 deletions

View File

@ -1,3 +1,4 @@
import 'dart:convert';
class AutomationStatusUpdate {
@ -16,23 +17,23 @@ class AutomationStatusUpdate {
factory AutomationStatusUpdate.fromJson(Map<String, dynamic> json) =>
AutomationStatusUpdate(
spaceUuid: json['spaceUuid'],
isEnable: json['isEnable'],
spaceUuid: json["spaceUuid"],
isEnable: json["isEnable"],
);
Map<String, dynamic> toJson() => {
'spaceUuid': spaceUuid,
'isEnable': isEnable,
"spaceUuid": spaceUuid,
"isEnable": isEnable,
};
factory AutomationStatusUpdate.fromMap(Map<String, dynamic> map) =>
AutomationStatusUpdate(
spaceUuid: map['spaceUuid'],
isEnable: map['isEnable'],
spaceUuid: map["spaceUuid"],
isEnable: map["isEnable"],
);
Map<String, dynamic> toMap() => {
'spaceUuid': spaceUuid,
'isEnable': isEnable,
"spaceUuid": spaceUuid,
"isEnable": isEnable,
};
}

View File

@ -36,7 +36,7 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
}
}
void saveSpaceIdCommunityId(
saveSpaceIdCommunityId(
SaveCommunityIdAndSpaceIdEvent event, Emitter<CreateRoutineState> emit) {
emit(const SpaceWithDeviceLoadingState());
selectedSpaceId = event.spaceID!;
@ -44,8 +44,7 @@ class CreateRoutineBloc extends Bloc<CreateRoutineEvent, CreateRoutineState> {
emit(const SelectedState());
}
void resetSelected(
ResetSelectedEvent event, Emitter<CreateRoutineState> emit) {
resetSelected(ResetSelectedEvent event, Emitter<CreateRoutineState> emit) {
emit(const SpaceWithDeviceLoadingState());
selectedSpaceId = '';
selectedCommunityId = '';

View File

@ -42,9 +42,10 @@ class ResetSelectedEvent extends CreateRoutineEvent {
List<Object> get props => [];
}
class FetchCommunityEvent extends CreateRoutineEvent {
const FetchCommunityEvent();
@override
List<Object> get props => [];
}
}

View File

@ -1,3 +1,4 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
@ -38,6 +39,7 @@ class SelectedState extends CreateRoutineState {
const SelectedState();
}
class ResetSelectedState extends CreateRoutineState {
const ResetSelectedState();
}
@ -48,4 +50,4 @@ class CommunityLoadedState extends CreateRoutineState {
class CommunitiesLoadingState extends CreateRoutineState {
const CommunitiesLoadingState();
}
}

View File

@ -25,8 +25,7 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
on<SetDays>(_setAllDays);
}
void _initialEvent(
InitialEffectPeriodEvent event, Emitter<EffectPeriodState> emit) {
void _initialEvent(InitialEffectPeriodEvent event, Emitter<EffectPeriodState> emit) {
add(SetCustomTime(event.effectiveTime.start, event.effectiveTime.end));
emit(state.copyWith(
selectedDaysBinary: event.effectiveTime.loops,
@ -36,8 +35,8 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
}
void _onSetPeriod(SetPeriod event, Emitter<EffectPeriodState> emit) {
var startTime = '';
var endTime = '';
String startTime = '';
String endTime = '';
switch (event.period) {
case EnumEffectivePeriodOptions.allDay:
@ -61,9 +60,7 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
}
emit(state.copyWith(
selectedPeriod: event.period,
customStartTime: startTime,
customEndTime: endTime));
selectedPeriod: event.period, customStartTime: startTime, customEndTime: endTime));
}
void _onToggleDay(ToggleDay event, Emitter<EffectPeriodState> emit) {
@ -79,8 +76,8 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
}
void _onSetCustomTime(SetCustomTime event, Emitter<EffectPeriodState> emit) {
final startTime = event.startTime;
final endTime = event.endTime;
String startTime = event.startTime;
String endTime = event.endTime;
EnumEffectivePeriodOptions period;
// Determine the period based on start and end times
@ -94,14 +91,11 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
period = EnumEffectivePeriodOptions.custom;
}
emit(state.copyWith(
customStartTime: startTime,
customEndTime: endTime,
selectedPeriod: period));
emit(
state.copyWith(customStartTime: startTime, customEndTime: endTime, selectedPeriod: period));
}
void _onResetEffectivePeriod(
ResetEffectivePeriod event, Emitter<EffectPeriodState> emit) {
void _onResetEffectivePeriod(ResetEffectivePeriod event, Emitter<EffectPeriodState> emit) {
emit(state.copyWith(
selectedPeriod: EnumEffectivePeriodOptions.allDay,
customStartTime: '00:00',

View File

@ -17,9 +17,9 @@ class EffectPeriodState extends Equatable {
factory EffectPeriodState.initial() {
return const EffectPeriodState(
selectedPeriod: EnumEffectivePeriodOptions.allDay,
selectedDaysBinary: '1111111', // All days selected
customStartTime: '00:00',
customEndTime: '23:59',
selectedDaysBinary: "1111111", // All days selected
customStartTime: "00:00",
customEndTime: "23:59",
);
}
@ -50,6 +50,5 @@ class EffectPeriodState extends Equatable {
}
@override
List<Object?> get props =>
[selectedPeriod, selectedDaysBinary, customStartTime, customEndTime];
List<Object?> get props => [selectedPeriod, selectedDaysBinary, customStartTime, customEndTime];
}

View File

@ -1,9 +1,11 @@
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
import 'package:syncrow_web/pages/routines/bloc/automation_scene_trigger_bloc/automation_status_update.dart';
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
@ -73,7 +75,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
}
}
void _resetErrorMessage(
_resetErrorMessage(
ResetErrorMessage event,
Emitter<RoutineState> emit,
) {
@ -91,7 +93,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems);
// Find the index of the item in teh current itemsList
final index = updatedIfItems.indexWhere(
int index = updatedIfItems.indexWhere(
(map) => map['uniqueCustomId'] == event.item['uniqueCustomId']);
// Replace the map if the index is valid
if (index != -1) {
@ -114,7 +116,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
final currentItems = List<Map<String, dynamic>>.from(state.thenItems);
// Find the index of the item in teh current itemsList
final index = currentItems.indexWhere(
int index = currentItems.indexWhere(
(map) => map['uniqueCustomId'] == event.item['uniqueCustomId']);
// Replace the map if the index is valid
if (index != -1) {
@ -133,7 +135,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
// List<DeviceFunctionData> selectedFunction = List<DeviceFunctionData>.from(event.functions);
final currentSelectedFunctions =
Map<String, List<DeviceFunctionData>> currentSelectedFunctions =
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
// if (currentSelectedFunctions.containsKey(event.uniqueCustomId)) {
@ -174,18 +176,18 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
Future<void> _onLoadScenes(
LoadScenes event, Emitter<RoutineState> emit) async {
emit(state.copyWith(isLoading: true, errorMessage: null));
final scenes = <ScenesModel>[];
List<ScenesModel> scenes = [];
try {
final context = NavigationService.navigatorKey.currentContext!;
final createRoutineBloc = context.read<CreateRoutineBloc>();
BuildContext context = NavigationService.navigatorKey.currentContext!;
var createRoutineBloc = context.read<CreateRoutineBloc>();
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
if (createRoutineBloc.selectedSpaceId == '' &&
createRoutineBloc.selectedCommunityId == '') {
final spaceBloc = context.read<SpaceTreeBloc>();
for (final communityId in spaceBloc.state.selectedCommunities) {
final spacesList =
var spaceBloc = context.read<SpaceTreeBloc>();
for (var communityId in spaceBloc.state.selectedCommunities) {
List<String> spacesList =
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
for (final spaceId in spacesList) {
for (var spaceId in spacesList) {
scenes.addAll(
await SceneApi.getScenes(spaceId, communityId, projectUuid));
}
@ -214,19 +216,19 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
Future<void> _onLoadAutomation(
LoadAutomation event, Emitter<RoutineState> emit) async {
emit(state.copyWith(isLoading: true, errorMessage: null));
final automations = <ScenesModel>[];
List<ScenesModel> automations = [];
final projectId = await ProjectManager.getProjectUUID() ?? '';
final context = NavigationService.navigatorKey.currentContext!;
final createRoutineBloc = context.read<CreateRoutineBloc>();
BuildContext context = NavigationService.navigatorKey.currentContext!;
var createRoutineBloc = context.read<CreateRoutineBloc>();
try {
if (createRoutineBloc.selectedSpaceId == '' &&
createRoutineBloc.selectedCommunityId == '') {
final spaceBloc = context.read<SpaceTreeBloc>();
for (final communityId in spaceBloc.state.selectedCommunities) {
final spacesList =
var spaceBloc = context.read<SpaceTreeBloc>();
for (var communityId in spaceBloc.state.selectedCommunities) {
List<String> spacesList =
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
for (final spaceId in spacesList) {
for (var spaceId in spacesList) {
automations.addAll(
await SceneApi.getAutomation(spaceId, communityId, projectId));
}
@ -334,8 +336,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
});
}).toList();
final context = NavigationService.navigatorKey.currentContext!;
final createRoutineBloc = context.read<CreateRoutineBloc>();
BuildContext context = NavigationService.navigatorKey.currentContext!;
var createRoutineBloc = context.read<CreateRoutineBloc>();
final createSceneModel = CreateSceneModel(
spaceUuid: createRoutineBloc.selectedSpaceId,
@ -359,7 +361,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
}
} on APIException catch (e) {
final errorData = e.message;
final errorMessage = errorData;
String errorMessage = errorData;
emit(state.copyWith(
isLoading: false,
errorMessage: errorMessage,
@ -398,7 +400,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
return;
}
emit(state.copyWith(isLoading: true, errorMessage: null));
var i = 0;
int i = 0;
final conditions = state.ifItems.expand((item) {
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
return functions.map((function) {
@ -466,8 +468,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
);
});
}).toList();
final context = NavigationService.navigatorKey.currentContext!;
final createRoutineBloc = context.read<CreateRoutineBloc>();
BuildContext context = NavigationService.navigatorKey.currentContext!;
var createRoutineBloc = context.read<CreateRoutineBloc>();
final createAutomationModel = CreateAutomationModel(
spaceUuid: createRoutineBloc.selectedSpaceId,
@ -497,7 +499,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
}
} on APIException catch (e) {
final errorData = e.message;
final errorMessage = errorData;
String errorMessage = errorData;
emit(state.copyWith(
isLoading: false,
errorMessage: errorMessage,
@ -703,14 +705,14 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
final List<Map<String, dynamic>> thenItems;
final List<Map<String, dynamic>> ifItems;
final updatedFunctions =
final Map<String, List<DeviceFunctionData>> updatedFunctions =
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
final deviceCards = <String, Map<String, dynamic>>{};
final Map<String, Map<String, dynamic>> deviceCards = {};
for (final action in sceneDetails.actions) {
for (var action in sceneDetails.actions) {
AllDevicesModel? matchingDevice;
for (final device in state.devices) {
for (var device in state.devices) {
if (device.uuid == action.entityId) {
matchingDevice = device;
break;
@ -775,7 +777,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
action.actionExecutor != 'delay') {
final functions = matchingDevice?.functions ?? [];
final functionCode = action.executorProperty?.functionCode;
for (final function in functions) {
for (DeviceFunction function in functions) {
if (function.code == functionCode) {
updatedFunctions[uniqueCustomId]!.add(
DeviceFunctionData(
@ -869,8 +871,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
final projectId = await ProjectManager.getProjectUUID() ?? '';
emit(state.copyWith(isLoading: true));
final context = NavigationService.navigatorKey.currentContext!;
final spaceBloc = context.read<SpaceTreeBloc>();
BuildContext context = NavigationService.navigatorKey.currentContext!;
var spaceBloc = context.read<SpaceTreeBloc>();
if (state.isTabToRun) {
await SceneApi.deleteScene(
unitUuid: spaceBloc.state.selectedSpaces[0],
@ -899,7 +901,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
emit(state.copyWith(isLoading: false, createRoutineView: false));
} on APIException catch (e) {
final errorData = e.message;
final errorMessage = errorData;
String errorMessage = errorData;
emit(state.copyWith(
isLoading: false,
errorMessage: errorMessage,
@ -927,17 +929,17 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
emit(state.copyWith(isLoading: true));
try {
final projectUuid = await ProjectManager.getProjectUUID() ?? '';
final devices = <AllDevicesModel>[];
final context = NavigationService.navigatorKey.currentContext!;
final createRoutineBloc = context.read<CreateRoutineBloc>();
final spaceBloc = context.read<SpaceTreeBloc>();
List<AllDevicesModel> devices = [];
BuildContext context = NavigationService.navigatorKey.currentContext!;
var createRoutineBloc = context.read<CreateRoutineBloc>();
var spaceBloc = context.read<SpaceTreeBloc>();
if (createRoutineBloc.selectedSpaceId == '' &&
createRoutineBloc.selectedCommunityId == '') {
for (final communityId in spaceBloc.state.selectedCommunities) {
final spacesList =
for (var communityId in spaceBloc.state.selectedCommunities) {
List<String> spacesList =
spaceBloc.state.selectedCommunityAndSpaces[communityId] ?? [];
for (final spaceId in spacesList) {
for (var spaceId in spacesList) {
devices.addAll(await DevicesManagementApi()
.fetchDevices(communityId, spaceId, projectUuid));
}
@ -1069,7 +1071,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
return;
}
emit(state.copyWith(isLoading: true, errorMessage: null));
var i = 0;
int i = 0;
final conditions = state.ifItems.expand((item) {
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
return functions.map((function) {
@ -1140,8 +1142,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
});
}).toList();
final context = NavigationService.navigatorKey.currentContext!;
final spaceBloc = context.read<CreateRoutineBloc>();
BuildContext context = NavigationService.navigatorKey.currentContext!;
var spaceBloc = context.read<CreateRoutineBloc>();
final createAutomationModel = CreateAutomationModel(
spaceUuid: spaceBloc.selectedSpaceId,
@ -1161,8 +1163,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
if (result['success']) {
add(ResetRoutineState());
add(const LoadAutomation());
add(const LoadScenes());
add(LoadAutomation());
add(LoadScenes());
} else {
emit(state.copyWith(
isLoading: false,
@ -1195,14 +1197,14 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
final automationDetails =
await SceneApi.getAutomationDetails(event.automationId, projectUuid);
final deviceIfCards = <String, Map<String, dynamic>>{};
final deviceThenCards = <String, Map<String, dynamic>>{};
final Map<String, Map<String, dynamic>> deviceIfCards = {};
final Map<String, Map<String, dynamic>> deviceThenCards = {};
final updatedFunctions =
final Map<String, List<DeviceFunctionData>> updatedFunctions =
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
for (final condition in automationDetails.conditions ?? []) {
final matchingDevice = state.devices.firstWhere(
for (RoutineCondition condition in automationDetails.conditions ?? []) {
AllDevicesModel? matchingDevice = state.devices.firstWhere(
(device) => device.uuid == condition.entityId,
orElse: () => AllDevicesModel(
uuid: condition.entityId,
@ -1239,7 +1241,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
}
final functions = matchingDevice.functions;
for (final function in functions) {
for (var function in functions) {
if (function.code == condition.expr.statusCode) {
updatedFunctions[uniqueCustomId]!.add(
DeviceFunctionData(
@ -1255,8 +1257,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
}
// Process actions (thenItems)
for (final action in automationDetails.actions) {
final matchingDevice = state.devices.firstWhere(
for (var action in automationDetails.actions) {
AllDevicesModel? matchingDevice = state.devices.firstWhere(
(device) => device.uuid == action.entityId,
orElse: () => AllDevicesModel(
uuid: action.entityId,
@ -1310,7 +1312,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
action.actionExecutor != 'delay') {
final functions = matchingDevice.functions;
final functionCode = action.executorProperty!.functionCode;
for (final function in functions) {
for (var function in functions) {
if (function.code == functionCode) {
updatedFunctions[uniqueCustomId]!.add(
DeviceFunctionData(
@ -1401,7 +1403,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
} catch (e) {
emit(state.copyWith(
loadingSceneId: null,
errorMessage: 'Trigger error: $e',
errorMessage: 'Trigger error: ${e.toString()}',
));
}
}
@ -1446,7 +1448,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
..remove(event.automationId);
emit(state.copyWith(
loadingAutomationIds: updatedLoadingIds,
errorMessage: 'Update error: $e',
errorMessage: 'Update error: ${e.toString()}',
));
}
}

View File

@ -86,8 +86,7 @@ class RemoveDragCard extends RoutineEvent {
final int index;
final bool isFromThen;
final String key;
const RemoveDragCard(
{required this.index, required this.isFromThen, required this.key});
const RemoveDragCard({required this.index, required this.isFromThen, required this.key});
@override
List<Object> get props => [index, isFromThen, key];
}
@ -212,6 +211,9 @@ class ClearFunctions extends RoutineEvent {}
class ResetErrorMessage extends RoutineEvent {}
class SceneTrigger extends RoutineEvent {
final String? sceneId;
final String? name;
@ -219,7 +221,7 @@ class SceneTrigger extends RoutineEvent {
const SceneTrigger({this.sceneId, this.name});
@override
List<Object> get props => [sceneId!, name!];
List<Object> get props => [sceneId!,name!];
}
//updateAutomationStatus
@ -228,10 +230,7 @@ class UpdateAutomationStatus extends RoutineEvent {
final AutomationStatusUpdate automationStatusUpdate;
final String communityId;
const UpdateAutomationStatus(
{required this.automationStatusUpdate,
required this.automationId,
required this.communityId});
const UpdateAutomationStatus({required this.automationStatusUpdate, required this.automationId, required this.communityId});
@override
List<Object> get props => [automationStatusUpdate];

View File

@ -15,44 +15,37 @@ class SettingBloc extends Bloc<SettingEvent, SettingState> {
on<SelectIcon>(_selectIcon);
}
Future<void> _initialSetting(
InitialEvent event, Emitter<SettingState> emit) async {
void _initialSetting(InitialEvent event, Emitter<SettingState> emit) async {
try {
emit(const LoadingState());
selectedIcon = event.selectedIcon;
emit(TabToRunSettingLoaded(
showInDevice: true,
selectedIcon: event.selectedIcon,
iconList: iconModelList));
showInDevice: true, selectedIcon: event.selectedIcon, iconList: iconModelList));
} catch (e) {
emit(const FailedState(error: 'Something went wrong'));
}
}
Future<void> _fetchIcons(FetchIcons event, Emitter<SettingState> emit) async {
void _fetchIcons(FetchIcons event, Emitter<SettingState> emit) async {
try {
isExpanded = event.expanded;
emit(const LoadingState());
if (isExpanded) {
iconModelList = await SceneApi.getIcon();
emit(TabToRunSettingLoaded(
showInDevice: true,
selectedIcon: selectedIcon,
iconList: iconModelList));
showInDevice: true, selectedIcon: selectedIcon, iconList: iconModelList));
}
} catch (e) {
emit(const FailedState(error: 'Something went wrong'));
}
}
Future<void> _selectIcon(SelectIcon event, Emitter<SettingState> emit) async {
void _selectIcon(SelectIcon event, Emitter<SettingState> emit) async {
try {
emit(const LoadingState());
selectedIcon = event.iconId;
emit(TabToRunSettingLoaded(
showInDevice: true,
selectedIcon: event.iconId,
iconList: iconModelList));
showInDevice: true, selectedIcon: event.iconId, iconList: iconModelList));
} catch (e) {
emit(const FailedState(error: 'Something went wrong'));
}

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/routines/create_new_routines/dropdown_menu_content.dart';
import 'package:syncrow_web/pages/routines/create_new_routines/space_tree_dropdown_bloc.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'space_tree_dropdown_bloc.dart';
class SpaceTreeDropdown extends StatefulWidget {
final String? selectedSpaceId;
@ -68,7 +68,7 @@ class _SpaceTreeDropdownState extends State<SpaceTreeDropdown> {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
'Community',
"Community",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontWeight: FontWeight.w400,
fontSize: 13,

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
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_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_bloc.dart';
import 'package:syncrow_web/pages/routines/create_new_routines/commu_dropdown.dart';
import 'package:syncrow_web/pages/routines/create_new_routines/space_dropdown.dart';
import 'package:syncrow_web/utils/color_manager.dart';
@ -27,11 +27,11 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
CreateRoutineBloc()..add(const FetchCommunityEvent()),
child: BlocBuilder<CreateRoutineBloc, CreateRoutineState>(
builder: (context, state) {
final bloc = BlocProvider.of<CreateRoutineBloc>(context);
final spaces = bloc.spacesOnlyWithDevices;
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
final spaces = _bloc.spacesOnlyWithDevices;
final isLoadingCommunities = state is CommunitiesLoadingState;
final isLoadingSpaces = state is SpaceWithDeviceLoadingState;
var spaceHint = 'Please Select';
String spaceHint = 'Please Select';
if (_selectedCommunity != null) {
if (isLoadingSpaces) {
spaceHint = 'Loading spaces...';
@ -77,9 +77,9 @@ class _CreateNewRoutinesDialogState extends State<CreateNewRoutinesDialog> {
SpaceTreeDropdown(
selectedSpaceId: _selectedId,
onChanged: (String? newValue) {
setState(() => _selectedId = newValue);
setState(() => _selectedId = newValue!);
if (_selectedId != null) {
bloc.add(SpaceOnlyWithDevicesEvent(
_bloc.add(SpaceOnlyWithDevicesEvent(
_selectedId!));
}
},

View File

@ -1,3 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
@ -10,7 +14,6 @@ class DropdownMenuContent extends StatefulWidget {
final VoidCallback onClose;
const DropdownMenuContent({
super.key,
required this.selectedSpaceId,
required this.onChanged,
required this.onClose,
@ -42,7 +45,7 @@ class _DropdownMenuContentState extends State<DropdownMenuContent> {
final state = bloc.state;
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 30) {
if (!state.paginationIsLoading) {
if (state is SpaceTreeState && !state.paginationIsLoading) {
bloc.add(PaginationEvent(state.paginationModel, state.communityList));
}
}
@ -123,7 +126,7 @@ class _DropdownMenuContentState extends State<DropdownMenuContent> {
_searchController.text.isEmpty
? context
.read<SpaceTreeBloc>()
.add(const SearchQueryEvent(''))
.add(SearchQueryEvent(''))
: context.read<SpaceTreeBloc>().add(
SearchQueryEvent(_searchController.text));
});

View File

@ -10,12 +10,12 @@ class SpaceDropdown extends StatelessWidget {
final String hintMessage;
const SpaceDropdown({
super.key,
Key? key,
required this.spaces,
required this.selectedValue,
required this.onChanged,
required this.hintMessage,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -25,7 +25,7 @@ class SpaceDropdown extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Space',
"Space",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
fontWeight: FontWeight.w400,
fontSize: 13,
@ -67,7 +67,7 @@ class SpaceDropdown extends StatelessWidget {
);
}).toList(),
onChanged: onChanged,
style: const TextStyle(color: Colors.black),
style: TextStyle(color: Colors.black),
hint: Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(

View File

@ -24,4 +24,4 @@ class SpaceTreeDropdownBloc
) {
emit(SpaceTreeDropdownState(selectedSpaceId: event.initialId));
}
}
}

View File

@ -12,4 +12,4 @@ class SpaceTreeDropdownResetEvent extends SpaceTreeDropdownEvent {
final String? initialId;
SpaceTreeDropdownResetEvent(this.initialId);
}
}

View File

@ -4,4 +4,4 @@ class SpaceTreeDropdownState {
final String? selectedSpaceId;
SpaceTreeDropdownState({this.selectedSpaceId});
}
}

View File

@ -17,10 +17,9 @@ class SaveRoutineHelper {
builder: (context) {
return BlocBuilder<RoutineBloc, RoutineState>(
builder: (context, state) {
final selectedConditionLabel =
state.selectedAutomationOperator == 'and'
? 'All Conditions are met'
: 'Any Condition is met';
final selectedConditionLabel = state.selectedAutomationOperator == 'and'
? 'All Conditions are met'
: 'Any Condition is met';
return AlertDialog(
contentPadding: EdgeInsets.zero,
@ -38,11 +37,10 @@ class SaveRoutineHelper {
Text(
'Create a scene: ${state.routineName ?? ""}',
textAlign: TextAlign.center,
style:
Theme.of(context).textTheme.headlineMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold,
),
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 18),
_buildDivider(),
@ -60,8 +58,7 @@ class SaveRoutineHelper {
_buildIfConditions(state, context),
Container(
width: 1,
color: ColorsManager.greyColor
.withValues(alpha: 0.8),
color: ColorsManager.greyColor.withValues(alpha: 0.8),
),
_buildThenActions(state, context),
],
@ -100,8 +97,7 @@ class SaveRoutineHelper {
child: Row(
spacing: 16,
children: [
Expanded(
child: Text('IF: $selectedConditionLabel', style: textStyle)),
Expanded(child: Text('IF: $selectedConditionLabel', style: textStyle)),
const Expanded(child: Text('THEN:', style: textStyle)),
],
),
@ -113,7 +109,7 @@ class SaveRoutineHelper {
spacing: 16,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
DialogFooterButton(
DialogFooterButton(
text: 'Back',
onTap: () => Navigator.pop(context),
),
@ -147,8 +143,7 @@ class SaveRoutineHelper {
child: ListView(
// shrinkWrap: true,
children: state.thenItems.map((item) {
final functions =
state.selectedFunctions[item['uniqueCustomId']] ?? [];
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
return functionRow(item, context, functions);
}).toList(),
),
@ -208,20 +203,19 @@ class SaveRoutineHelper {
),
),
child: Center(
child:
item['type'] == 'tap_to_run' || item['type'] == 'scene'
? Image.memory(
base64Decode(item['icon']),
width: 12,
height: 22,
fit: BoxFit.scaleDown,
)
: SvgPicture.asset(
item['imagePath'],
width: 12,
height: 12,
fit: BoxFit.scaleDown,
),
child: item['type'] == 'tap_to_run' || item['type'] == 'scene'
? Image.memory(
base64Decode(item['icon']),
width: 12,
height: 22,
fit: BoxFit.scaleDown,
)
: SvgPicture.asset(
item['imagePath'],
width: 12,
height: 12,
fit: BoxFit.scaleDown,
),
),
),
Flexible(

View File

@ -37,12 +37,12 @@ class SwitchFunction extends ACFunction {
List<ACOperationalValue> getOperationalValues() => [
ACOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
ACOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
@ -62,17 +62,17 @@ class ModeFunction extends ACFunction {
List<ACOperationalValue> getOperationalValues() => [
ACOperationalValue(
icon: Assets.assetsAcCooling,
description: 'Cooling',
description: "Cooling",
value: TempModes.cold.name,
),
ACOperationalValue(
icon: Assets.assetsAcHeating,
description: 'Heating',
description: "Heating",
value: TempModes.hot.name,
),
ACOperationalValue(
icon: Assets.assetsFanSpeed,
description: 'Ventilation',
description: "Ventilation",
value: TempModes.wind.name,
),
];
@ -90,23 +90,22 @@ class TempSetFunction extends ACFunction {
min: 200,
max: 300,
step: 1,
unit: '°C',
unit: "°C",
);
@override
List<ACOperationalValue> getOperationalValues() {
final values = <ACOperationalValue>[];
for (var temp = min!.toInt(); temp <= max!; temp += step!.toInt()) {
List<ACOperationalValue> values = [];
for (int temp = min!.toInt(); temp <= max!; temp += step!.toInt()) {
values.add(ACOperationalValue(
icon: Assets.assetsTempreture,
description: '${temp / 10}°C',
description: "${temp / 10}°C",
value: temp,
));
}
return values;
}
}
class LevelFunction extends ACFunction {
LevelFunction(
{required super.deviceId, required super.deviceName, required type})
@ -121,22 +120,22 @@ class LevelFunction extends ACFunction {
List<ACOperationalValue> getOperationalValues() => [
ACOperationalValue(
icon: Assets.assetsAcFanLow,
description: 'LOW',
description: "LOW",
value: FanSpeeds.low.name,
),
ACOperationalValue(
icon: Assets.assetsAcFanMiddle,
description: 'MIDDLE',
description: "MIDDLE",
value: FanSpeeds.middle.name,
),
ACOperationalValue(
icon: Assets.assetsAcFanHigh,
description: 'HIGH',
description: "HIGH",
value: FanSpeeds.high.name,
),
ACOperationalValue(
icon: Assets.assetsAcFanAuto,
description: 'AUTO',
description: "AUTO",
value: FanSpeeds.auto.name,
),
];
@ -156,26 +155,22 @@ class ChildLockFunction extends ACFunction {
List<ACOperationalValue> getOperationalValues() => [
ACOperationalValue(
icon: Assets.assetsSceneChildLock,
description: 'Lock',
description: "Lock",
value: true,
),
ACOperationalValue(
icon: Assets.assetsSceneChildUnlock,
description: 'Unlock',
description: "Unlock",
value: false,
),
];
}
class CurrentTempFunction extends ACFunction {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit = '°C';
final String unit = "°C";
CurrentTempFunction(
{required super.deviceId, required super.deviceName, required type})
@ -191,11 +186,11 @@ class CurrentTempFunction extends ACFunction {
@override
List<ACOperationalValue> getOperationalValues() {
final values = <ACOperationalValue>[];
for (var temp = min.toInt(); temp <= max; temp += step.toInt()) {
List<ACOperationalValue> values = [];
for (int temp = min.toInt(); temp <= max; temp += step.toInt()) {
values.add(ACOperationalValue(
icon: Assets.currentTemp,
description: '${temp / 10}°C',
description: "${temp / 10}°C",
value: temp,
));
}

View File

@ -6,10 +6,12 @@ class CpsOperationalValue {
final String description;
final dynamic value;
CpsOperationalValue({
required this.icon,
required this.description,
required this.value,
});
}
@ -43,12 +45,12 @@ final class CpsRadarSwitchFunction extends CpsFunctions {
List<CpsOperationalValue> getOperationalValues() => [
CpsOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
CpsOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
@ -69,12 +71,12 @@ final class CpsSpatialParameterSwitchFunction extends CpsFunctions {
List<CpsOperationalValue> getOperationalValues() => [
CpsOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
CpsOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
@ -94,11 +96,8 @@ final class CpsSensitivityFunction extends CpsFunctions {
icon: Assets.sensitivity,
);
@override
final double min;
@override
final double max;
@override
final double step;
static const _images = <String>[
@ -145,11 +144,8 @@ final class CpsMovingSpeedFunction extends CpsFunctions {
icon: Assets.speedoMeter,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -179,11 +175,8 @@ final class CpsSpatialStaticValueFunction extends CpsFunctions {
icon: Assets.spatialStaticValue,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -213,11 +206,8 @@ final class CpsSpatialMotionValueFunction extends CpsFunctions {
icon: Assets.spatialMotionValue,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -247,11 +237,8 @@ final class CpsMaxDistanceOfDetectionFunction extends CpsFunctions {
icon: Assets.currentDistanceIcon,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -260,7 +247,7 @@ final class CpsMaxDistanceOfDetectionFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.currentDistanceIcon,
description: '${value.toStringAsFixed(1)} M',
@ -285,11 +272,8 @@ final class CpsMaxDistanceOfStaticDetectionFunction extends CpsFunctions {
icon: Assets.currentDistanceIcon,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -298,7 +282,7 @@ final class CpsMaxDistanceOfStaticDetectionFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.currentDistanceIcon,
description: '${value.toStringAsFixed(1)} M',
@ -323,11 +307,8 @@ final class CpsDetectionRangeFunction extends CpsFunctions {
icon: Assets.farDetection,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -336,7 +317,7 @@ final class CpsDetectionRangeFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.farDetection,
description: '${value.toStringAsFixed(1)} M',
@ -361,11 +342,8 @@ final class CpsDistanceOfMovingObjectsFunction extends CpsFunctions {
icon: Assets.currentDistanceIcon,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -374,7 +352,7 @@ final class CpsDistanceOfMovingObjectsFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.currentDistanceIcon,
description: '${value.toStringAsFixed(1)} M',
@ -399,11 +377,8 @@ final class CpsPresenceJudgementThrsholdFunction extends CpsFunctions {
icon: Assets.presenceJudgementThrshold,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -433,11 +408,8 @@ final class CpsMotionAmplitudeTriggerThresholdFunction extends CpsFunctions {
icon: Assets.presenceJudgementThrshold,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -467,11 +439,8 @@ final class CpsPerpetualBoundaryFunction extends CpsFunctions {
icon: Assets.boundary,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -480,7 +449,7 @@ final class CpsPerpetualBoundaryFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.boundary,
description: '${value.toStringAsFixed(1)}M',
@ -505,11 +474,8 @@ final class CpsMotionTriggerBoundaryFunction extends CpsFunctions {
icon: Assets.motionMeter,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -518,7 +484,7 @@ final class CpsMotionTriggerBoundaryFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.motionMeter,
description: '${value.toStringAsFixed(1)} M',
@ -543,11 +509,8 @@ final class CpsMotionTriggerTimeFunction extends CpsFunctions {
icon: Assets.motionMeter,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -556,7 +519,7 @@ final class CpsMotionTriggerTimeFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.motionMeter,
description: '${value.toStringAsFixed(3)} sec',
@ -581,11 +544,8 @@ final class CpsMotionToStaticTimeFunction extends CpsFunctions {
icon: Assets.motionMeter,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -594,7 +554,7 @@ final class CpsMotionToStaticTimeFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.motionMeter,
description: '${value.toStringAsFixed(0)} sec',
@ -619,11 +579,8 @@ final class CpsEnteringNoBodyStateTimeFunction extends CpsFunctions {
icon: Assets.motionMeter,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -632,7 +589,7 @@ final class CpsEnteringNoBodyStateTimeFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.motionMeter,
description: '${value.toStringAsFixed(0)} sec',
@ -912,11 +869,8 @@ final class CpsSportsParaFunction extends CpsFunctions {
icon: Assets.sportsPara,
);
@override
final double min;
@override
final double max;
@override
final double step;
@override
@ -925,7 +879,7 @@ final class CpsSportsParaFunction extends CpsFunctions {
return List.generate(
count,
(index) {
final value = min + (index * step);
final value = (min + (index * step));
return CpsOperationalValue(
icon: Assets.motionMeter,
description: value.toStringAsFixed(0),

View File

@ -112,7 +112,7 @@ class CreateSceneAction {
CreateSceneExecutorProperty? executorProperty,
}) {
return CreateSceneAction(
actionType: actionType ?? actionType,
actionType: actionType ?? this.actionType,
entityId: entityId ?? this.entityId,
actionExecutor: actionExecutor ?? this.actionExecutor,
executorProperty: executorProperty ?? this.executorProperty,
@ -128,7 +128,7 @@ class CreateSceneAction {
};
} else {
return {
'actionType': actionType,
"actionType": actionType,
'entityId': entityId,
'actionExecutor': actionExecutor,
};

View File

@ -14,7 +14,7 @@ class DelayFunction extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'Duration in seconds',
description: "Duration in seconds",
value: 0.0,
minValue: 0,
maxValue: 43200,

View File

@ -24,7 +24,8 @@ class FlushPresenceDelayFunction extends FlushFunctions {
required super.deviceId,
required super.deviceName,
required super.type,
}) : super(
}) :
super(
code: FlushMountedPresenceSensorModel.codePresenceState,
operationName: 'Presence State',
icon: Assets.presenceStateIcon,
@ -36,7 +37,7 @@ class FlushPresenceDelayFunction extends FlushFunctions {
FlushOperationalValue(
icon: Assets.nobodyTime,
description: 'None',
value: 'none',
value: "none",
),
FlushOperationalValue(
icon: Assets.presenceStateIcon,
@ -48,11 +49,8 @@ class FlushPresenceDelayFunction extends FlushFunctions {
}
class FlushSensiReduceFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
FlushSensiReduceFunction({
@ -81,11 +79,8 @@ class FlushSensiReduceFunction extends FlushFunctions {
}
class FlushNoneDelayFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final String unit;
FlushNoneDelayFunction({
@ -114,11 +109,8 @@ class FlushNoneDelayFunction extends FlushFunctions {
}
class FlushIlluminanceFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
FlushIlluminanceFunction({
@ -136,11 +128,11 @@ class FlushIlluminanceFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var lux = min.toInt(); lux <= max; lux += step.toInt()) {
List<FlushOperationalValue> values = [];
for (int lux = min.toInt(); lux <= max; lux += step.toInt()) {
values.add(FlushOperationalValue(
icon: Assets.IlluminanceIcon,
description: '$lux Lux',
description: "$lux Lux",
value: lux,
));
}
@ -149,11 +141,8 @@ class FlushIlluminanceFunction extends FlushFunctions {
}
class FlushOccurDistReduceFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
FlushOccurDistReduceFunction({
@ -183,11 +172,8 @@ class FlushOccurDistReduceFunction extends FlushFunctions {
// ==== then functions ====
class FlushSensitivityFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
FlushSensitivityFunction({
@ -216,13 +202,9 @@ class FlushSensitivityFunction extends FlushFunctions {
}
class FlushNearDetectionFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FlushNearDetectionFunction({
@ -242,7 +224,7 @@ class FlushNearDetectionFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -254,13 +236,9 @@ class FlushNearDetectionFunction extends FlushFunctions {
}
class FlushMaxDetectDistFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FlushMaxDetectDistFunction({
@ -292,13 +270,9 @@ class FlushMaxDetectDistFunction extends FlushFunctions {
}
class FlushTargetConfirmTimeFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FlushTargetConfirmTimeFunction({
@ -318,7 +292,7 @@ class FlushTargetConfirmTimeFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -330,13 +304,9 @@ class FlushTargetConfirmTimeFunction extends FlushFunctions {
}
class FlushDisappeDelayFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FlushDisappeDelayFunction({
@ -356,7 +326,7 @@ class FlushDisappeDelayFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -368,13 +338,9 @@ class FlushDisappeDelayFunction extends FlushFunctions {
}
class FlushIndentLevelFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FlushIndentLevelFunction({
@ -394,7 +360,7 @@ class FlushIndentLevelFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',
@ -406,13 +372,9 @@ class FlushIndentLevelFunction extends FlushFunctions {
}
class FlushTriggerLevelFunction extends FlushFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
FlushTriggerLevelFunction({
@ -432,7 +394,7 @@ class FlushTriggerLevelFunction extends FlushFunctions {
@override
List<FlushOperationalValue> getOperationalValues() {
final values = <FlushOperationalValue>[];
for (var value = min; value <= max; value += step) {
for (var value = min.toDouble(); value <= max; value += step) {
values.add(FlushOperationalValue(
icon: Assets.nobodyTime,
description: '$value $unit',

View File

@ -14,12 +14,12 @@ class OneGangSwitchFunction extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
SwitchOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
@ -37,7 +37,7 @@ class OneGangCountdownFunction extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'sec',
description: "sec",
value: 0.0,
minValue: 0,
maxValue: 43200,

View File

@ -3,11 +3,8 @@ import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operation
import 'package:syncrow_web/utils/constants/assets.dart';
class ThreeGangSwitch1Function extends BaseSwitchFunction {
ThreeGangSwitch1Function({
required super.deviceId,
required super.deviceName,
required String type,
}) : super(
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName ,required type})
: super(
code: 'switch_1',
operationName: 'Light 1 Switch',
icon: Assets.assetsAcPower,
@ -17,23 +14,20 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
SwitchOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
}
class ThreeGangCountdown1Function extends BaseSwitchFunction {
ThreeGangCountdown1Function({
required super.deviceId,
required super.deviceName,
required String type,
}) : super(
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName ,required type})
: super(
code: 'countdown_1',
operationName: 'Light 1 Countdown',
icon: Assets.assetsLightCountdown,
@ -43,7 +37,7 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'sec',
description: "sec",
value: 0.0,
minValue: 0,
maxValue: 43200,
@ -53,11 +47,8 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
}
class ThreeGangSwitch2Function extends BaseSwitchFunction {
ThreeGangSwitch2Function({
required super.deviceId,
required super.deviceName,
required String type,
}) : super(
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName, required type})
: super(
code: 'switch_2',
operationName: 'Light 2 Switch',
icon: Assets.assetsAcPower,
@ -67,23 +58,20 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
SwitchOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
}
class ThreeGangCountdown2Function extends BaseSwitchFunction {
ThreeGangCountdown2Function({
required super.deviceId,
required super.deviceName,
required String type,
}) : super(
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName ,required type})
: super(
code: 'countdown_2',
operationName: 'Light 2 Countdown',
icon: Assets.assetsLightCountdown,
@ -93,7 +81,7 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'sec',
description: "sec",
value: 0.0,
minValue: 0,
maxValue: 43200,
@ -103,11 +91,8 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
}
class ThreeGangSwitch3Function extends BaseSwitchFunction {
ThreeGangSwitch3Function({
required super.deviceId,
required super.deviceName,
required String type,
}) : super(
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName ,required type})
: super(
code: 'switch_3',
operationName: 'Light 3 Switch',
icon: Assets.assetsAcPower,
@ -117,23 +102,20 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
SwitchOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
}
class ThreeGangCountdown3Function extends BaseSwitchFunction {
ThreeGangCountdown3Function({
required super.deviceId,
required super.deviceName,
required String type,
}) : super(
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName ,required type})
: super(
code: 'countdown_3',
operationName: 'Light 3 Countdown',
icon: Assets.assetsLightCountdown,
@ -143,7 +125,7 @@ class ThreeGangCountdown3Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'sec',
description: "sec",
value: 0.0,
minValue: 0,
maxValue: 43200,

View File

@ -14,12 +14,12 @@ class TwoGangSwitch1Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
SwitchOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
@ -37,20 +37,19 @@ class TwoGangSwitch2Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
SwitchOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
}
class TwoGangCountdown1Function extends BaseSwitchFunction {
TwoGangCountdown1Function(
{required super.deviceId, required super.deviceName})
TwoGangCountdown1Function({required super.deviceId, required super.deviceName})
: super(
code: 'countdown_1',
operationName: 'Light 1 Countdown',
@ -61,7 +60,7 @@ class TwoGangCountdown1Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'sec',
description: "sec",
value: 0.0,
minValue: 0,
maxValue: 43200,
@ -71,8 +70,7 @@ class TwoGangCountdown1Function extends BaseSwitchFunction {
}
class TwoGangCountdown2Function extends BaseSwitchFunction {
TwoGangCountdown2Function(
{required super.deviceId, required super.deviceName})
TwoGangCountdown2Function({required super.deviceId, required super.deviceName})
: super(
code: 'countdown_2',
operationName: 'Light 2 Countdown',
@ -83,7 +81,7 @@ class TwoGangCountdown2Function extends BaseSwitchFunction {
List<SwitchOperationalValue> getOperationalValues() => [
SwitchOperationalValue(
icon: '',
description: 'sec',
description: "sec",
value: 0.0,
minValue: 0,
maxValue: 43200,

View File

@ -13,8 +13,7 @@ class GatewayOperationalValue {
});
}
abstract class GatewayFunctions
extends DeviceFunction<GatewayOperationalValue> {
abstract class GatewayFunctions extends DeviceFunction<GatewayOperationalValue> {
final String type;
GatewayFunctions({
@ -44,12 +43,12 @@ final class GatewaySwitchAlarmSound extends GatewayFunctions {
List<GatewayOperationalValue> getOperationalValues() => [
GatewayOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
GatewayOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
@ -71,12 +70,12 @@ final class GatewayMasterState extends GatewayFunctions {
return [
GatewayOperationalValue(
icon: Assets.assetsAcPower,
description: 'Normal',
description: "Normal",
value: 'normal',
),
GatewayOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'Alarm',
description: "Alarm",
value: 'alarm',
),
];
@ -99,12 +98,12 @@ final class GatewayFactoryReset extends GatewayFunctions {
return [
GatewayOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
GatewayOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];

View File

@ -35,7 +35,7 @@ class TotalEnergyConsumedStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 20000000.00,
step: 1,
unit: 'kWh',
unit: "kWh",
);
@override
@ -54,7 +54,7 @@ class TotalActivePowerConsumedStatusFunction extends EnergyClampFunctions {
min: -19800000,
max: 19800000,
step: 0.1,
unit: 'kW',
unit: "kW",
);
@override
@ -101,7 +101,7 @@ class TotalCurrentStatusFunction extends EnergyClampFunctions {
min: 0.000,
max: 9000.000,
step: 1,
unit: 'A',
unit: "A",
);
@override
@ -120,7 +120,7 @@ class FrequencyStatusFunction extends EnergyClampFunctions {
min: 0,
max: 80,
step: 1,
unit: 'Hz',
unit: "Hz",
);
@override
@ -140,7 +140,7 @@ class EnergyConsumedAStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 20000000.00,
step: 1,
unit: 'kWh',
unit: "kWh",
);
@override
@ -159,7 +159,7 @@ class ActivePowerAStatusFunction extends EnergyClampFunctions {
min: 200,
max: 300,
step: 1,
unit: 'kW',
unit: "kW",
);
@override
@ -178,7 +178,7 @@ class VoltageAStatusFunction extends EnergyClampFunctions {
min: 0.0,
max: 500,
step: 1,
unit: 'V',
unit: "V",
);
@override
@ -197,7 +197,7 @@ class PowerFactorAStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 1.00,
step: 0.1,
unit: '',
unit: "",
);
@override
@ -216,7 +216,7 @@ class CurrentAStatusFunction extends EnergyClampFunctions {
min: 0.000,
max: 3000.000,
step: 1,
unit: 'A',
unit: "A",
);
@override
@ -236,7 +236,7 @@ class EnergyConsumedBStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 20000000.00,
step: 1,
unit: 'kWh',
unit: "kWh",
);
@override
@ -255,7 +255,7 @@ class ActivePowerBStatusFunction extends EnergyClampFunctions {
min: -6600000,
max: 6600000,
step: 1,
unit: 'kW',
unit: "kW",
);
@override
@ -274,7 +274,7 @@ class VoltageBStatusFunction extends EnergyClampFunctions {
min: 0.0,
max: 500,
step: 1,
unit: 'V',
unit: "V",
);
@override
@ -293,7 +293,7 @@ class CurrentBStatusFunction extends EnergyClampFunctions {
min: 0.000,
max: 3000.000,
step: 1,
unit: 'A',
unit: "A",
);
@override
@ -312,7 +312,7 @@ class PowerFactorBStatusFunction extends EnergyClampFunctions {
min: 0.0,
max: 1.0,
step: 0.1,
unit: '',
unit: "",
);
@override
@ -332,7 +332,7 @@ class EnergyConsumedCStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 20000000.00,
step: 1,
unit: 'kWh',
unit: "kWh",
);
@override
@ -351,7 +351,7 @@ class ActivePowerCStatusFunction extends EnergyClampFunctions {
min: -6600000,
max: 6600000,
step: 1,
unit: 'kW',
unit: "kW",
);
@override
@ -370,7 +370,7 @@ class VoltageCStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 500,
step: 0.1,
unit: 'V',
unit: "V",
);
@override
@ -389,7 +389,7 @@ class CurrentCStatusFunction extends EnergyClampFunctions {
min: 0.000,
max: 3000.000,
step: 0.1,
unit: 'A',
unit: "A",
);
@override
@ -408,7 +408,7 @@ class PowerFactorCStatusFunction extends EnergyClampFunctions {
min: 0.00,
max: 1.00,
step: 0.1,
unit: '',
unit: "",
);
@override

View File

@ -48,8 +48,7 @@ class RoutineDetailsModel {
spaceUuid: spaceUuid,
automationName: name,
decisionExpr: decisionExpr,
effectiveTime:
effectiveTime ?? EffectiveTime(start: '', end: '', loops: ''),
effectiveTime: effectiveTime ?? EffectiveTime(start: '', end: '', loops: ''),
conditions: conditions?.map((c) => c.toCondition()).toList() ?? [],
actions: actions.map((a) => a.toAutomationAction()).toList(),
);
@ -64,8 +63,7 @@ class RoutineDetailsModel {
if (iconId != null) 'iconUuid': iconId,
if (showInDevice != null) 'showInDevice': showInDevice,
if (effectiveTime != null) 'effectiveTime': effectiveTime!.toMap(),
if (conditions != null)
'conditions': conditions!.map((x) => x.toMap()).toList(),
if (conditions != null) 'conditions': conditions!.map((x) => x.toMap()).toList(),
if (type != null) 'type': type,
if (sceneId != null) 'sceneId': sceneId,
if (automationId != null) 'automationId': automationId,
@ -82,12 +80,10 @@ class RoutineDetailsModel {
),
iconId: map['iconUuid'],
showInDevice: map['showInDevice'],
effectiveTime: map['effectiveTime'] != null
? EffectiveTime.fromMap(map['effectiveTime'])
: null,
effectiveTime:
map['effectiveTime'] != null ? EffectiveTime.fromMap(map['effectiveTime']) : null,
conditions: map['conditions'] != null
? List<RoutineCondition>.from(
map['conditions'].map((x) => RoutineCondition.fromMap(x)))
? List<RoutineCondition>.from(map['conditions'].map((x) => RoutineCondition.fromMap(x)))
: null,
type: map['type'],
sceneId: map['sceneId'],
@ -141,8 +137,7 @@ class RoutineAction {
'actionExecutor': actionExecutor,
if (type != null) 'type': type,
if (name != null) 'name': name,
if (executorProperty != null)
'executorProperty': executorProperty!.toMap(),
if (executorProperty != null) 'executorProperty': executorProperty!.toMap(),
};
}

View File

@ -42,27 +42,27 @@ class ScenesModel {
factory ScenesModel.fromJson(Map<String, dynamic> json,
{bool? isAutomation}) {
return ScenesModel(
id: json['id'] ?? json['uuid'] ?? '',
sceneTuyaId: json['sceneTuyaId'] as String?,
name: json['name'] ?? '',
status: json['status'] ?? '',
type: json['type'] ?? '',
spaceName: json['spaceName'] ?? '',
spaceId: json['spaceId'] ?? '',
communityId: json['communityId'] ?? '',
id: json["id"] ?? json["uuid"] ?? '',
sceneTuyaId: json["sceneTuyaId"] as String?,
name: json["name"] ?? '',
status: json["status"] ?? '',
type: json["type"] ?? '',
spaceName: json["spaceName"] ?? '',
spaceId: json["spaceId"] ?? '',
communityId: json["communityId"] ?? '',
icon:
isAutomation == true ? Assets.automation : (json['icon'] as String?),
isAutomation == true ? Assets.automation : (json["icon"] as String?),
);
}
Map<String, dynamic> toJson() => {
'id': id,
'sceneTuyaId': sceneTuyaId ?? '',
'name': name,
'status': status,
'type': type,
'spaceName': spaceName,
'spaceId': spaceId,
'communityId': communityId,
"id": id,
"sceneTuyaId": sceneTuyaId ?? '',
"name": name,
"status": status,
"type": type,
"spaceName": spaceName,
"spaceId": spaceId,
"communityId": communityId,
};
}

View File

@ -29,6 +29,7 @@ class WHRestartStatusFunction extends WaterHeaterFunctions {
operationName: 'Restart Status',
icon: Assets.refreshStatusIcon,
);
@override
List<WaterHeaterOperationalValue> getOperationalValues() {
@ -36,7 +37,7 @@ class WHRestartStatusFunction extends WaterHeaterFunctions {
WaterHeaterOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'Power OFF',
value: 'off',
value: "off",
),
WaterHeaterOperationalValue(
icon: Assets.assetsAcPower,
@ -45,7 +46,7 @@ class WHRestartStatusFunction extends WaterHeaterFunctions {
),
WaterHeaterOperationalValue(
icon: Assets.refreshStatusIcon,
description: 'Restart Memory',
description: "Restart Memory",
value: 'memory',
),
];
@ -104,7 +105,8 @@ class BacklightFunction extends WaterHeaterFunctions {
required super.deviceId,
required super.deviceName,
required super.type,
}) : super(
}) :
super(
code: 'switch_backlight',
operationName: 'Backlight',
icon: Assets.indicator,

View File

@ -24,11 +24,11 @@ abstract class WpsFunctions extends DeviceFunction<WallSensorModel> {
// For far_detection (75-600cm in 75cm steps)
class FarDetectionFunction extends WpsFunctions {
@override
final double min;
@override
@override
final double max;
@override
@override
final double step;
@override
final String unit;
@ -62,13 +62,9 @@ class FarDetectionFunction extends WpsFunctions {
// For presence_time (0-65535 minutes)
class PresenceTimeFunction extends WpsFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
@override
final String unit;
PresenceTimeFunction(
@ -98,11 +94,8 @@ class PresenceTimeFunction extends WpsFunctions {
// For motion_sensitivity_value (1-5 levels)
class MotionSensitivityFunction extends WpsFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
MotionSensitivityFunction(
@ -131,11 +124,8 @@ class MotionSensitivityFunction extends WpsFunctions {
}
class MotionLessSensitivityFunction extends WpsFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
MotionLessSensitivityFunction(
@ -177,23 +167,20 @@ class IndicatorFunction extends WpsFunctions {
List<WpsOperationalValue> getOperationalValues() => [
WpsOperationalValue(
icon: Assets.assetsAcPower,
description: 'ON',
description: "ON",
value: true,
),
WpsOperationalValue(
icon: Assets.assetsAcPowerOFF,
description: 'OFF',
description: "OFF",
value: false,
),
];
}
class NoOneTimeFunction extends WpsFunctions {
@override
final double min;
@override
final double max;
@override
final String unit;
NoOneTimeFunction(
@ -234,23 +221,20 @@ class PresenceStateFunction extends WpsFunctions {
List<WpsOperationalValue> getOperationalValues() => [
WpsOperationalValue(
icon: Assets.assetsAcPower,
description: 'None',
description: "None",
value: 'none',
),
WpsOperationalValue(
icon: Assets.presenceStateIcon,
description: 'Presence',
description: "Presence",
value: 'presence',
),
];
}
class CurrentDistanceFunction extends WpsFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
CurrentDistanceFunction(
@ -267,11 +251,11 @@ class CurrentDistanceFunction extends WpsFunctions {
@override
List<WpsOperationalValue> getOperationalValues() {
final values = <WpsOperationalValue>[];
for (var cm = min.toInt(); cm <= max; cm += step.toInt()) {
List<WpsOperationalValue> values = [];
for (int cm = min.toInt(); cm <= max; cm += step.toInt()) {
values.add(WpsOperationalValue(
icon: Assets.assetsTempreture,
description: '${cm}CM',
description: "${cm}CM",
value: cm,
));
}
@ -280,11 +264,8 @@ class CurrentDistanceFunction extends WpsFunctions {
}
class IlluminanceValueFunction extends WpsFunctions {
@override
final double min;
@override
final double max;
@override
final double step;
IlluminanceValueFunction({
@ -302,11 +283,11 @@ class IlluminanceValueFunction extends WpsFunctions {
@override
List<WpsOperationalValue> getOperationalValues() {
final values = <WpsOperationalValue>[];
for (var lux = min.toInt(); lux <= max; lux += step.toInt()) {
List<WpsOperationalValue> values = [];
for (int lux = min.toInt(); lux <= max; lux += step.toInt()) {
values.add(WpsOperationalValue(
icon: Assets.IlluminanceIcon,
description: '$lux Lux',
description: "$lux Lux",
value: lux,
));
}

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/effictive_period_dialog.dart';
import 'package:syncrow_web/pages/routines/widgets/period_option.dart';
import 'package:syncrow_web/pages/routines/widgets/repeat_days.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/effictive_period_dialog.dart';
import 'package:syncrow_web/utils/color_manager.dart';
class EffectivePeriodView extends StatelessWidget {

View File

@ -19,7 +19,7 @@ class RoutinesView extends StatefulWidget {
}
class _RoutinesViewState extends State<RoutinesView> {
Future<void> _handleRoutineCreation(BuildContext context) async {
void _handleRoutineCreation(BuildContext context) async {
final result = await showDialog<Map<String, dynamic>>(
context: context,
builder: (context) => const CreateNewRoutinesDialog(),
@ -69,7 +69,7 @@ class _RoutinesViewState extends State<RoutinesView> {
spacing: 16,
children: [
Text(
'Create New Routines',
"Create New Routines",
style:
Theme.of(context).textTheme.titleLarge?.copyWith(
color: ColorsManager.grayColor,

View File

@ -11,8 +11,8 @@ class ConditionToggle extends StatelessWidget {
super.key,
});
static const _conditions = ['<', '==', '>'];
static const List<IconData> _icons = [
static const _conditions = ["<", "==", ">"];
static const _icons = [
Icons.chevron_left,
Icons.drag_handle,
Icons.chevron_right
@ -20,13 +20,13 @@ class ConditionToggle extends StatelessWidget {
@override
Widget build(BuildContext context) {
final selectedIndex = _conditions.indexOf(currentCondition ?? '==');
final selectedIndex = _conditions.indexOf(currentCondition ?? "==");
return Container(
height: 30,
width: MediaQuery.of(context).size.width * 0.1,
decoration: BoxDecoration(
color: ColorsManager.softGray.withValues(alpha: 0.5),
color: ColorsManager.softGray.withOpacity(0.5),
borderRadius: BorderRadius.circular(50),
),
clipBehavior: Clip.antiAlias,

View File

@ -1,5 +1,4 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:syncrow_web/pages/routines/widgets/condition_toggle.dart';
@ -46,10 +45,10 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
String? errorMessage;
int getDecimalPlaces(double step) {
final stepStr = step.toString();
String stepStr = step.toString();
if (stepStr.contains('.')) {
final parts = stepStr.split('.');
var decimalPart = parts[1];
List<String> parts = stepStr.split('.');
String decimalPart = parts[1];
decimalPart = decimalPart.replaceAll(RegExp(r'0+$'), '');
return decimalPart.isEmpty ? 0 : decimalPart.length;
} else {
@ -112,11 +111,13 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
}
}
void _validateInput(String value) {
final doubleValue = double.tryParse(value);
if (doubleValue == null) {
setState(() {
errorMessage = 'Invalid number';
errorMessage = "Invalid number";
hasError = true;
});
return;
@ -127,23 +128,23 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
if (doubleValue < min) {
setState(() {
errorMessage = 'Value must be at least $min';
errorMessage = "Value must be at least $min";
hasError = true;
});
} else if (doubleValue > max) {
setState(() {
errorMessage = 'Value must be at most $max';
errorMessage = "Value must be at most $max";
hasError = true;
});
} else {
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
final factor = pow(10, decimalPlaces).toInt();
final scaledStep = (widget.stepIncreaseAmount * factor).round();
final scaledValue = (doubleValue * factor).round();
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
int factor = pow(10, decimalPlaces).toInt();
int scaledStep = (widget.stepIncreaseAmount * factor).round();
int scaledValue = (doubleValue * factor).round();
if (scaledValue % scaledStep != 0) {
setState(() {
errorMessage = 'must be a multiple of ${widget.stepIncreaseAmount}';
errorMessage = "must be a multiple of ${widget.stepIncreaseAmount}";
hasError = true;
});
} else {
@ -155,10 +156,11 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
}
}
void _correctAndUpdateValue(String value) {
final doubleValue = double.tryParse(value) ?? 0.0;
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
var rounded = (doubleValue / widget.stepIncreaseAmount).round() *
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
double rounded = (doubleValue / widget.stepIncreaseAmount).round() *
widget.stepIncreaseAmount;
rounded = rounded.clamp(widget.sliderRange.$1, widget.sliderRange.$2);
rounded = double.parse(rounded.toStringAsFixed(decimalPlaces));
@ -177,9 +179,9 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
@override
Widget build(BuildContext context) {
final decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
int decimalPlaces = getDecimalPlaces(widget.stepIncreaseAmount);
final formatters = <TextInputFormatter>[];
List<TextInputFormatter> formatters = [];
if (decimalPlaces == 0) {
formatters.add(FilteringTextInputFormatter.digitsOnly);
} else {
@ -231,7 +233,7 @@ class _CustomRoutinesTextboxState extends State<CustomRoutinesTextbox> {
color: ColorsManager.lightGrayBorderColor, width: 1),
boxShadow: [
BoxShadow(
color: ColorsManager.blackColor.withValues(alpha: 0.05),
color: ColorsManager.blackColor.withOpacity(0.05),
blurRadius: 8,
offset: const Offset(0, 4),
),

View File

@ -33,17 +33,13 @@ class DeleteSceneWidget extends StatelessWidget {
alignment: AlignmentDirectional.center,
child: Text(
'Cancel',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.textGray,
),
),
),
),
Container(
width: 1, height: 50, color: ColorsManager.greyColor),
Container(width: 1, height: 50, color: ColorsManager.greyColor),
InkWell(
onTap: () {
context.read<RoutineBloc>().add(const DeleteScene());
@ -54,10 +50,7 @@ class DeleteSceneWidget extends StatelessWidget {
alignment: AlignmentDirectional.center,
child: Text(
'Confirm',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
),
),

View File

@ -33,18 +33,17 @@ class DraggableCard extends StatelessWidget {
Widget build(BuildContext context) {
return BlocBuilder<RoutineBloc, RoutineState>(
builder: (context, state) {
final deviceFunctions =
state.selectedFunctions[deviceData['uniqueCustomId']] ?? [];
final deviceFunctions = state.selectedFunctions[deviceData['uniqueCustomId']] ?? [];
final index = state.thenItems.indexWhere(
(item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']);
int index = state.thenItems
.indexWhere((item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']);
if (index != -1) {
return _buildCardContent(context, deviceFunctions, padding: padding);
}
final ifIndex = state.ifItems.indexWhere(
(item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']);
int ifIndex = state.ifItems
.indexWhere((item) => item['uniqueCustomId'] == deviceData['uniqueCustomId']);
if (ifIndex != -1) {
return _buildCardContent(context, deviceFunctions, padding: padding);
@ -54,8 +53,7 @@ class DraggableCard extends StatelessWidget {
data: deviceData,
feedback: Transform.rotate(
angle: -0.1,
child:
_buildCardContent(context, deviceFunctions, padding: padding),
child: _buildCardContent(context, deviceFunctions, padding: padding),
),
childWhenDragging: _buildGreyContainer(),
child: _buildCardContent(context, deviceFunctions, padding: padding),
@ -64,8 +62,7 @@ class DraggableCard extends StatelessWidget {
);
}
Widget _buildCardContent(
BuildContext context, List<DeviceFunctionData> deviceFunctions,
Widget _buildCardContent(BuildContext context, List<DeviceFunctionData> deviceFunctions,
{EdgeInsetsGeometry? padding}) {
return Stack(
children: [
@ -95,8 +92,7 @@ class DraggableCard extends StatelessWidget {
),
),
padding: const EdgeInsets.all(8),
child: deviceData['type'] == 'tap_to_run' ||
deviceData['type'] == 'scene'
child: deviceData['type'] == 'tap_to_run' || deviceData['type'] == 'scene'
? Image.memory(
base64Decode(deviceData['icon']),
)
@ -122,15 +118,12 @@ class DraggableCard extends StatelessWidget {
height: 4,
),
Visibility(
visible:
deviceData['tag'] != null && deviceData['tag'] != '',
visible: deviceData['tag'] != null && deviceData['tag'] != '',
child: Row(
spacing: 2,
children: [
SizedBox(
width: 8,
height: 8,
child: SvgPicture.asset(Assets.deviceTagIcon)),
width: 8, height: 8, child: SvgPicture.asset(Assets.deviceTagIcon)),
Flexible(
child: Text(
deviceData['tag'] ?? '',
@ -148,23 +141,20 @@ class DraggableCard extends StatelessWidget {
),
),
Visibility(
visible: deviceData['subSpace'] != null &&
deviceData['subSpace'] != '',
visible: deviceData['subSpace'] != null && deviceData['subSpace'] != '',
child: const SizedBox(
height: 4,
),
),
Visibility(
visible: deviceData['subSpace'] != null &&
deviceData['subSpace'] != '',
visible: deviceData['subSpace'] != null && deviceData['subSpace'] != '',
child: Row(
spacing: 2,
children: [
SizedBox(
width: 8,
height: 8,
child:
SvgPicture.asset(Assets.spaceLocationIcon)),
child: SvgPicture.asset(Assets.spaceLocationIcon)),
Flexible(
child: Text(
deviceData['subSpace'] ?? '',
@ -232,8 +222,7 @@ class DraggableCard extends StatelessWidget {
}
String _formatFunctionValue(DeviceFunctionData function) {
if (function.functionCode == 'temp_set' ||
function.functionCode == 'temp_current') {
if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') {
return '${(function.value / 10).toStringAsFixed(0)}°C';
} else if (function.functionCode.contains('countdown')) {
final seconds = function.value?.toInt() ?? 0;

View File

@ -17,13 +17,12 @@ class FunctionSlider extends StatelessWidget {
@override
Widget build(BuildContext context) {
final (min, max) = range;
final isValidRange = max > min;
final value = initialValue is int
final bool isValidRange = max > min;
final double value = initialValue is int
? (initialValue as int).toDouble()
: (initialValue as double);
final divisions =
isValidRange ? ((max - min) / dividendOfRange).round() : null;
final int? divisions = isValidRange ? ((max - min) / dividendOfRange).round() : null;
return Slider(
value: value.clamp(min, max),

View File

@ -62,7 +62,7 @@ class IfContainer extends StatelessWidget {
context: context,
data: state.ifItems[index],
removeComparetors: false,
dialogType: 'IF');
dialogType: "IF");
if (result != null) {
context.read<RoutineBloc>().add(

View File

@ -16,9 +16,8 @@ class FetchRoutineScenesAutomation extends StatelessWidget
Widget build(BuildContext context) {
return BlocBuilder<RoutineBloc, RoutineState>(
builder: (context, state) {
if (state.isLoading) {
if (state.isLoading)
return const Center(child: CircularProgressIndicator());
}
return SingleChildScrollView(
child: Padding(
@ -27,23 +26,23 @@ class FetchRoutineScenesAutomation extends StatelessWidget
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
_buildListTitle(context, 'Scenes (Tap to Run)'),
_buildListTitle(context, "Scenes (Tap to Run)"),
const SizedBox(height: 10),
Visibility(
visible: state.scenes.isNotEmpty,
replacement: _buildEmptyState(context, 'No scenes found'),
replacement: _buildEmptyState(context, "No scenes found"),
child: SizedBox(
height: 200,
child: _buildScenes(state),
),
),
const SizedBox(height: 10),
_buildListTitle(context, 'Automations'),
_buildListTitle(context, "Automations"),
const SizedBox(height: 3),
Visibility(
visible: state.automations.isNotEmpty,
replacement:
_buildEmptyState(context, 'No automations found'),
_buildEmptyState(context, "No automations found"),
child: SizedBox(
height: 200,
child: _buildAutomations(state),

View File

@ -67,15 +67,15 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
@override
Widget build(BuildContext context) {
final cardWidth = widget.isSmallScreenSize(context)
final double cardWidth = widget.isSmallScreenSize(context)
? 120
: widget.isMediumScreenSize(context)
? 135
: 150;
final cardHeight = widget.isSmallScreenSize(context) ? 190 : 200;
final double cardHeight = widget.isSmallScreenSize(context) ? 190 : 200;
final iconSize = widget.isSmallScreenSize(context)
final double iconSize = widget.isSmallScreenSize(context)
? 70
: widget.isMediumScreenSize(context)
? 80
@ -99,42 +99,41 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (widget.cardType != '')
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (widget.isFromScenes ?? false)
InkWell(
onTap: _handleSceneTap,
child: Image.asset(
_showTemporaryCheck
? Assets.scenesPlayIcon
: Assets.scenesPlayIconCheck,
fit: BoxFit.contain,
),
)
else if (widget.isLoading)
const SizedBox(
width: 49,
height: 20,
child: Center(
child: SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
)
else
CupertinoSwitch(
activeTrackColor: ColorsManager.primaryColor,
value: widget.status == 'enable',
onChanged: widget.onChanged,
)
],
)
else
const SizedBox(),
widget.cardType != ''
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (widget.isFromScenes ?? false)
InkWell(
onTap: _handleSceneTap,
child: Image.asset(
_showTemporaryCheck
? Assets.scenesPlayIcon
: Assets.scenesPlayIconCheck,
fit: BoxFit.contain,
),
)
else if (widget.isLoading)
const SizedBox(
width: 49,
height: 20,
child: Center(
child: SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
)
else
CupertinoSwitch(
activeTrackColor: ColorsManager.primaryColor,
value: widget.status == 'enable',
onChanged: widget.onChanged,
)
],
)
: const SizedBox(),
Column(
children: [
Center(
@ -160,9 +159,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
height: iconSize,
width: iconSize,
fit: BoxFit.contain,
errorBuilder:
(context, error, stackTrace) =>
Image.asset(
errorBuilder: (context, error, stackTrace) =>
Image.asset(
Assets.logo,
height: iconSize,
width: iconSize,
@ -205,8 +203,7 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
maxLines: 1,
style: context.textTheme.bodySmall?.copyWith(
color: ColorsManager.blackColor,
fontSize:
widget.isSmallScreenSize(context) ? 10 : 12,
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
),
),
if (widget.spaceName != '')
@ -225,9 +222,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
maxLines: 1,
style: context.textTheme.bodySmall?.copyWith(
color: ColorsManager.blackColor,
fontSize: widget.isSmallScreenSize(context)
? 10
: 12,
fontSize:
widget.isSmallScreenSize(context) ? 10 : 12,
),
),
],

View File

@ -21,12 +21,9 @@ class PeriodOptions extends StatelessWidget {
builder: (context, state) {
return Column(
children: [
_buildRadioOption(
context, EnumEffectivePeriodOptions.allDay, '24 Hours'),
_buildRadioOption(context, EnumEffectivePeriodOptions.daytime,
'Sunrise to Sunset'),
_buildRadioOption(
context, EnumEffectivePeriodOptions.night, 'Sunset to Sunrise'),
_buildRadioOption(context, EnumEffectivePeriodOptions.allDay, '24 Hours'),
_buildRadioOption(context, EnumEffectivePeriodOptions.daytime, 'Sunrise to Sunset'),
_buildRadioOption(context, EnumEffectivePeriodOptions.night, 'Sunset to Sunrise'),
ListTile(
contentPadding: EdgeInsets.zero,
onTap: () => showCustomTimePicker(context),
@ -37,8 +34,7 @@ class PeriodOptions extends StatelessWidget {
fontWeight: FontWeight.w400,
fontSize: 14),
),
subtitle: state.customStartTime != null &&
state.customEndTime != null
subtitle: state.customStartTime != null && state.customEndTime != null
? Text(
'${"${state.customStartTime}"} - ${"${state.customEndTime}"}',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
@ -82,16 +78,12 @@ class PeriodOptions extends StatelessWidget {
title: Text(
EffectPeriodHelper.formatEnumValue(value),
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.blackColor,
fontWeight: FontWeight.w400,
fontSize: 12),
color: ColorsManager.blackColor, fontWeight: FontWeight.w400, fontSize: 12),
),
subtitle: Text(
subtitle,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 10),
color: ColorsManager.textPrimaryColor, fontWeight: FontWeight.w400, fontSize: 10),
),
trailing: Radio<EnumEffectivePeriodOptions>(
value: value,

View File

@ -16,9 +16,7 @@ class RepeatDays extends StatelessWidget {
children: [
Text('Repeat',
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14)),
color: ColorsManager.textPrimaryColor, fontWeight: FontWeight.w400, fontSize: 14)),
const SizedBox(width: 8),
BlocBuilder<EffectPeriodBloc, EffectPeriodState>(
builder: (context, state) {
@ -33,8 +31,7 @@ class RepeatDays extends StatelessWidget {
final day = entry.key;
final abbreviation = entry.value;
final dayIndex = effectiveBloc.getDayIndex(day);
final isSelected =
state.selectedDaysBinary[dayIndex] == '1';
final isSelected = state.selectedDaysBinary[dayIndex] == '1';
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 3.0),
child: GestureDetector(
@ -45,9 +42,7 @@ class RepeatDays extends StatelessWidget {
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: isSelected
? Colors.grey
: Colors.grey.shade300,
color: isSelected ? Colors.grey : Colors.grey.shade300,
width: 1,
),
),
@ -58,9 +53,7 @@ class RepeatDays extends StatelessWidget {
abbreviation,
style: TextStyle(
fontSize: 16,
color: isSelected
? Colors.grey
: Colors.grey.shade300,
color: isSelected ? Colors.grey : Colors.grey.shade300,
),
),
),

View File

@ -74,15 +74,15 @@ class _RoutineDevicesState extends State<RoutineDevices> {
.toLowerCase()
.contains(state.searchText!.toLowerCase())
? DraggableCard(
imagePath: deviceData['imagePath']! as String,
title: deviceData['title']! as String,
imagePath: deviceData['imagePath'] as String,
title: deviceData['title'] as String,
deviceData: deviceData,
)
: const SizedBox.shrink();
} else {
return DraggableCard(
imagePath: deviceData['imagePath']! as String,
title: deviceData['title']! as String,
imagePath: deviceData['imagePath'] as String,
title: deviceData['title'] as String,
deviceData: deviceData,
);
}

View File

@ -24,7 +24,8 @@ class ACHelper {
required bool? removeComparetors,
required String dialogType,
}) async {
final acFunctions = functions.whereType<ACFunction>().where((function) {
List<ACFunction> acFunctions =
functions.whereType<ACFunction>().where((function) {
if (dialogType == 'THEN') {
return function.type == 'THEN' || function.type == 'BOTH';
}
@ -370,7 +371,7 @@ class ACHelper {
// return Container(
// padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
// decoration: BoxDecoration(
// color: ColorsManager.primaryColorWithOpacity.withValues(alpha:0.1),
// color: ColorsManager.primaryColorWithOpacity.withOpacity(0.1),
// borderRadius: BorderRadius.circular(10),
// ),
// child: Text(

View File

@ -3,8 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.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/dialog_footer.dart';
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class AutomationDialog extends StatefulWidget {
@ -31,11 +31,9 @@ class _AutomationDialogState extends State<AutomationDialog> {
@override
void initState() {
super.initState();
final functions = context
.read<RoutineBloc>()
.state
.selectedFunctions[widget.uniqueCustomId];
for (final data in functions ?? []) {
List<DeviceFunctionData>? functions =
context.read<RoutineBloc>().state.selectedFunctions[widget.uniqueCustomId];
for (DeviceFunctionData data in functions ?? []) {
if (data.entityId == widget.automationId) {
selectedAutomationActionExecutor = data.value;
}
@ -67,8 +65,7 @@ class _AutomationDialogState extends State<AutomationDialog> {
}),
),
ListTile(
leading:
SvgPicture.asset(Assets.acPowerOff, width: 24, height: 24),
leading: SvgPicture.asset(Assets.acPowerOff, width: 24, height: 24),
title: const Text('Disable'),
trailing: Radio<String?>(
value: 'rule_disable',

View File

@ -45,8 +45,7 @@ class CpsDialogValueSelector extends StatelessWidget {
operationName: operationName,
value: operation.value,
condition: selectedFunctionData?.condition,
valueDescription:
selectedFunctionData?.valueDescription,
valueDescription: selectedFunctionData?.valueDescription,
),
),
);

View File

@ -57,7 +57,7 @@ class CpsFunctionsList extends StatelessWidget {
'moving_max_dis',
'moving_range',
'presence_range',
if (dialogType == 'IF') 'sensitivity',
if (dialogType == "IF") 'sensitivity',
],
);
});

View File

@ -1,6 +1,5 @@
abstract final class CpsSliderHelpers {
static (double min, double max, double step) mappedRange(
String functionCode) {
static (double min, double max, double step) mappedRange(String functionCode) {
final (defaultMin, defaultMax) = sliderRange(functionCode);
final defaultDivdidend = dividendOfRange(functionCode);
return switch (functionCode) {
@ -63,10 +62,7 @@ abstract final class CpsSliderHelpers {
'perceptual_boundary' ||
'moving_boundary' =>
'M',
'moving_rigger_time' ||
'moving_static_time' ||
'none_body_time' =>
'sec',
'moving_rigger_time' || 'moving_static_time' || 'none_body_time' => 'sec',
_ => '',
};

View File

@ -9,14 +9,14 @@ import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
class DelayHelper {
static Future<Map<String, dynamic>?> showDelayPickerDialog(
BuildContext context, Map<String, dynamic> data) async {
var hours = 0;
var minutes = 0;
int hours = 0;
int minutes = 0;
return showDialog<Map<String, dynamic>?>(
context: context,
builder: (BuildContext context) {
final routineBloc = context.read<RoutineBloc>();
var totalSec = 0;
int totalSec = 0;
final selectedFunctionData =
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
@ -43,8 +43,7 @@ class DelayHelper {
Expanded(
child: CupertinoTimerPicker(
mode: CupertinoTimerPickerMode.hm,
initialTimerDuration:
Duration(hours: hours, minutes: minutes),
initialTimerDuration: Duration(hours: hours, minutes: minutes),
onTimerDurationChanged: (Duration newDuration) {
hours = newDuration.inHours;
minutes = newDuration.inMinutes % 60;
@ -56,7 +55,7 @@ class DelayHelper {
Navigator.of(context).pop();
},
onConfirm: () {
final totalSeconds = (hours * 3600) + (minutes * 60);
int totalSeconds = (hours * 3600) + (minutes * 60);
context.read<RoutineBloc>().add(AddFunctionToRoutine(
[
DeviceFunctionData(

View File

@ -38,10 +38,10 @@ class DiscardDialog {
color: ColorsManager.red,
fontWeight: FontWeight.bold,
),
onDismissText: 'Dont Close',
onConfirmText: 'Close',
onDismissText: "Dont Close",
onConfirmText: "Close",
onDismissColor: ColorsManager.grayColor,
onConfirmColor: ColorsManager.red.withValues(alpha: 0.8),
onConfirmColor: ColorsManager.red.withOpacity(0.8),
onDismiss: () {
Navigator.pop(context);
},

View File

@ -8,14 +8,13 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
import 'package:time_picker_spinner/time_picker_spinner.dart';
class EffectPeriodHelper {
static Future<List<String>?> showCustomTimePicker(
BuildContext context) async {
var selectedStartTime = '00:00';
var selectedEndTime = '23:59';
final pageController = PageController(initialPage: 0);
static Future<List<String>?> showCustomTimePicker(BuildContext context) async {
String selectedStartTime = "00:00";
String selectedEndTime = "23:59";
PageController pageController = PageController(initialPage: 0);
final startDateTime = DateTime(2022, 1, 1, 0, 0);
final endDateTime = DateTime(2022, 1, 1, 23, 59);
DateTime startDateTime = DateTime(2022, 1, 1, 0, 0);
DateTime endDateTime = DateTime(2022, 1, 1, 23, 59);
context.customAlertDialog(
alertBody: SizedBox(
@ -47,7 +46,7 @@ class EffectPeriodHelper {
],
),
),
title: 'Custom',
title: "Custom",
onConfirm: () {
context.read<EffectPeriodBloc>().add(
SetCustomTime(selectedStartTime, selectedEndTime),
@ -89,7 +88,7 @@ class EffectPeriodHelper {
),
TextButton(
onPressed: () {},
child: Text(isStartTime ? 'Start' : 'End',
child: Text(isStartTime ? "Start" : "End",
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
@ -136,17 +135,17 @@ class EffectPeriodHelper {
static String formatEnumValue(EnumEffectivePeriodOptions value) {
switch (value) {
case EnumEffectivePeriodOptions.allDay:
return 'All Day';
return "All Day";
case EnumEffectivePeriodOptions.daytime:
return 'Daytime';
return "Daytime";
case EnumEffectivePeriodOptions.night:
return 'Night';
return "Night";
case EnumEffectivePeriodOptions.custom:
return 'Custom';
return "Custom";
case EnumEffectivePeriodOptions.none:
return 'None';
return "None";
default:
return '';
return "";
}
}
}

View File

@ -7,6 +7,7 @@ import 'package:syncrow_web/pages/routines/models/device_functions.dart';
import 'package:syncrow_web/pages/routines/models/flush/flush_functions.dart';
import 'package:syncrow_web/pages/routines/widgets/custom_routines_textbox.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/flush_presence_sensor/flush_operational_values_list.dart';
import 'package:syncrow_web/pages/routines/widgets/slider_value_selector.dart';
class FlushValueSelectorWidget extends StatelessWidget {
final String selectedFunction;
@ -61,7 +62,7 @@ class FlushValueSelectorWidget extends StatelessWidget {
selectedFunction == FlushMountedPresenceSensorModel.codeFarDetection;
final isDistanceDetection = isNearDetection || isFarDetection;
var initialValue = (functionData.value as num?)?.toDouble() ?? 0.0;
double initialValue = (functionData.value as num?)?.toDouble() ?? 0.0;
if (isDistanceDetection) {
initialValue = initialValue / 100;
@ -156,7 +157,7 @@ class FlushValueSelectorWidget extends StatelessWidget {
String get getDisplayText {
final num? value = functionData.value;
var displayValue = value?.toDouble() ?? 0.0;
double displayValue = value?.toDouble() ?? 0.0;
if (functionData.functionCode ==
FlushMountedPresenceSensorModel.codeNearDetection ||

View File

@ -49,6 +49,8 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
}
}
@override
void dispose() {
_hoursController.dispose();
@ -101,7 +103,7 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
}
void _handleTimeChange(int hours, int minutes, int seconds) {
var total = hours * 3600 + minutes * 60 + seconds;
int total = hours * 3600 + minutes * 60 + seconds;
if (total > 10000) {
hours = 2;
minutes = 46;

View File

@ -45,8 +45,7 @@ class GatewayDialogValueSelector extends StatelessWidget {
operationName: operationName,
value: operation.value,
condition: selectedFunctionData?.condition,
valueDescription:
selectedFunctionData?.valueDescription,
valueDescription: selectedFunctionData?.valueDescription,
),
),
);

View File

@ -25,7 +25,8 @@ class OneGangSwitchHelper {
required String uniqueCustomId,
required bool removeComparetors,
}) async {
final oneGangFunctions = functions.whereType<BaseSwitchFunction>().toList();
List<BaseSwitchFunction> oneGangFunctions =
functions.whereType<BaseSwitchFunction>().toList();
return showDialog<Map<String, dynamic>?>(
context: context,
@ -245,9 +246,9 @@ class OneGangSwitchHelper {
withSpecialChar: false,
currentCondition: selectedFunctionData?.condition,
dialogType: dialogType,
sliderRange: (0, 43200),
sliderRange: (0, 43200),
displayedValue: (initialValue ?? 0).toString(),
initialValue: (initialValue ?? 0).toString(),
initialValue: (initialValue ?? 0).toString(),
onConditionChanged: (condition) {
context.read<FunctionBloc>().add(
AddFunction(

View File

@ -81,4 +81,6 @@ class EnergyOperationalValuesList extends StatelessWidget {
),
);
}
}

View File

@ -27,11 +27,13 @@ class EnergyValueSelectorWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final selectedFn = functions.firstWhere((f) => f.code == selectedFunction);
final selectedFn =
functions.firstWhere((f) => f.code == selectedFunction);
final values = selectedFn.getOperationalValues();
final step = selectedFn.step ?? 1.0;
final unit = selectedFn.unit ?? '';
final sliderRange = (selectedFn.min ?? 0.0, selectedFn.max ?? 100.0);
final step = selectedFn.step ?? 1.0;
final _unit = selectedFn.unit ?? '';
final (double, double) sliderRange =
(selectedFn.min ?? 0.0, selectedFn.max ?? 100.0);
if (_isSliderFunction(selectedFunction)) {
return CustomRoutinesTextbox(
@ -63,7 +65,7 @@ class EnergyValueSelectorWidget extends StatelessWidget {
),
),
),
unit: unit,
unit: _unit,
dividendOfRange: 1,
stepIncreaseAmount: step,
);

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/routines/bloc/effective_period/effect_period_bloc.dart';
@ -14,6 +13,7 @@ import 'package:syncrow_web/pages/routines/view/effective_period_view.dart';
import 'package:syncrow_web/pages/routines/widgets/delete_scene.dart';
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:flutter/cupertino.dart';
class SettingHelper {
static Future<String?> showSettingDialog({
@ -30,16 +30,14 @@ class SettingHelper {
providers: [
if (effectiveTime != null)
BlocProvider(
create: (_) => EffectPeriodBloc()
..add(InitialEffectPeriodEvent(effectiveTime)),
create: (_) => EffectPeriodBloc()..add(InitialEffectPeriodEvent(effectiveTime)),
),
if (effectiveTime == null)
BlocProvider(
create: (_) => EffectPeriodBloc(),
),
BlocProvider(
create: (_) => SettingBloc()
..add(InitialEvent(selectedIcon: iconId ?? ''))),
create: (_) => SettingBloc()..add(InitialEvent(selectedIcon: iconId ?? ''))),
],
child: AlertDialog(
contentPadding: EdgeInsets.zero,
@ -47,18 +45,15 @@ class SettingHelper {
builder: (context, effectPeriodState) {
return BlocBuilder<SettingBloc, SettingState>(
builder: (context, settingState) {
var selectedIcon = '';
var list = <IconModel>[];
String selectedIcon = '';
List<IconModel> list = [];
if (settingState is TabToRunSettingLoaded) {
selectedIcon = settingState.selectedIcon;
list = settingState.iconList;
}
return Container(
width: context.read<SettingBloc>().isExpanded ? 800 : 400,
height:
context.read<SettingBloc>().isExpanded && isAutomation
? 500
: 350,
height: context.read<SettingBloc>().isExpanded && isAutomation ? 500 : 350,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
@ -81,18 +76,14 @@ class SettingHelper {
children: [
Container(
padding: const EdgeInsets.only(
top: 10,
left: 10,
right: 10,
bottom: 10),
top: 10, left: 10, right: 10, bottom: 10),
child: Column(
children: [
InkWell(
onTap: () {},
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [
Text(
'Validity',
@ -100,18 +91,14 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.textPrimaryColor,
fontWeight:
FontWeight
.w400,
color:
ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14),
),
const Icon(
Icons
.arrow_forward_ios_outlined,
color: ColorsManager
.textGray,
Icons.arrow_forward_ios_outlined,
color: ColorsManager.textGray,
size: 15,
)
],
@ -121,27 +108,22 @@ class SettingHelper {
height: 5,
),
const Divider(
color:
ColorsManager.graysColor,
color: ColorsManager.graysColor,
),
const SizedBox(
height: 5,
),
InkWell(
onTap: () {
BlocProvider.of<
SettingBloc>(
context)
.add(FetchIcons(
BlocProvider.of<SettingBloc>(context).add(
FetchIcons(
expanded: !context
.read<
SettingBloc>()
.read<SettingBloc>()
.isExpanded));
},
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [
Text(
'Effective Period',
@ -149,18 +131,14 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.textPrimaryColor,
fontWeight:
FontWeight
.w400,
color:
ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14),
),
const Icon(
Icons
.arrow_forward_ios_outlined,
color: ColorsManager
.textGray,
Icons.arrow_forward_ios_outlined,
color: ColorsManager.textGray,
size: 15,
)
],
@ -170,16 +148,13 @@ class SettingHelper {
height: 5,
),
const Divider(
color:
ColorsManager.graysColor,
color: ColorsManager.graysColor,
),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Executed by',
@ -187,11 +162,8 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.textPrimaryColor,
fontWeight:
FontWeight
.w400,
color: ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14),
),
Text('Cloud',
@ -199,19 +171,12 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color:
ColorsManager
.textGray,
fontWeight:
FontWeight
.w400,
color: ColorsManager.textGray,
fontWeight: FontWeight.w400,
fontSize: 14)),
],
),
if (context
.read<RoutineBloc>()
.state
.isUpdate ??
if (context.read<RoutineBloc>().state.isUpdate ??
false)
const DeleteSceneWidget()
],
@ -223,27 +188,20 @@ class SettingHelper {
children: [
Container(
padding: const EdgeInsets.only(
top: 10,
left: 10,
right: 10,
bottom: 10),
top: 10, left: 10, right: 10, bottom: 10),
child: Column(
children: [
InkWell(
onTap: () {
BlocProvider.of<
SettingBloc>(
context)
.add(FetchIcons(
BlocProvider.of<SettingBloc>(context).add(
FetchIcons(
expanded: !context
.read<
SettingBloc>()
.read<SettingBloc>()
.isExpanded));
},
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [
Text(
'Icons',
@ -251,18 +209,14 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.textPrimaryColor,
fontWeight:
FontWeight
.w400,
color:
ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14),
),
const Icon(
Icons
.arrow_forward_ios_outlined,
color: ColorsManager
.textGray,
Icons.arrow_forward_ios_outlined,
color: ColorsManager.textGray,
size: 15,
)
],
@ -272,16 +226,13 @@ class SettingHelper {
height: 5,
),
const Divider(
color:
ColorsManager.graysColor,
color: ColorsManager.graysColor,
),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Show on devices page',
@ -289,30 +240,23 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.textPrimaryColor,
fontWeight:
FontWeight
.w400,
color: ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14),
),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
height: 30,
width: 1,
color: ColorsManager
.graysColor,
color: ColorsManager.graysColor,
),
Transform.scale(
scale: .8,
child:
CupertinoSwitch(
child: CupertinoSwitch(
value: true,
onChanged:
(value) {},
onChanged: (value) {},
applyTheme: true,
),
),
@ -324,16 +268,13 @@ class SettingHelper {
height: 5,
),
const Divider(
color:
ColorsManager.graysColor,
color: ColorsManager.graysColor,
),
const SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Executed by',
@ -341,11 +282,8 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.textPrimaryColor,
fontWeight:
FontWeight
.w400,
color: ColorsManager.textPrimaryColor,
fontWeight: FontWeight.w400,
fontSize: 14),
),
Text('Cloud',
@ -353,19 +291,12 @@ class SettingHelper {
.textTheme
.bodyMedium!
.copyWith(
color:
ColorsManager
.textGray,
fontWeight:
FontWeight
.w400,
color: ColorsManager.textGray,
fontWeight: FontWeight.w400,
fontSize: 14)),
],
),
if (context
.read<RoutineBloc>()
.state
.isUpdate ??
if (context.read<RoutineBloc>().state.isUpdate ??
false)
const DeleteSceneWidget()
],
@ -373,14 +304,12 @@ class SettingHelper {
],
),
),
if (context.read<SettingBloc>().isExpanded &&
!isAutomation)
if (context.read<SettingBloc>().isExpanded && !isAutomation)
SizedBox(
width: 400,
height: 150,
child: settingState is LoadingState
? const Center(
child: CircularProgressIndicator())
? const Center(child: CircularProgressIndicator())
: GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
@ -397,8 +326,7 @@ class SettingHelper {
height: 35,
child: InkWell(
onTap: () {
BlocProvider.of<SettingBloc>(
context)
BlocProvider.of<SettingBloc>(context)
.add(SelectIcon(
iconId: iconModel.uuid,
));
@ -407,17 +335,13 @@ class SettingHelper {
child: SizedBox(
child: ClipOval(
child: Container(
padding:
const EdgeInsets.all(
1),
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
border: Border.all(
color: selectedIcon ==
iconModel.uuid
color: selectedIcon == iconModel.uuid
? ColorsManager
.primaryColorWithOpacity
: Colors
.transparent,
: Colors.transparent,
width: 2,
),
shape: BoxShape.circle,
@ -432,12 +356,8 @@ class SettingHelper {
);
},
)),
if (context.read<SettingBloc>().isExpanded &&
isAutomation)
const SizedBox(
height: 350,
width: 400,
child: EffectivePeriodView())
if (context.read<SettingBloc>().isExpanded && isAutomation)
const SizedBox(height: 350, width: 400, child: EffectivePeriodView())
],
),
Container(
@ -461,33 +381,23 @@ class SettingHelper {
alignment: AlignmentDirectional.center,
child: Text(
'Cancel',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.textGray,
),
),
),
),
),
Container(
width: 1,
height: 50,
color: ColorsManager.greyColor),
Container(width: 1, height: 50, color: ColorsManager.greyColor),
Expanded(
child: InkWell(
onTap: () {
if (isAutomation) {
BlocProvider.of<RoutineBloc>(context).add(
EffectiveTimePeriodEvent(
EffectiveTime(
start: effectPeriodState
.customStartTime!,
end: effectPeriodState
.customEndTime!,
loops: effectPeriodState
.selectedDaysBinary)));
EffectiveTimePeriodEvent(EffectiveTime(
start: effectPeriodState.customStartTime!,
end: effectPeriodState.customEndTime!,
loops: effectPeriodState.selectedDaysBinary)));
Navigator.of(context).pop();
} else {
Navigator.of(context).pop(selectedIcon);
@ -497,12 +407,8 @@ class SettingHelper {
alignment: AlignmentDirectional.center,
child: Text(
'Confirm',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
color: ColorsManager
.primaryColorWithOpacity,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
),
),
),

View File

@ -24,7 +24,8 @@ class ThreeGangSwitchHelper {
required String dialogType,
required bool removeComparetors,
}) async {
final switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
List<BaseSwitchFunction> switchFunctions =
functions.whereType<BaseSwitchFunction>().toList();
return showDialog<Map<String, dynamic>?>(
context: context,

View File

@ -25,7 +25,8 @@ class TwoGangSwitchHelper {
required bool removeComparetors,
required String dialogType,
}) async {
final switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
List<BaseSwitchFunction> switchFunctions =
functions.whereType<BaseSwitchFunction>().toList();
return showDialog<Map<String, dynamic>?>(
context: context,
@ -236,7 +237,7 @@ class TwoGangSwitchHelper {
DeviceFunctionData? selectedFunctionData,
// Function(String) onConditionChanged,
) {
final conditions = ['<', '==', '>'];
final conditions = ["<", "==", ">"];
return ToggleButtons(
onPressed: (int index) {
@ -263,8 +264,8 @@ class TwoGangSwitchHelper {
minWidth: 40.0,
),
isSelected:
conditions.map((c) => c == (currentCondition ?? '==')).toList(),
children: conditions.map(Text.new).toList(),
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
children: conditions.map((c) => Text(c)).toList(),
);
}
@ -279,7 +280,7 @@ class TwoGangSwitchHelper {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
color: ColorsManager.primaryColorWithOpacity.withValues(alpha: 0.1),
color: ColorsManager.primaryColorWithOpacity.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Text(

View File

@ -49,6 +49,8 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
}
}
@override
void dispose() {
_hoursController.dispose();
@ -101,7 +103,7 @@ class _TimeWheelPickerState extends State<TimeWheelPicker> {
}
void _handleTimeChange(int hours, int minutes, int seconds) {
var total = hours * 3600 + minutes * 60 + seconds;
int total = hours * 3600 + minutes * 60 + seconds;
if (total > 10000) {
hours = 2;
minutes = 46;

View File

@ -63,8 +63,7 @@ class _WallPresenceSensorState extends State<WallPresenceSensor> {
@override
void initState() {
super.initState();
_wpsFunctions =
widget.functions.whereType<WpsFunctions>().where((function) {
_wpsFunctions = widget.functions.whereType<WpsFunctions>().where((function) {
if (widget.dialogType == 'THEN') {
return function.type == 'THEN' || function.type == 'BOTH';
}

View File

@ -30,8 +30,7 @@ class WpsOperationalValuesList extends StatelessWidget {
: ListView.builder(
padding: const EdgeInsets.all(20),
itemCount: values.length,
itemBuilder: (context, index) =>
_buildValueItem(context, values[index]),
itemBuilder: (context, index) => _buildValueItem(context, values[index]),
);
}
@ -62,8 +61,7 @@ class WpsOperationalValuesList extends StatelessWidget {
Widget _buildValueIcon(context, WpsOperationalValue value) {
return Column(
children: [
if (_shouldShowTextDescription)
Text(value.description.replaceAll('cm', '')),
if (_shouldShowTextDescription) Text(value.description.replaceAll("cm", '')),
SvgPicture.asset(value.icon, width: 25, height: 25),
],
);

View File

@ -61,4 +61,5 @@ class WaterHeaterOperationalValuesList extends StatelessWidget {
groupValue: selectedValue,
onChanged: (_) => onSelect(value));
}
}

View File

@ -12,7 +12,7 @@ class WaterHeaterValueSelectorWidget extends StatelessWidget {
final DeviceFunctionData functionData;
final List<WaterHeaterFunctions> whFunctions;
final AllDevicesModel? device;
final String dialogType;
final String dialogType;
const WaterHeaterValueSelectorWidget({
required this.selectedFunction,
@ -39,13 +39,14 @@ class WaterHeaterValueSelectorWidget extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildCountDownSlider(
context,
functionData.value,
device,
selectedFn.operationName,
functionData,
selectedFunction,
dialogType),
context,
functionData.value,
device,
selectedFn.operationName,
functionData,
selectedFunction,
dialogType
),
const SizedBox(height: 10),
],
);

View File

@ -15,8 +15,7 @@ class RoutineSearchAndButtons extends StatefulWidget {
});
@override
State<RoutineSearchAndButtons> createState() =>
_RoutineSearchAndButtonsState();
State<RoutineSearchAndButtons> createState() => _RoutineSearchAndButtonsState();
}
class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
@ -62,9 +61,8 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constraints.maxWidth > 700
? 450
: constraints.maxWidth - 32),
maxWidth:
constraints.maxWidth > 700 ? 450 : constraints.maxWidth - 32),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@ -73,13 +71,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
children: [
Text('* ',
style: context.textTheme.bodyMedium!
.copyWith(
color: ColorsManager.red,
fontSize: 13)),
.copyWith(color: ColorsManager.red, fontSize: 13)),
Text(
'Routine Name',
style: context.textTheme.bodyMedium!
.copyWith(
style: context.textTheme.bodyMedium!.copyWith(
fontSize: 13,
fontWeight: FontWeight.w600,
color: ColorsManager.blackColor,
@ -93,23 +88,20 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
decoration: containerWhiteDecoration,
child: TextFormField(
style: context.textTheme.bodyMedium!
.copyWith(
color: ColorsManager.blackColor),
.copyWith(color: ColorsManager.blackColor),
controller: _nameController,
decoration: InputDecoration(
hintText: 'Please enter the name',
hintStyle: context.textTheme.bodyMedium!
.copyWith(
fontSize: 12,
color: ColorsManager.grayColor),
.copyWith(fontSize: 12, color: ColorsManager.grayColor),
contentPadding:
const EdgeInsets.symmetric(
horizontal: 12, vertical: 10),
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
border: InputBorder.none,
),
onTapOutside: (_) {
context.read<RoutineBloc>().add(
SetRoutineName(_nameController.text));
context
.read<RoutineBloc>()
.add(SetRoutineName(_nameController.text));
},
validator: (value) {
if (value == null || value.isEmpty) {
@ -122,44 +114,41 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
],
),
),
if (constraints.maxWidth <= 1000)
const SizedBox()
else
SizedBox(
height: 40,
width: 200,
child: Center(
child: DefaultButton(
onPressed: state.isAutomation ||
state.isTabToRun
? () async {
final result = await SettingHelper
.showSettingDialog(
context: context,
iconId: state.selectedIcon ?? '',
);
if (result != null) {
context
.read<RoutineBloc>()
.add(AddSelectedIcon(result));
}
}
: null,
borderRadius: 15,
elevation: 0,
borderColor: ColorsManager.greyColor,
backgroundColor: ColorsManager.boxColor,
child: const Text(
'Settings',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: ColorsManager.primaryColor,
(constraints.maxWidth <= 1000)
? const SizedBox()
: SizedBox(
height: 40,
width: 200,
child: Center(
child: DefaultButton(
onPressed: state.isAutomation || state.isTabToRun
? () async {
final result = await SettingHelper.showSettingDialog(
context: context,
iconId: state.selectedIcon ?? '',
);
if (result != null) {
context
.read<RoutineBloc>()
.add(AddSelectedIcon(result));
}
}
: null,
borderRadius: 15,
elevation: 0,
borderColor: ColorsManager.greyColor,
backgroundColor: ColorsManager.boxColor,
child: const Text(
'Settings',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
color: ColorsManager.primaryColor,
),
),
),
),
),
),
),
],
),
),
@ -197,12 +186,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
child: Center(
child: DefaultButton(
onPressed: () async {
if (state.routineName == null ||
state.routineName!.isEmpty) {
if (state.routineName == null || state.routineName!.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text(
'Please enter the routine name'),
content: const Text('Please enter the routine name'),
duration: const Duration(seconds: 2),
backgroundColor: ColorsManager.red,
action: SnackBarAction(
@ -216,12 +203,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
return;
}
if (state.ifItems.isEmpty ||
state.thenItems.isEmpty) {
if (state.ifItems.isEmpty || state.thenItems.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text(
'Please add if and then condition'),
content: const Text('Please add if and then condition'),
duration: const Duration(seconds: 2),
backgroundColor: ColorsManager.red,
action: SnackBarAction(
@ -236,10 +221,8 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
}
// final result =
// await
BlocProvider.of<RoutineBloc>(context)
.add(ResetErrorMessage());
SaveRoutineHelper.showSaveRoutineDialog(
context);
BlocProvider.of<RoutineBloc>(context).add(ResetErrorMessage());
SaveRoutineHelper.showSaveRoutineDialog(context);
// if (result != null && result) {
// BlocProvider.of<RoutineBloc>(context).add(
// const CreateNewRoutineViewEvent(createRoutineView: false),
@ -278,14 +261,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
child: DefaultButton(
onPressed: state.isAutomation || state.isTabToRun
? () async {
final result =
await SettingHelper.showSettingDialog(
context: context,
iconId: state.selectedIcon ?? '');
final result = await SettingHelper.showSettingDialog(
context: context, iconId: state.selectedIcon ?? '');
if (result != null) {
context
.read<RoutineBloc>()
.add(AddSelectedIcon(result));
context.read<RoutineBloc>().add(AddSelectedIcon(result));
}
}
: null,
@ -335,12 +314,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
child: Center(
child: DefaultButton(
onPressed: () async {
if (state.routineName == null ||
state.routineName!.isEmpty) {
if (state.routineName == null || state.routineName!.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text(
'Please enter the routine name'),
content: const Text('Please enter the routine name'),
duration: const Duration(seconds: 2),
backgroundColor: ColorsManager.red,
action: SnackBarAction(
@ -354,12 +331,10 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
return;
}
if (state.ifItems.isEmpty ||
state.thenItems.isEmpty) {
if (state.ifItems.isEmpty || state.thenItems.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text(
'Please add if and then condition'),
content: const Text('Please add if and then condition'),
duration: const Duration(seconds: 2),
backgroundColor: ColorsManager.red,
action: SnackBarAction(
@ -374,8 +349,7 @@ class _RoutineSearchAndButtonsState extends State<RoutineSearchAndButtons> {
}
// final result =
// await
BlocProvider.of<RoutineBloc>(context)
.add(ResetErrorMessage());
BlocProvider.of<RoutineBloc>(context).add(ResetErrorMessage());
SaveRoutineHelper.showSaveRoutineDialog(context);
// if (result != null && result) {
// BlocProvider.of<RoutineBloc>(context).add(

View File

@ -27,16 +27,14 @@ class _ScenesAndAutomationsState extends State<ScenesAndAutomations> {
return BlocBuilder<RoutineBloc, RoutineState>(
builder: (context, state) {
if (!state.isLoading) {
final scenes = [...state.scenes, ...state.automations];
var scenes = [...state.scenes, ...state.automations];
return Wrap(
spacing: 10,
runSpacing: 10,
children: scenes.asMap().entries.map((entry) {
final scene = entry.value;
if (state.searchText != null && state.searchText!.isNotEmpty) {
return scene.name
.toLowerCase()
.contains(state.searchText!.toLowerCase())
return scene.name.toLowerCase().contains(state.searchText!.toLowerCase())
? DraggableCard(
imagePath: scene.icon ?? Assets.loginLogo,
title: scene.name,

View File

@ -6,8 +6,7 @@ import 'package:syncrow_web/pages/routines/widgets/routines_title_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
class ConditionTitleAndSearchBar extends StatelessWidget
with HelperResponsiveLayout {
class ConditionTitleAndSearchBar extends StatelessWidget with HelperResponsiveLayout {
const ConditionTitleAndSearchBar({
super.key,
});

View File

@ -30,118 +30,123 @@ class ThenContainer extends StatelessWidget {
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold)),
const SizedBox(height: 16),
if (state.isLoading && state.isUpdate == true)
const Center(
child: CircularProgressIndicator(),
)
else
Wrap(
spacing: 8,
runSpacing: 8,
children: List.generate(
state.thenItems.length,
(index) => GestureDetector(
onTap: () async {
if (state.thenItems[index]['deviceId'] ==
'delay') {
final result = await DelayHelper
.showDelayPickerDialog(context,
state.thenItems[index]);
state.isLoading && state.isUpdate == true
? const Center(
child: CircularProgressIndicator(),
)
: Wrap(
spacing: 8,
runSpacing: 8,
children: List.generate(
state.thenItems.length,
(index) => GestureDetector(
onTap: () async {
if (state.thenItems[index]
['deviceId'] ==
'delay') {
final result = await DelayHelper
.showDelayPickerDialog(context,
state.thenItems[index]);
if (result != null) {
context
.read<RoutineBloc>()
.add(AddToThenContainer({
...state.thenItems[index],
'imagePath': Assets.delay,
'title': 'Delay',
}));
}
return;
}
if (state.thenItems[index]['type'] ==
'automation') {
final result = await showDialog<bool>(
context: context,
builder: (BuildContext context) =>
AutomationDialog(
automationName:
state.thenItems[index]
['name'] ??
'Automation',
automationId:
state.thenItems[index]
['deviceId'] ??
'',
uniqueCustomId:
state.thenItems[index]
['uniqueCustomId'],
),
);
if (result != null) {
context
.read<RoutineBloc>()
.add(AddToThenContainer({
...state.thenItems[index],
'imagePath':
Assets.automation,
'title':
state.thenItems[index]
['name'] ??
state.thenItems[index]
['title'],
}));
}
return;
}
final result = await DeviceDialogHelper
.showDeviceDialog(
context: context,
data: state.thenItems[index],
removeComparetors: true,
dialogType: "THEN");
if (result != null) {
context
.read<RoutineBloc>()
.add(AddToThenContainer({
...state.thenItems[index],
'imagePath': Assets.delay,
'title': 'Delay',
}));
context.read<RoutineBloc>().add(
AddToThenContainer(
state.thenItems[index]));
} else if (![
'AC',
'1G',
'2G',
'3G',
'WPS',
'CPS',
"GW",
"NCPS",
'WH',
].contains(state.thenItems[index]
['productType'])) {
context.read<RoutineBloc>().add(
AddToThenContainer(
state.thenItems[index]));
}
return;
}
if (state.thenItems[index]['type'] ==
'automation') {
final result = await showDialog<bool>(
context: context,
builder: (BuildContext context) =>
AutomationDialog(
automationName: state
.thenItems[index]['name'] ??
'Automation',
automationId: state.thenItems[index]
['deviceId'] ??
'',
uniqueCustomId:
state.thenItems[index]
['uniqueCustomId'],
),
);
if (result != null) {
context
.read<RoutineBloc>()
.add(AddToThenContainer({
...state.thenItems[index],
'imagePath': Assets.automation,
'title': state.thenItems[index]
['name'] ??
state.thenItems[index]
['title'],
}));
}
return;
}
final result = await DeviceDialogHelper
.showDeviceDialog(
context: context,
data: state.thenItems[index],
removeComparetors: true,
dialogType: 'THEN');
if (result != null) {
context.read<RoutineBloc>().add(
AddToThenContainer(
state.thenItems[index]));
} else if (![
'AC',
'1G',
'2G',
'3G',
'WPS',
'CPS',
'GW',
'NCPS',
'WH',
].contains(state.thenItems[index]
['productType'])) {
context.read<RoutineBloc>().add(
AddToThenContainer(
state.thenItems[index]));
}
},
child: DraggableCard(
imagePath: state.thenItems[index]
['imagePath'] ??
'',
title:
state.thenItems[index]['title'] ?? '',
deviceData: state.thenItems[index],
padding: const EdgeInsets.symmetric(
horizontal: 4, vertical: 8),
isFromThen: true,
isFromIf: false,
onRemove: () {
context.read<RoutineBloc>().add(
RemoveDragCard(
index: index,
isFromThen: true,
key: state.thenItems[index]
['uniqueCustomId']));
},
),
))),
child: DraggableCard(
imagePath: state.thenItems[index]
['imagePath'] ??
'',
title: state.thenItems[index]
['title'] ??
'',
deviceData: state.thenItems[index],
padding: const EdgeInsets.symmetric(
horizontal: 4, vertical: 8),
isFromThen: true,
isFromIf: false,
onRemove: () {
context.read<RoutineBloc>().add(
RemoveDragCard(
index: index,
isFromThen: true,
key: state.thenItems[index]
['uniqueCustomId']));
},
),
))),
],
),
),
@ -163,7 +168,7 @@ class ThenContainer extends StatelessWidget {
}
if (mutableData['type'] == 'automation') {
final index = state.thenItems.indexWhere(
int index = state.thenItems.indexWhere(
(item) => item['deviceId'] == mutableData['deviceId']);
if (index != -1) {
return;
@ -189,7 +194,7 @@ class ThenContainer extends StatelessWidget {
}
if (mutableData['type'] == 'tap_to_run' && state.isAutomation) {
final index = state.thenItems.indexWhere(
int index = state.thenItems.indexWhere(
(item) => item['deviceId'] == mutableData['deviceId']);
if (index != -1) {
return;
@ -225,7 +230,7 @@ class ThenContainer extends StatelessWidget {
context: context,
data: mutableData,
removeComparetors: true,
dialogType: 'THEN');
dialogType: "THEN");
if (result != null) {
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
} else if (![
@ -236,8 +241,8 @@ class ThenContainer extends StatelessWidget {
'WPS',
'GW',
'CPS',
'NCPS',
'WH',
"NCPS",
"WH",
'PC',
].contains(mutableData['productType'])) {
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));

View File

@ -19,7 +19,7 @@ class ValueDisplay extends StatelessWidget {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
color: ColorsManager.primaryColorWithOpacity.withValues(alpha: 0.1),
color: ColorsManager.primaryColorWithOpacity.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: Text(