Merge branch 'main' of bitbucket.org:venbainformationtechnology/ts-tat
This commit is contained in:
commit
b1ec5e4fed
@ -34,8 +34,15 @@ class DepartmentData extends StatefulWidget {
|
||||
class DepartmentDataState extends State<DepartmentData> {
|
||||
final ApiService apiService = ApiService();
|
||||
Map<String, dynamic>? apiData;
|
||||
|
||||
final Map<String, FocusNode> focusNodes = {
|
||||
"name": FocusNode(),
|
||||
"description": FocusNode(),
|
||||
};
|
||||
|
||||
final Map<String, TextEditingController> controllers = {};
|
||||
Map<String, String> errorMessages = {};
|
||||
|
||||
String? selectedName;
|
||||
String? selectedDescription;
|
||||
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() {
|
||||
print("Inside Update Function - ${widget.departmentData}");
|
||||
|
||||
@ -103,7 +118,6 @@ class DepartmentDataState extends State<DepartmentData> {
|
||||
}
|
||||
|
||||
bool validateData() {
|
||||
|
||||
errorMessages.clear();
|
||||
|
||||
final data = {
|
||||
@ -111,15 +125,18 @@ class DepartmentDataState extends State<DepartmentData> {
|
||||
"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<DepartmentData> {
|
||||
}
|
||||
|
||||
Future<void> handleSubmit() async {
|
||||
print("inside submit");
|
||||
userId = await getUserId();
|
||||
|
||||
setState(() {
|
||||
@ -139,7 +155,6 @@ class DepartmentDataState extends State<DepartmentData> {
|
||||
|
||||
final departmentData1 = departmentDetails();
|
||||
print("submit data - $departmentData1");
|
||||
|
||||
}
|
||||
|
||||
Future<void> postDepartmentData({int isActive = 1}) async {
|
||||
@ -147,7 +162,7 @@ class DepartmentDataState extends State<DepartmentData> {
|
||||
|
||||
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<DepartmentData> {
|
||||
} 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<DepartmentData> {
|
||||
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<DepartmentData> {
|
||||
color: Color(0xFF575A74)),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
|
||||
CustomTextFieldForexWrapper(
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
@ -255,17 +269,24 @@ class DepartmentDataState extends State<DepartmentData> {
|
||||
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<DepartmentData> {
|
||||
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<DepartmentData> {
|
||||
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(
|
||||
|
||||
@ -472,7 +472,7 @@ class _OrgSetUpState extends State<OrgSetUp> {
|
||||
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<OrgSetUp> {
|
||||
? ClipRect(
|
||||
child: Image.network(
|
||||
selectedOrg!['logo'],
|
||||
width: 100,
|
||||
height: 30,
|
||||
width: 250, // increased
|
||||
height: 75, // increased
|
||||
|
||||
fit: BoxFit.contain,
|
||||
errorBuilder:
|
||||
(context, error, stackTrace) {
|
||||
|
||||
@ -227,12 +227,14 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
// 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<CustomAppBar> {
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
))
|
||||
: const CircleAvatar(
|
||||
radius: 20,
|
||||
// backgroundColor: Colors.white,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user