import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/insurance/insurance_view_model.dart';
import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart';
import 'package:hmg_patient_app_new/presentation/profile_settings/profile_settings.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:hmg_patient_app_new/widgets/routes/spring_page_route_builder.dart';
import 'package:smooth_corner/smooth_corner.dart';

class WelcomeWidget extends StatelessWidget {
  final String name;
  final String? imageUrl;
  final Widget? imageWidget;
  final VoidCallback? onTap;

  const WelcomeWidget({
    super.key,
    required this.name,
    this.imageUrl,
    this.imageWidget,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        InkWell(
          onTap: onTap,
          borderRadius: BorderRadius.circular(30),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            // spacing: 8.h,
            children: [
              SizedBox(
                height: 40.h,
                width: 20.w,
                child: Icon(Icons.menu, color: AppColors.textColor),
              ).onPress(() {
                getIt.get<ProfileSettingsViewModel>().getProfileSettings();
                Navigator.of(context).push(
                  CustomPageRoute(
                    direction: getIt.get<AppState>().isArabic() ? AxisDirection.right : AxisDirection.left,
                    page: ProfileSettings(),
                  ),
                );
              }),
              Container(
                height: 32.h,
                width: 1.5.w,
                margin: EdgeInsets.only(right: 10.w,left: 10.w),
                decoration: BoxDecoration(
                  color: AppColors.greyTextColor.withOpacity(.3),
                  borderRadius: BorderRadius.circular(1.r),
                ),
              ),
              imageWidget ??
              (imageUrl != null
                ? Utils.buildImgWithAssets(icon: imageUrl!, width: 40, height: 40)
                : SizedBox(width: 40, height: 40)),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                spacing: 4.h,
                mainAxisSize: MainAxisSize.min,
                children: [
                  LocaleKeys.welcome.tr(context: context).toText14(color: AppColors.greyTextColor, height: 1, isBold: true),
                  Row(
                    spacing: 4.h,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Flexible(child: name.toText16(isBold: true, textOverflow: TextOverflow.ellipsis, maxlines: 1, height: 1, isEnglishOnly: true)),
                      // Icon(Icons.keyboard_arrow_down, size: 20, color: AppColors.greyTextColor),
                      Transform.flip(
                        flipX: getIt.get<AppState>().isArabic(),
                        child: Utils.buildSvgWithAssets(
                          icon: AppAssets.arrowRight,
                          iconColor: AppColors.blackColor,
                          width: 22.w,
                          height: 22.h,
                          fit: BoxFit.contain,
                        )
                      ),
                      // Utils.buildSvgWithAssets(icon: AppAssets.arrowRight, height: 22.h, width: 22.w)
                    ],
                  ),
                ],
              ).paddingOnly(left: 8.h, right: 8.h).expanded,
            ],
          ),
        ),
      ],
    );
  }
}
