prativa code

dev_branch
Pratibha Chaudhary 2025-02-05 09:19:11 +05:30
parent d7072ee489
commit 0b9e0ed9be
18 changed files with 1152 additions and 758 deletions

View File

@ -4,10 +4,15 @@ import 'package:shayog/components/styles/textStyles.dart';
DataCell editableCell(int index, String? value,
{bool isLink = false, VoidCallback? onTap}) {
return DataCell(
GestureDetector(
onTap: isLink && onTap != null ? onTap : null,
child: Container(
alignment: Alignment.center,
child: MouseRegion(
cursor: isLink ? SystemMouseCursors.click : SystemMouseCursors.basic,
child: Center(
child: Text(
value ?? "",
textAlign: TextAlign.center,
@ -16,6 +21,9 @@ DataCell editableCell(int index, String? value,
),
),
),
),
),
);
}

View File

@ -14,7 +14,9 @@ class InputField extends StatelessWidget {
this.onFieldSubmitted,
this.validator,
this.edgesInsects,
this.underLineBorder,this.maxLength});
this.errorTxtColor,
this.underLineBorder,
this.maxLength});
String? title;
OutlineInputBorder? underLineBorder;
@ -25,6 +27,8 @@ class InputField extends StatelessWidget {
List<TextInputFormatter>? inputFormatter;
EdgeInsets? edgesInsects;
int? maxLength;
Color? errorTxtColor;
var inputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(2.0),
borderSide: BorderSide(color: AppColors.clrGrey));
@ -36,14 +40,13 @@ class InputField extends StatelessWidget {
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
contextMenuBuilder: (context, editableTextState) {
return Container(height: 0, color: Colors.transparent);
},
// contextMenuBuilder: (context, editableTextState) {
// return Container(height: 0, color: Colors.transparent);
// },
style: 12.txtSBoldBlack,
maxLength: maxLength,
decoration: InputDecoration(counterText: '',
maxLength: maxLength,
decoration: InputDecoration(
counterText: '',
isDense: true,
hintStyle: 11.txtSBoldGrey,
maintainHintHeight: true,
@ -57,11 +60,10 @@ maxLength: maxLength,
focusedErrorBorder: underLineBorder ?? inputBorder,
filled: true,
hintText: title ?? "",
labelStyle: 12.txtSBoldGrey,
fillColor: AppColors.clrD9,
errorStyle: TextStyle(
fontSize: 10.0,
// errorText: "",
errorStyle: TextStyle(fontSize: 10.0, color: errorTxtColor
// height: 0.2,
),
),

View File

@ -10,4 +10,5 @@ static Color clrF2 = Color(0xffF2F2F2);
static Color black = Color(0xff000000);
static Color white = Color(0xffFFFFFF);
static Color green = Color(0xff10A711);
static Color red = Colors.red;
}

View File

@ -27,6 +27,7 @@ extension TextStyles on num{
TextStyle get txtSBoldGrey => _textStyle(this,AppColors.darkGrey,Family.semiBold);
TextStyle get txtSBoldBlue => _textStyle(this,AppColors.primaryClr,Family.semiBold);
TextStyle get txtSBoldRed => _textStyle(this,Colors.red,Family.semiBold);
TextStyle get txtTransparent => _textStyle(this,Colors.transparent,Family.semiBold);
TextStyle get txtSBoldWhite => _textStyle(this,Colors.white,Family.semiBold);

View File

@ -20,48 +20,128 @@ class AddInternalUser extends StatelessWidget {
return Container(
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Stack(
child: allData(),
// child: Row(
// children: [
// Expanded(child: Container(
// padding: EdgeInsets.only(right: 16),
// height: 150,
// color: Colors.pink,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(
// text: AppStrings.firstName,
// isRequired: true,
// ),
// InputField(
// errorTxtColor: controller.errorTextColor,
// validator: Validations.checkValidations,
// controller: controller.nameCtrl,
// title: AppStrings.enterFirstName,
// ),
// TextView(
// text: AppStrings.userType,
// ),
//
// CustomDropdown(
// initialValue: controller.userTypeList[1],
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: controller.userTypeList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectedValue.value = selected;
// }
// },
// hintText: 'Select User Type',
// ),
// ],
// ),)),
// Expanded(child: Container(
// padding: EdgeInsets.only(right: 16),
// height: 150,
// color: Colors.green,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(
// text: AppStrings.lastName,
// isRequired: true,
// ),
// InputField(
// errorTxtColor: controller.errorTextColor,
// validator: Validations.checkValidations,
// controller: controller.lastNCtrl,
// title: AppStrings.enterLastName,
// ),
// TextView(
// text: AppStrings.status,
// ),
//
// CustomDropdown(
// initialValue: controller.status[0],
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: controller.status,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectedStatus.value = selected;
// }
// },
// hintText: 'Active'),
// ],
// ),)),
// Expanded(child: Container(
// height: 150,
// color: Colors.yellow,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(
// text: AppStrings.employeeCode,
// isRequired: true,
// ),
// InputField(
// errorTxtColor: controller.errorTextColor,
// validator: Validations.checkValidations,
// controller: controller.employeeCodeCtrl,
// title: AppStrings.enterEmployeeCode,
// ),
// TextView(
// text: AppStrings.emailAddress,
// isRequired: true,
// ),
// //SizedBox(height: 8),
// InputField(
// errorTxtColor: controller.errorTextColor,
// validator: Validations.checkEmailValidations,
// controller: controller.emailCtrl,
// title: AppStrings.enterEmailAddress,
// ),
//
// ],
// ),)),
// ],
// ),
);
}
allData() {
return Column(
children: [
Form(
key: controller.formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Obx(
// () => Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// CustomDropdown<String>(
// items: ['Item 1', 'Item 2', 'Item 3'],
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectedItem.value = selected;
// }
// },
// hintText: 'Select an item',
// ),
// controller.showE.value == true &&
// controller.selectedItem.value == ''
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// children: [
// const SizedBox(
// height: 4,
// ),
// Text(
// 'Please Select an option',
// style: TextStyle(
// color: Colors.red, fontSize: 10),
// ),
// ],
// )
// : Text(''),
// ],
// ),
// ),
Row(
children: [
Expanded(
@ -70,10 +150,11 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.firstName,isRequired: true,
text: AppStrings.firstName,
isRequired: true,
),
SizedBox(height: 8),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations,
controller: controller.nameCtrl,
title: AppStrings.enterFirstName,
@ -87,10 +168,11 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.lastName,isRequired: true,
text: AppStrings.lastName,
isRequired: true,
),
SizedBox(height: 8),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations,
controller: controller.lastNCtrl,
title: AppStrings.enterLastName,
@ -104,10 +186,11 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.employeeCode,isRequired: true,
text: AppStrings.employeeCode,
isRequired: true,
),
SizedBox(height: 8),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations,
controller: controller.employeeCodeCtrl,
title: AppStrings.enterEmployeeCode,
@ -116,11 +199,9 @@ class AddInternalUser extends StatelessWidget {
)),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
Row(
children: [
Expanded(
Flexible(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@ -128,7 +209,6 @@ class AddInternalUser extends StatelessWidget {
TextView(
text: AppStrings.userType,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.userTypeList[1],
backClr: AppColors.clrD9,
@ -153,7 +233,6 @@ class AddInternalUser extends StatelessWidget {
TextView(
text: AppStrings.status,
),
SizedBox(height: 8),
CustomDropdown(
initialValue: controller.status[0],
backClr: AppColors.clrD9,
@ -175,10 +254,12 @@ class AddInternalUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.emailAddress,isRequired: true,
text: AppStrings.emailAddress,
isRequired: true,
),
SizedBox(height: 8),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkEmailValidations,
controller: controller.emailCtrl,
title: AppStrings.enterEmailAddress,
@ -187,12 +268,9 @@ class AddInternalUser extends StatelessWidget {
)),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 8),
child: TextView(
text: AppStrings.mobileNo,isRequired: true,
),
TextView(
text: AppStrings.mobileNo,
isRequired: true,
),
Row(
children: [
@ -200,6 +278,7 @@ class AddInternalUser extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InputField(
errorTxtColor: controller.errorTextColor,
maxLength: 10,
validator: Validations.checkPhoneValidations,
controller: controller.mobileCtrl,
@ -272,7 +351,6 @@ class AddInternalUser extends StatelessWidget {
),
),
],
),
);
}
}

View File

@ -10,10 +10,44 @@ import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_strings.dart';
import '../../transporter/widgets/common_card.dart';
class InternalUserRoleMapping extends StatelessWidget {
class InternalUserRoleMapping extends StatefulWidget {
InternalUserRoleMapping({super.key});
@override
State<InternalUserRoleMapping> createState() => _InternalUserRoleMappingState();
}
class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
final ctrl = Get.put(DashboardCtrl());
String? selectedEmail;
// Error message
String? errorText;
// List of emails for the dropdown
final List<String> emails = ['email1@example.com', 'email2@example.com', 'email3@example.com'];
// Function for when the email is selected
void onEmailSelected(String? email) {
setState(() {
selectedEmail = email;
});
}
void onSaveClick() {
// Validate that an email is selected
if (selectedEmail == null || selectedEmail!.isEmpty) {
setState(() {
errorText = "Please select an email."; // Set the error message
});
} else {
setState(() {
errorText = null; // Clear the error message if selection is valid
});
// Perform your save action (e.g., API call, navigation, etc.)
print('Email Selected: $selectedEmail');
}
}
@override
Widget build(BuildContext context) {
@ -29,6 +63,24 @@ class InternalUserRoleMapping extends StatelessWidget {
color: Colors.white,
child: Column(
children: [
// CustomDropdown<String>(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: emails,
// itemLabel: (item) => item,
// onSelected: onEmailSelected,
// hintText: "Select Email",
// ),
// // Error message for the dropdown if no value is selected
// if (errorText != null)
// Padding(
// padding: const EdgeInsets.only(top: 8.0),
// child: Text(
// errorText!,
// style: TextStyle(color: Colors.red, fontSize: 12),
// ),
// ),
Container(
color: AppColors.clrF2,
child: Padding(
@ -54,6 +106,7 @@ class InternalUserRoleMapping extends StatelessWidget {
onSelected: (selected) {
if (selected != null) {
ctrl.selectedEmpCode.value = selected;
ctrl.validateRoleMapCode.value = false;
}
},
hintText: "Select Employee Code",
@ -63,7 +116,11 @@ class InternalUserRoleMapping extends StatelessWidget {
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
SizedBox(width: 16),
@ -85,6 +142,7 @@ class InternalUserRoleMapping extends StatelessWidget {
onSelected: (selected) {
if (selected != null) {
ctrl.selectedEmail.value = selected;
ctrl.validateRoleEmail.value = false;
}
},
hintText: "Select Email",
@ -94,7 +152,11 @@ class InternalUserRoleMapping extends StatelessWidget {
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
SizedBox(width: 16),
@ -226,11 +288,12 @@ class InternalUserRoleMapping extends StatelessWidget {
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
text: AppStrings.save,
clickAction: () {
CommonAlertDialog.showDialog(

View File

@ -4,6 +4,7 @@ import 'package:intl/intl.dart';
import 'package:shayog/components/styles/textStyles.dart';
import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/common_button.dart';
import '../../../../../components/common/custom_drop_down.dart';
import '../../../../../components/common/data_cell.dart';
import '../../../../../components/common/input_field.dart';
import '../../../../../components/styles/app_colors.dart';
@ -26,160 +27,141 @@ class ManageUser extends StatelessWidget {
Obx(
() => controller.isSelected.value
? Container(
margin: EdgeInsets.symmetric(vertical: 16),
// margin: EdgeInsets.symmetric(vertical: 16),
padding: EdgeInsets.all(16),
color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "User Name",
),
SizedBox(height: 8),
InputField(
title: "Enter User Name",
controller: controller.nameCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Plant'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userNames,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectUser.value =
selected;
}
},
hintText: 'Select Plant'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "User Type",
),
SizedBox(height: 8),
InputField(
title: "Enter User Type",
controller: controller.userTypeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.freightBillList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedFreight.value =
// selected;
// }
// },
// hintText: 'Select Freight Number'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypesNames,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectType.value =
selected;
}
},
hintText: 'Select Plant'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Email Address",
),
SizedBox(height: 8),
InputField(
title: "Enter Email Address",
controller: controller.emailCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userEmail,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectEmail.value =
selected;
}
},
hintText: 'Select Plant'),
],
)),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Employee/Transporter Code",
),
SizedBox(height: 8),
InputField(
title: "Enter Employee Code",
controller: controller.employeeCodeCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userEmpCode,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectCode.value =
selected;
}
},
hintText: 'Select Product'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Status",
),
SizedBox(height: 8),
InputField(
title: "Enter Status",
controller: controller.statusCtrl),
// CustomDropdown(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Product'),
CustomDropdown(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userStatus,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectUserStatus.value =
selected;
}
},
hintText: 'Select Status'),
],
)),
SizedBox(width: 16),
@ -191,8 +173,7 @@ class ManageUser extends StatelessWidget {
),
SizedBox(height: 8),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
@ -209,7 +190,7 @@ class ManageUser extends StatelessWidget {
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {
controller.isSelected.value = false;
//controller.isSelected.value = false;
controller.getManageUser();
controller.getAllUser();
},
@ -221,7 +202,6 @@ class ManageUser extends StatelessWidget {
),
],
),
),
],
),
)
@ -236,25 +216,30 @@ class ManageUser extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Scrollbar(
Container(
margin: EdgeInsets.only(bottom: 16, top: 16),
height: MediaQuery.of(context).size.height * 0.6,
child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
trackVisibility: true,
thumbVisibility: true,
thickness: 14,
controller: controller.verticalScrollController,
child: SingleChildScrollView(
controller: controller.verticalScrollController,
child: Scrollbar(
child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
thickness: 14,
trackVisibility: true,
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: controller.horizontalScrollController,
child: Container(
margin: EdgeInsets.only(top: 16),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
),
margin: EdgeInsets.only(bottom: 24, right: 24),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 40,
@ -271,7 +256,6 @@ class ManageUser extends StatelessWidget {
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("User Name"),
dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"),
@ -285,22 +269,21 @@ class ManageUser extends StatelessWidget {
dataColumn("Action"),
],
rows: List<DataRow>.generate(
controller.getAllUser.length, (index) {
final stoppage = controller.getAllUser[index];
controller.getAllUserMain.length, (index) {
final stoppage = controller.getAllUserMain[index];
return DataRow(
selected: stoppage.isSelected,
// onSelectChanged: (value) {
// controller.toggleSelection(index, value ?? false);
// },
cells: [
// editableCell(index, ""
// "${index + 1}"),
editableCell(index, stoppage.userName ?? "-"),
editableCell(index, stoppage.userEmail ?? "-"),
editableCell(
index, stoppage.userEmail ?? "-"),
editableCell(
index, stoppage.userEmpTransCode ?? "-"),
editableCell(index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.usertypeName ?? "-"),
editableCell(
@ -317,8 +300,11 @@ class ManageUser extends StatelessWidget {
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.lastUpdatedOn}'))),
editableCell(index, stoppage.status =="A"?"Active":"In-Active"),
editableCell(
index,
stoppage.status == "A"
? "Active"
: "In-Active"),
DataCell(CommonBtn(
style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6),
@ -355,14 +341,11 @@ class ManageUser extends StatelessWidget {
),
),
),
SizedBox(height: 16),
),
],
);
}),
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
@ -370,7 +353,6 @@ class ManageUser extends StatelessWidget {
controller.onPageChanged(page);
},
),
],
);
}

View File

@ -34,7 +34,7 @@ class UserPlantMapping extends StatelessWidget {
children: [
TextView(
text: "Employee/Transporter Code",
style: 13.txtBoldBlack,
isRequired: true,
),
SizedBox(height: 8),
@ -56,7 +56,11 @@ class UserPlantMapping extends StatelessWidget {
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
@ -69,7 +73,7 @@ class UserPlantMapping extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
"Email Address",style:13.txtBoldBlack,isRequired: true,
"Email Address",isRequired: true,
),
SizedBox(height: 8),
CustomDropdown(
@ -89,7 +93,11 @@ class UserPlantMapping extends StatelessWidget {
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
@ -236,7 +244,7 @@ class UserPlantMapping extends StatelessWidget {
clickAction: () {
CommonAlertDialog.showDialog(
message: 'Are you sure you want to do this action?',
positiveText: "Submit",
positiveText: "Save",
negativeBtCallback: () {
Get.back();
},

View File

@ -1,10 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/admin/user_management/user_plant_mapping.dart';
import 'package:shayog/feature/presentation/widgets/text_view.dart';
import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_images.dart';
import '../../../../../components/styles/app_strings.dart';
@ -45,8 +43,15 @@ class UserScreen extends StatelessWidget {
ctrl.selectedUser.value = index;
ctrl.clearPrefillData();
ctrl.isSelected.value = false;
ctrl.validateRoleMapCode.value = false;
ctrl.validateRoleEmail.value = false;
ctrl.validatePlantEmail.value = false;
ctrl.validatePlantCode.value = false;
ctrl.validateUserStatus.value = false;
ctrl.validateUserType.value = false;
if (ctrl.selectedUser.value == 0) {
print("fhudsfh");
ctrl.getManageUser();
}
if (ctrl.selectedUser.value == 2) {
@ -74,10 +79,7 @@ class UserScreen extends StatelessWidget {
child: TextView(
text: ctrl.userTabs[index].title ?? "",
style: 12.txtBoldWhite,
// style: TextStyle(
// fontSize: 12,
// fontWeight: FontWeight.w900,
// color: Colors.white),
),
),
),

View File

@ -28,7 +28,9 @@ class UserType extends StatelessWidget {
color: AppColors.clrF2,
child: Row(
children: [
Expanded(
Expanded(child: SizedBox(
// color: Colors.pink,
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@ -38,19 +40,27 @@ class UserType extends StatelessWidget {
),
SizedBox(height: 8),
InputField(
controller: controller.userTypeCtrl,
title: "Enter User Type",
),
SizedBox(height: 5),
SizedBox(height: 8),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
),
)),
SizedBox(width: 16),
Expanded(
Expanded(child: SizedBox(
// color: Colors.green,
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
@ -72,24 +82,29 @@ class UserType extends StatelessWidget {
}
},
hintText: 'Select Status'),
SizedBox(height: 5),
SizedBox(height: 8),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
),
)),
SizedBox(width: 16),
Expanded(
//flex: 2,
Expanded(child: SizedBox(
height: 100,
child: Column(
children: [
TextView(text:
"",
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
padding: const EdgeInsets.only(top: 18.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@ -124,9 +139,10 @@ class UserType extends StatelessWidget {
),
),
],
),
))
],
),
)
),
),
Container(
@ -253,6 +269,116 @@ class UserType extends StatelessWidget {
],
);
}
data(){
return Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
"Add User Type",isRequired: true,
),
SizedBox(height: 8),
InputField(
controller: controller.userTypeCtrl,
title: "Enter User Type",
),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text:
"Status Type",isRequired: true,
),
CustomDropdown(
initialValue: controller.selectStatus.value,
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.userTypeStatus,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectStatus.value = selected;
}
},
hintText: 'Select Status'),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
)),
SizedBox(width: 16),
Expanded(
//flex: 2,
child: Column(
children: [
TextView(text:
"",
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {},
),
SizedBox(width: 16),
CommonButton(
isLoading: controller.userTypeLoading,
height: 28,
borderRadius: 4,
width: 100,
text: AppStrings.submit,
clickAction: () {
if(controller.userTypeCtrl.text.isEmpty ||controller.selectStatus.value == "Select Status" ){
controller.validateUserStatus.value = true;
controller.validateUserType.value = true;
} else{
controller.validateUserStatus.value = false;
controller.validateUserType.value = false;
controller.createUserType();
}
},
),
],
),
),
],
))
],
);
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shayog/components/styles/app_images.dart';
import 'package:shayog/feature/presentation/screens/admin/user_management/model/select_assign_role_model/select_assign_role_model.dart';
@ -41,6 +42,13 @@ class DashboardCtrl extends GetxController {
RxBool isSelected = false.obs;
RxString selectedItem = ''.obs;
@override
void onClose() {
verticalScrollController.dispose();
horizontalScrollController.dispose();
super.onClose();
}
void toggleContainer() {
isSelected.value = true;
print("isSelected.value..${isSelected.value}");
@ -95,27 +103,63 @@ class DashboardCtrl extends GetxController {
RxInt currentPage = 1.obs; // Current page being viewed
RxInt totalPages = 1.obs; // Total number of pages from the API
RxList<AllUser> getAllUser = <AllUser>[].obs;
final int limit = 20;
RxList<AllUser> getAllUserMain = <AllUser>[].obs;
RxInt limit = 20.obs;
var userLoading = false.obs;
setNextPage() {
if (currentPage.value < totalPages.value.toInt()) {
currentPage.value++;
getManageUser();
}
}
setPrevPage() {
if (currentPage.value > 1) {
currentPage.value--;
getManageUser();
}
}
var userNames =[].obs;
var userTypesNames =[].obs;
var userEmpCode =[].obs;
var userEmail =[].obs;
var selectUser = "Select Status".obs;
var selectEmail = "Select Status".obs;
var selectCode = "Select Status".obs;
var selectType = "Select Status".obs;
getManageUser() async {
try {
userLoading.value = true;
Map<String, String> requestBody = {
"userName": "",
"userTypeName": "",
"email": "",
"employeeTransCode": "",
"status": ""
"userName": nameCtrl.text.isEmpty ? "" : nameCtrl.text,
"userTypeName": userTypeCtrl.text.isEmpty ? "" : userTypeCtrl.text,
"Email": emailCtrl.text.isEmpty ? "" : emailCtrl.text,
"EmployeeTransCode":
employeeCodeCtrl.text.isEmpty ? "" : employeeCodeCtrl.text,
"status": selectUserStatus.value == "Select Status"
? ""
: selectUserStatus.value == "Active"
? "A"
: "I",
};
var response =
await PostRequests.getAllUser(requestBody, currentPage.value, limit);
await PostRequests.getAllUser(requestBody, currentPage.value);
if (response != null) {
List<AllUser> flattenedContent =
response.content!.expand((list) => list).toList();
getAllUser.assignAll(flattenedContent);
getAllUserMain.assignAll(flattenedContent);
for (var i = 0; i < flattenedContent.length; i++) {
userTypesNames.add(flattenedContent[i].usertypeName);
userNames.add(flattenedContent[i].userName);
userEmpCode.add(flattenedContent[i].userEmpTransCode);
userEmail.add(flattenedContent[i].userEmail);
}
totalPages.value = response.totalPages!;
print("getAllUser>>>>>${getAllUser.length}");
}
@ -127,20 +171,20 @@ class DashboardCtrl extends GetxController {
void nextPage() {
if (currentPage.value < totalPages.value) {
currentPage.value++;
getManageUser(); // Fetch data for the next page
getManageUser();
}
}
void previousPage() {
if (currentPage.value > 1) {
currentPage.value--;
getManageUser(); // Fetch data for the previous page
getManageUser();
}
}
void onPageChanged(int page) {
currentPage.value = page;
getManageUser(); // Fetch data for the selected page
getManageUser();
}
//********************************edit User****************************//
@ -166,7 +210,6 @@ class DashboardCtrl extends GetxController {
getManageUser();
getAllUser.refresh();
//employeeCodeCtrl.clear();
}
// employeeCodeCtrl.clear();
selectedUser.value = 0;
@ -182,10 +225,14 @@ class DashboardCtrl extends GetxController {
var status = ['Active', 'In-Active'];
var selectedStatus = 'Select Status'.obs;
var selectedValue = 'Select User Type'.obs;
var isValidate = false.obs;
Color errorTextColor = Colors.red;
void createUser() {
if (formKey.currentState!.validate()) {
addInternalUser();
} else {
isValidate.value = true;
}
}
@ -286,29 +333,21 @@ class DashboardCtrl extends GetxController {
var userTypeData = <UserTypeData>[].obs;
var userTypeStatus = ['Active', 'In-Active'];
var selectStatus = 'Select Status'.obs;
clearUserType() {
userTypeCtrl.text.isEmpty;
selectedStatus.value.isEmpty;
}
// addUserType() {
// if (userTypeCtrl.text.isEmpty || selectedStatus.value == "") {
// CommonDialog.showDialog(
// message: "Select all mandatory fields",
// onclick: () {
// Get.back();
// });
// } else {
// createUserType();
// }
// }
var selectUserStatus = "Select Status".obs;
var userStatus = ["Active", "In-Active"];
createUserType() async {
try {
userTypeLoading.value = true;
Map<String, String> requestBody = {
"userTypeName": userTypeCtrl.text,
"status": selectStatus.value == "Active" ? "A" : "I",
"status": selectUserStatus.value == "Active" ? "A" : "I",
"createdBy": "0",
"lastUpdatedBy": "0"
};
@ -348,6 +387,7 @@ class DashboardCtrl extends GetxController {
var plantMappingLoader = false.obs;
RxList<PlantsData> plantMapping = <PlantsData>[].obs;
clearPlants() {
selectPlantEmail.value.isEmpty;
selectPlantCode.value.isEmpty;
@ -371,8 +411,6 @@ class DashboardCtrl extends GetxController {
selectedEmpCode.value.isEmpty;
}
getPlantMapping() async {
try {
plantMappingLoader.value = true;
@ -386,7 +424,6 @@ class DashboardCtrl extends GetxController {
plantMapping.value = response.data!;
showPlantRolesSection.value = true;
}
} finally {
plantMappingLoader.value = false;
}
@ -396,7 +433,9 @@ class DashboardCtrl extends GetxController {
RxList<InternalRoleMappingData> roleMappingData =
<InternalRoleMappingData>[].obs;
var fetchEmailsNCodesLoading = false.obs;
var statusMessage = "".obs;
// rolemapping
getRoleMappingData() async {
try {
fetchEmailsNCodesLoading.value = true;
@ -406,9 +445,12 @@ class DashboardCtrl extends GetxController {
};
var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody);
if (response != null) {
print('fetch role desc ${response.data?.length}');
roleMappingData.value = response.data!;
showRolesSection.value = true;
statusMessage.value = response.status.toString();
} else {
print("cdg");
// AppAlerts.alert(message: "sxjs");
}
} finally {
fetchEmailsNCodesLoading.value = false;
@ -534,10 +576,56 @@ class DashboardCtrl extends GetxController {
userTypeLoader.value = false;
}
}
RxBool validateRoleEmail = false.obs;
RxBool validateRoleMapCode = false.obs;
RxBool validatePlantEmail = false.obs;
RxBool validatePlantCode = false.obs;
RxBool validateUserStatus = false.obs;
RxBool validateUserType = false.obs;
searchEmpCode(String enterValue) {
print('-----typing ---- ${enterValue}');
//List<AllChandlo> searchList = [];
List<AllUser> searchList = [];
if (enterValue.isEmpty) {
//searchList = getCndMain;
searchList = getAllUserMain;
} else {
searchList = getAllUserMain
.where((user) =>
user.usertypeName!.toLowerCase().contains(enterValue.toLowerCase()))
.toList();
}
getAllUser.assignAll(searchList);
getAllUser.refresh();
for (var item in getAllUser) {
print('name :: ${item.usertypeName}');
}
}
RxString? validateEmail;
// Error message
RxString? showErrorText;
void onEmailSelected(dynamic email) {
selectedEmail.value = email;
}
void onSaveClick() {
// Validate that an email is selected
if (selectedEmail.value.isEmpty) {
errorText.value = "Required"; // Set the error message
} else {
errorText.value = ""; // Clear the error message if selection is valid
// Perform your save action (e.g., API call, navigation, etc.)
print('Email Selected: $selectedEmail');
}
}
}

View File

@ -297,35 +297,35 @@ class GenerateFrightBill extends StatelessWidget {
clickAction: () {},
),
SizedBox(width: 16),
// CommonButton(
// borderRadius: 4,
// height: 30,
// width: 100,
// text: AppStrings.submit,
//
// clickAction: () {
// controller.postData();
// },
// ),
CommonButton(
borderRadius: 4,
height: 30,
width: 100,
text: AppStrings.submit,
clickAction: () {
controller.validateFields();
if (controller.showPlantError.value ||
controller.showProductError.value ||
controller.showTransactionError.value
) {
print('controller.showProductError.value ${controller.showProductError.value}');
} else {
controller.postData();
}
},
),
// CommonButton(
// borderRadius: 4,
// height: 30,
// width: 100,
// text: AppStrings.submit,
// clickAction: () {
// controller.validateFields();
//
// if (controller.showPlantError.value ||
// controller.showProductError.value ||
// controller.showTransactionError.value
// ) {
// print('controller.showProductError.value ${controller.showProductError.value}');
//
// } else {
// controller.postData();
// }
// },
// ),
],
),
),

View File

@ -271,7 +271,9 @@ void showFreightBill(BuildContext context) {
bkClr: Colors.white,
margin: EdgeInsets.only(top: 24),
text: "Done",
clickAction: (){}),
clickAction: (){
Get.back();
}),
)
],
),

View File

@ -19,12 +19,9 @@ class CustomPagination extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: const EdgeInsets.symmetric(vertical: 2.0),
decoration: BoxDecoration(
//color: Colors.grey[200],
border: Border(
top: BorderSide(color: Colors.grey[300]!),
),
color: AppColors.clrF2,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.end, // Center the pagination
@ -61,10 +58,10 @@ class CustomPagination extends StatelessWidget {
return InkWell(
onTap: () => onPageChanged(pageNumber),
child: Container(
height: 25,
width: 25,
height: 22,
width: 22,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: isSelected ? AppColors.primaryClr : AppColors.primaryClr),
color: isSelected ? AppColors.primaryClr : Colors.transparent,

View File

@ -48,9 +48,9 @@ class TextView extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: margin ?? EdgeInsets.zero,
child: GestureDetector(
onTap: onTap,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
@ -75,7 +75,6 @@ class TextView extends StatelessWidget {
),
],
),
),
);
}
}

View File

@ -35,3 +35,40 @@ class ApiUrls {
static const grnPendingDetails =
"http://46.28.44.130:9092/bill/grndetailsPanding?page=0&size=20&sort=grn_date,desc";
}
// class ApiUrls {
// ApiUrls._();
//
// static const String baseUrl = "http://localhost:9092/";
//
// static const addFreightBill =
// 'bill/grndetails?page=0&size=20&sort=grn_date,desc';
// static const getFreightBills = 'bill/dropdown';
// static const generateFreightBill =
// 'http://localhost:9092/bill/addFreightBill';
// static const createUser = 'http://localhost:9093/api/users/createUser';
// static const editUser =
// 'http://localhost:9093/api/users/update?userEmpTransCode=';
// static const getAllUser =
// 'http://localhost:9093/api/users/userdetails?page=';
// static const viewFreightBill =
// 'http://localhost:9092/bill/freightbill?page';
// static const addUserType =
// 'http://localhost:9093/api/user-types/createUserType';
// static const dropDownList =
// 'http://localhost:9093/api/user-roles/userrole_dropdown';
// static const plantMapping = 'http://localhost:9093/userplant/fetchPlants';
// static const checkStatus =
// 'http://localhost:9093/api/user-types/update-status/';
// static const getInternalUserDropdown =
// 'http://localhost:9093/api/user-roles/userrole_dropdown';
// static const fetchEmailsAndEmpCode =
// 'http://localhost:9093/api/user-roles/fetchRoles';
// static const selectAndAssignRole =
// "http://localhost:9093/api/user-roles/assignRoles";
// static const assignPlantRole =
// "http://localhost:9093/userplant/assignPlants";
// static const userTypeDetails =
// "http://localhost:9093/api/user-types/usertypedetails?page=0&size=15&sort=last_updated_on,desc";
// static const grnPendingDetails =
// "http://localhost:9092/bill/grndetailsPanding?page=0&size=20&sort=grn_date,desc";
// }

View File

@ -67,9 +67,9 @@ class PostRequests {
}
static Future<GetAllUserResModel?> getAllUser(
Map<String, String> requestBody, int page, int limit) async {
Map<String, String> requestBody, int page) async {
var apiResponse = await RemoteService.postUser(requestBody,
"${ApiUrls.getAllUser}$page&size=$limit&sort=last_updated_on,desc");
"${ApiUrls.getAllUser}$page&size=9&sort=last_updated_on,desc");
if (apiResponse != null) {
return getAllUserResModelFromJson(apiResponse.response!);

View File

@ -226,7 +226,7 @@ class RemoteService {
final response =
await http.post(Uri.parse(endUrl), headers: getHeaders(), body: body);
print('${response.body}response');
print(_baseUrl + endUrl);
print(endUrl);
print('${response.statusCode}response');
var responseCode = response.statusCode;