mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 01:35:23 +00:00
con setting
This commit is contained in:
@ -10,6 +10,7 @@ import 'package:syncrow_app/features/scene/enum/operation_dialog_type.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_automation_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/icon_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/navigation/navigation_service.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
@ -36,6 +37,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
on<SelectConditionEvent>(_selectConditionRule);
|
||||
on<SceneTypeEvent>(_sceneTypeEvent);
|
||||
on<EffectiveTimePeriodEvent>(_onEffectiveTimeEvent);
|
||||
on<SceneIconEvent>(_fetchIconScene);
|
||||
}
|
||||
|
||||
CreateSceneEnum sceneType = CreateSceneEnum.none;
|
||||
@ -53,7 +55,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
String conditionRule = 'or';
|
||||
EffectiveTime? effectiveTime;
|
||||
|
||||
FutureOr<void> _onAddSceneTask(AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _onAddSceneTask(
|
||||
AddTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
if (event.isAutomation == true) {
|
||||
final copyList = List<SceneStaticFunction>.from(automationTempTasksList);
|
||||
@ -88,7 +91,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
}
|
||||
|
||||
void addToTempTaskList(TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
||||
void addToTempTaskList(
|
||||
TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
bool updated = false;
|
||||
|
||||
@ -173,7 +177,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
}
|
||||
|
||||
void addToTempAutomationTaskList(TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
||||
void addToTempAutomationTaskList(
|
||||
TempHoldSceneTasksEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
bool updated = false;
|
||||
for (var element in automationTempTasksList) {
|
||||
@ -195,8 +200,10 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
],
|
||||
comparator: automationComparatorValues[element.code],
|
||||
);
|
||||
automationTempTasksList[automationTempTasksList.indexOf(element)] = updatedElement;
|
||||
automationSelectedValues[updatedElement.code] = event.deviceControlModel.value;
|
||||
automationTempTasksList[automationTempTasksList.indexOf(element)] =
|
||||
updatedElement;
|
||||
automationSelectedValues[updatedElement.code] =
|
||||
event.deviceControlModel.value;
|
||||
updated = true;
|
||||
break;
|
||||
}
|
||||
@ -216,10 +223,12 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
icon: '',
|
||||
),
|
||||
],
|
||||
comparator: automationComparatorValues[event.deviceControlModel.code] ?? '==',
|
||||
comparator:
|
||||
automationComparatorValues[event.deviceControlModel.code] ?? '==',
|
||||
);
|
||||
automationTempTasksList.add(newElement);
|
||||
automationSelectedValues[newElement.code] = event.deviceControlModel.value;
|
||||
automationSelectedValues[newElement.code] =
|
||||
event.deviceControlModel.value;
|
||||
}
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
@ -228,7 +237,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
}
|
||||
|
||||
FutureOr<void> _selectedValue(SelectedValueEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _selectedValue(
|
||||
SelectedValueEvent event, Emitter<CreateSceneState> emit) {
|
||||
if (event.isAutomation == true) {
|
||||
automationSelectedValues[event.code] = event.value;
|
||||
automationComparatorValues[event.code] = event.comparator ?? '==';
|
||||
@ -265,7 +275,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
}
|
||||
|
||||
FutureOr<void> _removeTaskById(RemoveTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _removeTaskById(
|
||||
RemoveTaskByIdEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
if (event.isAutomation == true) {
|
||||
for (var element in automationTasksList) {
|
||||
@ -338,7 +349,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
: await SceneApi.createScene(event.createSceneModel!);
|
||||
} else if (event.createAutomationModel != null) {
|
||||
response = event.updateScene
|
||||
? await SceneApi.updateAutomation(event.createAutomationModel!, event.sceneId)
|
||||
? await SceneApi.updateAutomation(
|
||||
event.createAutomationModel!, event.sceneId)
|
||||
: await SceneApi.createAutomation(event.createAutomationModel!);
|
||||
}
|
||||
|
||||
@ -350,12 +362,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
automationTempTasksList.clear();
|
||||
automationSelectedValues.clear();
|
||||
automationComparatorValues.clear();
|
||||
effectiveTime = EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
effectiveTime =
|
||||
EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
sceneType = CreateSceneEnum.none;
|
||||
conditionRule = 'or';
|
||||
emit(const CreateSceneWithTasks(success: true));
|
||||
CustomSnackBar.greenSnackBar(
|
||||
event.updateScene ? 'Scene updated successfully' : 'Scene created successfully');
|
||||
CustomSnackBar.greenSnackBar(event.updateScene
|
||||
? 'Scene updated successfully'
|
||||
: 'Scene created successfully');
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
@ -369,7 +383,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _clearTaskList(ClearTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _clearTaskList(
|
||||
ClearTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
automationTasksList.clear();
|
||||
tasksList.clear();
|
||||
@ -392,7 +407,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
automationTempTasksList.clear();
|
||||
automationSelectedValues.clear();
|
||||
automationComparatorValues.clear();
|
||||
effectiveTime = EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
effectiveTime =
|
||||
EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
sceneType = CreateSceneEnum.none;
|
||||
conditionRule = 'or';
|
||||
|
||||
@ -401,10 +417,14 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
: await SceneApi.getSceneDetails(event.sceneId);
|
||||
if (response.id.isNotEmpty) {
|
||||
if (event.isAutomation) {
|
||||
automationTasksList = List<SceneStaticFunction>.from(getTaskListFunctionsFromApi(
|
||||
actions: [], isAutomation: true, conditions: response.conditions));
|
||||
automationTasksList = List<SceneStaticFunction>.from(
|
||||
getTaskListFunctionsFromApi(
|
||||
actions: [],
|
||||
isAutomation: true,
|
||||
conditions: response.conditions));
|
||||
tasksList = List<SceneStaticFunction>.from(
|
||||
getTaskListFunctionsFromApi(actions: response.actions, isAutomation: false));
|
||||
getTaskListFunctionsFromApi(
|
||||
actions: response.actions, isAutomation: false));
|
||||
|
||||
conditionRule = response.decisionExpr ?? conditionRule;
|
||||
|
||||
@ -417,11 +437,13 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
: EffectiveTime(start: '00:00', end: '23:59', loops: '1111111');
|
||||
|
||||
// Set the days directly from the API response
|
||||
BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentContext!)
|
||||
BlocProvider.of<EffectPeriodBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(SetDays(response.effectiveTime?.loops ?? '1111111'));
|
||||
|
||||
// Set Custom Time and reset days first
|
||||
BlocProvider.of<EffectPeriodBloc>(NavigationService.navigatorKey.currentContext!)
|
||||
BlocProvider.of<EffectPeriodBloc>(
|
||||
NavigationService.navigatorKey.currentContext!)
|
||||
.add(SetCustomTime(effectiveTime!.start, effectiveTime!.end));
|
||||
|
||||
emit(AddSceneTask(
|
||||
@ -431,7 +453,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
} else {
|
||||
tasksList = List<SceneStaticFunction>.from(
|
||||
getTaskListFunctionsFromApi(actions: response.actions, isAutomation: false));
|
||||
getTaskListFunctionsFromApi(
|
||||
actions: response.actions, isAutomation: false));
|
||||
emit(AddSceneTask(
|
||||
tasksList: tasksList,
|
||||
condition: conditionRule,
|
||||
@ -445,12 +468,35 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
}
|
||||
|
||||
///scene/icon
|
||||
///
|
||||
List<IconModel> iconModel = [];
|
||||
|
||||
FutureOr<void> _fetchIconScene(
|
||||
SceneIconEvent event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
try {
|
||||
final response = await SceneApi.getIcon();
|
||||
|
||||
// Parse the response as a List of IconModel
|
||||
iconModel = (response as List<dynamic>)
|
||||
.map((iconJson) => IconModel.fromJson(iconJson as Map<String, dynamic>))
|
||||
.toList();
|
||||
|
||||
emit(CreateSceneLoaded(iconModel)); // Ensure this state is defined to handle the loaded list
|
||||
} catch (e) {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String _getDayFromIndex(int index) {
|
||||
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
|
||||
return days[index];
|
||||
}
|
||||
|
||||
FutureOr<void> _clearTempTaskList(ClearTempTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _clearTempTaskList(
|
||||
ClearTempTaskListEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
if (event.isAutomation == true) {
|
||||
automationTempTasksList.clear();
|
||||
@ -494,13 +540,17 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _deleteScene(DeleteSceneEvent event, Emitter<CreateSceneState> emit) async {
|
||||
FutureOr<void> _deleteScene(
|
||||
DeleteSceneEvent event, Emitter<CreateSceneState> emit) async {
|
||||
emit(DeleteSceneLoading());
|
||||
|
||||
try {
|
||||
final response = sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
||||
? await SceneApi.deleteAutomation(automationId: event.sceneId, unitUuid: event.unitUuid)
|
||||
: await SceneApi.deleteScene(sceneId: event.sceneId, unitUuid: event.unitUuid);
|
||||
final response =
|
||||
sceneType.name == CreateSceneEnum.deviceStatusChanges.name
|
||||
? await SceneApi.deleteAutomation(
|
||||
automationId: event.sceneId, unitUuid: event.unitUuid)
|
||||
: await SceneApi.deleteScene(
|
||||
sceneId: event.sceneId, unitUuid: event.unitUuid);
|
||||
if (response == true) {
|
||||
emit(const DeleteSceneSuccess(true));
|
||||
} else {
|
||||
@ -511,7 +561,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
}
|
||||
}
|
||||
|
||||
FutureOr<void> _updateTaskValue(UpdateTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _updateTaskValue(
|
||||
UpdateTaskEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneLoading());
|
||||
if (event.isAutomation == true) {
|
||||
for (var i = 0; i < automationTasksList.length; i++) {
|
||||
@ -547,7 +598,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
}
|
||||
|
||||
FutureOr<void> _selectConditionRule(SelectConditionEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _selectConditionRule(
|
||||
SelectConditionEvent event, Emitter<CreateSceneState> emit) {
|
||||
emit(CreateSceneInitial());
|
||||
if (event.condition.contains('any')) {
|
||||
conditionRule = 'or';
|
||||
@ -562,7 +614,8 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
));
|
||||
}
|
||||
|
||||
FutureOr<void> _sceneTypeEvent(SceneTypeEvent event, Emitter<CreateSceneState> emit) {
|
||||
FutureOr<void> _sceneTypeEvent(
|
||||
SceneTypeEvent event, Emitter<CreateSceneState> emit) {
|
||||
// emit(CreateSceneInitial());
|
||||
|
||||
if (event.type == CreateSceneEnum.tabToRun) {
|
||||
|
@ -183,3 +183,5 @@ class EffectiveTimePeriodEvent extends CreateSceneEvent {
|
||||
final EffectiveTime period;
|
||||
const EffectiveTimePeriodEvent(this.period);
|
||||
}
|
||||
|
||||
class SceneIconEvent extends CreateSceneEvent {}
|
||||
|
@ -84,3 +84,8 @@ class SceneTypeState extends CreateSceneState {
|
||||
final CreateSceneEnum type;
|
||||
const SceneTypeState(this.type);
|
||||
}
|
||||
|
||||
class CreateSceneLoaded extends CreateSceneState {
|
||||
final List<IconModel> iconModels;
|
||||
CreateSceneLoaded(this.iconModels);
|
||||
}
|
||||
|
39
lib/features/scene/model/icon_model.dart
Normal file
39
lib/features/scene/model/icon_model.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
class IconModel {
|
||||
final String uuid;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final String iconBase64;
|
||||
|
||||
IconModel({
|
||||
required this.uuid,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
required this.iconBase64,
|
||||
});
|
||||
|
||||
// Method to decode the icon from Base64 and return as Uint8List
|
||||
Uint8List get iconBytes => base64Decode(iconBase64);
|
||||
|
||||
// Factory constructor to create an instance from JSON
|
||||
factory IconModel.fromJson(Map<String, dynamic> json) {
|
||||
return IconModel(
|
||||
uuid: json['uuid'] as String,
|
||||
createdAt: DateTime.parse(json['createdAt'] as String),
|
||||
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||||
iconBase64: json['icon'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
// Method to convert an instance back to JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'uuid': uuid,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
'icon': iconBase64,
|
||||
};
|
||||
}
|
||||
}
|
@ -53,6 +53,7 @@ class SceneDetailsModel {
|
||||
"name": name,
|
||||
"status": status,
|
||||
"type": type,
|
||||
|
||||
"actions": List<dynamic>.from(actions.map((x) => x.toJson())),
|
||||
"conditions": conditions != null
|
||||
? List<dynamic>.from(conditions!.map((x) => x.toJson()))
|
||||
|
@ -1,13 +1,15 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/view/scene_tasks_view.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/effective_period_setting/effective_period_bottom_sheet.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SceneAutoSettings extends StatelessWidget {
|
||||
@ -33,60 +35,305 @@ class SceneAutoSettings extends StatelessWidget {
|
||||
icon: const Icon(
|
||||
Icons.arrow_back_ios,
|
||||
)),
|
||||
child: SizedBox(
|
||||
child: BlocProvider(
|
||||
create: (BuildContext context) =>
|
||||
CreateSceneBloc()..add(SceneIconEvent()),
|
||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: DefaultContainer(
|
||||
DefaultContainer(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 10, left: 10, right: 10, bottom: 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Visibility(
|
||||
visible: isAutomation,
|
||||
child: SceneListTile(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 8),
|
||||
titleString: "Effective Period",
|
||||
trailingWidget:
|
||||
const Icon(Icons.arrow_forward_ios_rounded),
|
||||
onPressed: () {
|
||||
context.customBottomSheet(
|
||||
child: const EffectPeriodBottomSheetContent(),
|
||||
);
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SecondDialog(
|
||||
WidgetList: BlocBuilder<CreateSceneBloc,
|
||||
CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is CreateSceneLoading) {
|
||||
return CircularProgressIndicator();
|
||||
} else if (state is CreateSceneLoaded) {
|
||||
return Container(
|
||||
height: 100,
|
||||
width: 100,
|
||||
child: ListView.builder(
|
||||
itemCount:
|
||||
state.iconModels.length,
|
||||
itemBuilder: (context, index) {
|
||||
final iconModel =
|
||||
state.iconModels[index];
|
||||
return Image.memory(
|
||||
iconModel.iconBytes);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else if (state is CreateSceneError) {
|
||||
return Text(state.message);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: sceneName.isNotEmpty && isAutomation,
|
||||
child: SizedBox(
|
||||
width: context.width * 0.9,
|
||||
child: const Divider(
|
||||
color: ColorsManager.greyColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: sceneName.isNotEmpty,
|
||||
child: DeleteBottomSheetContent(
|
||||
isAutomation: isAutomation,
|
||||
sceneId: sceneId,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: (v) {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
title: 'Icons',
|
||||
onTapLabel1: (selected) {},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(text: 'Icons'),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios_outlined,
|
||||
color: ColorsManager.textGray,
|
||||
size: 15,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
height: 5,
|
||||
),
|
||||
],
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyMedium(text: 'Show on devices page'),
|
||||
Container(
|
||||
width: 100,
|
||||
child: 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,
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
//Cloud
|
||||
BodyMedium(text: 'Executed by'),
|
||||
Text('Cloud',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
// child: DefaultContainer(
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: [
|
||||
// const SizedBox(
|
||||
// height: 8,
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: isAutomation,
|
||||
// child: SceneListTile(
|
||||
// padding: const EdgeInsets.symmetric(
|
||||
// horizontal: 16, vertical: 8),
|
||||
// titleString: "Effective Period",
|
||||
// trailingWidget:
|
||||
// const Icon(Icons.arrow_forward_ios_rounded),
|
||||
// onPressed: () {
|
||||
// context.customBottomSheet(
|
||||
// child: const EffectPeriodBottomSheetContent(),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: sceneName.isNotEmpty && isAutomation,
|
||||
// child: SizedBox(
|
||||
// width: context.width * 0.9,
|
||||
// child: const Divider(
|
||||
// color: ColorsManager.greyColor,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Visibility(
|
||||
// visible: sceneName.isNotEmpty,
|
||||
// child: DeleteBottomSheetContent(
|
||||
// isAutomation: isAutomation,
|
||||
// sceneId: sceneId,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(
|
||||
// height: 16,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
class SecondDialog extends StatefulWidget {
|
||||
final String title;
|
||||
Widget WidgetList;
|
||||
final Function(String)? onTapLabel1;
|
||||
final Function()? cancelTab;
|
||||
final Function(int selectedSecond)? confirmTab;
|
||||
|
||||
SecondDialog({
|
||||
required this.WidgetList,
|
||||
required this.title,
|
||||
this.onTapLabel1,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
});
|
||||
|
||||
@override
|
||||
_SecondDialogState createState() => _SecondDialogState();
|
||||
}
|
||||
|
||||
class _SecondDialogState extends State<SecondDialog> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyLarge(
|
||||
text: widget.title,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontColor: ColorsManager.primaryColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Divider(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
Expanded(child: widget.WidgetList),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: SizedBox(
|
||||
child: InkWell(
|
||||
onTap: widget.cancelTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ abstract class ApiEndpoints {
|
||||
static const String getUnitScenes = '/scene/tap-to-run/{unitUuid}';
|
||||
|
||||
static const String getScene = '/scene/tap-to-run/details/{sceneId}';
|
||||
static const String getIconScene = '/scene/icon';
|
||||
|
||||
static const String getUnitAutomation = '/automation/{unitUuid}';
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:syncrow_app/features/scene/model/create_automation_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
@ -147,6 +149,22 @@ class SceneApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future getIcon() async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getIconScene,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
log(json);
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
//update Scene
|
||||
static updateScene(CreateSceneModel createSceneModel, String sceneId) async {
|
||||
try {
|
||||
|
@ -5,7 +5,7 @@ description: This is the mobile application project, developed with Flutter for
|
||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||
publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
version: 1.0.5+31
|
||||
version: 1.0.5+33
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.6 <4.0.0"
|
||||
|
Reference in New Issue
Block a user