
import 'package:easy_localization/src/public_ext.dart';
import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';

import '../../theme/colors.dart';

enum ClassType { EMAIL, NUMBER }

class LoginEmailTab extends StatefulWidget {
  Function(ClassType) onSelection;

  LoginEmailTab({required this.onSelection});

  @override
  State<LoginEmailTab> createState() => _LoginEmailTabState();
}

class _LoginEmailTabState extends State<LoginEmailTab> {
  ClassType type = ClassType.EMAIL;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      child: Row(
        children: [
          Expanded(
            child: InkWell(
              onTap: () {
                type = ClassType.EMAIL;
                widget.onSelection(ClassType.EMAIL);
              },
              child: Container(
                width: double.infinity,
                height: 45,
                decoration: BoxDecoration(
                  color: type == ClassType.EMAIL ? MyColors.darkPrimaryColor : Colors.grey[200],
                  // border: Border.all(color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.transparent, width: 2),
                  borderRadius: BorderRadius.all(Radius.circular(0)),
                ),
                child: Center(
                  child: Text(
                    LocaleKeys.email.tr(),
                    style: TextStyle(
                      color: type == ClassType.EMAIL ? MyColors.white : Colors.black,
                    ),
                  ),
                ),
              ),
            ),
          ),
          12.width,
          Expanded(
            child: InkWell(
              onTap: () {
                type = ClassType.NUMBER;
                widget.onSelection(ClassType.NUMBER);
              },
              child: Container(
                width: double.infinity,
                height: 45,
                decoration: BoxDecoration(
                  color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.grey[200],
                  // border: Border.all(color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.transparent, width: 2),
                  borderRadius: BorderRadius.all(Radius.circular(0)),
                ),
                child: Center(
                  child: Text(
                    LocaleKeys.phoneNumber.tr(),
                    style: TextStyle(
                      color: type == ClassType.NUMBER ? MyColors.white : Colors.black,
                    ),
                  ),
                ),
              ),
            ),
          ),

        ],
      ),
    );
  }
}
