@ -2,9 +2,11 @@ import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart';
import ' package:diplomaticquarterapp/core/viewModels/project_view_model.dart ' ;
import ' package:diplomaticquarterapp/core/viewModels/project_view_model.dart ' ;
import ' package:diplomaticquarterapp/pages/base/base_view.dart ' ;
import ' package:diplomaticquarterapp/pages/base/base_view.dart ' ;
import ' package:diplomaticquarterapp/services/authentication/auth_provider.dart ' ;
import ' package:diplomaticquarterapp/services/authentication/auth_provider.dart ' ;
import ' package:diplomaticquarterapp/theme/colors.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart ' ;
import ' package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart ' ;
import ' package:diplomaticquarterapp/uitl/translations_delegate_base.dart ' ;
import ' package:diplomaticquarterapp/uitl/translations_delegate_base.dart ' ;
import ' package:diplomaticquarterapp/uitl/utils_new.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/defaultButton.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/defaultButton.dart ' ;
import ' package:diplomaticquarterapp/widgets/text/app_texts_widget.dart ' ;
import ' package:diplomaticquarterapp/widgets/text/app_texts_widget.dart ' ;
import ' package:flutter/cupertino.dart ' ;
import ' package:flutter/cupertino.dart ' ;
@ -16,8 +18,7 @@ class ProfileSettings extends StatefulWidget {
_ProfileSettings createState ( ) = > _ProfileSettings ( ) ;
_ProfileSettings createState ( ) = > _ProfileSettings ( ) ;
}
}
class _ProfileSettings extends State < ProfileSettings >
class _ProfileSettings extends State < ProfileSettings > with TickerProviderStateMixin {
with TickerProviderStateMixin {
bool smsAlert = true ;
bool smsAlert = true ;
bool emailAlert = true ;
bool emailAlert = true ;
int language = 1 ;
int language = 1 ;
@ -25,6 +26,7 @@ class _ProfileSettings extends State<ProfileSettings>
TextEditingController emergencyContact = new TextEditingController ( ) ;
TextEditingController emergencyContact = new TextEditingController ( ) ;
TextEditingController emailController = new TextEditingController ( ) ;
TextEditingController emailController = new TextEditingController ( ) ;
TextEditingController emergencyContactName = new TextEditingController ( ) ;
TextEditingController emergencyContactName = new TextEditingController ( ) ;
@ override
@ override
void initState ( ) {
void initState ( ) {
Future . delayed ( new Duration ( seconds: 0 ) , ( ) {
Future . delayed ( new Duration ( seconds: 0 ) , ( ) {
@ -37,199 +39,300 @@ class _ProfileSettings extends State<ProfileSettings>
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
return BaseView < DashboardViewModel > (
return BaseView < DashboardViewModel > (
onModelReady: ( model ) = > { } ,
onModelReady: ( model ) = > { } ,
builder: ( _ , model , wi ) = > Container (
builder: ( _ , model , wi ) = > Container (
child: model . user ! = null
child: model . user ! = null
? ListView ( scrollDirection: Axis . vertical , children: < Widget > [
? Column (
Container (
children: [
color: Theme . of ( context ) . textTheme . headline2 . color ,
Expanded (
padding: EdgeInsets . all ( 15 ) ,
child: SingleChildScrollView (
child: Row (
child: Padding (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
padding: const EdgeInsets . all ( 21.0 ) ,
children: [
child: Column (
AppText (
crossAxisAlignment: CrossAxisAlignment . start ,
TranslationBase . of ( context ) . fileNo ,
children: < Widget > [
color: Colors . black ,
Card (
) ,
shape: cardRadius ( 8 ) ,
AppText (
margin: EdgeInsets . zero ,
model . user . patientID . toString ( ) ,
elevation: 3 ,
color: Colors . black ,
child: Padding (
) ,
padding: const EdgeInsets . all ( 12.0 ) ,
] ,
child: Row (
mainAxisAlignment: MainAxisAlignment . start ,
children: [
Text (
TranslationBase . of ( context ) . fileNo + " : " ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.64 ,
) ,
) ,
Text (
model . user . patientID . toString ( ) ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.64 ,
) ,
) ,
] ,
) ,
) ,
) ,
mHeight ( 12 ) ,
Text (
TranslationBase . of ( context ) . languageSetting ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.64 ,
) ,
) ,
Text (
TranslationBase . of ( context ) . selectLanguage ,
style: TextStyle (
fontSize: 12 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.48 ,
) ,
) ,
Row (
children: [
Expanded (
child: Row (
children: [
new Radio (
value: 2 ,
groupValue: language ,
onChanged: ( value ) {
setState ( ( ) {
language = value ;
} ) ;
} ,
) ,
Text (
TranslationBase . of ( context ) . english ,
style: TextStyle (
fontSize: 12 ,
letterSpacing: - 0.48 ,
) ,
) ,
] ,
) ,
) ,
Expanded (
child: Row (
children: [
Radio (
value: 1 ,
groupValue: language ,
onChanged: ( value ) {
setState ( ( ) {
language = value ;
} ) ;
} ,
) ,
Text (
TranslationBase . of ( context ) . arabic ,
style: TextStyle (
fontSize: 12 ,
letterSpacing: - 0.48 ,
) ,
) ,
] ,
) ,
) ,
] ,
) ,
mHeight ( 12 ) ,
Text (
TranslationBase . of ( context ) . alert ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.64 ,
) ,
) ,
Text (
TranslationBase . of ( context ) . recAlert ,
style: TextStyle (
fontSize: 12 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.48 ,
) ,
) ,
Row (
children: [
Checkbox (
value: emailAlert ,
onChanged: ( value ) {
setState ( ( ) {
emailAlert = value ;
} ) ;
} ,
activeColor: CustomColors . accentColor ,
) ,
Text (
TranslationBase . of ( context ) . emailAlert ,
style: TextStyle (
fontSize: 12 ,
letterSpacing: - 0.48 ,
) ,
) ,
] ,
) ,
Row (
children: [
Checkbox (
value: smsAlert ,
onChanged: ( value ) {
setState ( ( ) {
smsAlert = value ;
} ) ;
} ,
activeColor: CustomColors . accentColor ,
) ,
Text (
TranslationBase . of ( context ) . smsAlert ,
style: TextStyle (
fontSize: 12 ,
letterSpacing: - 0.48 ,
) ,
) ,
] ,
) ,
mHeight ( 16 ) ,
Text (
TranslationBase . of ( context ) . contactInfo ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
letterSpacing: - 0.64 ,
) ,
) ,
mHeight ( 12 ) ,
inputWidget ( TranslationBase . of ( context ) . email , " " , emailController ) ,
mHeight ( 8 ) ,
inputWidget ( TranslationBase . of ( context ) . emergencyName , " " , emergencyContactName ) ,
mHeight ( 8 ) ,
inputWidget ( TranslationBase . of ( context ) . emergencyContact , " " , emergencyContact ) ,
mHeight ( 8 ) ,
] ,
) ,
) ,
) ,
) ,
) ,
SizedBox (
) ,
height: 1 ,
Container (
width: MediaQuery . of ( context ) . size . width ,
width: double . infinity ,
child: Container (
child: Card (
color: Colors . grey [ 300 ] ,
margin: EdgeInsets . zero ,
elevation: 20 ,
child: Padding (
padding: const EdgeInsets . only ( left: 16 , right: 16 , bottom: 16 , top: 16 ) ,
child: DefaultButton (
TranslationBase . of ( context ) . save ,
( ) {
saveSettings ( ) ;
} ,
) ,
) ,
) ,
) ,
) ,
Padding (
) ,
child: AppText (
] ,
TranslationBase . of ( context ) . languageSetting ,
)
fontWeight: FontWeight . bold ) ,
: Center (
padding: EdgeInsets . all ( 10 ) ,
child: AppText ( TranslationBase . of ( context ) . loginToUseService ) ,
) ,
) ,
) ;
}
Widget inputWidget ( String _labelText , String _hintText , TextEditingController _controller , { String prefix , bool isEnable = true , bool hasSelection = false } ) {
return Container (
padding: EdgeInsets . only ( left: 16 , right: 16 , bottom: 15 , top: 15 ) ,
alignment: Alignment . center ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 15 ) ,
color: Colors . white ,
border: Border . all (
color: Color ( 0xffefefef ) ,
width: 1 ,
) ,
) ,
child: InkWell (
onTap: hasSelection ? ( ) { } : null ,
child: Row (
children: [
Expanded (
child: Column (
mainAxisSize: MainAxisSize . min ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
_labelText ,
style: TextStyle (
fontSize: 11 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.44 ,
) ,
) ,
Container (
) ,
color: Theme . of ( context ) . textTheme . headline2 . color ,
TextField (
padding: EdgeInsets . only (
enabled: isEnable ,
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
scrollPadding: EdgeInsets . zero ,
child: Row (
keyboardType: TextInputType . number ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
controller: _controller ,
children: [
/ / onChanged: ( value ) = > { validateForm ( ) } ,
AppText ( TranslationBase . of ( context ) . english ) ,
style: TextStyle (
new Radio (
fontSize: 14 ,
value: 2 ,
height: 21 / 14 ,
groupValue: language ,
fontWeight: FontWeight . w400 ,
onChanged: ( value ) {
color: Color ( 0xff2B353E ) ,
setState ( ( ) {
letterSpacing: - 0.44 ,
language = value ;
} ) ;
} ,
)
] ,
) ) ,
Container (
color: Theme . of ( context ) . textTheme . headline2 . color ,
padding: EdgeInsets . only (
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
AppText ( TranslationBase . of ( context ) . arabic ) ,
new Radio (
value: 1 ,
groupValue: language ,
onChanged: ( value ) {
setState ( ( ) {
language = value ;
} ) ;
} ,
)
] ,
) ) ,
Padding (
child: AppText ( TranslationBase . of ( context ) . alert ) ,
padding: EdgeInsets . all ( 10 ) ,
) ,
) ,
Container (
decoration: InputDecoration (
color: Theme . of ( context ) . textTheme . headline2 . color ,
isDense: true ,
padding: EdgeInsets . only (
hintText: _hintText ,
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
hintStyle: TextStyle (
child: Row (
fontSize: 14 ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
height: 21 / 14 ,
children: [
fontWeight: FontWeight . w400 ,
AppText ( TranslationBase . of ( context ) . emailAlert ) ,
color: Color ( 0xff575757 ) ,
Switch (
letterSpacing: - 0.56 ,
value: emailAlert ,
) ,
onChanged: ( value ) {
prefixIconConstraints: BoxConstraints ( minWidth: 50 ) ,
setState ( ( ) {
prefixIcon: prefix = = null
emailAlert = value ;
? null
} ) ;
: Text (
} ,
" + " + prefix ,
activeTrackColor: Colors . lightGreenAccent ,
style: TextStyle (
activeColor: Colors . green ,
fontSize: 14 ,
)
height: 21 / 14 ,
] ,
fontWeight: FontWeight . w500 ,
) ) ,
color: Color ( 0xff2E303A ) ,
Container (
letterSpacing: - 0.56 ,
color: Theme . of ( context ) . textTheme . headline2 . color ,
padding: EdgeInsets . only (
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
child: Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [
AppText ( TranslationBase . of ( context ) . smsAlert ) ,
Switch (
value: smsAlert ,
onChanged: ( value ) {
setState ( ( ) {
smsAlert = value ;
} ) ;
} ,
activeTrackColor: Colors . lightGreenAccent ,
activeColor: Colors . green ,
)
] ,
) ) ,
Padding (
child: AppText ( TranslationBase . of ( context ) . contactInfo ) ,
padding: EdgeInsets . all ( 10 ) ,
) ,
Container (
color: Theme . of ( context ) . textTheme . headline2 . color ,
padding: EdgeInsets . only (
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
AppText ( TranslationBase . of ( context ) . email ) ,
TextField (
controller: emailController ,
decoration: InputDecoration (
suffixIcon: Icon ( Icons . edit ) ,
) )
] ,
) ) ,
Container (
color: Theme . of ( context ) . textTheme . headline2 . color ,
padding: EdgeInsets . only (
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
AppText ( TranslationBase . of ( context ) . emergencyName ) ,
TextField (
controller: emergencyContactName ,
decoration: InputDecoration (
suffixIcon: Icon ( Icons . edit ) ,
) )
] ,
) ) ,
Container (
color: Theme . of ( context ) . textTheme . headline2 . color ,
padding: EdgeInsets . only (
top: 0 , left: 10 , right: 10 , bottom: 0 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
AppText (
TranslationBase . of ( context ) . emergencyContact ) ,
TextField (
controller: emergencyContact ,
decoration: InputDecoration (
suffixIcon: Icon ( Icons . edit ) ,
) ,
) ,
)
) ,
] ,
contentPadding: EdgeInsets . zero ,
) ) ,
border: InputBorder . none ,
Container (
focusedBorder: InputBorder . none ,
padding: EdgeInsets . all ( 10 ) ,
enabledBorder: InputBorder . none ,
child: Row (
) ,
children: < Widget > [
) ,
Expanded (
] ,
child: DefaultButton (
) ,
TranslationBase . of ( context ) . save ,
) ,
( ) {
if ( hasSelection ) Icon ( Icons . keyboard_arrow_down_outlined ) ,
saveSettings ( ) ;
] ,
} ,
) ,
) ) ,
) ,
] ,
) ;
) )
] )
: Center (
child:
AppText ( TranslationBase . of ( context ) . loginToUseService ) ,
) ) ) ;
}
}
getSettings ( context ) {
getSettings ( context ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
authService . getSettings ( ) . then ( ( result ) = > {
authService . getSettings ( ) . then ( ( result ) = > { GifLoaderDialogUtils . hideDialog ( context ) , setValue ( result [ " PateintInfoForUpdateList " ] [ 0 ] ) } ) ;
GifLoaderDialogUtils . hideDialog ( context ) ,
setValue ( result [ " PateintInfoForUpdateList " ] [ 0 ] )
} ) ;
}
}
setValue ( value ) {
setValue ( value ) {
@ -252,10 +355,6 @@ class _ProfileSettings extends State<ProfileSettings>
request [ " IsEmailAlertRequired " ] = this . emailAlert ;
request [ " IsEmailAlertRequired " ] = this . emailAlert ;
request [ " IsSMSAlertRequired " ] = this . smsAlert ;
request [ " IsSMSAlertRequired " ] = this . smsAlert ;
request [ " PreferredLanguage " ] = this . language . toString ( ) ;
request [ " PreferredLanguage " ] = this . language . toString ( ) ;
authService . saveSettings ( request ) . then ( ( result ) = > {
authService . saveSettings ( request ) . then ( ( result ) = > { AppToast . showSuccessToast ( message: TranslationBase . of ( context ) . profileUpdate ) , GifLoaderDialogUtils . hideDialog ( context ) } ) ;
AppToast . showSuccessToast (
message: TranslationBase . of ( context ) . profileUpdate ) ,
GifLoaderDialogUtils . hideDialog ( context )
} ) ;
}
}
}
}