import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart';
import 'package:diplomaticquarterapp/pages/login/login-type.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart';
import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class RegisterInfo extends StatefulWidget {
  @override
  _RegisterInfo createState() => _RegisterInfo();
}

class _RegisterInfo extends State<RegisterInfo> {
  final authService = new AuthProvider();
  final sharedPref = new AppSharedPreferences();
  RegisterInfoResponse registerInfo;
  bool isLoading;
  int page = 1;
  @override
  void initState() {
    getRegisterInfo();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
        appBarTitle: TranslationBase.of(context).register,
        isShowAppBar: true,
        body: SingleChildScrollView(
            child: Container(
          padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30),
          height: SizeConfig.realScreenHeight * .9,
          width: SizeConfig.realScreenWidth,
          child: Column(children: <Widget>[
            Expanded(
                flex: 1,
                child: AppText(
                  TranslationBase.of(context).patientInfo,
                  fontSize: SizeConfig.textMultiplier * 3,
                  textAlign: TextAlign.left,
                )),
            registerInfo != null && page == 1
                ? Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    children: <Widget>[
                      AppText('National ID'),
                      Container(
                          margin: EdgeInsets.only(bottom: 10),
                          child: TextFields(
                            hintText: registerInfo.idNumber,
                            prefixIcon: Icon(Icons.chrome_reader_mode,
                                color: Colors.red),
                            padding: EdgeInsets.only(
                                top: 20, bottom: 20, left: 10, right: 10),
                            readOnly: true,
                          )),
                      AppText('Name'),
                      Container(
                          margin: EdgeInsets.only(bottom: 10),
                          child: TextFields(
                            hintText: registerInfo.firstNameEn +
                                ' ' +
                                registerInfo.lastNameEn,
                            padding: EdgeInsets.only(
                                top: 20, bottom: 20, left: 10, right: 10),
                            readOnly: true,
                          )),
                      AppText('Gender'),
                      Container(
                          margin: EdgeInsets.only(bottom: 10),
                          child: TextFields(
                            hintText: registerInfo.maritalStatusCode == 'U'
                                ? 'Unknown'
                                : registerInfo.maritalStatusCode == 'M'
                                    ? 'Male'
                                    : 'Female',
                            padding: EdgeInsets.only(
                                top: 20, bottom: 20, left: 10, right: 10),
                            readOnly: true,
                          )),
                      AppText('Nationality'),
                      Container(
                          margin: EdgeInsets.only(bottom: 10),
                          child: TextFields(
                            hintText: registerInfo.nationalityCode,
                            padding: EdgeInsets.only(
                                top: 20, bottom: 20, left: 10, right: 10),
                            readOnly: true,
                          )),
                      AppText('Date of Birth'),
                      Container(
                          margin: EdgeInsets.only(bottom: 10),
                          child: TextFields(
                            hintText: registerInfo.dateOfBirth,
                            padding: EdgeInsets.only(
                                top: 20, bottom: 20, left: 10, right: 10),
                            readOnly: true,
                          )),
                    ],
                  )
                : registerInfo != null && page == 2
                    ? Column(
                        children: <Widget>[],
                      )
                    : SizedBox(),
            Expanded(
                flex: 2,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        Expanded(
                            child: DefaultButton(
                          TranslationBase.of(context).next,
                          () => {nextPage()},
                          textColor: Colors.white,
                        ))
                      ],
                    ),
                  ],
                ))
          ]),
        )));
  }

  nextPage() {
    setState(() {
      page++;
    });
  }

  registerNow() {}
  getRegisterInfo() async {
    registerInfo =
        RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA));

    print(await sharedPref.getObject(NHIC_DATA));
  }
}
