import 'package:flutter/material.dart';
import 'package:satu/core/utils/utils_parse.dart';
import 'package:satu/shared/app_colors.dart';
import 'package:satu/shared/ui_helpers.dart';

class CombineDock extends StatelessWidget {
  const CombineDock({
    required this.bankSum,
    required this.cashNum,
    required this.totalSum,
    Key? key,
  }) : super(key: key);
  final double bankSum;
  final double cashNum;
  final double totalSum;

  @override
  Widget build(BuildContext context) {
    final double total = bankSum + cashNum;
    final double shortChange = (total - totalSum) < 0 ? 0 : total - totalSum;
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        verticalSpaceSmall,
        const Padding(
          padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8.0),
          child: Text(
            'Расчет',
            style: TextStyle(fontSize: 12, color: placeholderColor),
          ),
        ),
        Container(
          decoration: const BoxDecoration(
            color: whiteColor,
          ),
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(15.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    const Text(
                      'К оплате',
                      style: TextStyle(
                        fontSize: 14,
                      ),
                    ),
                    Text(
                      '${formatDecimal(total)} ₸',
                      style: const TextStyle(fontSize: 20),
                    ),
                  ],
                ),
              ),
              const Divider(
                height: 1,
                color: disableColor,
              ),
              Padding(
                padding:
                    const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        const Text(
                          'Банковская карта',
                          style:
                              TextStyle(fontSize: 12, color: placeholderColor),
                        ),
                        Text(
                          '${formatDecimal(bankSum)} ₸',
                          style: const TextStyle(
                              fontSize: 12, color: placeholderColor),
                        ),
                      ],
                    ),
                    verticalSpaceSmall,
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        const Text(
                          'Наличными',
                          style:
                              TextStyle(fontSize: 12, color: placeholderColor),
                        ),
                        Text(
                          '${formatDecimal(cashNum)} ₸',
                          style: const TextStyle(
                              fontSize: 12, color: placeholderColor),
                        ),
                      ],
                    ),
                    verticalSpaceSmall,
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        const Text(
                          'Сдача',
                          style:
                              TextStyle(fontSize: 12, color: placeholderColor),
                        ),
                        Text(
                          '${formatDecimal(shortChange)} ₸',
                          style: const TextStyle(
                              fontSize: 12, color: placeholderColor),
                        ),
                      ],
                    )
                  ],
                ),
              ),
            ],
          ),
        )
      ],
    );
  }
}
