second commit
This commit is contained in:
477
lib/View/More/Staffs/Addstaff/Addstaffview.dart
Normal file
477
lib/View/More/Staffs/Addstaff/Addstaffview.dart
Normal file
@@ -0,0 +1,477 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../Controller/More/Staffs/Addstaff/Addstaffcontroller.dart';
|
||||
import '../../../../Helper/Constants/Colorconstants.dart';
|
||||
import '../../../../Helper/custombutton.dart';
|
||||
import '../../../../Helper/customederaction.dart';
|
||||
|
||||
class AddStaffView extends StatelessWidget {
|
||||
final bool location;
|
||||
|
||||
AddStaffView({super.key, required this.location});
|
||||
|
||||
AddStaffController addStaffController = Get.put(AddStaffController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: ColorConstants.lightColor,
|
||||
appBar: AppBar(
|
||||
elevation: 0.5,
|
||||
leading: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.arrow_back,
|
||||
color: ColorConstants.secondaryColor,
|
||||
size: 28,
|
||||
)),
|
||||
titleSpacing: 1,
|
||||
title: Text('Add Staff',style: TextStyle(color: ColorConstants.secondaryColor)),
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
GetBuilder<AddStaffController>(
|
||||
initState: (_){
|
||||
addStaffController.getLocation();
|
||||
},
|
||||
|
||||
builder: (controller) {
|
||||
return Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 10.0, right: 10.0, top: 10, bottom: 70),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
firstName(context),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
lastName(context),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
|
||||
Container(
|
||||
child: contactNo(context),
|
||||
height: 55,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(7)),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
email(context),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Container(
|
||||
height: 110,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
color: Color.fromRGBO(220, 220, 220, 0.6),
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(7),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 10,),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
addStaffController.isLocation.isTrue ?'Selected Location :':"Selected Location :",
|
||||
style: TextStyle(fontSize: 18, color: Colors.grey[500]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10,),
|
||||
addStaffController.isLocation.value == true
|
||||
? Container(
|
||||
height: 45,
|
||||
margin: EdgeInsets.only(left: 10),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.primaryColor,
|
||||
|
||||
shape: BoxShape.rectangle,
|
||||
border: Border.all(
|
||||
color: Colors.white
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
// width: 150,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 45,
|
||||
|
||||
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.store,
|
||||
color: ColorConstants.secondaryColor,
|
||||
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Container(width: 1,color: Colors.white,),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(controller.locationName??'',
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.white,
|
||||
height: 0.9,
|
||||
fontWeight: FontWeight.bold
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
:
|
||||
Expanded(
|
||||
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.only(left: 0),
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: ScrollPhysics(),
|
||||
itemCount: addStaffController.tenantLocation?.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 5.0, top: 10,bottom: 12,right: 10),
|
||||
child: GetX<AddStaffController>(
|
||||
|
||||
builder: (controller) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
controller.locationId.value = controller.tenantLocation?[index].locationid??0;
|
||||
controller.locationAddress = controller.tenantLocation?[index].locationaddress??'';
|
||||
controller.locationSuburb = controller.tenantLocation?[index].locationsuburb??'';
|
||||
controller.locationCity = controller.tenantLocation?[index].locationcity??'';
|
||||
controller.locationState = controller.tenantLocation?[index].locationstate??'';
|
||||
controller.locationPostcode = controller.tenantLocation?[index].locationpostcode??'';
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
print('locationAddressonTap${controller.locationAddress}');
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: controller.locationId.value == controller.tenantLocation?[index].locationid
|
||||
? ColorConstants.primaryColor
|
||||
: Colors.white,
|
||||
shape: BoxShape.rectangle,
|
||||
border: Border.all(
|
||||
color: controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid
|
||||
? Colors.white
|
||||
: Colors.grey[300]!),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
|
||||
Container(
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.store,
|
||||
color: controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid
|
||||
? ColorConstants.secondaryColor
|
||||
: Colors.grey[400],
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
|
||||
// height: 5,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1,
|
||||
child: Container(color:
|
||||
controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid? Colors.white:Colors.grey[300],),
|
||||
// height: 5,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
|
||||
// height: 5,
|
||||
),
|
||||
Text( controller.tenantLocation?[index].locationname??'',
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color:controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid? Colors.white: Colors.grey[600],
|
||||
height: 0.9,
|
||||
fontWeight:
|
||||
controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid
|
||||
? FontWeight.bold
|
||||
: FontWeight.w500)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: SizedBox(
|
||||
height: Get.height*0.08,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 11,top: 0),
|
||||
child: RoundedButton(
|
||||
onPressed: () {
|
||||
addStaffController.describeValidation();
|
||||
},
|
||||
color:ColorConstants.primaryColor,
|
||||
title: 'Create',
|
||||
controller: addStaffController.btnController,
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: "Lato",
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
height: Get.height*0.06,
|
||||
width: Get.width*0.8,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
String? validateEmail(String? value) {
|
||||
const pattern = r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'"
|
||||
r'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-'
|
||||
r'\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*'
|
||||
r'[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4]'
|
||||
r'[0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9]'
|
||||
r'[0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\'
|
||||
r'x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])';
|
||||
final regex = RegExp(pattern);
|
||||
|
||||
return value!.isNotEmpty && !regex.hasMatch(value)
|
||||
? 'Enter a valid email address'
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
Widget firstName(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
),
|
||||
child: TextFormField(
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
decoration: CustomDecoration.textFieldStyle(
|
||||
labelTextStr: 'First Name',
|
||||
prefixIcon: Icon(
|
||||
Icons.person,
|
||||
color: ColorConstants.primaryColor,
|
||||
)),
|
||||
controller: addStaffController.nameController,
|
||||
// focusNode: aadharNoNode,
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget lastName(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
),
|
||||
child: TextFormField(
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
decoration: CustomDecoration.textFieldStyle(
|
||||
labelTextStr: 'Last Name',
|
||||
prefixIcon: Icon(
|
||||
Icons.person,
|
||||
color: ColorConstants.primaryColor,
|
||||
)),
|
||||
controller: addStaffController.lastNameController,
|
||||
// focusNode: aadharNoNode,
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget contactNo(context) {
|
||||
return TextFormField(
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(signed: true, decimal: true),
|
||||
maxLength: 10,
|
||||
controller: addStaffController.phoneNoController,
|
||||
buildCounter: (BuildContext context,
|
||||
{int? currentLength, int? maxLength, bool? isFocused}) =>
|
||||
null,
|
||||
onChanged: (contactNo){
|
||||
if(contactNo.length==10){
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Contact no',
|
||||
labelStyle: TextStyle(color: Colors.grey),
|
||||
prefixIcon:Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width * 0.2,
|
||||
height: Get.height * 0.04,
|
||||
child: Row(
|
||||
children: [
|
||||
Spacer(flex: 1,),
|
||||
Flexible(
|
||||
child: Icon(
|
||||
Icons.phone_android_outlined,
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
Spacer(flex: 1,),
|
||||
Flexible(flex: 3,child: Text("+91",style: TextStyle(color: ColorConstants.primaryColor,fontWeight: FontWeight.bold))),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(7.0),
|
||||
borderSide: BorderSide(
|
||||
color: Color.fromRGBO(220, 220, 220, 0.6),
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(7.0),
|
||||
borderSide: BorderSide(
|
||||
color: Color.fromRGBO(220, 220, 220, 0.6),
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(7.0),
|
||||
borderSide: BorderSide(
|
||||
color: ColorConstants.primaryColor,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget email(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
),
|
||||
child: Form(
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
child: TextFormField(
|
||||
validator: validateEmail,
|
||||
decoration: CustomDecoration.textFieldStyle(
|
||||
labelTextStr: 'Email',
|
||||
prefixIcon: Icon(
|
||||
Icons.mail_outline,
|
||||
color: ColorConstants.primaryColor,
|
||||
)),
|
||||
controller: addStaffController.emailController,
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class UpperCaseTextFormatter extends TextInputFormatter {
|
||||
@override
|
||||
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
return TextEditingValue(
|
||||
text: capitalize(newValue.text),
|
||||
selection: newValue.selection,
|
||||
);
|
||||
}
|
||||
}
|
||||
String capitalize(String value) {
|
||||
if(value.trim().isEmpty) return "";
|
||||
return "${value[0].toUpperCase()}${value.substring(1)}";
|
||||
}
|
||||
|
||||
563
lib/View/More/Staffs/Staffview.dart
Normal file
563
lib/View/More/Staffs/Staffview.dart
Normal file
@@ -0,0 +1,563 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
import '../../../Controller/More/Staffs/Staffscontroller.dart';
|
||||
import '../../../Helper/Constants/AssetConstants.dart';
|
||||
import '../../../Helper/Constants/Colorconstants.dart';
|
||||
import '../../../Helper/utility.dart';
|
||||
import '../../Home/Homeview.dart';
|
||||
import '../Locations/Addlocation/Addlocationview.dart';
|
||||
import 'Addstaff/Addstaffview.dart';
|
||||
import 'Updatestaff/Updatestaffview.dart';
|
||||
|
||||
class StaffsView extends StatelessWidget {
|
||||
StaffsView({super.key});
|
||||
StaffsController staffsController = Get.put(StaffsController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Get.to(()=>HomeView(selectedIndex: 3));
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: ColorConstants.lightColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
elevation: 0.3,
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.all(5.0),
|
||||
child: Image(
|
||||
image: AssetImage(AssetConstants.NearleAppbarIcon),
|
||||
height: 30,
|
||||
),
|
||||
),
|
||||
title: Text('Staffs',
|
||||
style: TextStyle(color: ColorConstants.secondaryColor)),
|
||||
titleSpacing: 0,
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Expanded(
|
||||
flex: 9,
|
||||
child: mobileUserList(),
|
||||
)
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 5,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
height: 60,
|
||||
// width: Get.width * 0.8,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: ColorConstants.primaryColor),
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.pushReplacement(MaterialPageRoute(
|
||||
builder: (context) => HomeView(
|
||||
selectedIndex: 0,
|
||||
)));
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.home,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Text(
|
||||
'Home',
|
||||
style: TextStyle(color: Colors.white),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 60,
|
||||
width: 0.5,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Get.to(() => AddStaffView(
|
||||
location: false,
|
||||
));
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.person_add,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Text(
|
||||
'Add User',
|
||||
style: TextStyle(color: Colors.white),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 60,
|
||||
width: 0.5,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Get.to(HomeView(selectedIndex: 3));
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.more_horiz,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(
|
||||
height: 3,
|
||||
),
|
||||
Text(
|
||||
'More',
|
||||
style: TextStyle(color: Colors.white),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget mobileUserList() {
|
||||
return GetBuilder<StaffsController>(initState: (_) {
|
||||
staffsController.shimmer = true;
|
||||
staffsController.getStaffs();
|
||||
}, builder: (controller) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(
|
||||
left: 10.0,
|
||||
right: 10,
|
||||
),
|
||||
child:
|
||||
!controller.shimmer && controller.getStaff.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Image(
|
||||
height: 160,
|
||||
width: 160,
|
||||
image: AssetImage(AssetConstants.NoRecords),
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Text(
|
||||
"No users at this moment",
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600], fontSize: 14),
|
||||
),
|
||||
],
|
||||
))
|
||||
: controller.shimmer
|
||||
? staffShimmer()
|
||||
:
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.only(bottom: 80),
|
||||
itemCount: controller.getStaff.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
boxShadow: [BoxShadow(color: Colors.grey)],
|
||||
borderRadius: BorderRadius.all(Radius.circular(3)),
|
||||
),
|
||||
height: 120,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width*0.22,
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
UtilityPromotion.getLightColors(
|
||||
'${controller.getStaff[index].firstname?[0]}'.toString())
|
||||
.withAlpha(100),
|
||||
shape: BoxShape.rectangle,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
// width: 55,
|
||||
// height: 60,
|
||||
child: CircleAvatar(
|
||||
backgroundColor:
|
||||
Colors.white70,
|
||||
radius: 30,
|
||||
child: Text(
|
||||
"${controller.getStaff[index].firstname?[0].toString().toUpperCase()}",
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
fontSize: 22),
|
||||
)),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 26,
|
||||
right: 12,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Get.to(UpdateStaff(staffData:controller.getStaff[index]));
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
ColorConstants.primaryColor,
|
||||
shape: BoxShape.circle,
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
vertical: 6,
|
||||
horizontal: 6),
|
||||
child: Icon(
|
||||
Icons.edit,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
flex: 8,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// SizedBox(
|
||||
// height: 4,
|
||||
// ),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.person,
|
||||
color: ColorConstants.primaryColor,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"${controller.getStaff[index].firstname}",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[600],
|
||||
fontWeight:
|
||||
FontWeight.w600),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
// users[index]['Roleid']==1?
|
||||
// Icon(
|
||||
// Icons
|
||||
// .admin_panel_settings_outlined,
|
||||
// color:
|
||||
// ColorConstants.primaryColor,
|
||||
// size: 20,
|
||||
// )
|
||||
// : users[index]['Roleid']==2?Icon(Icons.phone_android,color:ColorConstants.primaryColor,size:20,):
|
||||
// Icon(Icons.laptop_windows,color:ColorConstants.primaryColor,size:20,)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.phone,
|
||||
color: ColorConstants.primaryColor,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
'+91 ${controller.getStaff[index].contactno}',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black54,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
height: 30,
|
||||
padding: EdgeInsets.only(right: 10,),
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.primaryColor,
|
||||
border: Border.all(
|
||||
color: ColorConstants.primaryColor)),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10),
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white),
|
||||
child: Icon(
|
||||
Icons.business,
|
||||
color: ColorConstants.primaryColor,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
'${controller.getStaff[index].locationname}',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.white,
|
||||
fontWeight:
|
||||
FontWeight.w400),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
staffShimmer() {
|
||||
return Shimmer.fromColors(
|
||||
enabled: true,
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.only(bottom: 60, top: 10),
|
||||
itemCount: 4,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InkWell(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey[400]!, width: 2),
|
||||
borderRadius: BorderRadius.all(Radius.circular(3)),
|
||||
),
|
||||
height: 90,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 55,
|
||||
height: 55,
|
||||
child: CircleAvatar(
|
||||
backgroundColor:
|
||||
ColorConstants.secondaryColor,
|
||||
child: Text(
|
||||
"",
|
||||
style: TextStyle(
|
||||
color: ColorConstants.secondaryColor,
|
||||
fontSize: 22),
|
||||
)),
|
||||
),
|
||||
],
|
||||
)),
|
||||
Expanded(
|
||||
flex: 8,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.person,
|
||||
color: ColorConstants.secondaryColor,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
"--------------",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.phone,
|
||||
color: ColorConstants.primaryColor,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(
|
||||
'-----------',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black54,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
// flex: 5,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.store,
|
||||
color: ColorConstants.primaryColor,
|
||||
size: 20,
|
||||
),
|
||||
SizedBox(
|
||||
width: 3,
|
||||
),
|
||||
Text(
|
||||
'-----------',
|
||||
// '',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.black54,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
],
|
||||
)),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.grey[600],
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
);
|
||||
}
|
||||
}
|
||||
478
lib/View/More/Staffs/Updatestaff/Updatestaffview.dart
Normal file
478
lib/View/More/Staffs/Updatestaff/Updatestaffview.dart
Normal file
@@ -0,0 +1,478 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../Controller/More/Staffs/Updatestaff/Updatestaffcontroller.dart';
|
||||
import '../../../../Helper/Constants/Colorconstants.dart';
|
||||
import '../../../../Helper/custombutton.dart';
|
||||
import '../../../../Helper/customederaction.dart';
|
||||
import '../../../../Model/Response/Staffs/Getstaffsresponse.dart';
|
||||
import '../../../Home/Homeview.dart';
|
||||
|
||||
class UpdateStaff extends StatelessWidget {
|
||||
final StaffDetails staffData;
|
||||
UpdateStaff({super.key, required this.staffData});
|
||||
UpdateStaffController updateStaffController = Get.put(UpdateStaffController());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: ColorConstants.lightColor,
|
||||
appBar: AppBar(
|
||||
elevation: 0.5,
|
||||
leading: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.arrow_back,
|
||||
color: ColorConstants.secondaryColor,
|
||||
size: 28,
|
||||
)),
|
||||
titleSpacing: 1,
|
||||
title: Text('Update Staff',style: TextStyle(color: ColorConstants.secondaryColor)),
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
),
|
||||
body: Container(
|
||||
child: ListView(
|
||||
children: [
|
||||
GetBuilder<UpdateStaffController>(
|
||||
initState: (_){
|
||||
updateStaffController.staffData = staffData;
|
||||
updateStaffController.setValues();
|
||||
updateStaffController.getLocation();
|
||||
},
|
||||
|
||||
builder: (controller) {
|
||||
return Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 10.0, right: 10.0, top: 10, bottom: 70),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
firstName(context),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
lastName(context),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
|
||||
Container(
|
||||
child: contactNo(context),
|
||||
height: 55,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(7)),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
email(context),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
Container(
|
||||
height: 110,
|
||||
width: Get.width,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(
|
||||
color: Color.fromRGBO(220, 220, 220, 0.6),
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(7),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 10,),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Text(
|
||||
updateStaffController.isLocation.isTrue ?'Selected Location :':"Selected Location :",
|
||||
style: TextStyle(fontSize: 18, color: Colors.grey[500]),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10,),
|
||||
updateStaffController.isLocation.value == true
|
||||
? Container(
|
||||
height: 45,
|
||||
margin: EdgeInsets.only(left: 10),
|
||||
padding: EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.primaryColor,
|
||||
|
||||
shape: BoxShape.rectangle,
|
||||
border: Border.all(
|
||||
color: Colors.white
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
// width: 150,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 45,
|
||||
|
||||
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.store,
|
||||
color: ColorConstants.secondaryColor,
|
||||
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Container(width: 1,color: Colors.white,),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
),
|
||||
Text(controller.locationName??'',
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Colors.white,
|
||||
height: 0.9,
|
||||
fontWeight: FontWeight.bold
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
:
|
||||
Expanded(
|
||||
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.only(left: 0),
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: ScrollPhysics(),
|
||||
itemCount: updateStaffController.tenantLocation?.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 5.0, top: 10,bottom: 12,right: 10),
|
||||
child: GetX<UpdateStaffController>(
|
||||
|
||||
builder: (controller) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
controller.locationId.value = controller.tenantLocation?[index].locationid??0;
|
||||
controller.locationAddress = controller.tenantLocation?[index].locationaddress??'';
|
||||
controller.locationSuburb = controller.tenantLocation?[index].locationsuburb??'';
|
||||
controller.locationCity = controller.tenantLocation?[index].locationcity??'';
|
||||
controller.locationState = controller.tenantLocation?[index].locationstate??'';
|
||||
controller.locationPostcode = controller.tenantLocation?[index].locationpostcode??'';
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
print('locationAddressonTap${controller.locationAddress}');
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: controller.locationId.value == controller.tenantLocation?[index].locationid
|
||||
? ColorConstants.primaryColor
|
||||
: Colors.white,
|
||||
shape: BoxShape.rectangle,
|
||||
border: Border.all(
|
||||
color: controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid
|
||||
? Colors.white
|
||||
: Colors.grey[300]!),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
|
||||
Container(
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.store,
|
||||
color: controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid
|
||||
? ColorConstants.secondaryColor
|
||||
: Colors.grey[400],
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
|
||||
// height: 5,
|
||||
),
|
||||
SizedBox(
|
||||
width: 1,
|
||||
child: Container(color:
|
||||
controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid? Colors.white:Colors.grey[300],),
|
||||
// height: 5,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5,
|
||||
|
||||
// height: 5,
|
||||
),
|
||||
Text( controller.tenantLocation?[index].locationname??'',
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color:controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid? Colors.white: Colors.grey[600],
|
||||
height: 0.9,
|
||||
fontWeight:
|
||||
controller.locationId.value ==
|
||||
controller.tenantLocation?[index].locationid
|
||||
? FontWeight.bold
|
||||
: FontWeight.w500)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: SizedBox(
|
||||
height: Get.height*0.08,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 11,top: 0),
|
||||
child: RoundedButton(
|
||||
onPressed: () {
|
||||
updateStaffController.describeValidation();
|
||||
},
|
||||
color:ColorConstants.primaryColor,
|
||||
title: 'Update',
|
||||
controller: updateStaffController.btnController,
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: "Lato",
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
height: Get.height*0.06,
|
||||
width: Get.width*0.8,
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget firstName(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
),
|
||||
child: TextFormField(
|
||||
keyboardType: TextInputType.text,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
decoration: CustomDecoration.textFieldStyle(
|
||||
labelTextStr: 'First Name',
|
||||
prefixIcon: Icon(
|
||||
Icons.person,
|
||||
color: ColorConstants.primaryColor,
|
||||
)),
|
||||
controller: updateStaffController.nameController,
|
||||
// focusNode: aadharNoNode,
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget lastName(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
),
|
||||
child: TextFormField(
|
||||
keyboardType: TextInputType.text,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
UpperCaseTextFormatter()
|
||||
],
|
||||
decoration: CustomDecoration.textFieldStyle(
|
||||
labelTextStr: 'Last Name',
|
||||
prefixIcon: Icon(
|
||||
Icons.person,
|
||||
color: ColorConstants.primaryColor,
|
||||
)),
|
||||
controller: updateStaffController.lastNameController,
|
||||
// focusNode: aadharNoNode,
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget contactNo(context) {
|
||||
return TextFormField(
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(signed: true, decimal: true),
|
||||
maxLength: 10,
|
||||
controller: updateStaffController.phoneNoController,
|
||||
buildCounter: (BuildContext context,
|
||||
{int? currentLength, int? maxLength, bool? isFocused}) =>
|
||||
null,
|
||||
onChanged: (contactNo) {
|
||||
if (contactNo.length == 10) {
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Contact no',
|
||||
labelStyle: TextStyle(color: Colors.grey),
|
||||
prefixIcon:Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: Get.width * 0.2,
|
||||
height: Get.height * 0.04,
|
||||
child: Row(
|
||||
children: [
|
||||
Spacer(flex: 1,),
|
||||
Flexible(
|
||||
child: Icon(
|
||||
Icons.phone_android_outlined,
|
||||
color: ColorConstants.primaryColor,
|
||||
),
|
||||
),
|
||||
Spacer(flex: 1,),
|
||||
Flexible(flex: 3,child: Text("+91",style: TextStyle(color: ColorConstants.primaryColor,fontWeight: FontWeight.bold))),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(7.0),
|
||||
borderSide: BorderSide(
|
||||
color: Color.fromRGBO(220, 220, 220, 0.6),
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(7.0),
|
||||
borderSide: BorderSide(
|
||||
color: Color.fromRGBO(220, 220, 220, 0.6),
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(7.0),
|
||||
borderSide: BorderSide(
|
||||
color: ColorConstants.primaryColor,
|
||||
width: 1.0,
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget email(context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: ColorConstants.secondaryColor,
|
||||
),
|
||||
child: Form(
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
child: TextFormField(
|
||||
validator: validateEmail,
|
||||
decoration: CustomDecoration.textFieldStyle(
|
||||
labelTextStr: 'Email',
|
||||
prefixIcon: Icon(
|
||||
Icons.mail_outline,
|
||||
color: ColorConstants.primaryColor,
|
||||
)),
|
||||
controller: updateStaffController.emailController,
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).requestFocus(FocusNode());
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String? validateEmail(String? value) {
|
||||
const pattern = r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'"
|
||||
r'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-'
|
||||
r'\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*'
|
||||
r'[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4]'
|
||||
r'[0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9]'
|
||||
r'[0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\'
|
||||
r'x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])';
|
||||
final regex = RegExp(pattern);
|
||||
|
||||
return value!.isNotEmpty && !regex.hasMatch(value)
|
||||
? 'Enter a valid email address'
|
||||
: null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UpperCaseTextFormatter extends TextInputFormatter {
|
||||
@override
|
||||
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
return TextEditingValue(
|
||||
text: capitalize(newValue.text),
|
||||
selection: newValue.selection,
|
||||
);
|
||||
}
|
||||
}
|
||||
String capitalize(String value) {
|
||||
if(value.trim().isEmpty) return "";
|
||||
return "${value[0].toUpperCase()}${value.substring(1)}";
|
||||
}
|
||||
Reference in New Issue
Block a user