import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/view_models/user_view_model.dart';
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
import 'package:mc_common_app/widgets/button/show_image_button.dart';
import 'package:mc_common_app/widgets/txt_field.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class LoginVerifyAccountPage extends StatelessWidget {
  int otpType = 1;
  String phoneNum = "";

  LoginVerifyAccountPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    UserVM userVM = context.read<UserVM>();
    return Scaffold(
      appBar: CustomAppBar( isRemoveBackButton: true,title: LocaleKeys.login.tr()),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        padding: const EdgeInsets.all(40),
        child: Column(
          children: [
            LocaleKeys.verifyAccount.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,),
            Utils.mFlex(1),
            TxtField(
              hint: "966501234567",
              value: phoneNum,
              onChanged: (v) {
                phoneNum = v;
              },
            ),
            Utils.mFlex(2),
            Row(
              children: [
                Expanded(
                  child: ShowImageButton(
                    onClick: () {
                      otpType = 1;
                      userVM.performBasicOtpLoginVerifyAccountPage(context, phoneNum: phoneNum, otpType: otpType);
                      // showMDialog(context, child: OtpDialog(
                      //   onClick: (String code) {
                      //     pop(context);
                      //     delay(300).then(
                      //       (value) => showMDialog(
                      //         context,
                      //         child: MessageDialog(
                      //           title: "Phone Number Verified",
                      //           onClick: () {
                      //             otpType=1;
                      //             performBasicOtp(context);
                      //             // navigateWithName(context, AppRoutes.completeProfile);
                      //           },
                      //         ),
                      //       ),
                      //     );
                      //   },
                      // ));
                    },
                    title: LocaleKeys.SMS.tr(),
                    icon: MyAssets.icSmsSvg,
                  ),
                ),
                20.width,
                Expanded(
                  child: ShowImageButton(
                    onClick: () {
                      otpType = 1;
                      userVM.performBasicOtpLoginVerifyAccountPage(context, phoneNum: phoneNum, otpType: otpType);
                      // showMDialog(context, child: OtpDialog(
                      //   onClick: (String code) {
                      //     pop(context);
                      //     delay(300).then(
                      //       (value) => showMDialog(
                      //         context,
                      //         child: MessageDialog(
                      //           title: "Phone Number Verified",
                      //           onClick: () {
                      //             otpType=2;
                      //             performBasicOtp(context);
                      //             // navigateWithName(context, AppRoutes.completeProfile);
                      //           },
                      //         ),
                      //       ),
                      //     );
                      //   },
                      // ));
                    },
                    title: LocaleKeys.whatsapp.tr(),
                    icon: MyAssets.icWhatsAppSvg,
                  ),
                ),
              ],
            ),
            Utils.mFlex(10),
          ],
        ),
      ),
    );
  }

}
