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

import 'package:get/get.dart';
import 'package:flashlink/config/theme/theme_extensions/theme_extension.dart';

import '../../../../config/translations/strings_enum.dart';
import '../../../base/base_view.dart';
import '../../../constants/iconfont/iconfont.dart';
import '../../../widgets/ix_app_bar.dart';
import '../../../widgets/ix_text_field.dart';
import '../../../widgets/submit_btn.dart';
import '../controllers/forgotpwd_controller.dart';

class ForgotpwdView extends BaseView<ForgotpwdController> {
  const ForgotpwdView({super.key});
  @override
  PreferredSizeWidget? get appBar => IXAppBar(title: '');

  @override
  Widget buildContent(BuildContext context) {
    return SafeArea(
      child: Padding(
        padding: EdgeInsets.symmetric(horizontal: 14.w),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              10.verticalSpaceFromWidth,

              // 标题
              Text(
                Strings.changePassword.tr,
                style: TextStyle(
                  fontSize: 28.sp,
                  height: 1.2,
                  color: Get.reactiveTheme.textTheme.bodyLarge!.color,
                ),
              ),

              24.verticalSpaceFromWidth,

              // 描述文字
              Text(
                Strings.changePasswordDescription.tr,
                style: TextStyle(
                  fontSize: 16.sp,
                  color: Get.reactiveTheme.hintColor,
                  height: 1.4,
                ),
              ),

              20.verticalSpaceFromWidth,
              IXTextField(
                hintText: Strings.enterNewPassword.tr,
                prefixIcon: IconFont.icon11,
                controller: controller.usernameController,
                focusNode: controller.usernameFocusNode,
                isPassword: true,
                validator: controller.validatorInputValue,
                tipText: Strings.usernamePasswordRule.tr,
                errorText: Strings.usernamePasswordRule.tr,
                onChanged: (value) {
                  controller.checkLogin();
                },
              ),

              16.verticalSpaceFromWidth,
              IXTextField(
                hintText: Strings.enterConfirmPassword.tr,
                prefixIcon: IconFont.icon11,
                controller: controller.passwordController,
                focusNode: controller.passwordFocusNode,
                validator: controller.validatorConfirmInputValue,
                isPassword: true,
                tipText: Strings.usernamePasswordRule.tr,
                errorText: Strings.confirmPasswordMustBeTheSame.tr,
                onChanged: (value) {
                  controller.checkLogin();
                },
              ),
              156.verticalSpaceFromWidth,
              SubmitButton(
                text: Strings.yes.tr,
                enabled: controller.isChangePassword,
                onPressed: controller.handleChangePassword,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
