import 'package:didvan/config/theme_data.dart';
import 'package:didvan/constants/app_icons.dart';
import 'package:didvan/models/new_statistic/total_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 TotalType6Card extends StatelessWidget {
  final TotalContent totalContent;
  const TotalType6Card({super.key, required this.totalContent});

  @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.4),
                  borderRadius: const BorderRadius.all(Radius.circular(4))),
              child: Center(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    DidvanText(
                      totalContent.title,
                      style: Theme.of(context).textTheme.bodyLarge,
                      textAlign: TextAlign.center,
                    ),
                  ],
                ),
              ),
            ),
            const DidvanDivider(
              verticalPadding: 8,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                SizedBox(
                  width: MediaQuery.of(context).size.width * 0.25,
                  child: DidvanText(
                    "نماد",
                    style: Theme.of(context).textTheme.bodyLarge,
                  ),
                ),
                const Expanded(child: VerticalDivider()),
                DidvanText(
                  "قیمت پایانی",
                  style: Theme.of(context).textTheme.bodyLarge,
                ),
                const Expanded(child: VerticalDivider()),
                SizedBox(
                  width: MediaQuery.of(context).size.width * 0.25,
                  child: DidvanText(
                    "تاثیر",
                    style: Theme.of(context).textTheme.bodyLarge,
                    textAlign: TextAlign.end,
                  ),
                ),
              ],
            ),
            Column(
              children: totalContent.data
                  .map(
                    (item) => Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        SizedBox(
                          width: MediaQuery.of(context).size.width * 0.25,
                          child: DidvanText(
                            item.name.toString(),
                            overflow: TextOverflow.fade,
                            style: Theme.of(context).textTheme.bodySmall,
                          ),
                        ),
                        SizedBox(
                          width: 52,
                          child: Center(
                            child: DidvanText(
                              overflow: TextOverflow.fade,
                              item.p.toString(),
                              style: Theme.of(context).textTheme.bodySmall,
                            ),
                          ),
                        ),
                        SizedBox(
                          width: MediaQuery.of(context).size.width * 0.25,
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: [
                              Icon(
                                  item.dt == "high"
                                      ? DidvanIcons.angle_up_regular
                                      : DidvanIcons.angle_down_regular,
                                  size: 14,
                                  color: item.dt == "high"
                                      ? Theme.of(context).colorScheme.success
                                      : Theme.of(context).colorScheme.error),
                              DidvanText("${item.d}",
                                  style: Theme.of(context).textTheme.bodySmall,
                                  color: item.dt == "high"
                                      ? Theme.of(context).colorScheme.success
                                      : Theme.of(context).colorScheme.error),
                            ],
                          ),
                        )
                      ],
                    ),
                  )
                  .toList(),
            )
          ],
        ),
      ),
    );
  }
}
