Merge branch 'main' of bitbucket.org:venbainformationtechnology/ts-tat

This commit is contained in:
venbaittech 2025-05-23 14:52:36 +05:30
commit b1ec5e4fed
3 changed files with 61 additions and 31 deletions

View File

@ -34,8 +34,15 @@ class DepartmentData extends StatefulWidget {
class DepartmentDataState extends State<DepartmentData> { class DepartmentDataState extends State<DepartmentData> {
final ApiService apiService = ApiService(); final ApiService apiService = ApiService();
Map<String, dynamic>? apiData; Map<String, dynamic>? apiData;
final Map<String, FocusNode> focusNodes = {
"name": FocusNode(),
"description": FocusNode(),
};
final Map<String, TextEditingController> controllers = {}; final Map<String, TextEditingController> controllers = {};
Map<String, String> errorMessages = {}; Map<String, String> errorMessages = {};
String? selectedName; String? selectedName;
String? selectedDescription; String? selectedDescription;
String? userId; String? userId;
@ -80,6 +87,14 @@ class DepartmentDataState extends State<DepartmentData> {
}); });
} }
@override
void dispose() {
for (var controller in controllers.values) {
controller.dispose();
}
super.dispose();
}
void updateDepartmentDetails() { void updateDepartmentDetails() {
print("Inside Update Function - ${widget.departmentData}"); print("Inside Update Function - ${widget.departmentData}");
@ -103,7 +118,6 @@ class DepartmentDataState extends State<DepartmentData> {
} }
bool validateData() { bool validateData() {
errorMessages.clear(); errorMessages.clear();
final data = { final data = {
@ -111,15 +125,18 @@ class DepartmentDataState extends State<DepartmentData> {
"description": controllers["description"]?.text, "description": controllers["description"]?.text,
}; };
final requiredFields = [ final requiredFields = ["name", "description"];
"name", bool hasFocused = false;
"description"
];
// Check validation for each field // Check validation for each field
for (String field in requiredFields) { 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"; errorMessages[field] = "Required";
if (!hasFocused) {
focusNodes[field]?.requestFocus();
hasFocused = true;
}
} }
} }
@ -127,7 +144,6 @@ class DepartmentDataState extends State<DepartmentData> {
} }
Future<void> handleSubmit() async { Future<void> handleSubmit() async {
print("inside submit");
userId = await getUserId(); userId = await getUserId();
setState(() { setState(() {
@ -139,7 +155,6 @@ class DepartmentDataState extends State<DepartmentData> {
final departmentData1 = departmentDetails(); final departmentData1 = departmentDetails();
print("submit data - $departmentData1"); print("submit data - $departmentData1");
} }
Future<void> postDepartmentData({int isActive = 1}) async { Future<void> postDepartmentData({int isActive = 1}) async {
@ -147,7 +162,7 @@ class DepartmentDataState extends State<DepartmentData> {
final departmentData = departmentDetails(); final departmentData = departmentDetails();
print("initally value of the Department - $departmentData"); print("initially value of the Department - $departmentData");
final String apiUrldata; final String apiUrldata;
@ -160,7 +175,7 @@ class DepartmentDataState extends State<DepartmentData> {
} else { } else {
print("for add Department id - null"); print("for add Department id - null");
apiUrldata = '$apiUrl/api/createDepartment'; apiUrldata = '$apiUrl/api/createDepartment';
print("called apiurl - $apiUrldata"); print("called apiUrl - $apiUrldata");
departmentData["created_by"] = userId; departmentData["created_by"] = userId;
} }
print("recently Department data - $departmentData"); print("recently Department data - $departmentData");
@ -223,7 +238,7 @@ class DepartmentDataState extends State<DepartmentData> {
Row( Row(
children: [ children: [
Text( Text(
'Create Department', (departmentDataId != null) ? 'Edit Department' : 'Create Department',
style: GoogleFonts.poppins(fontSize: 15, color: Colors.black), style: GoogleFonts.poppins(fontSize: 15, color: Colors.black),
), ),
const Spacer(), const Spacer(),
@ -246,7 +261,6 @@ class DepartmentDataState extends State<DepartmentData> {
color: Color(0xFF575A74)), color: Color(0xFF575A74)),
), ),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldForexWrapper( CustomTextFieldForexWrapper(
isFocused: false, isFocused: false,
isDesktop: widget.isDesktop, isDesktop: widget.isDesktop,
@ -255,17 +269,24 @@ class DepartmentDataState extends State<DepartmentData> {
height: 40, height: 40,
child: TextField( child: TextField(
controller: controllers["name"], controller: controllers["name"],
focusNode: focusNodes["name"],
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Department Name", labelText: "Name",
labelStyle: TextStyle(fontSize: 11, color: Colors.grey), labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never, floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 16), 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( SizedBox(
@ -279,8 +300,7 @@ class DepartmentDataState extends State<DepartmentData> {
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Color(0xFF575A74), color: Color(0xFF575A74)),
),
), ),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldForexWrapper( CustomTextFieldForexWrapper(
@ -288,23 +308,30 @@ class DepartmentDataState extends State<DepartmentData> {
isDesktop: widget.isDesktop, isDesktop: widget.isDesktop,
color: Colors.transparent, color: Colors.transparent,
child: SizedBox( child: SizedBox(
// Increase height for textarea
height: 100, height: 100,
child: TextField( child: TextField(
controller: controllers["description"], controller: controllers["description"],
style: const TextStyle(fontSize: 11), focusNode: focusNodes["description"],
maxLines: null, // Allow infinite lines (textarea behavior) style: const TextStyle(fontSize: 12),
expands: true, // Expands to fill the parent height maxLines: null,
expands: true,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Description", labelText: "Description",
labelStyle: TextStyle(fontSize: 11, color: Colors.grey), labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never, floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none, 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( SizedBox(

View File

@ -472,7 +472,7 @@ class _OrgSetUpState extends State<OrgSetUp> {
color: Colors.white, color: Colors.white,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, // now -> .center , old -> .start
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(top: 1.0), padding: const EdgeInsets.only(top: 1.0),
@ -523,8 +523,9 @@ class _OrgSetUpState extends State<OrgSetUp> {
? ClipRect( ? ClipRect(
child: Image.network( child: Image.network(
selectedOrg!['logo'], selectedOrg!['logo'],
width: 100, width: 250, // increased
height: 30, height: 75, // increased
fit: BoxFit.contain, fit: BoxFit.contain,
errorBuilder: errorBuilder:
(context, error, stackTrace) { (context, error, stackTrace) {

View File

@ -227,12 +227,14 @@ class _CustomAppBarState extends State<CustomAppBar> {
// padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10), // padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
child: selectedOrg?['logo'] != null child: selectedOrg?['logo'] != null
? ClipRect( ? SizedBox(
height: 60,
child: ClipRect(
child: Image.network( child: Image.network(
selectedOrg!['logo'], selectedOrg!['logo'],
width: 130, width: 180, //130
height: 80, height: 90, //80
// fit: BoxFit.contain, fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) { errorBuilder: (context, error, stackTrace) {
return const CircleAvatar( return const CircleAvatar(
radius: 20, radius: 20,
@ -241,7 +243,7 @@ class _CustomAppBarState extends State<CustomAppBar> {
); );
}, },
), ),
) ))
: const CircleAvatar( : const CircleAvatar(
radius: 20, radius: 20,
// backgroundColor: Colors.white, // backgroundColor: Colors.white,