Files
syncrow-app/lib/features/devices/view/widgets/scene_listview.dart
mohammad de024994c9 showSpaceBottomSheet in a DefaultAppBar and Routine trigger from the device screen
and fixes github comments
and i used this package flutter_html: ^3.0.0-beta.2
2025-01-20 15:50:36 +03:00

99 lines
3.8 KiB
Dart

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/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';
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: () {
context
.read<SceneBloc>()
.add(SceneTrigger(scene.id, scene.name));
// 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: scene.iconInBytes.isNotEmpty
? Image.memory(
scene.iconInBytes,
height: 32,
width: 32,
fit: BoxFit.fill,
errorBuilder: (context, error, stackTrace) =>
Image.asset(
Assets.assetsIconsLogo,
height: 32,
width: 32,
fit: BoxFit.fill,
),
)
: Image.asset(
Assets.assetsIconsLogo,
height: 32,
width: 32,
fit: BoxFit.fill,
),
),
Expanded(
child: BodyMedium(
text: scene.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
],
),
),
));
},
);
}
}