@ -25,6 +25,10 @@ class WorkplaceUpdatePage extends StatefulWidget {
class _WorkplaceUpdatePageState extends State < WorkplaceUpdatePage > {
TextEditingController workplaceName = new TextEditingController ( ) ;
TextEditingController workplaceNameAr = new TextEditingController ( ) ;
TextEditingController occupationNameEn = new TextEditingController ( ) ;
TextEditingController occupationNameAr = new TextEditingController ( ) ;
bool ? _isButtonDisabled ;
ProjectViewModel ? projectViewModel ;
@ -66,7 +70,13 @@ class _WorkplaceUpdatePageState extends State<WorkplaceUpdatePage> {
) ,
) ,
mHeight ( 8 ) ,
inputWidget ( TranslationBase . of ( context ) . workplaceName , " " , workplaceName ) ,
inputWidget ( TranslationBase . of ( context ) . workplaceName , " " , workplaceName , FilteringTextInputFormatter . allow ( RegExp ( " [a-zA-Z ] " ) ) ) ,
mHeight ( 8 ) ,
inputWidget ( TranslationBase . of ( context ) . workplaceNameAr , " " , workplaceNameAr , FilteringTextInputFormatter . allow ( RegExp ( " [ء-ي ] " ) ) ) ,
mHeight ( 8 ) ,
inputWidget ( TranslationBase . of ( context ) . occupationNameEn , " " , occupationNameEn , FilteringTextInputFormatter . allow ( RegExp ( " [a-zA-Z ] " ) ) ) ,
mHeight ( 8 ) ,
inputWidget ( TranslationBase . of ( context ) . occupationNameAr , " " , occupationNameAr , FilteringTextInputFormatter . allow ( RegExp ( " [ء-ي ] " ) ) ) ,
] ,
) ,
) ,
@ -94,10 +104,11 @@ class _WorkplaceUpdatePageState extends State<WorkplaceUpdatePage> {
) ,
) ,
onPressed: ( ) {
if ( _isButtonDisabled = = false )
/ / if ( _isButtonDisabled = = false )
if ( workplaceName . text . isNotEmpty & & workplaceNameAr . text . isNotEmpty & & occupationNameEn . text . isNotEmpty & & occupationNameAr . text . isNotEmpty )
updateWorkplaceNameDialog ( ) ;
else
AppToast . showErrorToast ( message: TranslationBase . of ( context ) . enter WorkplaceName ) ;
AppToast . showErrorToast ( message: TranslationBase . of ( context ) . enter DetailBelow ) ;
} ,
) ,
) ,
@ -109,7 +120,7 @@ class _WorkplaceUpdatePageState extends State<WorkplaceUpdatePage> {
) ;
}
Widget inputWidget ( String _labelText , String _hintText , TextEditingController _controller , { String ? prefix , bool isEnable = true , bool hasSelection = false } ) {
Widget inputWidget ( String _labelText , String _hintText , TextEditingController _controller , TextInputFormatter inputFormatter , { String ? prefix , bool isEnable = true , bool hasSelection = false } ) {
return Container (
padding: EdgeInsets . only ( left: 16 , right: 16 , bottom: 15 , top: 15 ) ,
alignment: Alignment . center ,
@ -145,7 +156,8 @@ class _WorkplaceUpdatePageState extends State<WorkplaceUpdatePage> {
keyboardType: TextInputType . name ,
controller: _controller ,
inputFormatters: [
projectViewModel ! . isArabic ? FilteringTextInputFormatter . allow ( RegExp ( " [ء-ي ] " ) ) : FilteringTextInputFormatter . allow ( RegExp ( " [a-zA-Z ] " ) ) ,
/ / projectViewModel ! . isArabic ? FilteringTextInputFormatter . allow ( RegExp ( " [ء-ي ] " ) ) : FilteringTextInputFormatter . allow ( RegExp ( " [a-zA-Z ] " ) ) ,
inputFormatter
] ,
onChanged: ( value ) = > { _onPassportTextChanged ( value ) } ,
style: TextStyle (
@ -226,9 +238,7 @@ class _WorkplaceUpdatePageState extends State<WorkplaceUpdatePage> {
LabsService service = new LabsService ( ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
service
. updateWorkplaceName ( projectViewModel ! . isArabic ? " - " : workplaceName . text , projectViewModel ! . isArabic ? workplaceName . text : " - " , widget . requestNumber , widget . setupID , widget . projectID )
. then ( ( res ) {
service . updateWorkplaceName ( workplaceName . text , workplaceNameAr . text , occupationNameEn . text , occupationNameAr . text , widget . requestNumber , widget . setupID , widget . projectID ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
Navigator . of ( context ) . pop ( true ) ;
} ) . catchError ( ( err ) {