mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
finished get scene details
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
@ -10,13 +11,15 @@ import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
part 'create_scene_event.dart';
|
||||
part 'create_scene_state.dart';
|
||||
|
||||
class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
||||
class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
with SceneOperationsDataHelper {
|
||||
CreateSceneBloc() : super(CreateSceneInitial()) {
|
||||
on<CreateSceneWithTasksEvent>(_createSceneWithTasks);
|
||||
on<AddTaskEvent>(_onAddSceneTask);
|
||||
on<SelectedValueEvent>(_selectedValue);
|
||||
on<RemoveTaskEvent>(_removeTaskById);
|
||||
on<ClearTaskListEvent>(_clearTaskList);
|
||||
on<FetchSceneTasks>(_fetchSceneTasks);
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> tasksList = [];
|
||||
@ -31,6 +34,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
||||
icon: event.icon,
|
||||
code: event.deviceControlModel.code ?? '',
|
||||
deviceId: event.deviceId,
|
||||
functionValue: event.deviceControlModel.value,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
value: event.deviceControlModel.value,
|
||||
@ -84,4 +88,22 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
||||
tasksList.clear();
|
||||
emit(AddSceneTask(tasksList: tasksList));
|
||||
}
|
||||
|
||||
FutureOr<void> _fetchSceneTasks(
|
||||
FetchSceneTasks event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
|
||||
try {
|
||||
final response = await SceneApi.getSceneDetails(event.sceneId);
|
||||
if (response.id.isNotEmpty) {
|
||||
tasksList = getTaskListFunctionsFromApi(
|
||||
actions: response.actions, deviceId: response.id);
|
||||
emit(AddSceneTask(tasksList: tasksList));
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(CreateSceneError(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,3 +59,11 @@ class ClearTaskListEvent extends CreateSceneEvent {
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class FetchSceneTasks extends CreateSceneEvent {
|
||||
final String sceneId;
|
||||
const FetchSceneTasks({required this.sceneId});
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ import 'dart:async';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
|
||||
part 'scene_state.dart';
|
||||
|
@ -12,7 +12,7 @@ class SceneInitial extends SceneState {}
|
||||
class SceneLoading extends SceneState {}
|
||||
|
||||
class SceneLoaded extends SceneState {
|
||||
final List<SceneModel> scenes;
|
||||
final List<ScenesModel> scenes;
|
||||
final String? loadingSceneId;
|
||||
|
||||
const SceneLoaded(this.scenes, {this.loadingSceneId});
|
||||
|
@ -3,6 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
94
lib/features/scene/model/scene_details_model.dart
Normal file
94
lib/features/scene/model/scene_details_model.dart
Normal file
@ -0,0 +1,94 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SceneDetailsModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String status;
|
||||
final String type;
|
||||
final List<Action> actions;
|
||||
|
||||
SceneDetailsModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.actions,
|
||||
});
|
||||
|
||||
factory SceneDetailsModel.fromRawJson(String str) =>
|
||||
SceneDetailsModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) =>
|
||||
SceneDetailsModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: json["status"],
|
||||
type: json["type"],
|
||||
actions:
|
||||
List<Action>.from(json["actions"].map((x) => Action.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"status": status,
|
||||
"type": type,
|
||||
"actions": List<dynamic>.from(actions.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class Action {
|
||||
final String actionExecutor;
|
||||
final String entityId;
|
||||
final ExecutorProperty executorProperty;
|
||||
|
||||
Action({
|
||||
required this.actionExecutor,
|
||||
required this.entityId,
|
||||
required this.executorProperty,
|
||||
});
|
||||
|
||||
factory Action.fromRawJson(String str) => Action.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Action.fromJson(Map<String, dynamic> json) => Action(
|
||||
actionExecutor: json["actionExecutor"],
|
||||
entityId: json["entityId"],
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"actionExecutor": actionExecutor,
|
||||
"entityId": entityId,
|
||||
"executorProperty": executorProperty.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class ExecutorProperty {
|
||||
final String functionCode;
|
||||
final dynamic functionValue;
|
||||
|
||||
ExecutorProperty({
|
||||
required this.functionCode,
|
||||
required this.functionValue,
|
||||
});
|
||||
|
||||
factory ExecutorProperty.fromRawJson(String str) =>
|
||||
ExecutorProperty.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory ExecutorProperty.fromJson(Map<String, dynamic> json) =>
|
||||
ExecutorProperty(
|
||||
functionCode: json["functionCode"],
|
||||
functionValue: json["functionValue"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"functionCode": functionCode,
|
||||
"functionValue": functionValue,
|
||||
};
|
||||
}
|
12
lib/features/scene/model/scene_settings_route_arguments.dart
Normal file
12
lib/features/scene/model/scene_settings_route_arguments.dart
Normal file
@ -0,0 +1,12 @@
|
||||
/// helper class for scene settings push route
|
||||
class SceneSettingsRouteArguments {
|
||||
final String sceneId;
|
||||
final String sceneName;
|
||||
final String sceneType;
|
||||
|
||||
SceneSettingsRouteArguments({
|
||||
required this.sceneId,
|
||||
required this.sceneName,
|
||||
required this.sceneType,
|
||||
});
|
||||
}
|
@ -11,6 +11,8 @@ class SceneStaticFunction {
|
||||
final String deviceId;
|
||||
final String operationName;
|
||||
final String uniqueCustomId;
|
||||
final dynamic functionValue;
|
||||
final String? deviceIcon;
|
||||
|
||||
SceneStaticFunction({
|
||||
required this.icon,
|
||||
@ -19,6 +21,8 @@ class SceneStaticFunction {
|
||||
required this.operationalValues,
|
||||
required this.deviceId,
|
||||
required this.operationName,
|
||||
required this.functionValue,
|
||||
this.deviceIcon,
|
||||
}) : uniqueCustomId = const Uuid().v4();
|
||||
|
||||
SceneStaticFunction copyWith({
|
||||
@ -28,6 +32,8 @@ class SceneStaticFunction {
|
||||
List<SceneOperationalValue>? operationalValues,
|
||||
String? deviceId,
|
||||
String? operationName,
|
||||
dynamic functionValue,
|
||||
String? deviceIcon,
|
||||
}) {
|
||||
return SceneStaticFunction(
|
||||
icon: icon ?? this.icon,
|
||||
@ -36,6 +42,8 @@ class SceneStaticFunction {
|
||||
operationalValues: operationalValues ?? this.operationalValues,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
operationName: operationName ?? this.operationName,
|
||||
functionValue: functionValue ?? this.functionValue,
|
||||
deviceIcon: deviceIcon ?? this.deviceIcon,
|
||||
);
|
||||
}
|
||||
|
||||
@ -46,7 +54,9 @@ class SceneStaticFunction {
|
||||
'code': code,
|
||||
'operationalValues': operationalValues.map((x) => x.toMap()).toList(),
|
||||
'deviceId': deviceId,
|
||||
'operationName': operationName
|
||||
'operationName': operationName,
|
||||
'functionValue': functionValue,
|
||||
'deviceIcon': deviceIcon
|
||||
};
|
||||
}
|
||||
|
||||
@ -60,6 +70,8 @@ class SceneStaticFunction {
|
||||
),
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
operationName: map['operationName'] ?? '',
|
||||
functionValue: map['functionValue'] ?? '',
|
||||
deviceIcon: map['deviceIcon'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@ -70,7 +82,7 @@ class SceneStaticFunction {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName)';
|
||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName, functionValue: $functionValue, deviceIcon: $deviceIcon)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -82,6 +94,8 @@ class SceneStaticFunction {
|
||||
other.deviceName == deviceName &&
|
||||
other.code == code &&
|
||||
other.operationName == operationName &&
|
||||
other.functionValue == functionValue &&
|
||||
other.deviceIcon == deviceIcon &&
|
||||
listEquals(other.operationalValues, operationalValues) &&
|
||||
other.deviceId == deviceId;
|
||||
}
|
||||
@ -93,6 +107,8 @@ class SceneStaticFunction {
|
||||
code.hashCode ^
|
||||
deviceId.hashCode ^
|
||||
operationName.hashCode ^
|
||||
functionValue.hashCode ^
|
||||
deviceIcon.hashCode ^
|
||||
operationalValues.hashCode;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SceneModel {
|
||||
class ScenesModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final Status status;
|
||||
final Type type;
|
||||
|
||||
SceneModel({
|
||||
ScenesModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
factory SceneModel.fromRawJson(String str) =>
|
||||
SceneModel.fromJson(json.decode(str));
|
||||
factory ScenesModel.fromRawJson(String str) =>
|
||||
ScenesModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory SceneModel.fromJson(Map<String, dynamic> json) => SceneModel(
|
||||
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: statusValues.map[json["status"]]!,
|
@ -2,6 +2,7 @@ import 'package:flutter/material.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/model/scene_settings_route_arguments.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';
|
||||
@ -40,9 +41,13 @@ class CreateSceneView extends StatelessWidget {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.sceneTasksRoute,
|
||||
arguments: CreateSceneEnum.tabToRun,
|
||||
arguments: SceneSettingsRouteArguments(
|
||||
sceneType: CreateSceneEnum.tabToRun.name,
|
||||
sceneId: '',
|
||||
sceneName: '',
|
||||
),
|
||||
);
|
||||
context.read<CreateSceneBloc>().add(ClearTaskListEvent());
|
||||
context.read<CreateSceneBloc>().add(const ClearTaskListEvent());
|
||||
},
|
||||
),
|
||||
DefaultContainer(
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
|
||||
@ -14,8 +15,12 @@ class SceneTasksView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
||||
as SceneSettingsRouteArguments;
|
||||
return DefaultScaffold(
|
||||
title: StringsManager.createScene,
|
||||
title: sceneSettings.sceneName.isNotEmpty
|
||||
? sceneSettings.sceneName
|
||||
: StringsManager.createScene,
|
||||
padding: EdgeInsets.zero,
|
||||
actions: [
|
||||
SizedBox(
|
||||
@ -33,21 +38,21 @@ class SceneTasksView extends StatelessWidget {
|
||||
],
|
||||
child: Stack(
|
||||
children: [
|
||||
const SingleChildScrollView(
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
// IF
|
||||
IFDefaultContainer(),
|
||||
SizedBox(
|
||||
const IFDefaultContainer(),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
// THEN
|
||||
ThenDefaultContainer(),
|
||||
SizedBox(
|
||||
ThenDefaultContainer(sceneId: sceneSettings.sceneId),
|
||||
const SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
|
@ -22,14 +22,16 @@ class ThenAddedTasksContainer extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
String operationValue = '';
|
||||
if (taskList.code.contains('countdown')) {
|
||||
final duration = Duration(
|
||||
seconds:
|
||||
int.tryParse(taskList.operationalValues.first.value.toString()) ??
|
||||
0);
|
||||
final functionValue =
|
||||
taskList.functionValue ?? taskList.operationalValues.first.value;
|
||||
final duration =
|
||||
Duration(seconds: int.tryParse(functionValue.toString()) ?? 0);
|
||||
operationValue =
|
||||
"${duration.inHours}h ${duration.inMinutes.remainder(60)}m ";
|
||||
} else {
|
||||
operationValue = taskList.operationalValues.first.value.toString();
|
||||
final functionValue =
|
||||
taskList.functionValue ?? taskList.operationalValues.first.value;
|
||||
operationValue = functionValue.toString();
|
||||
}
|
||||
return DefaultContainer(
|
||||
padding: EdgeInsets.zero,
|
||||
|
@ -15,8 +15,11 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
class ThenDefaultContainer extends StatelessWidget {
|
||||
const ThenDefaultContainer({
|
||||
super.key,
|
||||
required this.sceneId,
|
||||
});
|
||||
|
||||
final String sceneId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
@ -47,39 +50,64 @@ class ThenDefaultContainer extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
const LightDivider(),
|
||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is AddSceneTask) {
|
||||
final taskLists = state.tasksList;
|
||||
if (taskLists.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: taskLists.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ThenAddedTasksContainer(
|
||||
taskList: taskLists[index],
|
||||
);
|
||||
sceneId.isNotEmpty
|
||||
? BlocProvider(
|
||||
create: (context) =>
|
||||
CreateSceneBloc()..add(FetchSceneTasks(sceneId:sceneId)),
|
||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is AddSceneTask) {
|
||||
final taskLists = state.tasksList;
|
||||
if (taskLists.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: taskLists.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ThenAddedTasksContainer(
|
||||
taskList: taskLists[index],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return const SizedBox();
|
||||
}
|
||||
return const SizedBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
return SceneListTile(
|
||||
titleString: '+ Add Task',
|
||||
textAlign: TextAlign.center,
|
||||
onPressed: () => context.customBottomSheet(
|
||||
child: const CustomBottomSheetWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return SceneListTile(
|
||||
titleString: '+ Add Task',
|
||||
textAlign: TextAlign.center,
|
||||
onPressed: () => context.customBottomSheet(
|
||||
child: const CustomBottomSheetWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
))
|
||||
: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is AddSceneTask) {
|
||||
final taskLists = state.tasksList;
|
||||
if (taskLists.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: taskLists.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ThenAddedTasksContainer(
|
||||
taskList: taskLists[index],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return SceneListTile(
|
||||
titleString: '+ Add Task',
|
||||
textAlign: TextAlign.center,
|
||||
onPressed: () => context.customBottomSheet(
|
||||
child: const CustomBottomSheetWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return SceneListTile(
|
||||
titleString: '+ Add Task',
|
||||
textAlign: TextAlign.center,
|
||||
onPressed: () => context.customBottomSheet(
|
||||
child: const CustomBottomSheetWidget(),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_item.dart';
|
||||
|
||||
class SceneGrid extends StatelessWidget {
|
||||
final List<SceneModel> scenes;
|
||||
final List<ScenesModel> scenes;
|
||||
final String? loadingSceneId;
|
||||
|
||||
const SceneGrid({
|
||||
|
@ -2,15 +2,18 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SceneItem extends StatelessWidget {
|
||||
final SceneModel scene;
|
||||
final ScenesModel scene;
|
||||
final bool isLoading;
|
||||
|
||||
const SceneItem({
|
||||
@ -22,6 +25,17 @@ class SceneItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.sceneTasksRoute,
|
||||
arguments: SceneSettingsRouteArguments(
|
||||
sceneType: CreateSceneEnum.tabToRun.name,
|
||||
sceneId: scene.id,
|
||||
sceneName: scene.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
@ -23,15 +24,15 @@ class SceneApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<SceneModel>> getScenesByUnitId(String unitId) async {
|
||||
static Future<List<ScenesModel>> getScenesByUnitId(String unitId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUnitScenes.replaceAll('{unitUuid}', unitId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<SceneModel> scenes = [];
|
||||
List<ScenesModel> scenes = [];
|
||||
for (var scene in json) {
|
||||
scenes.add(SceneModel.fromJson(scene));
|
||||
scenes.add(ScenesModel.fromJson(scene));
|
||||
}
|
||||
return scenes;
|
||||
},
|
||||
@ -54,4 +55,23 @@ class SceneApi {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
//getScene
|
||||
|
||||
static Future<SceneDetailsModel> getSceneDetails(String sceneId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getScene.replaceAll('{sceneId}', sceneId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
//deleteScene
|
||||
|
||||
//updateScene
|
||||
}
|
||||
|
Reference in New Issue
Block a user