import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../../routing/app_routes.dart';
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
import '../../../../view/pages/timetable/data/timetable_name_mode.dart';
import '../widgets/settings_checkbox_tile.dart';
import '../widgets/settings_dropdown_tile.dart';

class TimetableSection extends StatelessWidget {
  const TimetableSection({super.key});

  @override
  Widget build(BuildContext context) {
    final settings = context.watch<SettingsCubit>();
    final timetableSettings = settings.val().timetableSettings;
    return Column(
      children: [
        SettingsDropdownTile<TimetableNameMode>(
          icon: Icons.abc_outlined,
          title: 'Fachbezeichnung',
          value: timetableSettings.timetableNameMode,
          options: TimetableNameMode.values,
          optionIcon: (e) => TimetableNameModes.getDisplayOptions(e).icon,
          optionLabel: (e) => TimetableNameModes.getDisplayOptions(e).displayName,
          onChanged: (e) =>
              settings.val(write: true).timetableSettings.timetableNameMode = e,
        ),
        SettingsCheckboxTile(
          icon: Icons.calendar_view_day_outlined,
          title: 'Doppelstunden zusammenhängend anzeigen',
          value: timetableSettings.connectDoubleLessons,
          onChanged: (e) =>
              settings.val(write: true).timetableSettings.connectDoubleLessons =
                  e,
        ),
        ListTile(
          leading: const Icon(Icons.palette_outlined),
          title: const Text('Fach-Farben'),
          trailing: const Icon(Icons.chevron_right),
          onTap: () => AppRoutes.openSubjectColors(context),
        ),
      ],
    );
  }
}
