import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:intl/intl.dart';
import 'package:unit2/model/profile/basic_information/primary-information.dart';
import 'package:unit2/theme-data.dart/colors.dart';
import 'package:unit2/theme-data.dart/form-style.dart';
import 'package:unit2/utils/global.dart';
import 'package:unit2/utils/text_container.dart';

class PrimaryInfo extends StatefulWidget {
  final PrimaryInformation primaryInformation;
  const PrimaryInfo({super.key, required this.primaryInformation});

  @override
  State<PrimaryInfo> createState() => _PrimaryInfoState();
}

class _PrimaryInfoState extends State<PrimaryInfo> {
  @override
  Widget build(BuildContext context) {
    final _formKey = GlobalKey<FormBuilderState>();
    bool enabled = false;
     DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
    return Scaffold(
        appBar: AppBar(
          title: const Text(primaryInformationScreenTitle),
          centerTitle: true,
          backgroundColor: primary,
        ),
        body: Container(
          padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 24),
          child: FormBuilder(
              child: Column(
            children: [
              FormBuilderTextField(
                enabled: enabled,
                name: lastname,
                initialValue: widget.primaryInformation.lastName!,
                decoration: normalTextFieldStyle("Last name", ""),

              ),
              const SizedBox(height: 15,),
                 FormBuilderTextField(
                enabled: enabled,
                name: firstname,
                initialValue: widget.primaryInformation.firstName!,
                decoration: normalTextFieldStyle("First name", ""),
              ),
              const SizedBox(height: 15,),
              SizedBox(
                width: screenWidth,
                child: Row(children: [
                  Flexible(
                    flex: 2,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: middlename,
                initialValue: widget.primaryInformation.middleName!,
                decoration: normalTextFieldStyle("Middle name", ""),
              ),),
              const SizedBox(width: 10,),
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: extensionName,
                initialValue: widget.primaryInformation.nameExtension??='N/A',
                decoration: normalTextFieldStyle("Name extension", ""),
              ),)
                ]),
                
              ),
              const SizedBox(height: 15,),
               SizedBox(width: screenWidth,
               child:  Row(children: [
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: extensionName,
                initialValue: dteFormat2.format(widget.primaryInformation.birthdate!),
                decoration: normalTextFieldStyle("Birth date", ""),
              ),),
              const SizedBox(width: 10,),
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: sex,
                initialValue: widget.primaryInformation.sex!,
                decoration: normalTextFieldStyle("Sex", ""),
              ),)
                ]),),
                  const SizedBox(height: 15,),
               SizedBox(width: screenWidth,
               child:  Row(children: [
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: bloodType,
                initialValue:widget.primaryInformation.bloodType!,
                decoration: normalTextFieldStyle("Blood type", ""),
              ),),
              const SizedBox(width: 10,),
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: civilStatus,
                initialValue: widget.primaryInformation.civilStatus!,
                decoration: normalTextFieldStyle("Civil Status", ""),
              ),),
                    const SizedBox(width: 10,),
                 Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: gender,
                initialValue:widget.primaryInformation.gender??="N/A",
                decoration: normalTextFieldStyle("Gender", ""),
              ),),
                ]),),
                
              const SizedBox(height: 15,),
              SizedBox(width: screenWidth,
               child:  Row(children: [
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: height,
                initialValue:widget.primaryInformation.heightM!.toString(),
                decoration: normalTextFieldStyle("Height", ""),
              ),),
              const SizedBox(width: 10,),
                  Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: width,
                initialValue: widget.primaryInformation.weightKg!.toString(),
                decoration: normalTextFieldStyle("Weight", ""),
              ),),
                    const SizedBox(width: 10,),
                 Flexible(
                    flex: 1,
                    child:     FormBuilderTextField(
                enabled: enabled,
                name: prefixSuffix,
                initialValue:"${widget.primaryInformation.titlePrefix??="NA"} | ${widget.primaryInformation.titleSuffix??="N/A"}",
                decoration: normalTextFieldStyle("Title Prefix and Suffix", ""),
              ),),
                ]),),
            ],
          )),
        ));
  }
}
