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/search_area.dart';
import 'package:taafee_mobile/common/widgets/text.dart';
import 'package:taafee_mobile/core/routing/routing_manager.dart';
import 'package:taafee_mobile/features/chat/presentation_layer/widgets/circle_avatar.dart';
import 'package:taafee_mobile/features/home/business_logic_layer/home_controller.dart';

// ignore: must_be_immutable
class AppBarWidget extends StatelessWidget {
  final HomeController homeController = Get.find<HomeController>();
  TextEditingController? textEditingController;
  @override
  AppBarWidget({super.key, this.textEditingController});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 190,
      color: AppColors.primeColor,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  CircleAvatarWidget(
                    radius: 20,
                    isUserAvatar: true,
                  ).paddingSymmetric(horizontal: 10),
                  Obx(() {
                    return BoldTextWidget(
                      "${homeController.user.value?.firstName}"
                      " "
                      "${homeController.user.value?.lastName}",
                      color: Colors.white,
                    ).paddingSymmetric(horizontal: 5);
                  })
                ],
              ).onTap(() {
                homeController.onPress(3);
              }),
              Row(
                children: [
                  SvgPicture.asset(
                    "assets/icons/notification.svg",
                    colorFilter:
                        const ColorFilter.mode(Colors.white, BlendMode.srcIn),
                  ).onTap(() {
                    RoutingManager.to(RouteName.notification);
                  }),
                ],
              ).paddingSymmetric(horizontal: 10)
            ],
          ).paddingSymmetric(
              horizontal: Responsive.isTablet() ? 40 : 10, vertical: 10),
          SearchAreaWidget(
            textEditingController: textEditingController,
          ).paddingOnly(top: Responsive.isTablet() ? 8 : 0),
        ],
      ),
    );
  }
}
