import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:gap/gap.dart';
import 'package:tanami_app/core/routes/route_name.dart';
import 'package:tanami_app/core/routes/routes.dart';
import 'package:tanami_app/core/styles/app_color.dart';
import 'package:tanami_app/core/styles/app_images.dart';
import 'package:tanami_app/core/styles/app_text.dart';
import 'package:tanami_app/shared/components/bloc/toggle/toggle_bloc.dart';
import 'package:tanami_app/shared/components/text_widget.dart';

import '../../../../../core/utils/language/localizations_delegate.dart';
import '../../../../../shared/components/toggle_widget.dart';
import '../../../../languageChange/presentation/bloc/text_bloc/text_bloc.dart';
import '../../../../languageChange/presentation/bloc/text_bloc/text_state.dart';
import 'settings_list_tile_item.dart';

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

  @override
  Widget build(BuildContext context) {
    var localizations = AppLocalizations.of(context);
    return Padding(
      padding: const EdgeInsets.symmetric(
        horizontal: 16,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          TextWidget().text14W600(
            localizations.translate(AppText.generalText),
            clr: AppColor.hintTextColor,
          ),
          const Gap(5),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              TextWidget().text14W600(
                localizations.translate(AppText.allowNotificationText),
                clr: AppColor.textLabelColor,
              ),
              BlocProvider(
                create: (_) => ToggleBloc("notification"),
                child: const CustomToggle(),
              )
            ],
          ),
          const Gap(15),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              TextWidget().text14W600(
                localizations.translate(AppText.biometricText),
                clr: AppColor.textLabelColor,
              ),
              BlocProvider(
                create: (_) => ToggleBloc("biometric"),
                child: const CustomToggle(),
              )
            ],
          ),
          const Gap(12),
          BlocBuilder<TextLanguageBloc, TextState>(builder: (context, state) {
            return SettingsListItem(
              onTapFunc: () {
                goRouter.pushNamed(RouteName.languageChangeScreen);
              },
              icon: AppImages.languageIcon,
              title: localizations.translate(AppText.languageText),
              trailing: state.text,
            );
          }),
          const Gap(10),
          const Divider(
            color: AppColor.academyCardTextColor,
          ),
        ],
      ),
    );
  }
}
// Globalconst.languageSelected == "en"
//                   ? "English"
//                 ,