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

import 'package:get/get.dart';
import 'package:taafee_mobile/common/const/const.dart';
import 'package:taafee_mobile/common/extensions/widget_extension.dart';
import 'package:taafee_mobile/common/widgets/text.dart';
import 'package:taafee_mobile/features/home/business_logic_layer/home_controller.dart';

// ignore: must_be_immutable
class AccountWidget extends StatelessWidget {
  final String icon;
  final String title;
  final bool? isShowCircleAvatar;
  final Color? color;
  HomeController homeController = Get.find<HomeController>();
  AccountWidget(
      {super.key,
      required this.icon,
      required this.title,
      this.isShowCircleAvatar = true,
      this.color});

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
      width: Get.width,
      height: Responsive.isTablet() ? 70 : 45,
      child: Row(
        children: [
          CircleAvatar(
            radius: Responsive.isTablet() ? 20 : null,
            backgroundColor: isShowCircleAvatar!
                ? AppColors.circleAvatarColor
                : Colors.transparent,
            child: SvgPicture.asset("assets/icons/$icon"),
          ).expanded(2),
          if (Responsive.isTablet())
            const SizedBox(
              width: 12,
            ),
          RegularTextWidget(
            color: color,
            title,
            fontSize: Responsive.isTablet() ? 22 : 14,
          ).expanded(7),
          if (Responsive.isTablet()) Container().expanded(7),
          isShowCircleAvatar!
              ? Obx(
                  () => (!(homeController.isArabic.value)
                      ? SvgPicture.asset("assets/icons/arrow right.svg")
                      : SvgPicture.asset("assets/icons/arrow-left.svg")),
                ).expanded(1)
              : Container(),
        ],
      ),
    ).paddingSymmetric(
        horizontal: Responsive.isTablet() ? Get.width * 0.15 : 0);
  }
}
