import 'package:cargocalculaterapp/core/theme/app_text_styles.dart';
import 'package:cargocalculaterapp/core/theme/colors/app_colors.dart';
import 'package:cargocalculaterapp/features/language/presentation/pages/language/widgets/labguage_button_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../../../../core/app_bloc/app_bloc.dart';
import '../../../../../core/utils/app_utils.dart';
import '../../../../../generated/l10n.dart';
import '../../../../../router/name_routes.dart';
import '../../argument/language_argument.dart';

class AppLanguagePage extends StatefulWidget {
  const AppLanguagePage({super.key, required this.languageArgument});

  final LanguageArgument? languageArgument;

  @override
  State<AppLanguagePage> createState() => _AppLanguagePageState();
}

class _AppLanguagePageState extends State<AppLanguagePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: LightThemeColors.primaryColor,
      body: SafeArea(
        minimum: AppUtils.kPaddingL16R16T16B24,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            AppUtils.kBoxHeight36,
             SvgPicture.asset(
               "assets/svg/ic_logo_lang.svg",
              height: 200,
              colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn),
            ),
            const Spacer(),
            Text(
              AppLocalization.current.select_language,
              style: AppTextStyles.language.copyWith(color: Colors.white),
            ),
            AppUtils.kBoxHeight24,
            Row(
              children: [
                LanguageButtonWidget(
                  name: "O’zbek",
                  onTap: () {
                    context.read<AppBloc>().add(const AppChangeLocale("uz"));
                    if (widget.languageArgument?.fromProfile ?? false) {
                      Navigator.pop(context);
                    } else {
                      Navigator.of(context).pushReplacementNamed(Routes.auth);
                    }
                  },
                  image: "assets/png/ic_uz.png",
                ),
                AppUtils.kBoxWidth8,
                LanguageButtonWidget(
                  name: "Pусский",
                  onTap: () {
                    context.read<AppBloc>().add(const AppChangeLocale("ru"));
                    if (widget.languageArgument?.fromProfile ?? false) {
                      Navigator.pop(context);
                    } else {
                      Navigator.of(context).pushReplacementNamed(Routes.auth);
                    }
                  },
                  image: "assets/png/ic_ru.png",
                ),
                AppUtils.kBoxWidth8,
                LanguageButtonWidget(
                  name: "Chinese",
                  onTap: () {
                    context.read<AppBloc>().add(const AppChangeLocale("zh"));
                    if (widget.languageArgument?.fromProfile ?? false) {
                      Navigator.pop(context);
                    } else {
                      Navigator.of(context).pushReplacementNamed(Routes.auth);
                    }
                  },
                  image: "assets/png/ic_china.jpg",
                ),
              ],
            ),
            AppUtils.kBoxHeight24,
          ],
        ),
      ),
    );
  }
}
