import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vitalapp/components/cell.dart';
import 'package:vitalapp/components/dialog_select.dart';
import 'package:vitalapp/pages/contract/package_list/controller.dart';

class SigningStatusPage extends GetView<ServicePackageContractController> {
  const SigningStatusPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 16),
      child: Column(
        children: [
          Obx(
            () => VListFormCellGroup(
              children: [
                VListFormCell(
                  label: '签约状态',
                  content: controller.state.signingStatus,
                  onTap: () async {
                    final result = await VDialogSelect<String, String>(
                      title: "签约状态",
                      source: const ['签约', '拒签'],
                      valueGetter: (data) => data,
                      labelGetter: (data) => data,
                      initialValue: controller.state.signingStatus,
                    ).show();
                    if (result != null) {
                      controller.state.signingStatus = result;
                    }
                  },
                ),
                if (controller.state.signingStatus == '拒签')
                  VListFormCell(
                    label: '拒签原因',
                    content: controller.state.reasonRefusal,
                    onTap: () async {
                      final result = await VDialogSelect<String, String>(
                        title: "拒签原因",
                        source: const [
                          '不自愿',
                          '举家外出',
                          '外出上学',
                          '婚出',
                          '服役',
                          '服刑',
                          '其他'
                        ],
                        valueGetter: (data) => data,
                        labelGetter: (data) => data,
                        initialValue: controller.state.reasonRefusal,
                      ).show();
                      if (result != null) {
                        controller.state.reasonRefusal = result;
                      }
                    },
                  ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
