import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/functions/getlanguage_function.dart';
import 'package:pharmacy_mobile/widgets/customer_pagebackground_widget.dart';
import 'package:pharmacy_mobile/widgets/customer_title_widget.dart';
import 'package:pharmacy_mobile/widgets/settings_menu_widget.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';

class LanguageSettingPage extends StatefulWidget {
  const LanguageSettingPage({super.key});

  @override
  State<LanguageSettingPage> createState() => _LanguageSettingPageState();
}

class _LanguageSettingPageState extends State<LanguageSettingPage> {
  static const List<String> languageList = ['English', 'Tagalog', 'Hilogaynon (Ilonggo)', 'Cebuano (Bisaya)'];
  late String currentLanguage = '';

  void autoRun() async {
    currentLanguage = await getLanguage(context);
    setState(() {});
  }

  @override
  void initState() {
    autoRun();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomerPagebackgroundWidget(
          child: Column(
        children: [
          const Gap(68),
          const CustomerTitleWidget(),
          const Gap(32),
          if (currentLanguage == languageList[0])
            Column(
              children: [
                const TextWidget(text: 'Language'),
                const Gap(16),
                SettingsMenuWidget(
                  title: 'Current',
                  value: currentLanguage,
                ),
                const Gap(16),
                SettingsMenuWidget(
                  title: 'Other Options',
                  value: currentLanguage,
                  isSelection: true,
                  selectionList: languageList,
                  selectionFor: 'Language',
                )
              ],
            )
          else if (currentLanguage == languageList[1])
            Column(children: [
              const TextWidget(text: 'Wika'),
              const Gap(16),
              SettingsMenuWidget(
                title: 'Kasalukuyan',
                value: currentLanguage,
              ),
              const Gap(16),
              SettingsMenuWidget(
                title: 'Iba pang mga Opsyon',
                value: currentLanguage,
                isSelection: true,
                selectionList: languageList,
                selectionFor: 'Language',
              )
            ])
          else if (currentLanguage == languageList[2])
            Column(children: [
              const TextWidget(text: 'Lenggwahe'),
              const Gap(16),
              SettingsMenuWidget(
                title: 'Ang Subong',
                value: currentLanguage,
              ),
              const Gap(16),
              SettingsMenuWidget(
                title: 'Iban pa nga mga Opsyon',
                value: currentLanguage,
                isSelection: true,
                selectionList: languageList,
                selectionFor: 'Language',
              )
            ])
          else if (currentLanguage == languageList[3])
            Column(children: [
              const TextWidget(text: 'Pinulongan'),
              const Gap(16),
              SettingsMenuWidget(
                title: 'Ang Karon',
                value: currentLanguage,
              ),
              const Gap(16),
              SettingsMenuWidget(
                title: 'Uban pa na mga Opsyon',
                value: currentLanguage,
                isSelection: true,
                selectionList: languageList,
                selectionFor: 'Language',
              )
            ])
        ],
      )),
    );
  }
}
