diff --git a/lib/Screens/department/departmentDetails.dart b/lib/Screens/department/departmentDetails.dart index e887bca..078e395 100644 --- a/lib/Screens/department/departmentDetails.dart +++ b/lib/Screens/department/departmentDetails.dart @@ -34,8 +34,15 @@ class DepartmentData extends StatefulWidget { class DepartmentDataState extends State { final ApiService apiService = ApiService(); Map? apiData; + + final Map focusNodes = { + "name": FocusNode(), + "description": FocusNode(), + }; + final Map controllers = {}; Map errorMessages = {}; + String? selectedName; String? selectedDescription; String? userId; @@ -80,6 +87,14 @@ class DepartmentDataState extends State { }); } + @override + void dispose() { + for (var controller in controllers.values) { + controller.dispose(); + } + super.dispose(); + } + void updateDepartmentDetails() { print("Inside Update Function - ${widget.departmentData}"); @@ -103,7 +118,6 @@ class DepartmentDataState extends State { } bool validateData() { - errorMessages.clear(); final data = { @@ -111,15 +125,18 @@ class DepartmentDataState extends State { "description": controllers["description"]?.text, }; - final requiredFields = [ - "name", - "description" - ]; + final requiredFields = ["name", "description"]; + bool hasFocused = false; // Check validation for each field for (String field in requiredFields) { - if (data[field] == null || data[field].toString().trim().isEmpty) { + if (data[field] == null || data[field]!.trim().isEmpty) { errorMessages[field] = "Required"; + + if (!hasFocused) { + focusNodes[field]?.requestFocus(); + hasFocused = true; + } } } @@ -127,7 +144,6 @@ class DepartmentDataState extends State { } Future handleSubmit() async { - print("inside submit"); userId = await getUserId(); setState(() { @@ -139,7 +155,6 @@ class DepartmentDataState extends State { final departmentData1 = departmentDetails(); print("submit data - $departmentData1"); - } Future postDepartmentData({int isActive = 1}) async { @@ -147,7 +162,7 @@ class DepartmentDataState extends State { final departmentData = departmentDetails(); - print("initally value of the Department - $departmentData"); + print("initially value of the Department - $departmentData"); final String apiUrldata; @@ -160,7 +175,7 @@ class DepartmentDataState extends State { } else { print("for add Department id - null"); apiUrldata = '$apiUrl/api/createDepartment'; - print("called apiurl - $apiUrldata"); + print("called apiUrl - $apiUrldata"); departmentData["created_by"] = userId; } print("recently Department data - $departmentData"); @@ -223,7 +238,7 @@ class DepartmentDataState extends State { Row( children: [ Text( - 'Create Department', + (departmentDataId != null) ? 'Edit Department' : 'Create Department', style: GoogleFonts.poppins(fontSize: 15, color: Colors.black), ), const Spacer(), @@ -246,7 +261,6 @@ class DepartmentDataState extends State { color: Color(0xFF575A74)), ), SizedBox(height: 5), - CustomTextFieldForexWrapper( isFocused: false, isDesktop: widget.isDesktop, @@ -255,17 +269,24 @@ class DepartmentDataState extends State { height: 40, child: TextField( controller: controllers["name"], + focusNode: focusNodes["name"], style: const TextStyle(fontSize: 12), decoration: const InputDecoration( - labelText: "Department Name", + labelText: "Name", labelStyle: TextStyle(fontSize: 11, color: Colors.grey), floatingLabelBehavior: FloatingLabelBehavior.never, border: InputBorder.none, contentPadding: EdgeInsets.symmetric(vertical: 16), ), - // validator: (val) => val == null || val.isEmpty ? 'Enter name' : null, )), ), + if (errorMessages["name"] != null) ...[ + SizedBox(height: 5), // Space before error message + Text( + errorMessages["name"]!, + style: TextStyle(color: Colors.red, fontSize: 12), + ), + ], ], ), SizedBox( @@ -277,10 +298,9 @@ class DepartmentDataState extends State { Text( "Description", style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74), - ), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74)), ), SizedBox(height: 5), CustomTextFieldForexWrapper( @@ -288,23 +308,30 @@ class DepartmentDataState extends State { isDesktop: widget.isDesktop, color: Colors.transparent, child: SizedBox( - // Increase height for textarea height: 100, child: TextField( controller: controllers["description"], - style: const TextStyle(fontSize: 11), - maxLines: null, // Allow infinite lines (textarea behavior) - expands: true, // Expands to fill the parent height + focusNode: focusNodes["description"], + style: const TextStyle(fontSize: 12), + maxLines: null, + expands: true, decoration: const InputDecoration( labelText: "Description", labelStyle: TextStyle(fontSize: 11, color: Colors.grey), floatingLabelBehavior: FloatingLabelBehavior.never, border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(vertical: 16, horizontal: 8), + contentPadding: EdgeInsets.symmetric(vertical: 16), ), ), ), ), + if (errorMessages["description"] != null) ...[ + SizedBox(height: 5), // Space before error message + Text( + errorMessages["description"]!, + style: TextStyle(color: Colors.red, fontSize: 12), + ), + ], ], ), SizedBox( diff --git a/lib/Screens/organization/orgSetup.dart b/lib/Screens/organization/orgSetup.dart index 7d189b5..2da5748 100644 --- a/lib/Screens/organization/orgSetup.dart +++ b/lib/Screens/organization/orgSetup.dart @@ -472,7 +472,7 @@ class _OrgSetUpState extends State { color: Colors.white, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, // now -> .center , old -> .start children: [ Padding( padding: const EdgeInsets.only(top: 1.0), @@ -523,8 +523,9 @@ class _OrgSetUpState extends State { ? ClipRect( child: Image.network( selectedOrg!['logo'], - width: 100, - height: 30, + width: 250, // increased + height: 75, // increased + fit: BoxFit.contain, errorBuilder: (context, error, stackTrace) { diff --git a/lib/routes/custom_appBar.dart b/lib/routes/custom_appBar.dart index ad0b3ad..11b9a26 100644 --- a/lib/routes/custom_appBar.dart +++ b/lib/routes/custom_appBar.dart @@ -227,12 +227,14 @@ class _CustomAppBarState extends State { // padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10), child: selectedOrg?['logo'] != null - ? ClipRect( + ? SizedBox( + height: 60, + child: ClipRect( child: Image.network( selectedOrg!['logo'], - width: 130, - height: 80, - // fit: BoxFit.contain, + width: 180, //130 + height: 90, //80 + fit: BoxFit.contain, errorBuilder: (context, error, stackTrace) { return const CircleAvatar( radius: 20, @@ -241,7 +243,7 @@ class _CustomAppBarState extends State { ); }, ), - ) + )) : const CircleAvatar( radius: 20, // backgroundColor: Colors.white,