import '/backend/api_requests/api_calls.dart';
import '/components/alert_box_custom_o_k_widget.dart';
import '/components/alert_box_custom_widget.dart';
import '/flutterlib/flutter_drop_down.dart';
import '/flutterlib/flutter_icon_button.dart';
import '/flutterlib/flutter_radio_button.dart';
import '/flutterlib/flutter_theme.dart';
import '/flutterlib/flutter_util.dart';
import '/flutterlib/flutter_widgets.dart';
import '/flutterlib/form_field_controller.dart';
import '/flutterlib/upload_data.dart';
import '/flutterlib/custom_functions.dart' as functions;
import 'package:aligned_dialog/aligned_dialog.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'update_member_model.dart';
export 'update_member_model.dart';

class UpdateMemberWidget extends StatefulWidget {
  const UpdateMemberWidget({
    Key? key,
    this.memberData,
    required this.companyID,
  }) : super(key: key);

  final dynamic memberData;
  final dynamic companyID;

  @override
  _UpdateMemberWidgetState createState() => _UpdateMemberWidgetState();
}

class _UpdateMemberWidgetState extends State<UpdateMemberWidget> {
  late UpdateMemberModel _model;

  @override
  void setState(VoidCallback callback) {
    super.setState(callback);
    _model.onUpdate();
  }

  @override
  void initState() {
    super.initState();
    _model = createModel(context, () => UpdateMemberModel());

    _model.nameEnglishController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.name_english''',
    ).toString().toString());
    _model.nameEnglishFocusNode ??= FocusNode();

    _model.nameChineseController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.name_chinese''',
    ).toString().toString());
    _model.nameChineseFocusNode ??= FocusNode();

    _model.phoneController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.phone''',
    ).toString().toString());
    _model.phoneFocusNode ??= FocusNode();

    _model.emailController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.email''',
    ).toString().toString());
    _model.emailFocusNode ??= FocusNode();

    _model.dateController ??= TextEditingController(
        text: '${getJsonField(
      widget.memberData,
      r'''$.year_date''',
    ).toString().toString()}/${getJsonField(
      widget.memberData,
      r'''$.month_date''',
    ).toString().toString()}/${getJsonField(
      widget.memberData,
      r'''$.day_date''',
    ).toString().toString()}');
    _model.dateFocusNode ??= FocusNode();

    _model.documentNoController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.document_number''',
    ).toString().toString());
    _model.documentNoFocusNode ??= FocusNode();

    _model.countryController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.country''',
    ).toString().toString());
    _model.countryFocusNode ??= FocusNode();

    _model.cityController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.city''',
    ).toString().toString());
    _model.cityFocusNode ??= FocusNode();

    _model.addressEnController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.address_english''',
    ).toString().toString());
    _model.addressEnFocusNode ??= FocusNode();

    _model.addressCnController ??= TextEditingController(
        text: getJsonField(
      widget.memberData,
      r'''$.address_chinese''',
    ).toString().toString());
    _model.addressCnFocusNode ??= FocusNode();
  }

  @override
  void dispose() {
    _model.maybeDispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    context.watch<FFAppState>();

    return Align(
      alignment: AlignmentDirectional(0.0, 0.0),
      child: Form(
        key: _model.formKey,
        autovalidateMode: AutovalidateMode.disabled,
        child: SingleChildScrollView(
          child: Column(
            mainAxisSize: MainAxisSize.max,
            children: [
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Align(
                    alignment: AlignmentDirectional(-1.0, 0.0),
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 20.0, 0.0, 0.0),
                      child: FlutterRadioButton(
                        options: [
                          FFLocalizations.of(context).getText(
                            'daas505c' /* Director */,
                          ),
                          FFLocalizations.of(context).getText(
                            'amzqgzcc' /* Shareholder */,
                          ),
                          FFLocalizations.of(context).getText(
                            'hmc3gs5v' /* Company Secretary */,
                          )
                        ].toList(),
                        onChanged: (val) => setState(() {}),
                        controller: _model.positionValueController ??=
                            FormFieldController<String>(
                                functions.positionLabel(getJsonField(
                          widget.memberData,
                          r'''$.position''',
                        ).toString())!),
                        optionHeight: 32.0,
                        textStyle: FlutterTheme.of(context).labelMedium,
                        buttonPosition: RadioButtonPosition.left,
                        direction: Axis.vertical,
                        radioButtonColor: FlutterTheme.of(context).primary,
                        inactiveRadioButtonColor:
                            FlutterTheme.of(context).secondaryText,
                        toggleable: false,
                        horizontalAlignment: WrapAlignment.start,
                        verticalAlignment: WrapCrossAlignment.start,
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'rcfvxura' /* TItle */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    FlutterDropDown<String>(
                      controller: _model.titleValueController ??=
                          FormFieldController<String>(
                        _model.titleValue ??= getJsonField(
                          widget.memberData,
                          r'''$.title''',
                        ).toString(),
                      ),
                      options: List<String>.from(['mr', 'mrs', 'miss']),
                      optionLabels: [
                        FFLocalizations.of(context).getText(
                          '6zx9k4pb' /* Mr */,
                        ),
                        FFLocalizations.of(context).getText(
                          '8iqd970r' /* Mrs */,
                        ),
                        FFLocalizations.of(context).getText(
                          '8zqupoo0' /* Miss */,
                        )
                      ],
                      onChanged: (val) =>
                          setState(() => _model.titleValue = val),
                      width: 326.0,
                      height: 40.0,
                      textStyle: FlutterTheme.of(context).bodyMedium,
                      hintText: FFLocalizations.of(context).getText(
                        '64xcc4g4' /* Please select... */,
                      ),
                      icon: Icon(
                        Icons.keyboard_arrow_down_rounded,
                        color: FlutterTheme.of(context).secondaryText,
                        size: 24.0,
                      ),
                      fillColor: Color(0xFFEBEBE4),
                      elevation: 2.0,
                      borderColor: FlutterTheme.of(context).alternate,
                      borderWidth: 2.0,
                      borderRadius: 40.0,
                      margin:
                          EdgeInsetsDirectional.fromSTEB(16.0, 4.0, 16.0, 4.0),
                      hidesUnderline: true,
                      isSearchable: false,
                      isMultiSelect: false,
                    ),
                  ],
                ),
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'xo7oiuz0' /* Name(English) */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.nameEnglishController,
                          focusNode: _model.nameEnglishFocusNode,
                          autofocus: true,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.name,
                          validator: _model.nameEnglishControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'j04e2w4k' /* Name(Chinese) */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.nameChineseController,
                          focusNode: _model.nameChineseFocusNode,
                          autofocus: true,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.name,
                          validator: _model.nameChineseControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'c0ce4wyg' /* Contact number */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.phoneController,
                          focusNode: _model.phoneFocusNode,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.number,
                          validator: _model.phoneControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'e4ai3yns' /* Email */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.emailController,
                          focusNode: _model.emailFocusNode,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.emailAddress,
                          validator: _model.emailControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'zw7s85vs' /* Date of Birth */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.dateController,
                          focusNode: _model.dateFocusNode,
                          textCapitalization: TextCapitalization.none,
                          readOnly: true,
                          obscureText: false,
                          decoration: InputDecoration(
                            hintText: FFLocalizations.of(context).getText(
                              '3w6nzzge' /* YYYY/MM/DD */,
                            ),
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.datetime,
                          validator: _model.dateControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 8.0, 0.0),
                    child: FlutterIconButton(
                      borderColor: FlutterTheme.of(context).primaryText,
                      borderRadius: 20.0,
                      borderWidth: 1.0,
                      buttonSize: 40.0,
                      fillColor:
                          FlutterTheme.of(context).secondaryBackground,
                      icon: Icon(
                        Icons.calendar_month,
                        color: FlutterTheme.of(context).primaryText,
                        size: 24.0,
                      ),
                      onPressed: () async {
                        final _datePickedDate = await showDatePicker(
                          context: context,
                          initialDate: getCurrentTimestamp,
                          firstDate: DateTime(1900),
                          lastDate: getCurrentTimestamp,
                        );

                        if (_datePickedDate != null) {
                          safeSetState(() {
                            _model.datePicked = DateTime(
                              _datePickedDate.year,
                              _datePickedDate.month,
                              _datePickedDate.day,
                            );
                          });
                        }
                        setState(() {
                          _model.dateController?.text = functions
                              .formatDate(_model.datePicked!.toString());
                        });
                        setState(() {
                          _model.setBirthDate = true;
                        });
                      },
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'shcd8b2v' /* Type of document */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    FlutterDropDown<String>(
                      controller: _model.documentTypeValueController ??=
                          FormFieldController<String>(
                        _model.documentTypeValue ??= getJsonField(
                          widget.memberData,
                          r'''$.document_type''',
                        ).toString(),
                      ),
                      options: [
                        FFLocalizations.of(context).getText(
                          'lbzm113k' /* HongKong(HKID) */,
                        ),
                        FFLocalizations.of(context).getText(
                          'pbsdtu7w' /* Passport */,
                        )
                      ],
                      onChanged: (val) =>
                          setState(() => _model.documentTypeValue = val),
                      width: 326.0,
                      height: 40.0,
                      textStyle: FlutterTheme.of(context).bodyMedium,
                      hintText: FFLocalizations.of(context).getText(
                        'uaxuivep' /* Please select... */,
                      ),
                      icon: Icon(
                        Icons.keyboard_arrow_down_rounded,
                        color: FlutterTheme.of(context).secondaryText,
                        size: 24.0,
                      ),
                      fillColor: Color(0xFFEBEBE4),
                      elevation: 2.0,
                      borderColor: FlutterTheme.of(context).alternate,
                      borderWidth: 2.0,
                      borderRadius: 40.0,
                      margin:
                          EdgeInsetsDirectional.fromSTEB(16.0, 4.0, 16.0, 4.0),
                      hidesUnderline: true,
                      isSearchable: false,
                      isMultiSelect: false,
                    ),
                  ],
                ),
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'xgq6sphy' /* Document no. */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.documentNoController,
                          focusNode: _model.documentNoFocusNode,
                          autofocus: true,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          validator: _model.documentNoControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          '9dyzzn6x' /* Country */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.countryController,
                          focusNode: _model.countryFocusNode,
                          autofocus: true,
                          textCapitalization: TextCapitalization.words,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          validator: _model.countryControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'oyorcxzb' /* City */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.cityController,
                          focusNode: _model.cityFocusNode,
                          autofocus: true,
                          textCapitalization: TextCapitalization.words,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          validator: _model.cityControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'znx7b03q' /* Address(English) */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.addressEnController,
                          focusNode: _model.addressEnFocusNode,
                          textCapitalization: TextCapitalization.words,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.multiline,
                          validator: _model.addressEnControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'tjz8k3zh' /* Address(Chinese) */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              Row(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Expanded(
                    child: Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0),
                      child: Container(
                        width: 326.0,
                        child: TextFormField(
                          controller: _model.addressCnController,
                          focusNode: _model.addressCnFocusNode,
                          textInputAction: TextInputAction.next,
                          obscureText: false,
                          decoration: InputDecoration(
                            labelStyle:
                                FlutterTheme.of(context).labelMedium,
                            hintStyle: FlutterTheme.of(context).labelMedium,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Color(0xFF6D7581),
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).primary,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            errorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            focusedErrorBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: FlutterTheme.of(context).error,
                                width: 2.0,
                              ),
                              borderRadius: BorderRadius.circular(23.8),
                            ),
                            filled: true,
                            fillColor: Colors.white,
                          ),
                          style:
                              FlutterTheme.of(context).bodyMedium.override(
                                    fontFamily: 'Readex Pro',
                                    fontSize: 16.0,
                                  ),
                          keyboardType: TextInputType.multiline,
                          validator: _model.addressCnControllerValidator
                              .asValidator(context),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
              Padding(
                padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Padding(
                      padding:
                          EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                      child: Text(
                        FFLocalizations.of(context).getText(
                          'dvr4tji1' /* Copy of document */,
                        ),
                        style: FlutterTheme.of(context).bodyMedium.override(
                              fontFamily: 'Roboto',
                              color: Colors.black,
                              fontSize: 16.0,
                              fontWeight: FontWeight.w500,
                            ),
                      ),
                    ),
                  ],
                ),
              ),
              if ((_model.uploadPhoto == true) ||
                  (_model.reuploadPhoto == true) ||
                  (getJsonField(
                        widget.memberData,
                        r'''$.documents[:].url''',
                      ) !=
                      null))
                Padding(
                  padding: EdgeInsetsDirectional.fromSTEB(0.0, 5.0, 0.0, 12.0),
                  child: Row(
                    mainAxisSize: MainAxisSize.max,
                    children: [
                      Padding(
                        padding:
                            EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
                        child: InkWell(
                          splashColor: Colors.transparent,
                          focusColor: Colors.transparent,
                          hoverColor: Colors.transparent,
                          highlightColor: Colors.transparent,
                          onTap: () async {
                            _model.deleteDocument1 = await NumstationGroup
                                .deleteMemberDocumentCall
                                .call(
                              token: FFAppState().token,
                              id: getJsonField(
                                widget.memberData,
                                r'''$.documents[:].id''',
                              ),
                            );
                            if ((_model.deleteDocument1?.succeeded ?? true)) {
                              await showDialog(
                                context: context,
                                builder: (alertDialogContext) {
                                  return AlertDialog(
                                    content: Text(
                                        'Document deleted! Please upload a new document.'),
                                    actions: [
                                      TextButton(
                                        onPressed: () =>
                                            Navigator.pop(alertDialogContext),
                                        child: Text('Ok'),
                                      ),
                                    ],
                                  );
                                },
                              );
                            }
                            setState(() {
                              _model.isDataUploading2 = false;
                              _model.uploadedLocalFile2 =
                                  FFUploadedFile(bytes: Uint8List.fromList([]));
                            });

                            final selectedMedia =
                                await selectMediaWithSourceBottomSheet(
                              context: context,
                              allowPhoto: true,
                            );
                            if (selectedMedia != null &&
                                selectedMedia.every((m) => validateFileFormat(
                                    m.storagePath, context))) {
                              setState(() => _model.isDataUploading1 = true);
                              var selectedUploadedFiles = <FFUploadedFile>[];

                              try {
                                selectedUploadedFiles = selectedMedia
                                    .map((m) => FFUploadedFile(
                                          name: m.storagePath.split('/').last,
                                          bytes: m.bytes,
                                          height: m.dimensions?.height,
                                          width: m.dimensions?.width,
                                          blurHash: m.blurHash,
                                        ))
                                    .toList();
                              } finally {
                                _model.isDataUploading1 = false;
                              }
                              if (selectedUploadedFiles.length ==
                                  selectedMedia.length) {
                                setState(() {
                                  _model.uploadedLocalFile1 =
                                      selectedUploadedFiles.first;
                                });
                              } else {
                                setState(() {});
                                return;
                              }
                            }

                            setState(() {
                              _model.uploadPhoto = false;
                              _model.reuploadPhoto = true;
                              _model.hideApiPhoto = false;
                            });

                            setState(() {});
                          },
                          child: Text(
                            FFLocalizations.of(context).getText(
                              'u4no1wm8' /* Reupload */,
                            ),
                            style: FlutterTheme.of(context)
                                .bodyMedium
                                .override(
                                  fontFamily: 'Roboto',
                                  color: Color(0xFF009B9A),
                                  fontSize: 16.0,
                                  fontWeight: FontWeight.w500,
                                  decoration: TextDecoration.underline,
                                ),
                          ),
                        ),
                      ),
                      Flexible(
                        child: Align(
                          alignment: AlignmentDirectional(1.0, 0.0),
                          child: Builder(
                            builder: (context) => Padding(
                              padding: EdgeInsetsDirectional.fromSTEB(
                                  0.0, 0.0, 16.0, 0.0),
                              child: InkWell(
                                splashColor: Colors.transparent,
                                focusColor: Colors.transparent,
                                hoverColor: Colors.transparent,
                                highlightColor: Colors.transparent,
                                onTap: () async {
                                  _model.deleteDocument = await NumstationGroup
                                      .deleteMemberDocumentCall
                                      .call(
                                    token: FFAppState().token,
                                    id: getJsonField(
                                      widget.memberData,
                                      r'''$.documents[:].id''',
                                    ),
                                  );
                                  if ((_model.deleteDocument?.succeeded ??
                                      true)) {
                                    await showAlignedDialog(
                                      context: context,
                                      isGlobal: true,
                                      avoidOverflow: false,
                                      targetAnchor: AlignmentDirectional(
                                              0.0, 0.0)
                                          .resolve(Directionality.of(context)),
                                      followerAnchor: AlignmentDirectional(
                                              0.0, 0.0)
                                          .resolve(Directionality.of(context)),
                                      builder: (dialogContext) {
                                        return Material(
                                          color: Colors.transparent,
                                          child: AlertBoxCustomOKWidget(
                                            text: 'Document deleted!',
                                          ),
                                        );
                                      },
                                    ).then((value) => setState(() {}));
                                  } else {
                                    if (_model.reuploadPhoto == false) {
                                      setState(() {
                                        _model.isDataUploading2 = false;
                                        _model.uploadedLocalFile2 =
                                            FFUploadedFile(
                                                bytes: Uint8List.fromList([]));
                                      });
                                    } else {
                                      setState(() {
                                        _model.isDataUploading1 = false;
                                        _model.uploadedLocalFile1 =
                                            FFUploadedFile(
                                                bytes: Uint8List.fromList([]));
                                      });
                                    }

                                    setState(() {
                                      _model.uploadPhoto = false;
                                      _model.reuploadPhoto = false;
                                    });
                                  }

                                  setState(() {});
                                },
                                child: Text(
                                  FFLocalizations.of(context).getText(
                                    'c13addax' /* Delete */,
                                  ),
                                  style: FlutterTheme.of(context)
                                      .bodyMedium
                                      .override(
                                        fontFamily: 'Roboto',
                                        color:
                                            FlutterTheme.of(context).error,
                                        fontSize: 16.0,
                                        fontWeight: FontWeight.w500,
                                        decoration: TextDecoration.underline,
                                      ),
                                ),
                              ),
                            ),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              if ((_model.uploadPhoto == true) ||
                  (_model.reuploadPhoto == true) ||
                  (getJsonField(
                        widget.memberData,
                        r'''$.documents[:].url''',
                      ) !=
                      null))
                Padding(
                  padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 0.0),
                  child: Container(
                    width: 326.0,
                    height: 140.0,
                    decoration: BoxDecoration(
                      color: FlutterTheme.of(context).secondaryBackground,
                      borderRadius: BorderRadius.circular(8.0),
                      border: Border.all(
                        color: Colors.black,
                      ),
                    ),
                    child: Align(
                      alignment: AlignmentDirectional(0.0, 0.0),
                      child: Column(
                        mainAxisSize: MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          if ((_model.uploadPhoto == false) &&
                              (_model.reuploadPhoto == false) &&
                              (getJsonField(
                                    widget.memberData,
                                    r'''$.documents[:].url''',
                                  ) !=
                                  null))
                            Container(
                              decoration: BoxDecoration(),
                              child: ClipRRect(
                                borderRadius: BorderRadius.circular(8.0),
                                child: Image.network(
                                  getJsonField(
                                    widget.memberData,
                                    r'''$.documents[:].url''',
                                  ).toString(),
                                  width: 245.0,
                                  height: 127.0,
                                  fit: BoxFit.cover,
                                ),
                              ),
                            ),
                          if (_model.reuploadPhoto == true)
                            Container(
                              decoration: BoxDecoration(),
                              child: ClipRRect(
                                borderRadius: BorderRadius.circular(8.0),
                                child: Image.memory(
                                  _model.uploadedLocalFile1.bytes ??
                                      Uint8List.fromList([]),
                                  width: 245.0,
                                  height: 127.0,
                                  fit: BoxFit.cover,
                                ),
                              ),
                            ),
                          if (_model.uploadPhoto == true)
                            Container(
                              decoration: BoxDecoration(),
                              child: ClipRRect(
                                borderRadius: BorderRadius.circular(8.0),
                                child: Image.memory(
                                  _model.uploadedLocalFile2.bytes ??
                                      Uint8List.fromList([]),
                                  width: 245.0,
                                  height: 127.0,
                                  fit: BoxFit.cover,
                                ),
                              ),
                            ),
                        ],
                      ),
                    ),
                  ),
                ),
              if ((_model.uploadPhoto == false) &&
                  (getJsonField(
                        widget.memberData,
                        r'''$.documents[:]''',
                      ) ==
                      null) &&
                  (_model.reuploadPhoto == false))
                Padding(
                  padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 0.0),
                  child: InkWell(
                    splashColor: Colors.transparent,
                    focusColor: Colors.transparent,
                    hoverColor: Colors.transparent,
                    highlightColor: Colors.transparent,
                    onTap: () async {
                      final selectedMedia =
                          await selectMediaWithSourceBottomSheet(
                        context: context,
                        imageQuality: 100,
                        allowPhoto: true,
                      );
                      if (selectedMedia != null &&
                          selectedMedia.every((m) =>
                              validateFileFormat(m.storagePath, context))) {
                        setState(() => _model.isDataUploading2 = true);
                        var selectedUploadedFiles = <FFUploadedFile>[];

                        try {
                          selectedUploadedFiles = selectedMedia
                              .map((m) => FFUploadedFile(
                                    name: m.storagePath.split('/').last,
                                    bytes: m.bytes,
                                    height: m.dimensions?.height,
                                    width: m.dimensions?.width,
                                    blurHash: m.blurHash,
                                  ))
                              .toList();
                        } finally {
                          _model.isDataUploading2 = false;
                        }
                        if (selectedUploadedFiles.length ==
                            selectedMedia.length) {
                          setState(() {
                            _model.uploadedLocalFile2 =
                                selectedUploadedFiles.first;
                          });
                        } else {
                          setState(() {});
                          return;
                        }
                      }

                      setState(() {
                        _model.uploadPhoto = true;
                      });
                    },
                    child: Container(
                      width: 326.0,
                      height: 140.0,
                      decoration: BoxDecoration(
                        color: FlutterTheme.of(context).secondaryBackground,
                        borderRadius: BorderRadius.circular(8.0),
                        border: Border.all(
                          color: Colors.black,
                        ),
                      ),
                      child: Column(
                        mainAxisSize: MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          ClipRRect(
                            borderRadius: BorderRadius.circular(8.0),
                            child: SvgPicture.asset(
                              'assets/images/map.svg',
                              width: 28.0,
                              height: 28.0,
                              fit: BoxFit.cover,
                            ),
                          ),
                          Padding(
                            padding: EdgeInsetsDirectional.fromSTEB(
                                0.0, 13.0, 0.0, 0.0),
                            child: Text(
                              FFLocalizations.of(context).getText(
                                '4qw662d2' /* Tap to upload */,
                              ),
                              style: FlutterTheme.of(context).bodyMedium,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              Builder(
                builder: (context) => Padding(
                  padding: EdgeInsetsDirectional.fromSTEB(0.0, 20.0, 0.0, 20.0),
                  child: FFButtonWidget(
                    onPressed: () async {
                      if (_model.setBirthDate == true) {
                        _model.updateMember1 =
                            await NumstationGroup.saveOrUpdateMemberCall.call(
                          token: FFAppState().token,
                          companyId: widget.companyID,
                          position:
                              functions.positionLabel(_model.positionValue),
                          title: _model.titleValue,
                          nameEnglish: _model.nameEnglishController.text,
                          nameChinese: _model.nameChineseController.text,
                          email: _model.emailController.text,
                          phone: int.tryParse(_model.phoneController.text),
                          documentType: _model.documentTypeValue,
                          country: _model.countryController.text,
                          addressEnglish: _model.addressEnController.text,
                          addressChinese: _model.addressCnController.text,
                          documentNumber: _model.documentNoController.text,
                          city: _model.cityController.text,
                          memberId: getJsonField(
                            widget.memberData,
                            r'''$.id''',
                          ),
                          yearDate: dateTimeFormat(
                            'y',
                            _model.datePicked,
                            locale: FFLocalizations.of(context).languageCode,
                          ),
                          monthDate: dateTimeFormat(
                            'MM',
                            _model.datePicked,
                            locale: FFLocalizations.of(context).languageCode,
                          ),
                          dayDate: dateTimeFormat(
                            'dd',
                            _model.datePicked,
                            locale: FFLocalizations.of(context).languageCode,
                          ),
                          documentFile: () {
                            if (_model.uploadPhoto == true) {
                              return _model.uploadedLocalFile2;
                            } else if (_model.reuploadPhoto == true) {
                              return _model.uploadedLocalFile1;
                            } else {
                              return null;
                            }
                          }(),
                        );
                        if (!(_model.updateMember1?.succeeded ?? true)) {
                          await showDialog(
                            context: context,
                            builder: (alertDialogContext) {
                              return AlertDialog(
                                content: Text('Failed!'),
                                actions: [
                                  TextButton(
                                    onPressed: () =>
                                        Navigator.pop(alertDialogContext),
                                    child: Text('Ok'),
                                  ),
                                ],
                              );
                            },
                          );
                        }
                      } else {
                        _model.updateMember2 =
                            await NumstationGroup.saveOrUpdateMemberCall.call(
                          token: FFAppState().token,
                          companyId: widget.companyID,
                          position:
                              functions.positionLabel(_model.positionValue),
                          title: _model.titleValue,
                          nameEnglish: _model.nameEnglishController.text,
                          nameChinese: _model.nameChineseController.text,
                          email: _model.emailController.text,
                          phone: int.tryParse(_model.phoneController.text),
                          documentType: _model.documentTypeValue,
                          country: _model.countryController.text,
                          addressEnglish: _model.addressEnController.text,
                          addressChinese: _model.addressCnController.text,
                          documentNumber: _model.documentNoController.text,
                          city: _model.cityController.text,
                          memberId: getJsonField(
                            widget.memberData,
                            r'''$.id''',
                          ),
                          yearDate: getJsonField(
                            widget.memberData,
                            r'''$.year_date''',
                          ).toString(),
                          monthDate: getJsonField(
                            widget.memberData,
                            r'''$.month_date''',
                          ).toString(),
                          dayDate: getJsonField(
                            widget.memberData,
                            r'''$.day_date''',
                          ).toString(),
                          documentFile: () {
                            if (_model.uploadPhoto == true) {
                              return _model.uploadedLocalFile2;
                            } else if (_model.reuploadPhoto == true) {
                              return _model.uploadedLocalFile1;
                            } else {
                              return null;
                            }
                          }(),
                        );
                        if (!(_model.updateMember2?.succeeded ?? true)) {
                          await showDialog(
                            context: context,
                            builder: (alertDialogContext) {
                              return AlertDialog(
                                content: Text('Failed!'),
                                actions: [
                                  TextButton(
                                    onPressed: () =>
                                        Navigator.pop(alertDialogContext),
                                    child: Text('Ok'),
                                  ),
                                ],
                              );
                            },
                          );
                        }
                      }

                      setState(() {
                        _model.setBirthDate = false;
                      });
                      await showAlignedDialog(
                        context: context,
                        isGlobal: true,
                        avoidOverflow: false,
                        targetAnchor: AlignmentDirectional(0.0, 0.0)
                            .resolve(Directionality.of(context)),
                        followerAnchor: AlignmentDirectional(0.0, 0.0)
                            .resolve(Directionality.of(context)),
                        builder: (dialogContext) {
                          return Material(
                            color: Colors.transparent,
                            child: AlertBoxCustomWidget(
                              text: 'All changes have been changed!',
                            ),
                          );
                        },
                      ).then((value) => setState(() {}));

                      context.pushNamed('dashboard');

                      setState(() {});
                    },
                    text: FFLocalizations.of(context).getText(
                      '43n398i4' /* Save */,
                    ),
                    options: FFButtonOptions(
                      width: 326.0,
                      height: 50.0,
                      padding:
                          EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 20.0),
                      iconPadding:
                          EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
                      color: Color(0xFF009B9A),
                      textStyle:
                          FlutterTheme.of(context).titleSmall.override(
                                fontFamily: 'Roboto',
                                color: Colors.white,
                                fontSize: 20.0,
                              ),
                      elevation: 3.0,
                      borderSide: BorderSide(
                        color: Colors.transparent,
                        width: 1.0,
                      ),
                      borderRadius: BorderRadius.circular(40.0),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
