@ -1,49 +1,58 @@
import ' dart:collection ' ;
import ' package:auto_size_text/auto_size_text.dart ' ;
import ' package:diplomaticquarterapp/config/size_config.dart ' ;
import ' package:diplomaticquarterapp/ models/Appointments/DoctorListResponse .dart' ;
import ' package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bariatrics-screen.dart ' ;
import ' package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart ' ;
import ' package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart ' ;
import ' package:diplomaticquarterapp/theme/colors.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart ' ;
import ' package:diplomaticquarterapp/uitl/translations_delegate_base.dart ' ;
import ' package:diplomaticquarterapp/uitl/utils_new.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/borderedButton.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/secondary_button.dart ' ;
import ' package:diplomaticquarterapp/widgets/data_display/text.dart ' ;
import ' package:diplomaticquarterapp/widgets/buttons/defaultButton.dart ' ;
import ' package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart ' ;
import ' package:diplomaticquarterapp/widgets/transitions/fade_page.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter_svg/svg.dart ' ;
import ' package:percent_indicator/percent_indicator.dart ' ;
class ResultPage extends State less Widget {
class ResultPage extends State fu lWidget {
final double finalResult ;
final String textResult ;
final String msg ;
ResultPage ( { this . finalResult , this . textResult , this . msg } ) ;
@ override
_ResultPageState createState ( ) = > _ResultPageState ( ) ;
}
class _ResultPageState extends State < ResultPage > {
Color inductorColor ;
double percent ;
Color colorInductor ( ) {
if ( finalResult > = 30 ) {
if ( widget. finalResult > = 30 ) {
inductorColor = Color ( 0xffC70D00 ) ;
} else if ( finalResult < 30 & & finalResult > = 25 ) {
} else if ( widget. finalResult < 30 & & widget . finalResult > = 25 ) {
inductorColor = Color ( 0xffC25400 ) ;
} else if ( finalResult < 25 & & finalResult > = 18.5 ) {
} else if ( widget. finalResult < 25 & & widget . finalResult > = 18.5 ) {
inductorColor = Color ( 0xff36D600 ) ;
} else if ( finalResult < 18.5 ) {
} else if ( widget. finalResult < 18.5 ) {
inductorColor = Color ( 0xff1BE0EE ) ;
}
return inductorColor ;
}
double percentInductor ( ) {
if ( finalResult > = 30 ) {
if ( widget. finalResult > = 30 ) {
percent = 1.0 ;
} else if ( finalResult < 30 & & finalResult > = 25 ) {
} else if ( widget. finalResult < 30 & & widget . finalResult > = 25 ) {
percent = 0.73 ;
} else if ( finalResult < 25 & & finalResult > = 18.5 ) {
} else if ( widget. finalResult < 25 & & widget . finalResult > = 18.5 ) {
percent = 0.5 ;
} else if ( finalResult < 18.5 ) {
} else if ( widget. finalResult < 18.5 ) {
percent = 0.25 ;
}
return percent ;
@ -69,7 +78,7 @@ class ResultPage extends StatelessWidget {
mainAxisSize: MainAxisSize . min ,
children: [
Text (
TranslationBase . of ( context ) . bodyMassIndex + finalResult. toString ( ) ,
TranslationBase . of ( context ) . bodyMassIndex + widget. finalResult. toString ( ) ,
style: TextStyle (
fontSize: 16 ,
letterSpacing: - 0.64 ,
@ -81,21 +90,21 @@ class ResultPage extends StatelessWidget {
height: MediaQuery . of ( context ) . size . width / 2.8 ,
child: Row (
children: [
showMass ( context , TranslationBase . of ( context ) . underWeight , " < 18.5 " , finalResult < = 18.5 ? Colors . red : Colors . black , 8 ) ,
showMass ( context , TranslationBase . of ( context ) . underWeight , " < 18.5 " , widget. finalResult < = 18.5 ? Colors . red : Colors . black , 8 ) ,
mWidth ( 12 ) ,
showMass ( context , TranslationBase . of ( context ) . healthy , " 18.5 - 24.9 " , ( finalResult > 18.5 & & finalResult < 25 ) ? Colors . red : Colors . black , 6 ) ,
showMass ( context , TranslationBase . of ( context ) . healthy , " 18.5 - 24.9 " , ( widget. finalResult > 18.5 & & widget . finalResult < 25 ) ? Colors . red : Colors . black , 6 ) ,
mWidth ( 12 ) ,
showMass ( context , TranslationBase . of ( context ) . overWeight , " 25 - 29.9 " , ( finalResult > = 25 & & finalResult < 30 ) ? Colors . red : Colors . black , 4 ) ,
showMass ( context , TranslationBase . of ( context ) . overWeight , " 25 - 29.9 " , ( widget. finalResult > = 25 & & widget . finalResult < 30 ) ? Colors . red : Colors . black , 4 ) ,
mWidth ( 12 ) ,
showMass ( context , TranslationBase . of ( context ) . obese , " 30 - 34.9 " , ( finalResult > = 30 & & finalResult < 35 ) ? Colors . red : Colors . black , 2 ) ,
showMass ( context , TranslationBase . of ( context ) . obese , " 30 - 34.9 " , ( widget. finalResult > = 30 & & widget . finalResult < 35 ) ? Colors . red : Colors . black , 2 ) ,
mWidth ( 12 ) ,
showMass ( context , TranslationBase . of ( context ) . extremeObese , " > 35 " , ( finalResult > = 35 ) ? Colors . red : Colors . black , 0 ) ,
showMass ( context , TranslationBase . of ( context ) . extremeObese , " > 35 " , ( widget. finalResult > = 35 ) ? Colors . red : Colors . black , 0 ) ,
] ,
) ,
) ,
mHeight ( 20 ) ,
Text (
textResult,
widget. textResult,
style: TextStyle (
fontSize: 16.0 ,
fontWeight: FontWeight . w600 ,
@ -104,7 +113,7 @@ class ResultPage extends StatelessWidget {
) ,
mHeight ( 4 ) ,
Text (
msg,
widget. msg,
style: TextStyle ( fontSize: 14.0 , fontWeight: FontWeight . w600 , letterSpacing: - 0.56 , color: CustomColors . textColor ) ,
) ,
] ,
@ -115,14 +124,10 @@ class ResultPage extends StatelessWidget {
Container (
color: Colors . white ,
padding: EdgeInsets . all ( 16 ) ,
child: SecondaryButton (
label: TranslationBase . of ( context ) . seeListOfDoctor ,
color: CustomColors . accentColor ,
onTap: ( ) {
Navigator . push (
context ,
FadePage ( page: BariatricsPage ( 1 , 1 , finalResult ) ) ,
) ;
child: DefaultButton (
TranslationBase . of ( context ) . seeListOfDoctor ,
( ) {
callDoctorsSearchAPI ( ) ;
} ,
) ,
) ,
@ -131,6 +136,65 @@ class ResultPage extends StatelessWidget {
) ;
}
callDoctorsSearchAPI ( ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
List < DoctorList > doctorsList = [ ] ;
List < String > arr = [ ] ;
List < String > arrDistance = [ ] ;
List < String > result ;
int numAll ;
List < PatientDoctorAppointmentList > _patientDoctorAppointmentListHospital = List ( ) ;
DoctorsListService service = new DoctorsListService ( ) ;
service . getDoctorsList ( 108 , 0 , false , context ) . then ( ( res ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
if ( res [ ' MessageStatus ' ] = = 1 ) {
setState ( ( ) {
if ( res [ ' DoctorList ' ] . length ! = 0 ) {
doctorsList . clear ( ) ;
res [ ' DoctorList ' ] . forEach ( ( v ) {
doctorsList . add ( new DoctorList . fromJson ( v ) ) ;
} ) ;
doctorsList . forEach ( ( element ) {
List < PatientDoctorAppointmentList > doctorByHospital = _patientDoctorAppointmentListHospital
. where (
( elementClinic ) = > elementClinic . filterName = = element . projectName ,
)
. toList ( ) ;
if ( doctorByHospital . length ! = 0 ) {
_patientDoctorAppointmentListHospital [ _patientDoctorAppointmentListHospital . indexOf ( doctorByHospital [ 0 ] ) ] . patientDoctorAppointmentList . add ( element ) ;
} else {
_patientDoctorAppointmentListHospital
. add ( PatientDoctorAppointmentList ( filterName: element . projectName , distanceInKMs: element . projectDistanceInKiloMeters . toString ( ) , patientDoctorAppointment: element ) ) ;
}
} ) ;
} else { }
} ) ;
result = LinkedHashSet < String > . from ( arr ) . toList ( ) ;
numAll = result . length ;
navigateToSearchResults ( context , doctorsList , _patientDoctorAppointmentListHospital ) ;
} else {
AppToast . showErrorToast ( message: res [ ' ErrorEndUserMessage ' ] ) ;
}
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( err ) ;
AppToast . showErrorToast ( message: err ) ;
} ) ;
}
Future navigateToSearchResults ( context , List < DoctorList > docList , List < PatientDoctorAppointmentList > patientDoctorAppointmentListHospital ) async {
Navigator . push ( context , FadePage ( page: SearchResults ( isLiveCareAppointment: false , doctorsList: docList , patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital ) ) )
. then ( ( value ) {
setState ( ( ) {
/ / dropdownValue = null ;
} ) ;
/ / getProjectsList ( ) ;
} ) ;
}
Widget showMass ( BuildContext context , String title , String weight , Color color , int f ) {
return Expanded (
flex: 1 ,