import 'package:auto_route/annotations.dart';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart' show Gap;
import 'package:intl/intl.dart';
import 'package:krow/core/presentation/widgets/scroll_layout_helper.dart';
import 'package:krow/core/presentation/widgets/ui_kit/kw_app_bar.dart';
import 'package:krow/features/notificatins/domain/notification_entity.dart';

import '../../../core/presentation/gen/assets.gen.dart';
import '../../../core/presentation/styles/kw_text_styles.dart';
import '../../../core/presentation/styles/theme.dart';
import '../../../core/presentation/widgets/ui_kit/kw_button.dart';

@RoutePage()
class NotificationDetailsScreen extends StatelessWidget {
  final NotificationEntity notification;

  const NotificationDetailsScreen({super.key, required this.notification});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: KwAppBar(
        titleText: notification.type.name,
      ),
      body: ScrollLayoutHelper(
        upperWidget: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Gap(16),
            _buildTitle(),
            Gap(24),
            Text(notification.title, style: AppTextStyles.headingH1),
            Gap(8),
            Text(notification.body,
                style: AppTextStyles.bodyMediumReg
                    .copyWith(color: AppColors.blackBlack)),
          ],
        ),
        lowerWidget: _buildFooter(context),
      ),
    );
  }

  Widget _buildFooter(BuildContext context) {
    return Column(
      children: [
        Gap(24),
        Row(
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('Best regards',
                    style: AppTextStyles.bodyMediumReg
                        .copyWith(color: AppColors.blackBlack)),
                Gap(2),
                Text(
                  'KROW Team',
                  style: AppTextStyles.bodyMediumSmb,
                ),
              ],
            ),
            Spacer(),
            Assets.images.logo.svg(
                colorFilter: const ColorFilter.mode(
              AppColors.bgColorDark,
              BlendMode.srcIn,
            )),
          ],
        ),
        Gap(24),
        KwButton.primary(
          label: 'Go to',
          onPressed: () {
            Navigator.of(context).pop();
          },
        ),
      ],
    );
  }

  Row _buildTitle() {
    return Row(
      children: [
        _buildIcon(),
        Gap(12),
        Text(notification.body, style: AppTextStyles.bodyMediumMed),
        Spacer(),
        Text(DateFormat('hh:mm a').format(notification.dateTime),
            style: AppTextStyles.bodyMediumMed)
      ],
    );
  }

  Container _buildIcon() {
    return Container(
      height: 36,
      width: 36,
      decoration: BoxDecoration(
        color: AppColors.bgColorDark,
        shape: BoxShape.circle,
      ),
      child: Center(
        child: Assets.images.icons.receiptSearch.svg(
            height: 16,
            width: 16,
            colorFilter: const ColorFilter.mode(
              AppColors.primaryMint,
              BlendMode.srcIn,
            )),
      ),
    );
  }
}
