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/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/models/get_employee_basic_details.model.dart'; import 'package:mohem_flutter_app/ui/profile/profile.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: 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: 28, left: 26, right: 26,), 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: [ "Full Name".toText13(color: MyColors.lightGrayColor), "${fullName}".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20,), "Marital Status".toText13(color: MyColors.lightGrayColor), "${maritalStatus}".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20,), "Date of Birth".toText13(color: MyColors.lightGrayColor), "${birthDate}".toText16(isBold: true, color: MyColors.blackColor), SizedBox( height: 20,), "Civil Identity Number".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("Update", () async { // context.setLocale(const Locale("en", "US")); // to change Loacle Profile(); }).insideContainer, ); } }