import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
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/theme/colors.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class CustomSettingOptionsTile extends StatelessWidget {
  final Widget leadingWidget;
  final String titleText;
  final bool needBorderBelow;
  final bool isForLanguage;
  final bool showTrailingArrow;
  final Function() onTap;
  final String? subTitle;
  final Color subtitleTextColor;

  const CustomSettingOptionsTile({
    super.key,
    required this.leadingWidget,
    required this.onTap,
    required this.titleText,
    this.needBorderBelow = false,
    this.isForLanguage = false,
    this.showTrailingArrow = true,
    this.subTitle,
    this.subtitleTextColor = MyColors.primaryColor,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    leadingWidget,
                    12.width,
                    titleText.toText(fontSize: 16),
                  ],
                ),
                if (subTitle != null)
                  Row(
                    children: [
                      28.width,
                      subTitle!.toText(fontSize: 14, color: subtitleTextColor),
                    ],
                  ),
              ],
            ),
            isForLanguage
                ? LocaleKeys.english.tr().toText(fontSize: 12, isUnderLine: true, color: MyColors.primaryColor)
                : showTrailingArrow
                    ? const Icon(Icons.arrow_forward, size: 18)
                    : const SizedBox()
          ],
        ).onPress(onTap),
        subTitle != null ? 3.height : 5.height,
        if (needBorderBelow) ...[
          const Divider(thickness: 1),
        ],
      ],
    );
  }
}

class CustomProfileOptionsTile extends StatelessWidget {
  final String titleText;
  final bool needBorderBelow;
  final bool needEditButton;
  final Function() onTap;
  final String subtitleText;

  const CustomProfileOptionsTile({super.key, required this.onTap, required this.titleText, required this.subtitleText, this.needBorderBelow = false, this.needEditButton = true});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                titleText.toText(fontSize: 16),
                subtitleText.toText(fontSize: 12, color: MyColors.darkTextColor.withOpacity(0.7)),
              ],
            ),
            if (needEditButton) ...[MyAssets.icEdit.buildSvg()],
          ],
        ).onPress(onTap),
        5.height,
        if (needBorderBelow) ...[
          const Divider(thickness: 1),
        ],
      ],
    );
  }
}
