import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:mohem_flutter_app/api/profile_api_client.dart'; import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/ui/profile/dynamic_screens/dynamic_input_profile_screen.dart'; import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; import 'package:mohem_flutter_app/widgets/button/default_button.dart'; class BasicDetails extends StatefulWidget { const BasicDetails({Key? key}) : super(key: key); @override _BasicDetailsState createState() => _BasicDetailsState(); } class _BasicDetailsState extends State { String? fullName = ""; String? maritalStatus = ""; String? birthDate = ""; String? civilIdentityNumber = ""; String? emailAddress = ""; String? employeeNo = ""; List getEmployeeBasicDetailsList = []; @override void initState() { super.initState(); getEmployeeBasicDetails(); basicDetails(); } void getEmployeeBasicDetails() async { try { Utils.showLoading(context); getEmployeeBasicDetailsList = await ProfileApiClient().getEmployeeBasicDetails(); Utils.hideLoading(context); basicDetails(); print("getEmployeeBasicDetailsList.length"); print(getEmployeeBasicDetailsList.length); setState(() {}); } catch (ex) { Utils.hideLoading(context); Utils.handleException(ex, context, null); } } basicDetails() { for (int i = 0; i < getEmployeeBasicDetailsList.length; i++) { if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'FULL_NAME') { fullName = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'MARITAL_STATUS') { maritalStatus = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'DATE_OF_BIRTH') { birthDate = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'NATIONAL_IDENTIFIER') { civilIdentityNumber = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'EMAIL_ADDRESS') { emailAddress = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; } else if (getEmployeeBasicDetailsList[i].aPPLICATIONCOLUMNNAME == 'EMPLOYEE_NUMBER') { employeeNo = getEmployeeBasicDetailsList[i].sEGMENTVALUEDSP; } } } Widget build(BuildContext context) { return Scaffold( appBar: AppBarWidget( context, title: LocaleKeys.profile_basicDetails.tr(), ), // appBar: AppBar( // backgroundColor: MyColors.white, // leading: Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // IconButton( // icon: const Icon( // Icons.arrow_back_ios, // color: MyColors.backgroundBlackColor, // ), // onPressed: () => Navigator.pop(context), // ), // "Basic Details".toText24(isBold: true, color: MyColors.blackColor), // ], // ), // ), backgroundColor: MyColors.backgroundColor, bottomSheet: footer(), body: Column( children: [ Container( width: double.infinity, margin: EdgeInsets.only(top: 20, left: 21, right: 21,bottom: 20), padding: EdgeInsets.only(left: 14, right: 14, top: 13, bottom: 5), height: 280, decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.5), spreadRadius: 5, blurRadius: 26, offset: Offset(0, 3), ), ], color: Colors.white, borderRadius: BorderRadius.circular(10.0), ), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ LocaleKeys.fullName.tr().toText13(color: MyColors.lightGrayColor), "${fullName}".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20, ), LocaleKeys.maritalStatus.tr().toText13(color: MyColors.lightGrayColor), "${maritalStatus}".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20, ), LocaleKeys.dateOfBirth.tr().toText13(color: MyColors.lightGrayColor), "${birthDate}".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20, ), LocaleKeys.civilIdentityNumber.tr().toText13(color: MyColors.lightGrayColor), "${civilIdentityNumber}".toText16(isBold: true, color: MyColors.blackColor), ]), ), ], )); } footer() { return Container( decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), color: MyColors.white, boxShadow: [ BoxShadow(color: MyColors.lightGreyEFColor, spreadRadius: 3), ], ), child: DefaultButton(LocaleKeys.update.tr(), () async { showAlertDialog(context); }).insideContainer, ); } showAlertDialog(BuildContext context) { dynamic changeOrNew = 1; Widget cancelButton = TextButton( child: Text("Cancel"), onPressed: () { Navigator.pop(context); }, ); Widget continueButton = TextButton( child: Text("Next"), onPressed: () { continueDynamicForms(); }, ); StatefulBuilder alert = StatefulBuilder(builder: (context, setState) { return AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))), title: Text("Confirm"), content: Builder(builder: (context) { // Get available height and width of the build area of this widget. Make a choice depending on the size. var height = MediaQuery.of(context).size.height * .5; return Container( height: height, child: Column(children: [ Text( "Select the type of change you want to make.", style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), Divider(), Column( children: [ ListTile( title: Text("correct or complete the current details"), leading: Radio( value: 1, groupValue: changeOrNew, onChanged: (value) { setState(() { changeOrNew = int.parse(value.toString()); }); }, activeColor: Colors.green, ), ), ListTile( title: Text("Enter new Information because of a real change to the current details (e.g because of a change in marital status)"), leading: Radio( value: 2, groupValue: changeOrNew, onChanged: (value) { setState(() { changeOrNew = int.parse(value.toString()); }); }, activeColor: Colors.green, ), ), ], ) ])); }), actions: [ cancelButton, continueButton, ], ); }); showDialog( context: context, builder: (BuildContext context) { return alert; }, ); } void continueDynamicForms() { Navigator.pushNamed(context, AppRoutes.addDynamicInputProfile, arguments: DynamicProfileParams(LocaleKeys.profile_basicDetails.tr(), 'HR_PERINFO_SS', uRL: 'GET_BASIC_DET_DFF_STRUCTURE', requestID: 'BASIC_DETAILS', getEmployeeBasicDetailsList: getEmployeeBasicDetailsList)); } }