/*
 * @Author       : WuWei
 * @LastEditors: wuwei
 * @Date         : 2023-10-24 11:57:56
 * @LastEditTime: 2023-12-28 16:51:48
 * @Description  : Do not edit
 */
part of '../index.dart';

///总计模块
class _TotalFeeCard extends StatelessWidget {
  const _TotalFeeCard({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<_Store>(context);
    final colorScheme = WTheme.of(context).colorScheme;

    _BuildFeeItem(String left, String right) {
      return Wisdom.row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        padding: EdgeInsets.symmetric(vertical: 2.pt),
        children: [
          WisText(
            '$left',
            color: colorScheme.minor,
            size: 12.pt,
            overflow: TextOverflow.ellipsis,
          ).asExpanded(),
          SizedBox(
            width: 10.pt,
          ),
          WisText(
            '￥$right',
            size: 12.pt,
            color: colorScheme.red,
          ),
        ],
      );
    }

    return SliverToBoxAdapter(
      child: GradientCard(
        gradient: LinearGradient(
          colors: [Color(0x99FFEACE), Color(0xffF99B1A)],
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
        ),
        margin: EdgeInsets.fromLTRB(15.pt, 15.pt, 15.pt, 0),

        child: Wisdom.column(
          padding: EdgeInsets.fromLTRB(15.pt, 15.pt, 15.pt, 15.pt),
          children: [
            Wisdom.row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Wisdom.column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    WisText(
                      '欠费金额${store.totalCount?.liquidatedDamagesFee != null && store.totalCount!.liquidatedDamagesFee! > 0 ? '（含违约金￥${store.totalCount?.liquidatedDamagesFee}）' : ''}',
                      color: Color(0xffD17B04),
                      size: 12.pt,
                      bold: true,
                      overflow: TextOverflow.ellipsis,
                    ),
                    Wisdom(
                      padding: EdgeInsets.symmetric(vertical: 10.pt),
                      child: WisText(
                        '￥${store.totalCount?.totalArrearsFee ?? 0}',
                        color: colorScheme.red,
                        size: 20.pt,
                        bold: true,
                      ),
                    ),
                    WisText(
                      '可预缴金额： ${store.totalCount != null && store.totalCount!.advanceFee! > 0 ? store.totalCount?.advanceFee : 0}',
                      color: Color(0xffD17B04),
                      size: 12.pt,
                    ),
                  ],
                ),
                Wisdom(
                  margin: EdgeInsets.only(
                    left: 10.pt,
                  ),
                  onTap: () => store.toFeeRecord(),
                  padding: EdgeInsets.symmetric(
                    horizontal: 15.pt,
                    vertical: 8.pt,
                  ),
                  border: Border.all(
                    color: Colors.white,
                  ),
                  borderRadius: BorderRadius.circular(20.pt),
                  child: WisText(
                    '收支记录',
                    color: Colors.white,
                  ),
                ),
                // Column(
                //   children: [
                // Wisdom(
                //   margin: EdgeInsets.only(
                //     top: 10.pt,
                //   ),
                //   padding: EdgeInsets.symmetric(
                //     horizontal: 15.pt,
                //     vertical: 8.pt,
                //   ),
                //   border: Border.all(
                //     color: Color(0xffF6F7FC),
                //   ),
                //   borderRadius: BorderRadius.circular(20.pt),
                //   child: WisText(
                //     '添加账单',
                //     color: Color(0xffF6F7FC),
                //   ),
                // ),
                //   ],
                // ),
              ],
            ),
            SizedBox(height: 10.pt),
            WisCard(
              color: colorScheme.background4,
              padding: EdgeInsets.all(15.pt),
              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Wisdom(
                        margin: EdgeInsets.only(right: 10.pt),
                        child: WisText(
                          '欠费属期范围',
                          size: 12.pt,
                          bold: true,
                          color: colorScheme.mainTitle,
                        ),
                      ),
                      WisText(
                        store.oweCount?.billingPeriod ?? '--',
                        size: 12.pt,
                        color: colorScheme.minor,
                        textAlign: TextAlign.right,
                      ).asExpanded(),
                    ],
                  ),
                  if (store.oweCount?.feeTypeFees != null &&
                      store.oweCount!.feeTypeFees!.length > 0) ...[
                    Divider(height: 10.pt),
                    Wisdom(
                      child: Column(
                        children: [
                          Wisdom.row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            padding: EdgeInsets.symmetric(vertical: 2.pt),
                            children: [
                              WisText(
                                '费项名称',
                                color: colorScheme.mainTitle,
                                bold: true,
                                size: 12.pt
                              ).asExpanded(),
                              SizedBox(
                                width: 10.pt,
                              ),
                              WisText(
                                '金额',
                                color: colorScheme.mainTitle,
                                size: 12.pt,
                                bold: true,
                              ),
                            ],
                          ),
                          for (FeeTypeFeesOfOweFeeCountModel item
                              in store.oweCount?.feeTypeFees ?? [])
                            _BuildFeeItem(item.feeType ?? '',
                                item.fee != null ? '${item.fee}' : ''),
                        ],
                      ),
                    ),
                  ]
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
