import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:unit2/bloc/passo/land/land_property_owner_info/land_property_owner_info_bloc.dart';
import 'package:unit2/model/passo/land_property_owner.dart';
import 'package:unit2/screens/passo/Land/add_land.dart';
import 'package:unit2/widgets/passo/custom_button.dart';
import 'package:unit2/widgets/passo/custom_formBuilder_fields.dart';

class LandPropertyOwnerInfo extends StatefulWidget {
  Function NextBtn;
  LandPropertyOwnerInfo(this.NextBtn);
  @override
  _LandPropertyOwnerInfo createState() => _LandPropertyOwnerInfo();
}

class _LandPropertyOwnerInfo extends State<LandPropertyOwnerInfo> {
  final transaction_codes = ['New', 'Revision'];
  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
        child: Padding(
      padding: const EdgeInsets.all(15.0),
      child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Container(
              margin:
                  const EdgeInsets.only(left: 0, top: 20, right: 0, bottom: 10),
              child: const Text('PROPERTY OWNER INFO',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
                  textAlign: TextAlign.left),
            ),
            const SizedBox(height: 15),
            customDropDownField(
                "Transaction Code", "", "transaction_code", transaction_codes),
            customTextField("ARP No./ TD No.", "", "td_no"),
            customTextField("Owner", "", "owner"),
            Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(flex: 1, child: customTextField("PIN", "", "pin")),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customTextField("TIN", "", "tin"))
                ]),
            Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: customTextField("OCT/TCT CLOA No.", "", "cloa_no"),
                  ),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customDatTimePicker("Dated", "", "dated"))
                ]),
            Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: customTextField("Survey No.", "", "survey_no"),
                  ),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customTextField("Lot No.", "", "lot_no")),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customTextField("Blk", "", "blk")),
                ]),

            Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: customTextField("Address", "", "address"),
                  ),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customTextField("Tel No.", "", "tel_no"))
                ]),
            Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: customTextField(
                        "Administrator/Beneficial User", "", "admin"),
                  ),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customTextField("TIN", "", "admin_tin"))
                ]),
            Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: customTextField("Address", "", "admin_address"),
                  ),
                  const SizedBox(width: 10.0),
                  Expanded(
                      // optional flex property if flex is 1 because the default flex is 1
                      flex: 1,
                      child: customTextField("Tel No.", "", "admin_telno"))
                ]),

            // SizedBox(
            //   width: double.infinity,
            //   height: 50,
            //   child: ElevatedButton(
            //       style: secondaryBtnStyle(const Color(0xffd92828),
            //           Color.fromARGB(0, 253, 252, 252), Colors.white54),
            //       child: const Text(
            //         "SUBMIT & PROCEED",
            //         style: TextStyle(
            //             color: Color.fromARGB(239, 255, 255, 255),
            //             fontWeight: FontWeight.w700),
            //       ),
            //       onPressed: () {
            //         // formKey.currentState?.save();
            //         // // var faas = PropertyInfo(
            //         // //     id: 1,
            //         // //     transCode: formKey
            //         // //         .currentState!.value['transaction_code']
            //         // //         .toString(),
            //         // //     tdn: formKey.currentState!.value['arp_td'],
            //         // //     pin: formKey.currentState!.value['pin'],
            //         // //     owner: formKey.currentState!.value['owner'],
            //         // //     address: formKey.currentState!.value['address'],
            //         // //     telno: formKey.currentState!.value['tel_no'],
            //         // //     tin: formKey.currentState!.value['tin'],
            //         // //     adminUser: formKey.currentState!.value['benificiary'],
            //         // //     adminAddress: formKey
            //         // //         .currentState!.value['benificiary_address'],
            //         // //     adminTin:
            //         // //         formKey.currentState!.value['benificiary_tin'],
            //         // //     adminTelno:
            //         // //         formKey.currentState!.value['benificiary_telno']);
            //         // // context.read<AssessorsBloc>().add(AddFaas(faas: faas));
            //         // // _loadTempId();
            //         // _pageController.nextPage(
            //         //     duration: _kDuration, curve: _kCurve);
            //       }),
            // ),
            SizedBox(
              height: 30,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                CustomButton(
                  icon: const Icon(Icons.chevron_right, color: Colors.white),
                  onPressed: () {
                    var land = LandPropertyOwner(
                        id: 1,
                        transCode: landKey
                            .currentState!.value['transaction_code']
                            .toString(),
                        tdn: landKey.currentState!.value['td_no'],
                        cloaNo: landKey.currentState!.value['cloa_no'],
                        dated: landKey.currentState!.value['dated'],
                        assessedById: "1",
                        assessedByName: "cyril",
                        dateCreated: landKey.currentState!.value['dated'],
                        dateModified: landKey.currentState!.value['dated'],
                        pin: landKey.currentState!.value['pin'],
                        surveyNo: landKey.currentState!.value['survey_no'],
                        lotNo: landKey.currentState!.value['lot_no'],
                        blkNo: landKey.currentState!.value['blk'],
                        owner: landKey.currentState!.value['owner'],
                        address: landKey.currentState!.value['address'],
                        telno: landKey.currentState!.value['tel_no'],
                        tin: landKey.currentState!.value['tin'],
                        adminUser: landKey.currentState!.value['admin'],
                        adminAddress:
                            landKey.currentState!.value['admin_address'],
                        adminTin: landKey.currentState!.value['admin_tin'],
                        // faasType: "LAND",
                        adminTelno: landKey.currentState!.value['admin_telno']);

                    context
                        .read<LandPropertyOwnerInfoBloc>()
                        .add(AddPropertyOwnerLand(land: land));

                    widget.NextBtn();
                  },
                )
              ],
            ),
            const SizedBox(
              height: 20,
            ),
          ]),
    ));
  }
}
