// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';

class PortfolioCardHeader extends StatelessWidget {
  const PortfolioCardHeader({
    this.logo,
    this.padding,
    this.radius,
    this.projectName,
    this.subtitle,
    this.keyword,
    super.key,
  });

  final Widget? logo;
  final double? padding;
  final double? radius;
  final TextWrapper? projectName;
  final TextWrapper? subtitle;
  final List<TextWrapper>? keyword;

  @override
  Widget build(BuildContext context) => Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              if (logo != null) logo!,
              const Gap(10),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  if (projectName != null)
                    Text(
                      projectName!.text,
                      style:
                          projectName!.style ?? context.textTheme.titleMedium,
                    ).toGradient(
                      LinearGradientHelper.fromNullableColors(
                        projectName!.gradient,
                      ),
                    ),
                  if (subtitle != null) ...[
                    const Gap(5),
                    Text(
                      subtitle!.text,
                      style: subtitle!.style ?? context.textTheme.titleSmall,
                    ).toGradient(
                      LinearGradientHelper.fromNullableColors(
                        subtitle!.gradient,
                      ),
                    ),
                  ],
                ],
              ),
            ],
          ),
          const Gap(10),
          Wrap(
            children: [
              if (keyword != null)
                ...keyword!.map(
                  (e) => Container(
                    margin: const EdgeInsets.all(3),
                    padding: const EdgeInsets.all(6),
                    decoration: BoxDecoration(
                      color: Theme.of(context).focusColor,
                      borderRadius: BorderRadius.circular(8),
                    ),
                    child: Text(
                      e.text,
                      style: e.style ?? context.textTheme.bodySmall,
                    ),
                  ),
                ),
            ],
          ),
        ],
      );
}
