import 'package:flutter/material.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';

class SceneDevicesBodyTabBar extends StatelessWidget {
  const SceneDevicesBodyTabBar({
    required this.tabController,
    required this.rooms,
    required this.selectedRoomId,
    super.key,
  });

  final String selectedRoomId;

  final TabController tabController;
  final List<SubSpaceModel> rooms;

  @override
  Widget build(BuildContext context) {
    return TabBar(
      controller: tabController,
      dividerColor: Colors.transparent,
      indicatorColor: Colors.transparent,
      isScrollable: true,
      tabAlignment: TabAlignment.start,
      tabs: rooms.map((e) {
        final isSelected = selectedRoomId == e.id;
        return Tab(
          child: BodyLarge(
            text: e.name ?? '',
            textAlign: TextAlign.start,
            style: context.bodyLarge.copyWith(
              color: isSelected
                  ? ColorsManager.textPrimaryColor
                  : ColorsManager.textPrimaryColor.withValues(
                      alpha: 0.2,
                    ),
            ),
          ),
        );
      }).toList(),
    );
  }
}
