import 'package:cpt_rewards/modules/rewards_successful/rewards_successful_page.dart';
import 'package:cs_resources/generated/assets.dart';
import 'package:cs_resources/generated/l10n.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_load_image.dart';
import 'package:widgets/my_text_view.dart';
import 'package:widgets/widget_export.dart';
import '../rewards_confirm_vm.dart';

class AccountDeactivationDialog extends HookConsumerWidget {
  VoidCallback confirmAction;

  AccountDeactivationDialog({
    required this.confirmAction,
  });

  Widget CheckboxList(BuildContext context, ref) {
    final state = ref.watch(rewardsConfirmVmProvider);
    int amount = state.amount ?? 0;
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Text(
          textAlign: TextAlign.center,
          S.current.sure_redeem_goods(amount),
          style: const TextStyle(
              fontSize: 19.0, color: Colors.black, fontWeight: FontWeight.w500),
        ).paddingOnly(left: 40, right: 40)
      ],
    );
  }

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final _vm = ref.read(rewardsConfirmVmProvider.notifier);
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Container(
          width: double.infinity,
          height: 55,
          decoration: BoxDecoration(
            color: context.appColors.btnBgDefault,
            borderRadius: const BorderRadius.only(
              topRight: Radius.circular(15),
              topLeft: Radius.circular(15),
            ),
          ),
          child: Row(
            children: [
              const SizedBox(width: 45),
              MyTextView(
                S.current.points_payment,
                fontSize: 18,
                textAlign: TextAlign.center,
                isFontMedium: true,
                textColor: Colors.white,
              ).expanded(),
              const MyAssetImage(
                Assets.baseServiceDialogDeleteIcon,
                width: 25,
                height: 25.5,
              ).onTap(() {
                onCancel();
              }, padding: 10)
            ],
          ),
        ),
        Container(
          width: double.infinity,
          padding: const EdgeInsets.only(top: 22),
          decoration: BoxDecoration(
            color: context.appColors.whiteSecondBG,
            borderRadius: const BorderRadius.only(
              bottomLeft: Radius.circular(15),
              bottomRight: Radius.circular(15),
            ),
          ),
          child: Column(
            children: [
              Container(height: 150, child: CheckboxList(context, ref)),
              Row(
                children: [
                  const SizedBox(width: 18),
                  Expanded(
                      flex: 1,
                      child: InkWell(
                        onTap: () async {
                          onCancel();
                          // RewardsSuccessfulPage.startInstance();
                          _vm.rewardBuy();
                        },
                        child: MyTextView(
                          S.current.pay_now,
                          fontSize: 16,
                          paddingTop: 13,
                          paddingBottom: 13,
                          isFontMedium: true,
                          textAlign: TextAlign.center,
                          textColor: Colors.white,
                          backgroundColor: context.appColors.btnBgDefault,
                          cornerRadius: 7,
                        ),
                      )),
                  const SizedBox(width: 18),
                ],
              ).marginOnly(bottom: 30, top: 28),
            ],
          ),
        ),
      ],
    ).constrained(width: 340);
  }

//取消弹框
  void onCancel() async {
    SmartDialog.dismiss();
  }
}
