import 'package:didvan/config/theme_data.dart';
import 'package:didvan/constants/app_icons.dart';
import 'package:didvan/models/new_statistic/exchange_model.dart';
import 'package:didvan/views/widgets/didvan/card.dart';
import 'package:didvan/views/widgets/didvan/divider.dart';
import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:flutter/material.dart';

class ExchangeCard extends StatelessWidget {
  final ExChangeContent exchangeContent;
  const ExchangeCard({super.key, required this.exchangeContent});

  Color _diffColor(context) => exchangeContent.data.dt == 'high'
      ? Theme.of(context).colorScheme.success
      : Theme.of(context).colorScheme.error;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: DidvanCard(
        padding: const EdgeInsets.all(8),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
                decoration: BoxDecoration(
                    color: Colors.grey.withValues(alpha: 0.3),
                    borderRadius: const BorderRadius.all(Radius.circular(4))),
                child: Center(
                    child: DidvanText(
                  exchangeContent.title,
                  style: Theme.of(context).textTheme.bodyLarge,
                ))),
            const DidvanDivider(
              verticalPadding: 8,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                const DidvanText("رقم روز کاری جاری"),
                DidvanText(exchangeContent.data.p)
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                const DidvanText("رقم روز کاری گذشته"),
                DidvanText(exchangeContent.data.y)
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                const DidvanText("میزان تغییرات" " (واحد) "),
                Row(
                  children: [
                    Icon(
                      exchangeContent.data.dt == 'high'
                          ? DidvanIcons.angle_up_regular
                          : DidvanIcons.angle_down_regular,
                      size: 14,
                      color: _diffColor(context),
                    ),
                    DidvanText(
                      exchangeContent.data.d,
                      color: _diffColor(context),
                    ),
                  ],
                )
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                const DidvanText("میزان تغییرات" " (درصد) "),
                Row(
                  children: [
                    Icon(
                      exchangeContent.data.dt == 'high'
                          ? DidvanIcons.angle_up_regular
                          : DidvanIcons.angle_down_regular,
                      size: 14,
                      color: _diffColor(context),
                    ),
                    DidvanText(
                      "${exchangeContent.data.dp}%",
                      color: _diffColor(context),
                    ),
                  ],
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
