mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 02:09:39 +00:00
86 lines
2.9 KiB
Dart
86 lines
2.9 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/scene_bloc/scene_bloc.dart';
|
|
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.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 ScenesModel scene;
|
|
final bool isLoading;
|
|
|
|
const SceneItem({
|
|
required this.scene,
|
|
required this.isLoading,
|
|
super.key,
|
|
});
|
|
|
|
@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,
|
|
),
|
|
);
|
|
BlocProvider.of<CreateSceneBloc>(context).add(FetchSceneTasksEvent(sceneId: scene.id));
|
|
},
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Image.asset(
|
|
height: 32,
|
|
width: 32,
|
|
Assets.assetsIconsLogo,
|
|
fit: BoxFit.fill,
|
|
),
|
|
IconButton(
|
|
padding: EdgeInsets.zero,
|
|
onPressed: () {
|
|
context.read<SceneBloc>().add(SceneTrigger(scene.id, scene.name));
|
|
},
|
|
icon: isLoading
|
|
? const Center(
|
|
child: CircularProgressIndicator(),
|
|
)
|
|
: const Icon(
|
|
Icons.play_circle,
|
|
size: 40,
|
|
color: ColorsManager.greyColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
FittedBox(
|
|
child: BodyMedium(
|
|
text: scene.name,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.fade,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|