@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import ' package:diplomaticquarterapp/uitl/date_uitl.dart ' ;
import ' package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart ' ;
import ' package:diplomaticquarterapp/uitl/translations_delegate_base.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/defaultButton.dart ' ;
import ' package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart ' ;
import ' package:flutter/cupertino.dart ' ;
import ' package:flutter/material.dart ' ;
@ -95,214 +96,318 @@ class _H2oSettingState extends State<H2oSetting> {
return AppScaffold (
isShowAppBar: true ,
appBarTitle: TranslationBase . of ( context ) . h2o ,
showNewAppBar: true ,
showNewAppBarTitle: true ,
backgroundColor: Color ( 0xffF7F7F7 ) ,
showHomeAppBarIcon: false ,
body: SingleChildScrollView (
padding: EdgeInsets . fromLTRB ( 8 , 8 , 8 , 80 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
TextField (
controller: _nameController ,
decoration: InputDecoration (
labelText: TranslationBase . of ( context ) . enterNameHere ,
labelStyle: TextStyle ( color: Colors . black87 ) ,
fillColor: Colors . white ,
filled: true ,
border: UnderlineInputBorder (
borderSide: BorderSide (
width: 0 ,
style: BorderStyle . none ,
) ,
borderRadius: BorderRadius . circular ( 6.0 ) ,
) ,
) ,
) ,
SizedBox ( height: 8 ) ,
Text ( TranslationBase . of ( context ) . preferredunit ) ,
SizedBox ( height: 8 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . ml , TranslationBase . of ( context ) . l , _isUnitML , ( value ) {
if ( _isUnitML ! = value ) {
setState ( ( ) {
_isUnitML = value ;
} ) ;
}
} ) ,
Padding (
padding: EdgeInsets . only ( top: 8.0 , bottom: 8.0 ) ,
child: Divider ( height: 1.5 , color: Colors . black54 ) ,
) ,
Text ( TranslationBase . of ( context ) . gender ) ,
SizedBox ( height: 8 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . male , TranslationBase . of ( context ) . female , _isGenderMale , ( value ) {
if ( _isGenderMale ! = value ) {
setState ( ( ) {
_isGenderMale = value ;
} ) ;
}
} ) ,
Padding (
padding: EdgeInsets . only ( top: 8.0 , bottom: 8.0 ) ,
child: Divider ( height: 1.5 , color: Colors . black54 ) ,
) ,
Text ( TranslationBase . of ( context ) . height ) ,
_commonSlidersRow ( _heightController , 1 , 270 , _heightValue , ( text ) {
_heightController . text = text ;
} , ( value ) {
setState ( ( ) {
_heightValue = value ;
} ) ;
} ) ,
SizedBox ( height: 8 ) ,
Text ( TranslationBase . of ( context ) . heightUnit ) ,
SizedBox ( height: 8 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . cm , TranslationBase . of ( context ) . ft , _isHeightCM , ( value ) {
if ( _isHeightCM ! = value ) {
setState ( ( ) {
_isHeightCM = value ;
} ) ;
}
} ) ,
SizedBox ( height: 8 ) ,
_commonSlidersRow ( _weightController , 1 , 250 , _weightValue , ( text ) {
_weightController . text = text ;
} , ( value ) {
setState ( ( ) {
_weightValue = value ;
} ) ;
} ) ,
SizedBox ( height: 8 ) ,
Text ( TranslationBase . of ( context ) . weightUnit ) ,
SizedBox ( height: 8 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . kg , TranslationBase . of ( context ) . lb , _isWeightKG , ( value ) {
if ( _isWeightKG ! = value ) {
setState ( ( ) {
_isWeightKG = value ;
} ) ;
}
} ) ,
Padding (
padding: EdgeInsets . only ( top: 8.0 , bottom: 8.0 ) ,
child: Divider ( height: 1.5 , color: Colors . black54 ) ,
) ,
Container (
padding: EdgeInsets . all ( 8 ) ,
width: MediaQuery . of ( context ) . size . width ,
decoration: BoxDecoration ( borderRadius: BorderRadius . circular ( 8 ) , color: Colors . white ) ,
body: Column (
children: [
Expanded (
child: SingleChildScrollView (
physics: BouncingScrollPhysics ( ) ,
padding: EdgeInsets . all ( 21 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text ( " ${ TranslationBase . of ( context ) . birth_date } : " ) ,
inputWidget ( TranslationBase . of ( context ) . enterNameHere , TranslationBase . of ( context ) . enterNameHere , _nameController ) ,
/ / TextField (
/ / controller: _nameController ,
/ / decoration: InputDecoration (
/ / labelText: TranslationBase . of ( context ) . enterNameHere ,
/ / labelStyle: TextStyle ( color: Colors . black87 ) ,
/ / fillColor: Colors . white ,
/ / filled: true ,
/ / border: UnderlineInputBorder (
/ / borderSide: BorderSide (
/ / width: 0 ,
/ / style: BorderStyle . none ,
/ / ) ,
/ / borderRadius: BorderRadius . circular ( 6.0 ) ,
/ / ) ,
/ / ) ,
/ / ) ,
SizedBox ( height: 16 ) ,
Text (
TranslationBase . of ( context ) . preferredunit ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.48 , height: 18 / 12 ) ,
) ,
SizedBox ( height: 12 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . ml , TranslationBase . of ( context ) . l , _isUnitML , ( value ) {
if ( _isUnitML ! = value ) {
setState ( ( ) {
_isUnitML = value ;
} ) ;
}
} ) ,
SizedBox ( height: 12 ) ,
Text (
TranslationBase . of ( context ) . pleaseSelectGender ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.48 , height: 18 / 12 ) ,
) ,
SizedBox ( height: 12 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . male , TranslationBase . of ( context ) . female , _isGenderMale , ( value ) {
if ( _isGenderMale ! = value ) {
setState ( ( ) {
_isGenderMale = value ;
} ) ;
}
} ) ,
SizedBox ( height: 12 ) ,
Text ( TranslationBase . of ( context ) . height ) ,
_commonSlidersRow ( _heightController , 1 , 270 , _heightValue , ( text ) {
_heightController . text = text ;
} , ( value ) {
setState ( ( ) {
_heightValue = value ;
} ) ;
} ) ,
SizedBox ( height: 8 ) ,
InkWell (
onTap: ( ) {
showModalBottomSheet (
context: context ,
builder: ( context ) {
return Container (
height: 250 ,
padding: EdgeInsets . all ( 8 ) ,
child: Column ( children: [
Container (
height: 40 ,
alignment: Alignment . centerRight ,
child: Row ( mainAxisSize: MainAxisSize . min , children: [
InkWell (
onTap: ( ) = > Navigator . pop ( context ) ,
child: Container (
alignment: Alignment . center ,
padding: EdgeInsets . fromLTRB ( 8 , 4 , 8 , 4 ) ,
child: Text ( TranslationBase . of ( context ) . cancel ) ,
) ,
) ,
SizedBox ( width: 8 ) ,
InkWell (
onTap: ( ) {
Navigator . pop ( context ) ;
setState ( ( ) {
_dobDate = _tempDate ;
} ) ;
} ,
child: Container (
alignment: Alignment . center ,
padding: EdgeInsets . fromLTRB ( 8 , 4 , 8 , 4 ) ,
child: Text ( TranslationBase . of ( context ) . ok ) ,
Text ( TranslationBase . of ( context ) . heightUnit ) ,
SizedBox ( height: 8 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . cm , TranslationBase . of ( context ) . ft , _isHeightCM , ( value ) {
if ( _isHeightCM ! = value ) {
setState ( ( ) {
_isHeightCM = value ;
} ) ;
}
} ) ,
SizedBox ( height: 8 ) ,
_commonSlidersRow ( _weightController , 1 , 250 , _weightValue , ( text ) {
_weightController . text = text ;
} , ( value ) {
setState ( ( ) {
_weightValue = value ;
} ) ;
} ) ,
SizedBox ( height: 8 ) ,
Text ( TranslationBase . of ( context ) . weightUnit ) ,
SizedBox ( height: 8 ) ,
_commonButtonsRow ( TranslationBase . of ( context ) . kg , TranslationBase . of ( context ) . lb , _isWeightKG , ( value ) {
if ( _isWeightKG ! = value ) {
setState ( ( ) {
_isWeightKG = value ;
} ) ;
}
} ) ,
Padding (
padding: EdgeInsets . only ( top: 8.0 , bottom: 8.0 ) ,
child: Divider ( height: 1.5 , color: Colors . black54 ) ,
) ,
Container (
padding: EdgeInsets . all ( 8 ) ,
width: MediaQuery . of ( context ) . size . width ,
decoration: BoxDecoration ( borderRadius: BorderRadius . circular ( 8 ) , color: Colors . white ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text ( " ${ TranslationBase . of ( context ) . birth_date } : " ) ,
SizedBox ( height: 8 ) ,
InkWell (
onTap: ( ) {
showModalBottomSheet (
context: context ,
builder: ( context ) {
return Container (
height: 250 ,
padding: EdgeInsets . all ( 8 ) ,
child: Column ( children: [
Container (
height: 40 ,
alignment: Alignment . centerRight ,
child: Row ( mainAxisSize: MainAxisSize . min , children: [
InkWell (
onTap: ( ) = > Navigator . pop ( context ) ,
child: Container (
alignment: Alignment . center ,
padding: EdgeInsets . fromLTRB ( 8 , 4 , 8 , 4 ) ,
child: Text ( TranslationBase . of ( context ) . cancel ) ,
) ,
) ,
SizedBox ( width: 8 ) ,
InkWell (
onTap: ( ) {
Navigator . pop ( context ) ;
setState ( ( ) {
_dobDate = _tempDate ;
} ) ;
} ,
child: Container (
alignment: Alignment . center ,
padding: EdgeInsets . fromLTRB ( 8 , 4 , 8 , 4 ) ,
child: Text ( TranslationBase . of ( context ) . ok ) ,
) ,
)
] ) ,
) ,
)
] ) ,
) ,
Expanded (
child: Container (
width: MediaQuery . of ( context ) . size . width ,
child: CupertinoDatePicker (
initialDateTime: _dobDate ,
mode: CupertinoDatePickerMode . date ,
onDateTimeChanged: ( _date ) {
_tempDate = _date ;
} ,
) ,
) ,
)
] ) ,
) ;
Expanded (
child: Container (
width: MediaQuery . of ( context ) . size . width ,
child: CupertinoDatePicker (
initialDateTime: _dobDate ,
mode: CupertinoDatePickerMode . date ,
onDateTimeChanged: ( _date ) {
_tempDate = _date ;
} ,
) ,
) ,
)
] ) ,
) ;
} ) ;
} , / / implement cupertino dialog to select date
child: Row (
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [ Text ( DateUtil . getFormattedDate ( _dobDate , " yyyy-MM-dd " ) ) , Icon ( Icons . arrow_drop_down_outlined ) ] ) ,
)
] ,
) ,
) ,
SizedBox ( height: 8 ) ,
_commonDialogSelectorRow ( TranslationBase . of ( context ) . activityLevel , _activityLevelListEng [ _selectedActiveLevel - 1 ] , ( ) {
showDialog (
context: context ,
child: CommonRadioButtonDialog (
list: _activityLevelListEng ,
title: TranslationBase . of ( context ) . activityLevel ,
onSelect: ( index ) {
Navigator . pop ( context ) ;
setState ( ( ) {
_selectedActiveLevel = index + 1 ;
} ) ;
} ,
selectedIndex: _selectedActiveLevel - 1 ,
) ,
) ;
} ) ,
SizedBox ( height: 8 ) ,
_commonDialogSelectorRow ( TranslationBase . of ( context ) . reminderLabel , _remindedTimeListEng [ _selectedRemindedTime ] , ( ) {
showDialog (
context: context ,
child: CommonRadioButtonDialog (
list: _remindedTimeListEng ,
onSelect: ( index ) {
Navigator . pop ( context ) ;
setState ( ( ) {
_selectedRemindedTime = index ;
} ) ;
} , / / implement cupertino dialog to select date
child: Row (
crossAxisAlignment: CrossAxisAlignment . center ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
children: [ Text ( DateUtil . getFormattedDate ( _dobDate , " yyyy-MM-dd " ) ) , Icon ( Icons . arrow_drop_down_outlined ) ] ) ,
)
} ,
selectedIndex: _selectedRemindedTime ,
) ,
) ;
} ) ,
SizedBox ( height: 16 ) ,
SizedBox (
height: 50 ,
width: MediaQuery . of ( context ) . size . width ,
child: FlatButton (
color: Theme . of ( context ) . appBarTheme . color ,
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 8.0 ) ,
) ,
onPressed: _updateUserDetails ,
child: Text (
TranslationBase . of ( context ) . save ,
style: TextStyle ( color: Colors . white , fontSize: 18 , fontWeight: FontWeight . w600 ) ,
) ,
) ,
) ,
] ,
) ,
) ,
SizedBox ( height: 8 ) ,
_commonDialogSelectorRow ( TranslationBase . of ( context ) . activityLevel , _activityLevelListEng [ _selectedActiveLevel - 1 ] , ( ) {
showDialog (
context: context ,
child: CommonRadioButtonDialog (
list: _activityLevelListEng ,
title: TranslationBase . of ( context ) . activityLevel ,
onSelect: ( index ) {
Navigator . pop ( context ) ;
setState ( ( ) {
_selectedActiveLevel = index + 1 ;
} ) ;
} ,
selectedIndex: _selectedActiveLevel - 1 ,
) ,
) ;
} ) ,
SizedBox ( height: 8 ) ,
_commonDialogSelectorRow ( TranslationBase . of ( context ) . reminderLabel , _remindedTimeListEng [ _selectedRemindedTime ] , ( ) {
showDialog (
context: context ,
child: CommonRadioButtonDialog (
list: _remindedTimeListEng ,
onSelect: ( index ) {
Navigator . pop ( context ) ;
setState ( ( ) {
_selectedRemindedTime = index ;
} ) ;
} ,
selectedIndex: _selectedRemindedTime ,
) ,
) ;
} ) ,
SizedBox ( height: 16 ) ,
SizedBox (
height: 50 ,
width: MediaQuery . of ( context ) . size . width ,
child: FlatButton (
color: Theme . of ( context ) . appBarTheme . color ,
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 8.0 ) ,
) ,
onPressed: _updateUserDetails ,
child: Text (
TranslationBase . of ( context ) . save ,
style: TextStyle ( color: Colors . white , fontSize: 18 , fontWeight: FontWeight . w600 ) ,
) ,
) ,
Container (
color: Colors . white ,
padding: EdgeInsets . only ( top: 16 , bottom: 16 , right: 21 , left: 21 ) ,
child: DefaultButton (
TranslationBase . of ( context ) . save ,
_updateUserDetails ,
color: Color ( 0xff349745 ) ,
) ,
) ,
] ,
) ,
) ;
}
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 ,
) ,
) ,
TextField (
enabled: isEnable ,
scrollPadding: EdgeInsets . zero ,
keyboardType: TextInputType . number ,
controller: _controller ,
onChanged: ( value ) = > {
/ / validateForm ( )
} ,
style: TextStyle (
fontSize: 14 ,
height: 21 / 14 ,
fontWeight: FontWeight . w400 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.44 ,
) ,
decoration: InputDecoration (
isDense: true ,
hintText: _hintText ,
hintStyle: TextStyle (
fontSize: 14 ,
height: 21 / 14 ,
fontWeight: FontWeight . w400 ,
color: Color ( 0xff575757 ) ,
letterSpacing: - 0.56 ,
) ,
prefixIconConstraints: BoxConstraints ( minWidth: 50 ) ,
prefixIcon: prefix = = null
? null
: Text (
" + " + prefix ,
style: TextStyle (
fontSize: 14 ,
height: 21 / 14 ,
fontWeight: FontWeight . w500 ,
color: Color ( 0xff2E303A ) ,
letterSpacing: - 0.56 ,
) ,
) ,
contentPadding: EdgeInsets . zero ,
border: InputBorder . none ,
focusedBorder: InputBorder . none ,
enabledBorder: InputBorder . none ,
) ,
) ,
] ,
) ,
)
) ,
if ( hasSelection ) Icon ( Icons . keyboard_arrow_down_outlined ) ,
] ,
) ,
) ,
@ -310,6 +415,16 @@ class _H2oSettingState extends State<H2oSetting> {
}
Widget _commonButtonsRow ( String rightText , String leftText , bool checkParam , Function ( bool ) callBack ) {
return Row (
children: [
Row ( children: [
Checkbox ( value: null , onChanged: null )
] , )
] ,
) ;
return Row ( children: [
Expanded (
child: SizedBox (