mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
bug fixes in setting and if contianer
This commit is contained in:
@ -2,10 +2,7 @@ import 'dart:async';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_event.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/navigation_service.dart';
|
|
||||||
|
|
||||||
class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
||||||
final daysMap = {
|
final daysMap = {
|
||||||
@ -52,10 +49,6 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlocProvider.of<RoutineBloc>(NavigationService.navigatorKey.currentContext!).add(
|
|
||||||
EffectiveTimePeriodEvent(
|
|
||||||
EffectiveTime(start: startTime, end: endTime, loops: state.selectedDaysBinary)));
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
selectedPeriod: event.period, customStartTime: startTime, customEndTime: endTime));
|
selectedPeriod: event.period, customStartTime: startTime, customEndTime: endTime));
|
||||||
}
|
}
|
||||||
@ -70,12 +63,6 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
|||||||
}
|
}
|
||||||
final newDaysBinary = daysList.join();
|
final newDaysBinary = daysList.join();
|
||||||
emit(state.copyWith(selectedDaysBinary: newDaysBinary));
|
emit(state.copyWith(selectedDaysBinary: newDaysBinary));
|
||||||
|
|
||||||
BlocProvider.of<RoutineBloc>(NavigationService.navigatorKey.currentContext!).add(
|
|
||||||
EffectiveTimePeriodEvent(EffectiveTime(
|
|
||||||
start: state.customStartTime ?? '00:00',
|
|
||||||
end: state.customEndTime ?? '23:59',
|
|
||||||
loops: newDaysBinary)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSetCustomTime(SetCustomTime event, Emitter<EffectPeriodState> emit) {
|
void _onSetCustomTime(SetCustomTime event, Emitter<EffectPeriodState> emit) {
|
||||||
@ -96,10 +83,6 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
|||||||
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(customStartTime: startTime, customEndTime: endTime, selectedPeriod: period));
|
state.copyWith(customStartTime: startTime, customEndTime: endTime, selectedPeriod: period));
|
||||||
|
|
||||||
BlocProvider.of<RoutineBloc>(NavigationService.navigatorKey.currentContext!).add(
|
|
||||||
EffectiveTimePeriodEvent(
|
|
||||||
EffectiveTime(start: startTime, end: endTime, loops: state.selectedDaysBinary)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onResetEffectivePeriod(ResetEffectivePeriod event, Emitter<EffectPeriodState> emit) {
|
void _onResetEffectivePeriod(ResetEffectivePeriod event, Emitter<EffectPeriodState> emit) {
|
||||||
@ -108,9 +91,6 @@ class EffectPeriodBloc extends Bloc<EffectPeriodEvent, EffectPeriodState> {
|
|||||||
customStartTime: '00:00',
|
customStartTime: '00:00',
|
||||||
customEndTime: '23:59',
|
customEndTime: '23:59',
|
||||||
selectedDaysBinary: '1111111'));
|
selectedDaysBinary: '1111111'));
|
||||||
|
|
||||||
BlocProvider.of<RoutineBloc>(NavigationService.navigatorKey.currentContext!).add(
|
|
||||||
EffectiveTimePeriodEvent(EffectiveTime(start: '00:00', end: '23:59', loops: '1111111')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onResetDays(ResetDays event, Emitter<EffectPeriodState> emit) {
|
void _onResetDays(ResetDays event, Emitter<EffectPeriodState> emit) {
|
||||||
|
@ -37,24 +37,31 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onAddToIfContainer(AddToIfContainer event, Emitter<RoutineState> emit) {
|
void _onAddToIfContainer(AddToIfContainer event, Emitter<RoutineState> emit) {
|
||||||
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems)
|
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems);
|
||||||
..add(event.item);
|
|
||||||
if (event.isTabToRun) {
|
// Find the index of the item in teh current itemsList
|
||||||
emit(state.copyWith(
|
int index =
|
||||||
ifItems: updatedIfItems, isTabToRun: true, isAutomation: false));
|
updatedIfItems.indexWhere((map) => map['uniqueCustomId'] == event.item['uniqueCustomId']);
|
||||||
|
// Replace the map if the index is valid
|
||||||
|
if (index != -1) {
|
||||||
|
updatedIfItems[index] = event.item;
|
||||||
} else {
|
} else {
|
||||||
emit(state.copyWith(
|
updatedIfItems.add(event.item);
|
||||||
ifItems: updatedIfItems, isTabToRun: false, isAutomation: true));
|
}
|
||||||
|
|
||||||
|
if (event.isTabToRun) {
|
||||||
|
emit(state.copyWith(ifItems: updatedIfItems, isTabToRun: true, isAutomation: false));
|
||||||
|
} else {
|
||||||
|
emit(state.copyWith(ifItems: updatedIfItems, isTabToRun: false, isAutomation: true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAddToThenContainer(
|
void _onAddToThenContainer(AddToThenContainer event, Emitter<RoutineState> emit) {
|
||||||
AddToThenContainer event, Emitter<RoutineState> emit) {
|
|
||||||
final currentItems = List<Map<String, dynamic>>.from(state.thenItems);
|
final currentItems = List<Map<String, dynamic>>.from(state.thenItems);
|
||||||
|
|
||||||
// Find the index of the item in teh current itemsList
|
// Find the index of the item in teh current itemsList
|
||||||
int index = currentItems.indexWhere(
|
int index =
|
||||||
(map) => map['uniqueCustomId'] == event.item['uniqueCustomId']);
|
currentItems.indexWhere((map) => map['uniqueCustomId'] == event.item['uniqueCustomId']);
|
||||||
// Replace the map if the index is valid
|
// Replace the map if the index is valid
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
currentItems[index] = event.item;
|
currentItems[index] = event.item;
|
||||||
@ -65,21 +72,38 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
emit(state.copyWith(thenItems: currentItems));
|
emit(state.copyWith(thenItems: currentItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAddFunctionsToRoutine(
|
void _onAddFunctionsToRoutine(AddFunctionToRoutine event, Emitter<RoutineState> emit) {
|
||||||
AddFunctionToRoutine event, Emitter<RoutineState> emit) {
|
|
||||||
try {
|
try {
|
||||||
if (event.functions.isEmpty) return;
|
if (event.functions.isEmpty) return;
|
||||||
|
|
||||||
final currentSelectedFunctions =
|
List<DeviceFunctionData> selectedFunction = List<DeviceFunctionData>.from(event.functions);
|
||||||
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
|
|
||||||
|
|
||||||
|
Map<String, List<DeviceFunctionData>> currentSelectedFunctions =
|
||||||
|
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
|
||||||
if (currentSelectedFunctions.containsKey(event.uniqueCustomId)) {
|
if (currentSelectedFunctions.containsKey(event.uniqueCustomId)) {
|
||||||
currentSelectedFunctions[event.uniqueCustomId] =
|
List<DeviceFunctionData> currentFunctions =
|
||||||
List.from(currentSelectedFunctions[event.uniqueCustomId]!)
|
List<DeviceFunctionData>.from(currentSelectedFunctions[event.uniqueCustomId] ?? []);
|
||||||
..addAll(event.functions);
|
|
||||||
|
List<String> functionCode = [];
|
||||||
|
for (int i = 0; i < selectedFunction.length; i++) {
|
||||||
|
for (int j = 0; j < currentFunctions.length; j++) {
|
||||||
|
if (selectedFunction[i].functionCode == currentFunctions[j].functionCode) {
|
||||||
|
currentFunctions[j] = selectedFunction[i];
|
||||||
|
if (!functionCode.contains(currentFunctions[j].functionCode)) {
|
||||||
|
functionCode.add(currentFunctions[j].functionCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < functionCode.length; i++) {
|
||||||
|
selectedFunction.removeWhere((code) => code.functionCode == functionCode[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSelectedFunctions[event.uniqueCustomId] = List.from(currentFunctions)
|
||||||
|
..addAll(selectedFunction);
|
||||||
} else {
|
} else {
|
||||||
currentSelectedFunctions[event.uniqueCustomId] =
|
currentSelectedFunctions[event.uniqueCustomId] = List.from(event.functions);
|
||||||
List.from(event.functions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit(state.copyWith(selectedFunctions: currentSelectedFunctions));
|
emit(state.copyWith(selectedFunctions: currentSelectedFunctions));
|
||||||
@ -88,8 +112,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadScenes(
|
Future<void> _onLoadScenes(LoadScenes event, Emitter<RoutineState> emit) async {
|
||||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
|
||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -108,8 +131,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onLoadAutomation(
|
Future<void> _onLoadAutomation(LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
|
||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -128,15 +150,13 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onSearchRoutines(
|
FutureOr<void> _onSearchRoutines(SearchRoutines event, Emitter<RoutineState> emit) async {
|
||||||
SearchRoutines event, Emitter<RoutineState> emit) async {
|
|
||||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
emit(state.copyWith(searchText: event.query));
|
emit(state.copyWith(searchText: event.query));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onAddSelectedIcon(
|
FutureOr<void> _onAddSelectedIcon(AddSelectedIcon event, Emitter<RoutineState> emit) {
|
||||||
AddSelectedIcon event, Emitter<RoutineState> emit) {
|
|
||||||
emit(state.copyWith(selectedIcon: event.icon));
|
emit(state.copyWith(selectedIcon: event.icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,8 +165,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
return actions.first['deviceId'] == 'delay';
|
return actions.first['deviceId'] == 'delay';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onCreateScene(
|
Future<void> _onCreateScene(CreateSceneEvent event, Emitter<RoutineState> emit) async {
|
||||||
CreateSceneEvent event, Emitter<RoutineState> emit) async {
|
|
||||||
try {
|
try {
|
||||||
// Check if first action is delay
|
// Check if first action is delay
|
||||||
if (_isFirstActionDelay(state.thenItems)) {
|
if (_isFirstActionDelay(state.thenItems)) {
|
||||||
@ -161,8 +180,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
|
|
||||||
final actions = state.thenItems
|
final actions = state.thenItems
|
||||||
.map((item) {
|
.map((item) {
|
||||||
final functions =
|
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
|
||||||
if (functions.isEmpty) return null;
|
if (functions.isEmpty) return null;
|
||||||
|
|
||||||
final function = functions.first;
|
final function = functions.first;
|
||||||
@ -217,8 +235,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onCreateAutomation(
|
Future<void> _onCreateAutomation(CreateAutomationEvent event, Emitter<RoutineState> emit) async {
|
||||||
CreateAutomationEvent event, Emitter<RoutineState> emit) async {
|
|
||||||
try {
|
try {
|
||||||
if (state.routineName == null || state.routineName!.isEmpty) {
|
if (state.routineName == null || state.routineName!.isEmpty) {
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
@ -231,8 +248,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
|
|
||||||
final conditions = state.ifItems
|
final conditions = state.ifItems
|
||||||
.map((item) {
|
.map((item) {
|
||||||
final functions =
|
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
|
||||||
if (functions.isEmpty) return null;
|
if (functions.isEmpty) return null;
|
||||||
|
|
||||||
final function = functions.first;
|
final function = functions.first;
|
||||||
@ -271,8 +287,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
conditions: conditions,
|
conditions: conditions,
|
||||||
actions: state.thenItems
|
actions: state.thenItems
|
||||||
.map((item) {
|
.map((item) {
|
||||||
final functions =
|
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
|
||||||
if (functions.isEmpty) return null;
|
if (functions.isEmpty) return null;
|
||||||
|
|
||||||
final function = functions.first;
|
final function = functions.first;
|
||||||
@ -327,16 +342,21 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onRemoveDragCard(
|
FutureOr<void> _onRemoveDragCard(RemoveDragCard event, Emitter<RoutineState> emit) {
|
||||||
RemoveDragCard event, Emitter<RoutineState> emit) {
|
|
||||||
if (event.isFromThen) {
|
if (event.isFromThen) {
|
||||||
final thenItems = List<Map<String, dynamic>>.from(state.thenItems);
|
final thenItems = List<Map<String, dynamic>>.from(state.thenItems);
|
||||||
|
final selectedFunctions = Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
|
||||||
|
|
||||||
thenItems.removeAt(event.index);
|
thenItems.removeAt(event.index);
|
||||||
emit(state.copyWith(thenItems: thenItems));
|
selectedFunctions.remove(event.key);
|
||||||
|
emit(state.copyWith(thenItems: thenItems, selectedFunctions: selectedFunctions));
|
||||||
} else {
|
} else {
|
||||||
final ifItems = List<Map<String, dynamic>>.from(state.ifItems);
|
final ifItems = List<Map<String, dynamic>>.from(state.ifItems);
|
||||||
|
final selectedFunctions = Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
|
||||||
|
|
||||||
ifItems.removeAt(event.index);
|
ifItems.removeAt(event.index);
|
||||||
emit(state.copyWith(ifItems: ifItems));
|
selectedFunctions.remove(event.key);
|
||||||
|
emit(state.copyWith(ifItems: ifItems, selectedFunctions: selectedFunctions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,13 +367,11 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onEffectiveTimeEvent(
|
FutureOr<void> _onEffectiveTimeEvent(EffectiveTimePeriodEvent event, Emitter<RoutineState> emit) {
|
||||||
EffectiveTimePeriodEvent event, Emitter<RoutineState> emit) {
|
|
||||||
emit(state.copyWith(effectiveTime: event.effectiveTime));
|
emit(state.copyWith(effectiveTime: event.effectiveTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _onSetRoutineName(
|
FutureOr<void> _onSetRoutineName(SetRoutineName event, Emitter<RoutineState> emit) {
|
||||||
SetRoutineName event, Emitter<RoutineState> emit) {
|
|
||||||
emit(state.copyWith(routineName: event.name));
|
emit(state.copyWith(routineName: event.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,10 @@ class CreateSceneEvent extends RoutineEvent {
|
|||||||
class RemoveDragCard extends RoutineEvent {
|
class RemoveDragCard extends RoutineEvent {
|
||||||
final int index;
|
final int index;
|
||||||
final bool isFromThen;
|
final bool isFromThen;
|
||||||
const RemoveDragCard({required this.index, required this.isFromThen});
|
final String key;
|
||||||
|
const RemoveDragCard({required this.index, required this.isFromThen, required this.key});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [index];
|
List<Object> get props => [index, isFromThen, key];
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChangeAutomationOperator extends RoutineEvent {
|
class ChangeAutomationOperator extends RoutineEvent {
|
||||||
@ -121,4 +122,5 @@ class SetRoutineName extends RoutineEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [name];
|
List<Object> get props => [name];
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClearFunctions extends RoutineEvent {}
|
class ClearFunctions extends RoutineEvent {}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/effictive_period_dialog.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/routine_dialogs/effictive_period_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/period_option.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/period_option.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/repeat_days.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/repeat_days.dart';
|
||||||
@ -11,39 +9,36 @@ class EffectivePeriodView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return Padding(
|
||||||
create: (_) => EffectPeriodBloc(),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Padding(
|
child: ListView(
|
||||||
padding: const EdgeInsets.all(16.0),
|
children: [
|
||||||
child: ListView(
|
Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
const Spacer(),
|
||||||
children: [
|
Expanded(
|
||||||
const Spacer(),
|
child: Text(
|
||||||
Expanded(
|
'Effective Period',
|
||||||
child: Text(
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
'Effective Period',
|
color: ColorsManager.textPrimaryColor,
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
fontWeight: FontWeight.w400,
|
||||||
color: ColorsManager.textPrimaryColor,
|
fontSize: 14),
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const Spacer(),
|
),
|
||||||
],
|
const Spacer(),
|
||||||
),
|
],
|
||||||
const Divider(
|
),
|
||||||
color: ColorsManager.backgroundColor,
|
const Divider(
|
||||||
),
|
color: ColorsManager.backgroundColor,
|
||||||
const PeriodOptions(
|
),
|
||||||
showCustomTimePicker: EffectPeriodHelper.showCustomTimePicker,
|
const PeriodOptions(
|
||||||
),
|
showCustomTimePicker: EffectPeriodHelper.showCustomTimePicker,
|
||||||
const SizedBox(height: 16),
|
),
|
||||||
const RepeatDays(),
|
const SizedBox(height: 16),
|
||||||
const SizedBox(height: 24),
|
const RepeatDays(),
|
||||||
],
|
const SizedBox(height: 24),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,7 @@ class IfContainer extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
const Text('IF',
|
const Text('IF', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
|
||||||
if (state.isAutomation)
|
if (state.isAutomation)
|
||||||
AutomationOperatorSelector(
|
AutomationOperatorSelector(
|
||||||
selectedOperator: state.selectedAutomationOperator),
|
selectedOperator: state.selectedAutomationOperator),
|
||||||
@ -52,20 +50,38 @@ class IfContainer extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: List.generate(
|
children: List.generate(
|
||||||
state.ifItems.length,
|
state.ifItems.length,
|
||||||
(index) => DraggableCard(
|
(index) => GestureDetector(
|
||||||
imagePath:
|
onTap: () async {
|
||||||
state.ifItems[index]['imagePath'] ?? '',
|
if (!state.isTabToRun) {
|
||||||
title: state.ifItems[index]['title'] ?? '',
|
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||||
deviceData: state.ifItems[index],
|
context, state.ifItems[index]);
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 4, vertical: 8),
|
if (result != null) {
|
||||||
isFromThen: false,
|
context
|
||||||
isFromIf: true,
|
.read<RoutineBloc>()
|
||||||
onRemove: () {
|
.add(AddToIfContainer(state.ifItems[index], false));
|
||||||
context.read<RoutineBloc>().add(
|
} else if (!['AC', '1G', '2G', '3G']
|
||||||
RemoveDragCard(
|
.contains(state.ifItems[index]['productType'])) {
|
||||||
index: index, isFromThen: false));
|
context
|
||||||
|
.read<RoutineBloc>()
|
||||||
|
.add(AddToIfContainer(state.ifItems[index], false));
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
child: DraggableCard(
|
||||||
|
imagePath: state.ifItems[index]['imagePath'] ?? '',
|
||||||
|
title: state.ifItems[index]['title'] ?? '',
|
||||||
|
deviceData: state.ifItems[index],
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||||
|
isFromThen: false,
|
||||||
|
isFromIf: true,
|
||||||
|
onRemove: () {
|
||||||
|
context.read<RoutineBloc>().add(RemoveDragCard(
|
||||||
|
index: index,
|
||||||
|
isFromThen: false,
|
||||||
|
key: state.ifItems[index]['uniqueCustomId']));
|
||||||
|
},
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -81,22 +97,14 @@ class IfContainer extends StatelessWidget {
|
|||||||
|
|
||||||
if (!state.isTabToRun) {
|
if (!state.isTabToRun) {
|
||||||
if (mutableData['deviceId'] == 'tab_to_run') {
|
if (mutableData['deviceId'] == 'tab_to_run') {
|
||||||
context
|
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, true));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(AddToIfContainer(mutableData, true));
|
|
||||||
} else {
|
} else {
|
||||||
final result = await DeviceDialogHelper.showDeviceDialog(
|
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData);
|
||||||
context, mutableData);
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context
|
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
||||||
.read<RoutineBloc>()
|
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {
|
||||||
.add(AddToIfContainer(mutableData, false));
|
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
||||||
} else if (!['AC', '1G', '2G', '3G']
|
|
||||||
.contains(mutableData['productType'])) {
|
|
||||||
context
|
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(AddToIfContainer(mutableData, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,15 +144,12 @@ class AutomationOperatorSelector extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Any condition is met',
|
'Any condition is met',
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
color: selectedOperator == 'or'
|
color:
|
||||||
? ColorsManager.whiteColors
|
selectedOperator == 'or' ? ColorsManager.whiteColors : ColorsManager.blackColor,
|
||||||
: ColorsManager.blackColor,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'or'));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(const ChangeAutomationOperator(operator: 'or'));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@ -170,9 +175,7 @@ class AutomationOperatorSelector extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'and'));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(const ChangeAutomationOperator(operator: 'and'));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -21,12 +21,9 @@ class PeriodOptions extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
_buildRadioOption(
|
_buildRadioOption(context, EnumEffectivePeriodOptions.allDay, '24 Hours'),
|
||||||
context, EnumEffectivePeriodOptions.allDay, '24 Hours'),
|
_buildRadioOption(context, EnumEffectivePeriodOptions.daytime, 'Sunrise to Sunset'),
|
||||||
_buildRadioOption(context, EnumEffectivePeriodOptions.daytime,
|
_buildRadioOption(context, EnumEffectivePeriodOptions.night, 'Sunset to Sunrise'),
|
||||||
'Sunrise to Sunset'),
|
|
||||||
_buildRadioOption(
|
|
||||||
context, EnumEffectivePeriodOptions.night, 'Sunset to Sunrise'),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
onTap: () => showCustomTimePicker(context),
|
onTap: () => showCustomTimePicker(context),
|
||||||
@ -37,8 +34,7 @@ class PeriodOptions extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
fontSize: 14),
|
fontSize: 14),
|
||||||
),
|
),
|
||||||
subtitle: state.customStartTime != null &&
|
subtitle: state.customStartTime != null && state.customEndTime != null
|
||||||
state.customEndTime != null
|
|
||||||
? Text(
|
? Text(
|
||||||
'${"${state.customStartTime}"} - ${"${state.customEndTime}"}',
|
'${"${state.customStartTime}"} - ${"${state.customEndTime}"}',
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
@ -83,9 +79,7 @@ class PeriodOptions extends StatelessWidget {
|
|||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
subtitle,
|
subtitle,
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
color: ColorsManager.textPrimaryColor,
|
color: ColorsManager.textPrimaryColor, fontWeight: FontWeight.w400, fontSize: 10),
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 10),
|
|
||||||
),
|
),
|
||||||
trailing: Radio<EnumEffectivePeriodOptions>(
|
trailing: Radio<EnumEffectivePeriodOptions>(
|
||||||
value: value,
|
value: value,
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/effective_period/effect_period_state.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_event.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_event.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_state.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/setting_bloc/setting_state.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/models/create_scene_and_autoamtion/create_automation_model.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/icon_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/icon_model.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/view/effective_period_view.dart';
|
import 'package:syncrow_web/pages/routiens/view/effective_period_view.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
@ -19,444 +22,392 @@ class SettingHelper {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
final isAutomation = context.read<RoutineBloc>().state.isAutomation;
|
final isAutomation = context.read<RoutineBloc>().state.isAutomation;
|
||||||
return BlocProvider(
|
return MultiBlocProvider(
|
||||||
create: (_) =>
|
providers: [
|
||||||
SettingBloc()..add(InitialEvent(selectedIcon: iconId ?? '')),
|
BlocProvider(
|
||||||
|
create: (_) => EffectPeriodBloc(),
|
||||||
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (_) => SettingBloc()..add(InitialEvent(selectedIcon: iconId ?? ''))),
|
||||||
|
],
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<SettingBloc, SettingState>(
|
content: BlocBuilder<EffectPeriodBloc, EffectPeriodState>(
|
||||||
builder: (context, state) {
|
builder: (context, effectPeriodState) {
|
||||||
String selectedIcon = '';
|
return BlocBuilder<SettingBloc, SettingState>(
|
||||||
List<IconModel> list = [];
|
builder: (context, settingState) {
|
||||||
if (state is TabToRunSettingLoaded) {
|
String selectedIcon = '';
|
||||||
selectedIcon = state.selectedIcon;
|
List<IconModel> list = [];
|
||||||
list = state.iconList;
|
if (settingState is TabToRunSettingLoaded) {
|
||||||
}
|
selectedIcon = settingState.selectedIcon;
|
||||||
return Container(
|
list = settingState.iconList;
|
||||||
width: context.read<SettingBloc>().isExpanded ? 800 : 400,
|
}
|
||||||
height: context.read<SettingBloc>().isExpanded && isAutomation
|
return Container(
|
||||||
? 500
|
width: context.read<SettingBloc>().isExpanded ? 800 : 400,
|
||||||
: 300,
|
height: context.read<SettingBloc>().isExpanded && isAutomation ? 500 : 300,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.only(top: 20),
|
padding: const EdgeInsets.only(top: 20),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const DialogHeader('Settings'),
|
const DialogHeader('Settings'),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 400,
|
|
||||||
child: isAutomation
|
|
||||||
? Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 10,
|
|
||||||
left: 10,
|
|
||||||
right: 10,
|
|
||||||
bottom: 10),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () {},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Validity',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager
|
|
||||||
.textPrimaryColor,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight
|
|
||||||
.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
const Icon(
|
|
||||||
Icons
|
|
||||||
.arrow_forward_ios_outlined,
|
|
||||||
color: ColorsManager
|
|
||||||
.textGray,
|
|
||||||
size: 15,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
const Divider(
|
|
||||||
color: ColorsManager.graysColor,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<SettingBloc>(
|
|
||||||
context)
|
|
||||||
.add(FetchIcons(
|
|
||||||
expanded: !context
|
|
||||||
.read<
|
|
||||||
SettingBloc>()
|
|
||||||
.isExpanded));
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Effective Period',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager
|
|
||||||
.textPrimaryColor,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight
|
|
||||||
.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
const Icon(
|
|
||||||
Icons
|
|
||||||
.arrow_forward_ios_outlined,
|
|
||||||
color: ColorsManager
|
|
||||||
.textGray,
|
|
||||||
size: 15,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
const Divider(
|
|
||||||
color: ColorsManager.graysColor,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Executed by',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager
|
|
||||||
.textPrimaryColor,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
Text('Cloud',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color:
|
|
||||||
ColorsManager
|
|
||||||
.textGray,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight
|
|
||||||
.w400,
|
|
||||||
fontSize: 14)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 10,
|
|
||||||
left: 10,
|
|
||||||
right: 10,
|
|
||||||
bottom: 10),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<SettingBloc>(
|
|
||||||
context)
|
|
||||||
.add(FetchIcons(
|
|
||||||
expanded: !context
|
|
||||||
.read<
|
|
||||||
SettingBloc>()
|
|
||||||
.isExpanded));
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Icons',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager
|
|
||||||
.textPrimaryColor,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight
|
|
||||||
.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
const Icon(
|
|
||||||
Icons
|
|
||||||
.arrow_forward_ios_outlined,
|
|
||||||
color: ColorsManager
|
|
||||||
.textGray,
|
|
||||||
size: 15,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
const Divider(
|
|
||||||
color: ColorsManager.graysColor,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Show on devices page',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager
|
|
||||||
.textPrimaryColor,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
height: 30,
|
|
||||||
width: 1,
|
|
||||||
color: ColorsManager
|
|
||||||
.graysColor,
|
|
||||||
),
|
|
||||||
Transform.scale(
|
|
||||||
scale: .8,
|
|
||||||
child: CupertinoSwitch(
|
|
||||||
value: true,
|
|
||||||
onChanged: (value) {},
|
|
||||||
applyTheme: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
const Divider(
|
|
||||||
color: ColorsManager.graysColor,
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment:
|
|
||||||
MainAxisAlignment
|
|
||||||
.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Executed by',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager
|
|
||||||
.textPrimaryColor,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.w400,
|
|
||||||
fontSize: 14),
|
|
||||||
),
|
|
||||||
Text('Cloud',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color:
|
|
||||||
ColorsManager
|
|
||||||
.textGray,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight
|
|
||||||
.w400,
|
|
||||||
fontSize: 14)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (context.read<SettingBloc>().isExpanded &&
|
|
||||||
!isAutomation)
|
|
||||||
SizedBox(
|
|
||||||
width: 400,
|
|
||||||
height: 150,
|
|
||||||
child: state is LoadingState
|
|
||||||
? const Center(
|
|
||||||
child: CircularProgressIndicator())
|
|
||||||
: GridView.builder(
|
|
||||||
gridDelegate:
|
|
||||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 6,
|
|
||||||
crossAxisSpacing: 12,
|
|
||||||
mainAxisSpacing: 12,
|
|
||||||
),
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: list.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final iconModel = list[index];
|
|
||||||
return SizedBox(
|
|
||||||
width: 35,
|
|
||||||
height: 35,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<SettingBloc>(
|
|
||||||
context)
|
|
||||||
.add(SelectIcon(
|
|
||||||
iconId: iconModel.uuid,
|
|
||||||
));
|
|
||||||
selectedIcon = iconModel.uuid;
|
|
||||||
},
|
|
||||||
child: SizedBox(
|
|
||||||
child: ClipOval(
|
|
||||||
child: Container(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.all(1),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: selectedIcon ==
|
|
||||||
iconModel.uuid
|
|
||||||
? ColorsManager
|
|
||||||
.primaryColorWithOpacity
|
|
||||||
: Colors
|
|
||||||
.transparent,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: Image.memory(
|
|
||||||
iconModel.iconBytes,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
if (context.read<SettingBloc>().isExpanded &&
|
|
||||||
isAutomation)
|
|
||||||
const SizedBox(
|
|
||||||
height: 350,
|
|
||||||
width: 400,
|
|
||||||
child: EffectivePeriodView())
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: MediaQuery.sizeOf(context).width,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(
|
|
||||||
color: ColorsManager.greyColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
SizedBox(
|
||||||
child: InkWell(
|
width: 400,
|
||||||
onTap: () {
|
child: isAutomation
|
||||||
Navigator.of(context).pop();
|
? Column(
|
||||||
},
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Container(
|
children: [
|
||||||
alignment: AlignmentDirectional.center,
|
Container(
|
||||||
child: Text(
|
padding: const EdgeInsets.only(
|
||||||
'Cancel',
|
top: 10, left: 10, right: 10, bottom: 10),
|
||||||
style: Theme.of(context)
|
child: Column(
|
||||||
.textTheme
|
children: [
|
||||||
.bodyMedium!
|
InkWell(
|
||||||
.copyWith(
|
onTap: () {},
|
||||||
color: ColorsManager.textGray,
|
child: Row(
|
||||||
),
|
mainAxisAlignment:
|
||||||
),
|
MainAxisAlignment.spaceBetween,
|
||||||
),
|
children: [
|
||||||
),
|
Text(
|
||||||
),
|
'Validity',
|
||||||
Container(
|
style: Theme.of(context)
|
||||||
width: 1,
|
.textTheme
|
||||||
height: 50,
|
.bodyMedium!
|
||||||
color: ColorsManager.greyColor),
|
.copyWith(
|
||||||
Expanded(
|
color:
|
||||||
child: InkWell(
|
ColorsManager.textPrimaryColor,
|
||||||
onTap: () {
|
fontWeight: FontWeight.w400,
|
||||||
Navigator.of(context).pop(selectedIcon);
|
fontSize: 14),
|
||||||
},
|
),
|
||||||
child: Container(
|
const Icon(
|
||||||
alignment: AlignmentDirectional.center,
|
Icons.arrow_forward_ios_outlined,
|
||||||
child: Text(
|
color: ColorsManager.textGray,
|
||||||
'Confirm',
|
size: 15,
|
||||||
style: Theme.of(context)
|
)
|
||||||
.textTheme
|
],
|
||||||
.bodyMedium!
|
),
|
||||||
.copyWith(
|
),
|
||||||
color: ColorsManager
|
const SizedBox(
|
||||||
.primaryColorWithOpacity,
|
height: 5,
|
||||||
),
|
),
|
||||||
),
|
const Divider(
|
||||||
),
|
color: ColorsManager.graysColor,
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<SettingBloc>(context).add(
|
||||||
|
FetchIcons(
|
||||||
|
expanded: !context
|
||||||
|
.read<SettingBloc>()
|
||||||
|
.isExpanded));
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Effective Period',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color:
|
||||||
|
ColorsManager.textPrimaryColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14),
|
||||||
|
),
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_forward_ios_outlined,
|
||||||
|
color: ColorsManager.textGray,
|
||||||
|
size: 15,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
color: ColorsManager.graysColor,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Executed by',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color: ColorsManager.textPrimaryColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14),
|
||||||
|
),
|
||||||
|
Text('Cloud',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color: ColorsManager.textGray,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 10, left: 10, right: 10, bottom: 10),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<SettingBloc>(context).add(
|
||||||
|
FetchIcons(
|
||||||
|
expanded: !context
|
||||||
|
.read<SettingBloc>()
|
||||||
|
.isExpanded));
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Icons',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color:
|
||||||
|
ColorsManager.textPrimaryColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14),
|
||||||
|
),
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_forward_ios_outlined,
|
||||||
|
color: ColorsManager.textGray,
|
||||||
|
size: 15,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
color: ColorsManager.graysColor,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Show on devices page',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color: ColorsManager.textPrimaryColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: 30,
|
||||||
|
width: 1,
|
||||||
|
color: ColorsManager.graysColor,
|
||||||
|
),
|
||||||
|
Transform.scale(
|
||||||
|
scale: .8,
|
||||||
|
child: CupertinoSwitch(
|
||||||
|
value: true,
|
||||||
|
onChanged: (value) {},
|
||||||
|
applyTheme: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
color: ColorsManager.graysColor,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Executed by',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color: ColorsManager.textPrimaryColor,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14),
|
||||||
|
),
|
||||||
|
Text('Cloud',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium!
|
||||||
|
.copyWith(
|
||||||
|
color: ColorsManager.textGray,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 14)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
if (context.read<SettingBloc>().isExpanded && !isAutomation)
|
||||||
|
SizedBox(
|
||||||
|
width: 400,
|
||||||
|
height: 150,
|
||||||
|
child: settingState is LoadingState
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: GridView.builder(
|
||||||
|
gridDelegate:
|
||||||
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 6,
|
||||||
|
crossAxisSpacing: 12,
|
||||||
|
mainAxisSpacing: 12,
|
||||||
|
),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: list.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final iconModel = list[index];
|
||||||
|
return SizedBox(
|
||||||
|
width: 35,
|
||||||
|
height: 35,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<SettingBloc>(context)
|
||||||
|
.add(SelectIcon(
|
||||||
|
iconId: iconModel.uuid,
|
||||||
|
));
|
||||||
|
selectedIcon = iconModel.uuid;
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
child: ClipOval(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(1),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: selectedIcon == iconModel.uuid
|
||||||
|
? ColorsManager
|
||||||
|
.primaryColorWithOpacity
|
||||||
|
: Colors.transparent,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Image.memory(
|
||||||
|
iconModel.iconBytes,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
if (context.read<SettingBloc>().isExpanded && isAutomation)
|
||||||
|
const SizedBox(height: 350, width: 400, child: EffectivePeriodView())
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
Container(
|
||||||
],
|
width: MediaQuery.sizeOf(context).width,
|
||||||
),
|
decoration: const BoxDecoration(
|
||||||
);
|
border: Border(
|
||||||
},
|
top: BorderSide(
|
||||||
),
|
color: ColorsManager.greyColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
alignment: AlignmentDirectional.center,
|
||||||
|
child: Text(
|
||||||
|
'Cancel',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
|
color: ColorsManager.textGray,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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)));
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop(selectedIcon);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
alignment: AlignmentDirectional.center,
|
||||||
|
child: Text(
|
||||||
|
'Confirm',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -15,203 +15,203 @@ class RoutineSearchAndButtons extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(
|
return BlocBuilder<RoutineBloc, RoutineState>(builder: (context, state) {
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
return LayoutBuilder(
|
||||||
return Wrap(
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
runSpacing: 16,
|
return Wrap(
|
||||||
children: [
|
runSpacing: 16,
|
||||||
Row(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
Row(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
Expanded(
|
children: [
|
||||||
child: Wrap(
|
Expanded(
|
||||||
spacing: 12,
|
child: Wrap(
|
||||||
runSpacing: 12,
|
spacing: 12,
|
||||||
crossAxisAlignment: WrapCrossAlignment.end,
|
runSpacing: 12,
|
||||||
children: [
|
crossAxisAlignment: WrapCrossAlignment.end,
|
||||||
ConstrainedBox(
|
children: [
|
||||||
constraints: BoxConstraints(
|
ConstrainedBox(
|
||||||
maxWidth: constraints.maxWidth > 700
|
constraints: BoxConstraints(
|
||||||
? 450
|
maxWidth:
|
||||||
: constraints.maxWidth - 32),
|
constraints.maxWidth > 700 ? 450 : constraints.maxWidth - 32),
|
||||||
child: StatefulTextField(
|
child: StatefulTextField(
|
||||||
title: 'Routine Name',
|
title: 'Routine Name',
|
||||||
height: 40,
|
height: 40,
|
||||||
controller: TextEditingController(),
|
controller: TextEditingController(),
|
||||||
hintText: 'Please enter the name',
|
hintText: 'Please enter the name',
|
||||||
boxDecoration: containerWhiteDecoration,
|
boxDecoration: containerWhiteDecoration,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
width: 450,
|
width: 450,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
context
|
context.read<RoutineBloc>().add(SetRoutineName(value));
|
||||||
.read<RoutineBloc>()
|
},
|
||||||
.add(SetRoutineName(value));
|
),
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
(constraints.maxWidth <= 1000)
|
||||||
(constraints.maxWidth <= 1000)
|
? const SizedBox()
|
||||||
? const SizedBox()
|
: SizedBox(
|
||||||
: SizedBox(
|
height: 40,
|
||||||
height: 40,
|
width: 200,
|
||||||
width: 200,
|
child: Center(
|
||||||
child: Center(
|
child: DefaultButton(
|
||||||
child: DefaultButton(
|
onPressed: state.isAutomation || state.isTabToRun
|
||||||
onPressed: () async {
|
? () async {
|
||||||
final result =
|
final result = await SettingHelper.showSettingDialog(
|
||||||
await SettingHelper.showSettingDialog(
|
context: context,
|
||||||
context: context,
|
);
|
||||||
);
|
if (result != null) {
|
||||||
if (result != null) {
|
context
|
||||||
context
|
.read<RoutineBloc>()
|
||||||
.read<RoutineBloc>()
|
.add(AddSelectedIcon(result));
|
||||||
.add(AddSelectedIcon(result));
|
}
|
||||||
}
|
}
|
||||||
},
|
: null,
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
borderColor: ColorsManager.greyColor,
|
borderColor: ColorsManager.greyColor,
|
||||||
backgroundColor: ColorsManager.boxColor,
|
backgroundColor: ColorsManager.boxColor,
|
||||||
child: const Text(
|
child: const Text(
|
||||||
'Settings',
|
'Settings',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: ColorsManager.primaryColor,
|
color: ColorsManager.primaryColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
if (constraints.maxWidth > 1000)
|
||||||
if (constraints.maxWidth > 1000)
|
Row(
|
||||||
Row(
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
children: [
|
SizedBox(
|
||||||
SizedBox(
|
height: 40,
|
||||||
height: 40,
|
width: 200,
|
||||||
width: 200,
|
child: Center(
|
||||||
child: Center(
|
child: DefaultButton(
|
||||||
child: DefaultButton(
|
onPressed: () {},
|
||||||
onPressed: () {},
|
borderRadius: 15,
|
||||||
borderRadius: 15,
|
elevation: 0,
|
||||||
elevation: 0,
|
borderColor: ColorsManager.greyColor,
|
||||||
borderColor: ColorsManager.greyColor,
|
backgroundColor: ColorsManager.boxColor,
|
||||||
backgroundColor: ColorsManager.boxColor,
|
child: const Text(
|
||||||
child: const Text(
|
'Cancel',
|
||||||
'Cancel',
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontSize: 12,
|
||||||
fontSize: 12,
|
color: ColorsManager.blackColor,
|
||||||
color: ColorsManager.blackColor,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 12),
|
||||||
const SizedBox(width: 12),
|
SizedBox(
|
||||||
SizedBox(
|
height: 40,
|
||||||
height: 40,
|
width: 200,
|
||||||
width: 200,
|
child: Center(
|
||||||
child: Center(
|
child: DefaultButton(
|
||||||
child: DefaultButton(
|
onPressed: () {
|
||||||
onPressed: () {
|
SaveRoutineHelper.showSaveRoutineDialog(context);
|
||||||
SaveRoutineHelper.showSaveRoutineDialog(context);
|
},
|
||||||
},
|
borderRadius: 15,
|
||||||
borderRadius: 15,
|
elevation: 0,
|
||||||
elevation: 0,
|
backgroundColor: ColorsManager.primaryColor,
|
||||||
backgroundColor: ColorsManager.primaryColor,
|
child: const Text(
|
||||||
child: const Text(
|
'Save',
|
||||||
'Save',
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontSize: 12,
|
||||||
fontSize: 12,
|
color: ColorsManager.whiteColors,
|
||||||
color: ColorsManager.whiteColors,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (constraints.maxWidth <= 1000)
|
|
||||||
Wrap(
|
|
||||||
runSpacing: 12,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 40,
|
|
||||||
width: 200,
|
|
||||||
child: Center(
|
|
||||||
child: DefaultButton(
|
|
||||||
onPressed: () {},
|
|
||||||
borderRadius: 15,
|
|
||||||
elevation: 0,
|
|
||||||
borderColor: ColorsManager.greyColor,
|
|
||||||
backgroundColor: ColorsManager.boxColor,
|
|
||||||
child: const Text(
|
|
||||||
'Settings',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
SizedBox(
|
|
||||||
height: 40,
|
|
||||||
width: 200,
|
|
||||||
child: Center(
|
|
||||||
child: DefaultButton(
|
|
||||||
onPressed: () {},
|
|
||||||
borderRadius: 15,
|
|
||||||
elevation: 0,
|
|
||||||
borderColor: ColorsManager.greyColor,
|
|
||||||
backgroundColor: ColorsManager.boxColor,
|
|
||||||
child: const Text(
|
|
||||||
'Cancel',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
SizedBox(
|
|
||||||
height: 40,
|
|
||||||
width: 200,
|
|
||||||
child: Center(
|
|
||||||
child: DefaultButton(
|
|
||||||
onPressed: () {},
|
|
||||||
borderRadius: 15,
|
|
||||||
elevation: 0,
|
|
||||||
backgroundColor: ColorsManager.primaryColor,
|
|
||||||
child: const Text(
|
|
||||||
'Save',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.whiteColors,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
if (constraints.maxWidth <= 1000)
|
||||||
);
|
Wrap(
|
||||||
},
|
runSpacing: 12,
|
||||||
);
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 40,
|
||||||
|
width: 200,
|
||||||
|
child: Center(
|
||||||
|
child: DefaultButton(
|
||||||
|
onPressed: () {},
|
||||||
|
borderRadius: 15,
|
||||||
|
elevation: 0,
|
||||||
|
borderColor: ColorsManager.greyColor,
|
||||||
|
backgroundColor: ColorsManager.boxColor,
|
||||||
|
child: const Text(
|
||||||
|
'Settings',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
SizedBox(
|
||||||
|
height: 40,
|
||||||
|
width: 200,
|
||||||
|
child: Center(
|
||||||
|
child: DefaultButton(
|
||||||
|
onPressed: () {},
|
||||||
|
borderRadius: 15,
|
||||||
|
elevation: 0,
|
||||||
|
borderColor: ColorsManager.greyColor,
|
||||||
|
backgroundColor: ColorsManager.boxColor,
|
||||||
|
child: const Text(
|
||||||
|
'Cancel',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
SizedBox(
|
||||||
|
height: 40,
|
||||||
|
width: 200,
|
||||||
|
child: Center(
|
||||||
|
child: DefaultButton(
|
||||||
|
onPressed: () {},
|
||||||
|
borderRadius: 15,
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: ColorsManager.primaryColor,
|
||||||
|
child: const Text(
|
||||||
|
'Save',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text('THEN',
|
const Text('THEN', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.bold)),
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Wrap(
|
Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
@ -37,16 +35,12 @@ class ThenContainer extends StatelessWidget {
|
|||||||
state.thenItems.length,
|
state.thenItems.length,
|
||||||
(index) => GestureDetector(
|
(index) => GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (state.thenItems[index]['deviceId'] ==
|
if (state.thenItems[index]['deviceId'] == 'delay') {
|
||||||
'delay') {
|
final result = await DelayHelper.showDelayPickerDialog(
|
||||||
final result = await DelayHelper
|
context, state.thenItems[index]);
|
||||||
.showDelayPickerDialog(
|
|
||||||
context, state.thenItems[index]);
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context
|
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(AddToThenContainer({
|
|
||||||
...state.thenItems[index],
|
...state.thenItems[index],
|
||||||
'imagePath': Assets.delay,
|
'imagePath': Assets.delay,
|
||||||
'title': 'Delay',
|
'title': 'Delay',
|
||||||
@ -55,37 +49,32 @@ class ThenContainer extends StatelessWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final result = await DeviceDialogHelper
|
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||||
.showDeviceDialog(
|
context, state.thenItems[index]);
|
||||||
context, state.thenItems[index]);
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(
|
context
|
||||||
AddToThenContainer(
|
.read<RoutineBloc>()
|
||||||
state.thenItems[index]));
|
.add(AddToThenContainer(state.thenItems[index]));
|
||||||
} else if (!['AC', '1G', '2G', '3G']
|
} else if (!['AC', '1G', '2G', '3G']
|
||||||
.contains(state.thenItems[index]
|
.contains(state.thenItems[index]['productType'])) {
|
||||||
['productType'])) {
|
context
|
||||||
context.read<RoutineBloc>().add(
|
.read<RoutineBloc>()
|
||||||
AddToThenContainer(
|
.add(AddToThenContainer(state.thenItems[index]));
|
||||||
state.thenItems[index]));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: DraggableCard(
|
child: DraggableCard(
|
||||||
imagePath: state.thenItems[index]
|
imagePath: state.thenItems[index]['imagePath'] ?? '',
|
||||||
['imagePath'] ??
|
title: state.thenItems[index]['title'] ?? '',
|
||||||
'',
|
|
||||||
title:
|
|
||||||
state.thenItems[index]['title'] ?? '',
|
|
||||||
deviceData: state.thenItems[index],
|
deviceData: state.thenItems[index],
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||||
horizontal: 4, vertical: 8),
|
|
||||||
isFromThen: true,
|
isFromThen: true,
|
||||||
isFromIf: false,
|
isFromIf: false,
|
||||||
onRemove: () {
|
onRemove: () {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(RemoveDragCard(
|
||||||
RemoveDragCard(
|
index: index,
|
||||||
index: index, isFromThen: true));
|
isFromThen: true,
|
||||||
|
key: state.thenItems[index]['uniqueCustomId']));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
))),
|
))),
|
||||||
@ -140,8 +129,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mutableData['deviceId'] == 'delay') {
|
if (mutableData['deviceId'] == 'delay') {
|
||||||
final result =
|
final result = await DelayHelper.showDelayPickerDialog(context, mutableData);
|
||||||
await DelayHelper.showDelayPickerDialog(context, mutableData);
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer({
|
context.read<RoutineBloc>().add(AddToThenContainer({
|
||||||
@ -153,13 +141,11 @@ class ThenContainer extends StatelessWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final result =
|
final result = await DeviceDialogHelper.showDeviceDialog(context, mutableData);
|
||||||
await DeviceDialogHelper.showDeviceDialog(context, mutableData);
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
} else if (!['AC', '1G', '2G', '3G']
|
} else if (!['AC', '1G', '2G', '3G'].contains(mutableData['productType'])) {
|
||||||
.contains(mutableData['productType'])) {
|
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user