import 'package:flutter/material.dart';
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_grid_view.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';

class RoutinesExpansionTile extends StatelessWidget {
  const RoutinesExpansionTile({
    super.key,
    required this.title,
    required this.emptyRoutinesMessage,
    required this.routines,
    required this.loadingStates,
    required this.disablePlayButton,
    this.loadingSceneId,
  });
  final String title;
  final String emptyRoutinesMessage;
  final List<ScenesModel> routines;
  final Map<String, bool> loadingStates;
  final String? loadingSceneId;
  final bool disablePlayButton;

  @override
  Widget build(BuildContext context) {
    return ExpansionTile(
      tilePadding: const EdgeInsets.symmetric(
        horizontal: 6,
      ),
      initiallyExpanded: true,
      iconColor: ColorsManager.grayColor,
      title: BodyMedium(
        text: title,
      ),
      childrenPadding: EdgeInsetsDirectional.only(bottom: 10),
      children: [
        Visibility(
          visible: routines.isNotEmpty,
          replacement: Center(
            child: BodyMedium(
              text: emptyRoutinesMessage,
              textAlign: TextAlign.center,
            ),
          ),
          child: SceneGrid(
            scenes: routines,
            loadingSceneId: loadingSceneId,
            disablePlayButton: disablePlayButton,
            loadingStates: loadingStates,
          ),
        ),
      ],
    );
  }
}
