mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
85 lines
3.3 KiB
Dart
85 lines
3.3 KiB
Dart
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/bloc/smart_scene/smart_scene_select_dart_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/model/scenes_model.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';
|
|
|
|
class SceneListview extends StatelessWidget {
|
|
final List<ScenesModel> scenes;
|
|
final String? loadingSceneId;
|
|
const SceneListview({
|
|
required this.scenes,
|
|
required this.loadingSceneId,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView.builder(
|
|
shrinkWrap: true,
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: scenes.length,
|
|
itemBuilder: (context, index) {
|
|
final scene = scenes[index];
|
|
return Container(
|
|
padding: const EdgeInsets.only(right: 10),
|
|
child: DefaultContainer(
|
|
onTap: () {
|
|
Navigator.pushNamed(
|
|
context,
|
|
Routes.sceneTasksRoute,
|
|
arguments: SceneSettingsRouteArguments(
|
|
sceneType: CreateSceneEnum.tabToRun.name,
|
|
sceneId: scene.id,
|
|
sceneName: scene.name,
|
|
),
|
|
);
|
|
context.read<SmartSceneSelectBloc>().add(const SmartSceneClearEvent());
|
|
|
|
BlocProvider.of<CreateSceneBloc>(context)
|
|
.add(FetchSceneTasksEvent(sceneId: scene.id, isAutomation: false));
|
|
|
|
/// the state to set the scene type must be after the fetch
|
|
BlocProvider.of<CreateSceneBloc>(context)
|
|
.add(const SceneTypeEvent(CreateSceneEnum.tabToRun));
|
|
},
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * 0.4,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Image.memory(
|
|
height: 32,
|
|
width: 32,
|
|
scene.iconInBytes,
|
|
fit: BoxFit.fill,
|
|
errorBuilder: (context, error, stackTrace) => Image.asset(
|
|
height: 32, width: 32, fit: BoxFit.fill, Assets.assetsIconsLogo),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: BodyMedium(
|
|
text: scene.name,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
));
|
|
},
|
|
);
|
|
}
|
|
}
|