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,18 +4,26 @@ import 'package:shayog/components/styles/textStyles.dart';
DataCell editableCell(int index, String? value, DataCell editableCell(int index, String? value,
{bool isLink = false, VoidCallback? onTap}) { {bool isLink = false, VoidCallback? onTap}) {
return DataCell( return DataCell(
GestureDetector( GestureDetector(
onTap: isLink && onTap != null ? onTap : null, onTap: isLink && onTap != null ? onTap : null,
child: MouseRegion( child: Container(
cursor: isLink ? SystemMouseCursors.click : SystemMouseCursors.basic,
child: Text( alignment: Alignment.center,
value ?? "", child: MouseRegion(
textAlign: TextAlign.center, cursor: isLink ? SystemMouseCursors.click : SystemMouseCursors.basic,
maxLines: 2, child: Center(
style: isLink ? 11.txtSBoldBlue : 11.txtSBoldBlack, child: Text(
value ?? "",
textAlign: TextAlign.center,
maxLines: 2,
style: isLink ? 11.txtSBoldBlue : 11.txtSBoldBlack,
),
),
), ),
), ),
), ),
); );
} }

View File

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

View File

@ -10,4 +10,5 @@ static Color clrF2 = Color(0xffF2F2F2);
static Color black = Color(0xff000000); static Color black = Color(0xff000000);
static Color white = Color(0xffFFFFFF); static Color white = Color(0xffFFFFFF);
static Color green = Color(0xff10A711); 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 txtSBoldGrey => _textStyle(this,AppColors.darkGrey,Family.semiBold);
TextStyle get txtSBoldBlue => _textStyle(this,AppColors.primaryClr,Family.semiBold); TextStyle get txtSBoldBlue => _textStyle(this,AppColors.primaryClr,Family.semiBold);
TextStyle get txtSBoldRed => _textStyle(this,Colors.red,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); TextStyle get txtSBoldWhite => _textStyle(this,Colors.white,Family.semiBold);

View File

@ -20,259 +20,337 @@ class AddInternalUser extends StatelessWidget {
return Container( return Container(
padding: EdgeInsets.all(16), padding: EdgeInsets.all(16),
color: AppColors.clrF2, color: AppColors.clrF2,
child: Stack( child: allData(),
children: [ // child: Row(
Form( // children: [
key: controller.formKey, // Expanded(child: Container(
child: Column( // padding: EdgeInsets.only(right: 16),
mainAxisAlignment: MainAxisAlignment.start, // height: 150,
crossAxisAlignment: CrossAxisAlignment.start, // color: Colors.pink,
children: [ // child: Column(
// Obx( // mainAxisAlignment: MainAxisAlignment.start,
// () => Column( // crossAxisAlignment: CrossAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start, // children: [
// children: [ // TextView(
// CustomDropdown<String>( // text: AppStrings.firstName,
// items: ['Item 1', 'Item 2', 'Item 3'], // isRequired: true,
// itemLabel: (item) => item, // ),
// onSelected: (selected) { // InputField(
// if (selected != null) { // errorTxtColor: controller.errorTextColor,
// controller.selectedItem.value = selected; // validator: Validations.checkValidations,
// } // controller: controller.nameCtrl,
// }, // title: AppStrings.enterFirstName,
// hintText: 'Select an item', // ),
// ), // TextView(
// controller.showE.value == true && // text: AppStrings.userType,
// controller.selectedItem.value == '' // ),
// ? Column( //
// crossAxisAlignment: CrossAxisAlignment.start, // CustomDropdown(
// mainAxisAlignment: MainAxisAlignment.start, // initialValue: controller.userTypeList[1],
// children: [ // backClr: AppColors.clrD9,
// const SizedBox( // borderClr: AppColors.clrGrey,
// height: 4, // items: controller.userTypeList,
// ), // itemLabel: (item) => item,
// Text( // onSelected: (selected) {
// 'Please Select an option', // if (selected != null) {
// style: TextStyle( // controller.selectedValue.value = selected;
// color: Colors.red, fontSize: 10), // }
// ), // },
// ], // hintText: 'Select User Type',
// ) // ),
// : Text(''), // ],
// ], // ),)),
// ), // Expanded(child: Container(
// ), // padding: EdgeInsets.only(right: 16),
Row( // height: 150,
children: [ // color: Colors.green,
Expanded( // child: Column(
child: Column( // mainAxisAlignment: MainAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, // children: [
children: [ // TextView(
TextView( // text: AppStrings.lastName,
text: AppStrings.firstName,isRequired: true, // isRequired: true,
), // ),
SizedBox(height: 8), // InputField(
InputField( // errorTxtColor: controller.errorTextColor,
validator: Validations.checkValidations, // validator: Validations.checkValidations,
controller: controller.nameCtrl, // controller: controller.lastNCtrl,
title: AppStrings.enterFirstName, // title: AppStrings.enterLastName,
), // ),
], // TextView(
)), // text: AppStrings.status,
SizedBox(width: 16), // ),
Expanded( //
child: Column( // CustomDropdown(
mainAxisAlignment: MainAxisAlignment.start, // initialValue: controller.status[0],
crossAxisAlignment: CrossAxisAlignment.start, // backClr: AppColors.clrD9,
children: [ // borderClr: AppColors.clrGrey,
TextView( // items: controller.status,
text: AppStrings.lastName,isRequired: true, // itemLabel: (item) => item,
), // onSelected: (selected) {
SizedBox(height: 8), // if (selected != null) {
InputField( // controller.selectedStatus.value = selected;
validator: Validations.checkValidations, // }
controller: controller.lastNCtrl, // },
title: AppStrings.enterLastName, // hintText: 'Active'),
), // ],
], // ),)),
)), // Expanded(child: Container(
SizedBox(width: 16), // height: 150,
Expanded( // color: Colors.yellow,
child: Column( // child: Column(
mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
children: [ // children: [
TextView( // TextView(
text: AppStrings.employeeCode,isRequired: true, // text: AppStrings.employeeCode,
), // isRequired: true,
SizedBox(height: 8), // ),
InputField( // InputField(
validator: Validations.checkValidations, // errorTxtColor: controller.errorTextColor,
controller: controller.employeeCodeCtrl, // validator: Validations.checkValidations,
title: AppStrings.enterEmployeeCode, // controller: controller.employeeCodeCtrl,
), // title: AppStrings.enterEmployeeCode,
], // ),
)), // TextView(
], // text: AppStrings.emailAddress,
), // isRequired: true,
Padding( // ),
padding: const EdgeInsets.only(top: 16.0), // //SizedBox(height: 8),
child: Row( // 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: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( TextView(
child: Column( text: AppStrings.firstName,
mainAxisAlignment: MainAxisAlignment.start, isRequired: true,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.userType,
),
SizedBox(height: 8),
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',
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.status,
),
SizedBox(height: 8),
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'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.emailAddress,isRequired: true,
),
SizedBox(height: 8),
InputField(
validator: Validations.checkEmailValidations,
controller: controller.emailCtrl,
title: AppStrings.enterEmailAddress,
),
],
)),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 8),
child: TextView(
text: AppStrings.mobileNo,isRequired: true,
),
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InputField(
maxLength: 10,
validator: Validations.checkPhoneValidations,
controller: controller.mobileCtrl,
title: AppStrings.enterMobileNo,
), ),
)), InputField(
Expanded( errorTxtColor: controller.errorTextColor,
flex: 2, validator: Validations.checkValidations,
child: Padding( controller: controller.nameCtrl,
padding: const EdgeInsets.symmetric(horizontal: 8.0), title: AppStrings.enterFirstName,
child: Row( ),
mainAxisAlignment: MainAxisAlignment.end, ],
children: [ )),
CommonBtn( SizedBox(width: 16),
bkClr: Colors.white, Expanded(
text: AppStrings.cancel, child: Column(
clickAction: () { mainAxisAlignment: MainAxisAlignment.start,
Get.back(); crossAxisAlignment: CrossAxisAlignment.start,
}, children: [
), TextView(
SizedBox(width: 16), text: AppStrings.lastName,
controller.employeeCodeCtrl.text.isEmpty isRequired: true,
? CommonButton( ),
height: 30, InputField(
width: 100, errorTxtColor: controller.errorTextColor,
borderRadius: 4, validator: Validations.checkValidations,
isLoading: controller.isLoading, controller: controller.lastNCtrl,
text: AppStrings.add, title: AppStrings.enterLastName,
clickAction: () { ),
controller.createUser(); ],
} )),
// if(controller.formKey.currentState!.validate()){ SizedBox(width: 16),
// controller.createUser(); Expanded(
// } else { child: Column(
// controller.validatePlants.value == true; mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// } children: [
// if (controller.formKey.currentState TextView(
// ?.validate() ?? text: AppStrings.employeeCode,
// false) { isRequired: true,
// ScaffoldMessenger.of(context) ),
// .showSnackBar( InputField(
// SnackBar( errorTxtColor: controller.errorTextColor,
// content: Text( validator: Validations.checkValidations,
// 'Form submitted successfully!')), controller: controller.employeeCodeCtrl,
// ); title: AppStrings.enterEmployeeCode,
// controller.createUser(); ),
// } else { ],
// controller.showE.value = true; )),
// } ],
// } ),
) Row(
: CommonButton( children: [
height: 30, Flexible(
width: 100, child: Column(
borderRadius: 4, mainAxisAlignment: MainAxisAlignment.start,
isLoading: controller.editLoading, crossAxisAlignment: CrossAxisAlignment.start,
text: AppStrings.edit, children: [
clickAction: () { TextView(
controller.editAllUser( text: AppStrings.userType,
controller.employeeCodeCtrl.text); ),
}, 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',
),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
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'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: AppStrings.emailAddress,
isRequired: true,
),
SizedBox(height: 8),
InputField(
errorTxtColor: controller.errorTextColor,
validator: Validations.checkEmailValidations,
controller: controller.emailCtrl,
title: AppStrings.enterEmailAddress,
),
],
)),
],
),
TextView(
text: AppStrings.mobileNo,
isRequired: true,
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: InputField(
errorTxtColor: controller.errorTextColor,
maxLength: 10,
validator: Validations.checkPhoneValidations,
controller: controller.mobileCtrl,
title: AppStrings.enterMobileNo,
),
)),
Expanded(
flex: 2,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CommonBtn(
bkClr: Colors.white,
text: AppStrings.cancel,
clickAction: () {
Get.back();
},
),
SizedBox(width: 16),
controller.employeeCodeCtrl.text.isEmpty
? CommonButton(
height: 30,
width: 100,
borderRadius: 4,
isLoading: controller.isLoading,
text: AppStrings.add,
clickAction: () {
controller.createUser();
}
// if(controller.formKey.currentState!.validate()){
// controller.createUser();
// } else {
// controller.validatePlants.value == true;
//
// }
// if (controller.formKey.currentState
// ?.validate() ??
// false) {
// ScaffoldMessenger.of(context)
// .showSnackBar(
// SnackBar(
// content: Text(
// 'Form submitted successfully!')),
// );
// controller.createUser();
// } else {
// controller.showE.value = true;
// }
// }
)
: CommonButton(
height: 30,
width: 100,
borderRadius: 4,
isLoading: controller.editLoading,
text: AppStrings.edit,
clickAction: () {
controller.editAllUser(
controller.employeeCodeCtrl.text);
},
),
],
),
))
],
),
],
), ),
], ),
), ],
); );
} }
} }

View File

@ -10,10 +10,44 @@ import '../../../../../components/styles/app_colors.dart';
import '../../../../../components/styles/app_strings.dart'; import '../../../../../components/styles/app_strings.dart';
import '../../transporter/widgets/common_card.dart'; import '../../transporter/widgets/common_card.dart';
class InternalUserRoleMapping extends StatelessWidget { class InternalUserRoleMapping extends StatefulWidget {
InternalUserRoleMapping({super.key}); InternalUserRoleMapping({super.key});
@override
State<InternalUserRoleMapping> createState() => _InternalUserRoleMappingState();
}
class _InternalUserRoleMappingState extends State<InternalUserRoleMapping> {
final ctrl = Get.put(DashboardCtrl()); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -29,6 +63,24 @@ class InternalUserRoleMapping extends StatelessWidget {
color: Colors.white, color: Colors.white,
child: Column( child: Column(
children: [ 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( Container(
color: AppColors.clrF2, color: AppColors.clrF2,
child: Padding( child: Padding(
@ -54,6 +106,7 @@ class InternalUserRoleMapping extends StatelessWidget {
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
ctrl.selectedEmpCode.value = selected; ctrl.selectedEmpCode.value = selected;
ctrl.validateRoleMapCode.value = false;
} }
}, },
hintText: "Select Employee Code", hintText: "Select Employee Code",
@ -63,7 +116,11 @@ class InternalUserRoleMapping extends StatelessWidget {
text: "Required", text: "Required",
style: 10.txtSBoldRed, style: 10.txtSBoldRed,
) : SizedBox.shrink(), ) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
], ],
)), )),
SizedBox(width: 16), SizedBox(width: 16),
@ -85,6 +142,7 @@ class InternalUserRoleMapping extends StatelessWidget {
onSelected: (selected) { onSelected: (selected) {
if (selected != null) { if (selected != null) {
ctrl.selectedEmail.value = selected; ctrl.selectedEmail.value = selected;
ctrl.validateRoleEmail.value = false;
} }
}, },
hintText: "Select Email", hintText: "Select Email",
@ -94,7 +152,11 @@ class InternalUserRoleMapping extends StatelessWidget {
text: "Required", text: "Required",
style: 10.txtSBoldRed, style: 10.txtSBoldRed,
) : SizedBox.shrink(), ) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
], ],
)), )),
SizedBox(width: 16), SizedBox(width: 16),
@ -226,11 +288,12 @@ class InternalUserRoleMapping extends StatelessWidget {
clickAction: () {}, clickAction: () {},
), ),
SizedBox(width: 16), SizedBox(width: 16),
CommonButton( CommonButton(
borderRadius: 4, borderRadius: 4,
height: 30, height: 30,
width: 100, width: 100,
text: AppStrings.submit, text: AppStrings.save,
clickAction: () { clickAction: () {
CommonAlertDialog.showDialog( CommonAlertDialog.showDialog(

View File

@ -4,6 +4,7 @@ import 'package:intl/intl.dart';
import 'package:shayog/components/styles/textStyles.dart'; import 'package:shayog/components/styles/textStyles.dart';
import '../../../../../components/common/common_btn.dart'; import '../../../../../components/common/common_btn.dart';
import '../../../../../components/common/common_button.dart'; import '../../../../../components/common/common_button.dart';
import '../../../../../components/common/custom_drop_down.dart';
import '../../../../../components/common/data_cell.dart'; import '../../../../../components/common/data_cell.dart';
import '../../../../../components/common/input_field.dart'; import '../../../../../components/common/input_field.dart';
import '../../../../../components/styles/app_colors.dart'; import '../../../../../components/styles/app_colors.dart';
@ -24,207 +25,186 @@ class ManageUser extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Obx( Obx(
() => controller.isSelected.value () => controller.isSelected.value
? Container( ? Container(
margin: EdgeInsets.symmetric(vertical: 16), // margin: EdgeInsets.symmetric(vertical: 16),
padding: EdgeInsets.all(16), padding: EdgeInsets.all(16),
color: AppColors.clrF2, color: AppColors.clrF2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextView(
text: "User Name",
),
SizedBox(height: 8),
InputField(
title: "Enter User Name",
controller: controller.nameCtrl),
// CustomDropdown( child: Column(
// backClr: AppColors.clrD9, mainAxisAlignment: MainAxisAlignment.start,
// borderClr: AppColors.clrGrey, crossAxisAlignment: CrossAxisAlignment.start,
// items: ctrl.plantList,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// ctrl.selectedPlant.value =
// selected;
// }
// },
// hintText: 'Select Plant'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.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'),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.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'),
],
)),
],
),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Row(
children: [ children: [
Expanded(
child: Column( Row(
mainAxisAlignment: children: [
MainAxisAlignment.start, Expanded(
crossAxisAlignment: child: Column(
CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "User Name",
),
SizedBox(height: 8),
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,
children: [
TextView(
text: "User Type",
),
SizedBox(height: 8),
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,
children: [
TextView(
text: "Email Address",
),
SizedBox(height: 8),
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'),
],
)),
],
),
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
TextView( TextView(
text: "Employee/Transporter Code", text: "Employee/Transporter Code",
), ),
SizedBox(height: 8), SizedBox(height: 8),
InputField(
title: "Enter Employee Code", CustomDropdown(
controller: controller.employeeCodeCtrl), backClr: AppColors.clrD9,
// CustomDropdown( borderClr: AppColors.clrGrey,
// backClr: AppColors.clrD9, items: controller.userEmpCode,
// borderClr: AppColors.clrGrey, itemLabel: (item) => item,
// items: ctrl.plantList, onSelected: (selected) {
// itemLabel: (item) => item, if (selected != null) {
// onSelected: (selected) { controller.selectCode.value =
// if (selected != null) { selected;
// ctrl.selectedPlant.value = }
// selected; },
// } hintText: 'Select Product'),
// },
// hintText: 'Select Product'),
], ],
)), )),
SizedBox(width: 16), SizedBox(width: 16),
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [ children: [
TextView( TextView(
text: "Status", text: "Status",
), ),
SizedBox(height: 8), SizedBox(height: 8),
InputField( CustomDropdown(
title: "Enter Status", backClr: AppColors.clrD9,
controller: controller.statusCtrl), borderClr: AppColors.clrGrey,
// CustomDropdown( items: controller.userStatus,
// backClr: AppColors.clrD9, itemLabel: (item) => item,
// borderClr: AppColors.clrGrey, onSelected: (selected) {
// items: ctrl.plantList, if (selected != null) {
// itemLabel: (item) => item, controller.selectUserStatus.value =
// onSelected: (selected) { selected;
// if (selected != null) { }
// ctrl.selectedPlant.value = },
// selected; hintText: 'Select Status'),
// }
// },
// hintText: 'Select Product'),
], ],
)), )),
SizedBox(width: 16), SizedBox(width: 16),
Expanded( Expanded(
child: Column( child: Column(
children: [
TextView(
text: "",
),
SizedBox(height: 8),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [ children: [
CommonBtn( TextView(
bkClr: Colors.white, text: "",
text: AppStrings.cancel,
clickAction: () {
controller.isSelected.value = false;
},
), ),
SizedBox(width: 16), SizedBox(height: 8),
CommonButton( Row(
borderRadius: 4, mainAxisAlignment: MainAxisAlignment.end,
width: 100, children: [
height: 30, CommonBtn(
text: AppStrings.submit, bkClr: Colors.white,
textStyle: 14.txtSBoldWhite, text: AppStrings.cancel,
clickAction: () { clickAction: () {
controller.isSelected.value = false; controller.isSelected.value = false;
controller.getManageUser(); },
controller.getAllUser(); ),
}, SizedBox(width: 16),
CommonButton(
borderRadius: 4,
width: 100,
height: 30,
text: AppStrings.submit,
textStyle: 14.txtSBoldWhite,
clickAction: () {
//controller.isSelected.value = false;
controller.getManageUser();
controller.getAllUser();
},
),
],
), ),
], ],
), ),
], ),
), ],
), ),
], ],
), ),
), )
],
),
)
: SizedBox(), : SizedBox(),
), ),
Obx(() { Obx(() {
@ -236,133 +216,136 @@ class ManageUser extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Scrollbar( Container(
thumbVisibility: true, margin: EdgeInsets.only(bottom: 16, top: 16),
controller: controller.verticalScrollController, height: MediaQuery.of(context).size.height * 0.6,
child: SingleChildScrollView( child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
trackVisibility: true,
thumbVisibility: true,
thickness: 14,
controller: controller.verticalScrollController, controller: controller.verticalScrollController,
child: Scrollbar( child: SingleChildScrollView(
thumbVisibility: true, controller: controller.verticalScrollController,
controller: controller.horizontalScrollController, child: RawScrollbar(
child: SingleChildScrollView( thumbColor: AppColors.clrD9,
scrollDirection: Axis.horizontal, radius: Radius.circular(2),
thickness: 14,
trackVisibility: true,
thumbVisibility: true,
controller: controller.horizontalScrollController, controller: controller.horizontalScrollController,
child: Container( child: SingleChildScrollView(
margin: EdgeInsets.only(top: 16), scrollDirection: Axis.horizontal,
decoration: BoxDecoration( controller: controller.horizontalScrollController,
border: Border.all( child: Container(
color: Colors.grey.shade400, margin: EdgeInsets.only(bottom: 24, right: 24),
width: 1.0, child: DataTable(
dataRowHeight: 28,
headingRowHeight: 40,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("User Name"),
dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"),
dataColumn("Mobile No."),
dataColumn("User Type"),
dataColumn("Created By"),
dataColumn("Created Date"),
dataColumn("Last Updated By"),
dataColumn("Last Update Date"),
dataColumn("Status"),
dataColumn("Action"),
],
rows: List<DataRow>.generate(
controller.getAllUserMain.length, (index) {
final stoppage = controller.getAllUserMain[index];
return DataRow(
selected: stoppage.isSelected,
cells: [
editableCell(index, stoppage.userName ?? "-"),
editableCell(
index, stoppage.userEmail ?? "-"),
editableCell(
index, stoppage.userEmpTransCode ?? "-"),
editableCell(
index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.usertypeName ?? "-"),
editableCell(
index, stoppage.createdBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.createdOn}'))),
editableCell(
index, stoppage.lastUpdatedBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.lastUpdatedOn}'))),
editableCell(
index,
stoppage.status == "A"
? "Active"
: "In-Active"),
DataCell(CommonBtn(
style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6),
width: 35,
text: "Edit",
clickAction: () {
controller.nameCtrl.text =
stoppage.userFname ?? '';
controller.lastNCtrl.text =
stoppage.userLname ?? '';
controller.mobileCtrl.text =
stoppage.userMobile ?? '';
controller.emailCtrl.text =
stoppage.userEmail ?? '';
controller.userTypeId.value =
stoppage.usertypeId.toString();
controller.selectedValue.value =
stoppage.userAddedChannel ?? '';
controller.selectedStatus.value =
stoppage.status ?? '';
controller.employeeCodeCtrl.text =
stoppage.userEmpTransCode ?? '';
controller.selectUserVal.value =
stoppage.usertypeName ?? '';
controller.selectedUser.value = 1;
},
)),
],
);
}),
), ),
), ),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 40,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn("User Name"),
dataColumn("Email ID"),
dataColumn("Employee/\nTransporter Code"),
dataColumn("Mobile No."),
dataColumn("User Type"),
dataColumn("Created By"),
dataColumn("Created Date"),
dataColumn("Last Updated By"),
dataColumn("Last Update Date"),
dataColumn("Status"),
dataColumn("Action"),
],
rows: List<DataRow>.generate(
controller.getAllUser.length, (index) {
final stoppage = controller.getAllUser[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.userEmpTransCode ?? "-"),
editableCell(index, stoppage.userMobile ?? "-"),
editableCell(
index, stoppage.usertypeName ?? "-"),
editableCell(
index, stoppage.createdBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.createdOn}'))),
editableCell(
index, stoppage.lastUpdatedBy.toString()),
editableCell(
index,
DateFormat("d MMMM yyyy").format(
DateTime.parse(
'${stoppage.lastUpdatedOn}'))),
editableCell(index, stoppage.status =="A"?"Active":"In-Active"),
DataCell(CommonBtn(
style: 8.txtSBoldWhite,
margin: EdgeInsets.symmetric(vertical: 6),
width: 35,
text: "Edit",
clickAction: () {
controller.nameCtrl.text =
stoppage.userFname ?? '';
controller.lastNCtrl.text =
stoppage.userLname ?? '';
controller.mobileCtrl.text =
stoppage.userMobile ?? '';
controller.emailCtrl.text =
stoppage.userEmail ?? '';
controller.userTypeId.value =
stoppage.usertypeId.toString();
controller.selectedValue.value =
stoppage.userAddedChannel ?? '';
controller.selectedStatus.value =
stoppage.status ?? '';
controller.employeeCodeCtrl.text =
stoppage.userEmpTransCode ?? '';
controller.selectUserVal.value =
stoppage.usertypeName ?? '';
controller.selectedUser.value = 1;
},
)),
],
);
}),
),
), ),
), ),
), ),
), ),
), ),
SizedBox(height: 16),
], ],
); );
}), }),
CustomPagination( CustomPagination(
currentPage: controller.currentPage.value, currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value, totalPages: controller.totalPages.value,
@ -370,7 +353,6 @@ class ManageUser extends StatelessWidget {
controller.onPageChanged(page); controller.onPageChanged(page);
}, },
), ),
], ],
); );
} }

View File

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

View File

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

View File

@ -28,105 +28,121 @@ class UserType extends StatelessWidget {
color: AppColors.clrF2, color: AppColors.clrF2,
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(child: SizedBox(
child: Column( // color: Colors.pink,
mainAxisAlignment: MainAxisAlignment.start, height: 100,
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ mainAxisAlignment: MainAxisAlignment.start,
TextView(text: crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text:
"Add User Type",isRequired: true, "Add User Type",isRequired: true,
),
SizedBox(height: 8),
InputField(
controller: controller.userTypeCtrl,
title: "Enter User Type",
),
SizedBox(height: 5),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
],
)),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text:
"Status Type",isRequired: true,
),
SizedBox(height: 8),
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'),
SizedBox(height: 5),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : SizedBox.shrink(),
],
)),
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();
}
},
),
],
), ),
), SizedBox(height: 8),
], InputField(
controller: controller.userTypeCtrl,
title: "Enter User Type",
),
SizedBox(height: 8),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
),
)),
SizedBox(width: 16),
Expanded(child: SizedBox(
// color: Colors.green,
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text:
"Status Type",isRequired: true,
),
SizedBox(height: 8),
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'),
SizedBox(height: 8),
controller.validateUserType.value == true ? TextView(
text: "Required",
style: 10.txtSBoldRed,
) : TextView(
text: "ABC",
style: 10.txtTransparent,
),
],
),
)),
Expanded(child: SizedBox(
height: 100,
child: Column(
children: [
TextView(text:
"",
),
Padding(
padding: const EdgeInsets.only(top: 18.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();
}
},
),
],
),
),
],
),
)) ))
], ],
), )
), ),
), ),
Container( 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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:shayog/components/styles/app_images.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'; 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; RxBool isSelected = false.obs;
RxString selectedItem = ''.obs; RxString selectedItem = ''.obs;
@override
void onClose() {
verticalScrollController.dispose();
horizontalScrollController.dispose();
super.onClose();
}
void toggleContainer() { void toggleContainer() {
isSelected.value = true; isSelected.value = true;
print("isSelected.value..${isSelected.value}"); print("isSelected.value..${isSelected.value}");
@ -95,27 +103,63 @@ class DashboardCtrl extends GetxController {
RxInt currentPage = 1.obs; // Current page being viewed RxInt currentPage = 1.obs; // Current page being viewed
RxInt totalPages = 1.obs; // Total number of pages from the API RxInt totalPages = 1.obs; // Total number of pages from the API
RxList<AllUser> getAllUser = <AllUser>[].obs; RxList<AllUser> getAllUser = <AllUser>[].obs;
final int limit = 20; RxList<AllUser> getAllUserMain = <AllUser>[].obs;
RxInt limit = 20.obs;
var userLoading = false.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 { getManageUser() async {
try { try {
userLoading.value = true; userLoading.value = true;
Map<String, String> requestBody = { Map<String, String> requestBody = {
"userName": "", "userName": nameCtrl.text.isEmpty ? "" : nameCtrl.text,
"userTypeName": "", "userTypeName": userTypeCtrl.text.isEmpty ? "" : userTypeCtrl.text,
"email": "", "Email": emailCtrl.text.isEmpty ? "" : emailCtrl.text,
"employeeTransCode": "", "EmployeeTransCode":
"status": "" employeeCodeCtrl.text.isEmpty ? "" : employeeCodeCtrl.text,
"status": selectUserStatus.value == "Select Status"
? ""
: selectUserStatus.value == "Active"
? "A"
: "I",
}; };
var response = var response =
await PostRequests.getAllUser(requestBody, currentPage.value, limit); await PostRequests.getAllUser(requestBody, currentPage.value);
if (response != null) { if (response != null) {
List<AllUser> flattenedContent = List<AllUser> flattenedContent =
response.content!.expand((list) => list).toList(); response.content!.expand((list) => list).toList();
getAllUser.assignAll(flattenedContent); 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!; totalPages.value = response.totalPages!;
print("getAllUser>>>>>${getAllUser.length}"); print("getAllUser>>>>>${getAllUser.length}");
} }
@ -127,20 +171,20 @@ class DashboardCtrl extends GetxController {
void nextPage() { void nextPage() {
if (currentPage.value < totalPages.value) { if (currentPage.value < totalPages.value) {
currentPage.value++; currentPage.value++;
getManageUser(); // Fetch data for the next page getManageUser();
} }
} }
void previousPage() { void previousPage() {
if (currentPage.value > 1) { if (currentPage.value > 1) {
currentPage.value--; currentPage.value--;
getManageUser(); // Fetch data for the previous page getManageUser();
} }
} }
void onPageChanged(int page) { void onPageChanged(int page) {
currentPage.value = page; currentPage.value = page;
getManageUser(); // Fetch data for the selected page getManageUser();
} }
//********************************edit User****************************// //********************************edit User****************************//
@ -166,7 +210,6 @@ class DashboardCtrl extends GetxController {
getManageUser(); getManageUser();
getAllUser.refresh(); getAllUser.refresh();
//employeeCodeCtrl.clear();
} }
// employeeCodeCtrl.clear(); // employeeCodeCtrl.clear();
selectedUser.value = 0; selectedUser.value = 0;
@ -182,10 +225,14 @@ class DashboardCtrl extends GetxController {
var status = ['Active', 'In-Active']; var status = ['Active', 'In-Active'];
var selectedStatus = 'Select Status'.obs; var selectedStatus = 'Select Status'.obs;
var selectedValue = 'Select User Type'.obs; var selectedValue = 'Select User Type'.obs;
var isValidate = false.obs;
Color errorTextColor = Colors.red;
void createUser() { void createUser() {
if (formKey.currentState!.validate()) { if (formKey.currentState!.validate()) {
addInternalUser(); addInternalUser();
} else {
isValidate.value = true;
} }
} }
@ -286,29 +333,21 @@ class DashboardCtrl extends GetxController {
var userTypeData = <UserTypeData>[].obs; var userTypeData = <UserTypeData>[].obs;
var userTypeStatus = ['Active', 'In-Active']; var userTypeStatus = ['Active', 'In-Active'];
var selectStatus = 'Select Status'.obs; var selectStatus = 'Select Status'.obs;
clearUserType() { clearUserType() {
userTypeCtrl.text.isEmpty; userTypeCtrl.text.isEmpty;
selectedStatus.value.isEmpty; selectedStatus.value.isEmpty;
} }
// addUserType() { var selectUserStatus = "Select Status".obs;
// if (userTypeCtrl.text.isEmpty || selectedStatus.value == "") { var userStatus = ["Active", "In-Active"];
// CommonDialog.showDialog(
// message: "Select all mandatory fields",
// onclick: () {
// Get.back();
// });
// } else {
// createUserType();
// }
// }
createUserType() async { createUserType() async {
try { try {
userTypeLoading.value = true; userTypeLoading.value = true;
Map<String, String> requestBody = { Map<String, String> requestBody = {
"userTypeName": userTypeCtrl.text, "userTypeName": userTypeCtrl.text,
"status": selectStatus.value == "Active" ? "A" : "I", "status": selectUserStatus.value == "Active" ? "A" : "I",
"createdBy": "0", "createdBy": "0",
"lastUpdatedBy": "0" "lastUpdatedBy": "0"
}; };
@ -348,6 +387,7 @@ class DashboardCtrl extends GetxController {
var plantMappingLoader = false.obs; var plantMappingLoader = false.obs;
RxList<PlantsData> plantMapping = <PlantsData>[].obs; RxList<PlantsData> plantMapping = <PlantsData>[].obs;
clearPlants() { clearPlants() {
selectPlantEmail.value.isEmpty; selectPlantEmail.value.isEmpty;
selectPlantCode.value.isEmpty; selectPlantCode.value.isEmpty;
@ -371,8 +411,6 @@ class DashboardCtrl extends GetxController {
selectedEmpCode.value.isEmpty; selectedEmpCode.value.isEmpty;
} }
getPlantMapping() async { getPlantMapping() async {
try { try {
plantMappingLoader.value = true; plantMappingLoader.value = true;
@ -386,7 +424,6 @@ class DashboardCtrl extends GetxController {
plantMapping.value = response.data!; plantMapping.value = response.data!;
showPlantRolesSection.value = true; showPlantRolesSection.value = true;
} }
} finally { } finally {
plantMappingLoader.value = false; plantMappingLoader.value = false;
} }
@ -396,7 +433,9 @@ class DashboardCtrl extends GetxController {
RxList<InternalRoleMappingData> roleMappingData = RxList<InternalRoleMappingData> roleMappingData =
<InternalRoleMappingData>[].obs; <InternalRoleMappingData>[].obs;
var fetchEmailsNCodesLoading = false.obs; var fetchEmailsNCodesLoading = false.obs;
var statusMessage = "".obs;
// rolemapping
getRoleMappingData() async { getRoleMappingData() async {
try { try {
fetchEmailsNCodesLoading.value = true; fetchEmailsNCodesLoading.value = true;
@ -406,9 +445,12 @@ class DashboardCtrl extends GetxController {
}; };
var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody); var response = await PostRequests.fetchEmailsAndEmpCodes(requestBody);
if (response != null) { if (response != null) {
print('fetch role desc ${response.data?.length}');
roleMappingData.value = response.data!; roleMappingData.value = response.data!;
showRolesSection.value = true; showRolesSection.value = true;
statusMessage.value = response.status.toString();
} else {
print("cdg");
// AppAlerts.alert(message: "sxjs");
} }
} finally { } finally {
fetchEmailsNCodesLoading.value = false; fetchEmailsNCodesLoading.value = false;
@ -534,10 +576,56 @@ class DashboardCtrl extends GetxController {
userTypeLoader.value = false; userTypeLoader.value = false;
} }
} }
RxBool validateRoleEmail = false.obs; RxBool validateRoleEmail = false.obs;
RxBool validateRoleMapCode = false.obs; RxBool validateRoleMapCode = false.obs;
RxBool validatePlantEmail = false.obs; RxBool validatePlantEmail = false.obs;
RxBool validatePlantCode = false.obs; RxBool validatePlantCode = false.obs;
RxBool validateUserStatus = false.obs; RxBool validateUserStatus = false.obs;
RxBool validateUserType = 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: () {}, clickAction: () {},
), ),
SizedBox(width: 16), SizedBox(width: 16),
// CommonButton(
// borderRadius: 4,
// height: 30,
// width: 100,
// text: AppStrings.submit,
//
// clickAction: () {
// controller.postData();
// },
// ),
CommonButton( CommonButton(
borderRadius: 4, borderRadius: 4,
height: 30, height: 30,
width: 100, width: 100,
text: AppStrings.submit, text: AppStrings.submit,
clickAction: () { clickAction: () {
controller.validateFields(); controller.postData();
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, bkClr: Colors.white,
margin: EdgeInsets.only(top: 24), margin: EdgeInsets.only(top: 24),
text: "Done", text: "Done",
clickAction: (){}), clickAction: (){
Get.back();
}),
) )
], ],
), ),

View File

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

View File

@ -48,33 +48,32 @@ class TextView extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return Padding(
padding: margin ?? EdgeInsets.zero, padding: margin ?? EdgeInsets.zero,
child: GestureDetector( child: Row(
onTap: onTap,
child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text( Text(
capitalise != null && capitalise! ? text.toUpperCase() : text, capitalise != null && capitalise! ? text.toUpperCase() : text,
maxLines: maxlines, maxLines: maxlines,
overflow: maxlines != null ? TextOverflow.ellipsis : null, overflow: maxlines != null ? TextOverflow.ellipsis : null,
textAlign: textAlign, textAlign: textAlign,
style: style ?? 12.txtBoldBlack, style: style ?? 12.txtBoldBlack,
), ),
if (isRequired == true) if (isRequired == true)
const Padding( const Padding(
padding: EdgeInsets.only(left: 4.0), padding: EdgeInsets.only(left: 4.0),
child: Text( child: Text(
"*", "*",
style: TextStyle( style: TextStyle(
color: Colors.red, color: Colors.red,
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
),
), ),
), ),
], ),
), ],
), ),
); );
} }

View File

@ -35,3 +35,40 @@ class ApiUrls {
static const grnPendingDetails = static const grnPendingDetails =
"http://46.28.44.130:9092/bill/grndetailsPanding?page=0&size=20&sort=grn_date,desc"; "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( 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, 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) { if (apiResponse != null) {
return getAllUserResModelFromJson(apiResponse.response!); return getAllUserResModelFromJson(apiResponse.response!);

View File

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