import 'package:flutter/material.dart';
import 'package:mc_common_app/config/routes.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/navigator.dart';
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:easy_localization/easy_localization.dart';

class SettingOptionsInviteFriends extends StatelessWidget {
  const SettingOptionsInviteFriends({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        title: LocaleKeys.more.tr(),
        isRemoveBackButton: false,
        isDrawerEnabled: false,
        onBackButtonTapped: () => Navigator.pop(context),
      ),
      body: Column(
        children: [
          Expanded(
            child: ListView(
              children: [
                Column(
                  children: [
                    CustomSettingOptionsTile(
                      leadingWidget: const Icon(Icons.person, size: 20),
                      titleText: LocaleKeys.inviteFriends.tr(),
                      needBorderBelow: true,
                      onTap: () {},
                    ),
                    CustomSettingOptionsTile(
                      leadingWidget: const Icon(Icons.help, size: 20),
                      titleText: LocaleKeys.help.tr(),
                      needBorderBelow: true,
                      onTap: () => navigateWithName(
                          context, AppRoutes.settingOptionsFaqs),
                    ),
                    CustomSettingOptionsTile(
                      leadingWidget: const Icon(Icons.person, size: 20),
                      titleText: LocaleKeys.account.tr(),
                      onTap: () =>
                          navigateWithName(context, AppRoutes.profileView),
                    ),
                  ],
                ).toContainer(
                    width: double.infinity,
                    isShadowEnabled: true,
                    paddingAll: 10,
                    margin: const EdgeInsets.fromLTRB(24, 24, 24, 0),
                    borderRadius: 0),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

class CustomSettingOptionsTile extends StatelessWidget {
  final Widget leadingWidget;
  final String titleText;
  final bool needBorderBelow;
  final bool isForLanguage;
  final Function() onTap;

  const CustomSettingOptionsTile(
      {super.key,
      required this.leadingWidget,
      required this.onTap,
      required this.titleText,
      this.needBorderBelow = false,
      this.isForLanguage = false});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              children: [
                leadingWidget,
                12.width,
                titleText.toText(fontSize: 16),
              ],
            ),
            isForLanguage
                ? const Icon(Icons.language, size: 18)
                : const Icon(Icons.arrow_forward, size: 18)
          ],
        ).onPress(onTap),
        5.height,
        if (needBorderBelow) ...[
          const Divider(thickness: 1),
        ],
      ],
    );
  }
}
