import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';


import '../../../core/constants/form_field_constants.dart';
import '../../../core/constants/translation_keys.dart';
import '../../../core/utils/fields_utils.dart';
import '../../../custom_widgets/Fields/input_field.dart';
import '../../../custom_widgets/custom_app_bar.dart';
import '../../../custom_widgets/custom_button.dart';
import '../../../res/app_colors.dart';
import '../controllers/add_new_account_controller.dart';

class AddNewAccountView extends GetView<AddNewAccountController> {
  const AddNewAccountView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    String className = runtimeType.toString().split('.').last;

    return Scaffold(
      // persistentFooterButtons: [
      //   Padding(
      //     padding: const EdgeInsets.only(left: 20, right: 30, bottom: 10),
      //     child: CustomButton(
      //       onPressed: () {
      //         controller.validateAndSendRequest();
      //       },
      //       buttonText: TranslationKeys.makeTranslation(TranslationKeys.textCreateAccount),
      //       buttonColor: AppColors.colorButton,
      //       buttonPadding: const EdgeInsets.only(top: 12, bottom: 12),
      //     ),
      //   )
      // ],
      appBar: DashBoardAppBar(
        title: TranslationKeys.makeTranslation(TranslationKeys.textAddAccount),
        onBackButtonPressed: () {
          Get.back();
        },
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(vertical: 20.0, horizontal: 20.0),
        child: SingleChildScrollView(
          child: Column(
            children: [
              GetBuilder<AddNewAccountController>(
                builder: (controller) {
                  return controller.currencyCodesField = InputField(
                    refKey: FormFieldConstants.instance().getFormKey("addNewAccountField"),
                    controller: FormFieldConstants.instance().getController("addNewAccountField"),
                    labelText: "Select Default Currency",
                    isDropDown: true,
                    hintText: "Select Default Currency",
                    dropDownType: DropDownType.SPECIAL,
                    items: controller.currencyListDropDown,
                    onItemSelected: (item) {
                      controller.updateCurrency(item);
                    },
                  );
                },
              ),
              controller.nameAddressField = InputField(
                enableInteractiveSelection: false,
                refKey: FormFieldConstants.instance().getFormKey("${className}userNameField"),
                controller: FormFieldConstants.instance().getController("${className}userNameField"),
                hintText: "Enter account title",
                labelText: "Account Title",
                inputFormatters: [LengthLimitingTextInputFormatter(FieldUtils.addressFieldLength)],
                onSubmitted: (value) {
                  controller.validateAndSendRequest();
                },
              ),
              const SizedBox(height: 30),
              Padding(
                padding: const EdgeInsets.only(left: 20, right: 30, bottom: 10),
                child: CustomButton(
                  onPressed: () {
                    controller.validateAndSendRequest();
                  },
                  buttonText: TranslationKeys.makeTranslation(TranslationKeys.textCreateAccount),
                  buttonColor: AppColors.colorButton,
                  buttonPadding: const EdgeInsets.only(top: 12, bottom: 12),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
