import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:tm_app/core/constants/assets.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/breakpoints.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/notification__response/notification_response_model.dart';
import 'package:tm_app/view_models/notification_view_model.dart';

import '../../../core/routes/app_routes.dart';
import '../strings/notification_strings.dart';

class NotificationMoreDialog extends StatelessWidget {
  const NotificationMoreDialog({
    required this.notification,
    required this.viewModel,
    super.key,
  });

  final NotificationItem notification;
  final NotificationViewModel viewModel;

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: AppColors.backgroundColor,
      insetPadding: EdgeInsets.symmetric(horizontal: 24.0.w()),
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
      child: Container(
        width:
            Size(SizeConfig.screenWidth, SizeConfig.screenHeight).displaySize ==
                        DisplaySize.small ||
                    Size(
                          SizeConfig.screenWidth,
                          SizeConfig.screenHeight,
                        ).displaySize ==
                        DisplaySize.large
                ? 720
                : double.infinity,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(4),
          color: AppColors.primary10Light,
          border: Border.all(color: AppColors.primary20),
        ),
        // margin: EdgeInsets.symmetric(horizontal: 24.0.w()),
        padding: EdgeInsets.symmetric(horizontal: 16.0.w(), vertical: 16.0.h()),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              children: [
                SvgPicture.asset(AssetsManager.notification),
                SizedBox(width: 8.0.w()),
                Text(
                  notification.title!,
                  style: TextStyle(
                    fontSize: 16.0.sp(),
                    fontWeight: FontWeight.w600,
                    color: AppColors.grey80,
                  ),
                ),
              ],
            ),
            SizedBox(height: 8.0.h()),
            Padding(
              padding: EdgeInsets.only(left: 28.0.w()),
              child: Text(
                notification.message!,
                style: TextStyle(
                  fontSize: 14.0.sp(),
                  fontWeight: FontWeight.w400,
                  color: AppColors.grey70,
                ),
              ),
            ),
            SizedBox(height: 12.0.h()),
            Padding(
              padding: EdgeInsets.only(left: 28.0.w()),
              child: Row(
                children: [
                  SvgPicture.asset(AssetsManager.calendar),
                  SizedBox(width: 4.0.w()),
                  Text(
                    viewModel.timeAgo(notification.createdAt!.toString()),
                    style: TextStyle(
                      fontSize: 12.0.sp(),
                      fontWeight: FontWeight.w400,
                      color: AppColors.grey60,
                    ),
                  ),
                  const Spacer(),
                  Visibility(
                    visible:
                        (notification.metadata?.tender != null &&
                            notification.metadata?.tender != ''),
                    child: TextButton(
                      onPressed: () {
                        context.pop();
                        TenderDetailRouteData(
                          tenderId:
                              notification.metadata?.tender!.toString() ?? '',
                        ).push(context);
                      },
                      child: Row(
                        children: [
                          Text(
                            NotificationStrings.seeDetails,
                            style: TextStyle(
                              fontSize: 14.0.sp(),
                              fontWeight: FontWeight.w500,
                              color: AppColors.mainBlue,
                            ),
                          ),
                          SizedBox(width: 4.0.w()),
                          SvgPicture.asset(
                            AssetsManager.arrowRight,
                            colorFilter: const ColorFilter.mode(
                              AppColors.mainBlue,
                              BlendMode.srcIn,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
