-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from mohit-codes/main
Tips added | view report API url corrected
- Loading branch information
Showing
7 changed files
with
248 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const tips = [ | ||
{ | ||
'heading': 'Get plenty of fiber', | ||
'detail': | ||
'- Include foods in diet with high fiber such as fruits, vegetables, beans, whole grains and Oats.' | ||
}, | ||
{ | ||
'heading': 'Get more physical activity', | ||
'detail': | ||
'- aerobic exercise and resistance training can help control diabetes.\n - The greatest benefit comes from a fitness program that includes both.\n - Useful forms of exercise include weightlifting, brisk walking, running, biking, dancing, hiking, swimming, and more.' | ||
}, | ||
{ | ||
'heading': 'Drink water and stay hydrated', | ||
'detail': | ||
'- Drinking enough water may help you keep your blood sugar levels within healthy limits.\n - Keep in mind that water and other non-caloric beverages are best.\n - Sugar-sweetened drinks raise blood glucose, drive weight gain, and increase diabetes risk .' | ||
}, | ||
{ | ||
'heading': 'Manage stress levels', | ||
'detail': | ||
'- Stress can affect your blood sugar levels.\n - Hormones such as glucagon and cortisol are secreted during stress.\n - These hormones cause blood sugar levels to go up.' | ||
}, | ||
{ | ||
'heading': 'Eat less salt', | ||
'detail': | ||
'- Eating lots of salt can increase your risk of high blood pressure,which in turn increases risk of heart diseases and stroke.\n - And when you have diabetes, you’re already more at risk of all of these conditions.\n - Try to limit yourself to a maximum of 6g (one teaspoonful) of salt a day.\n - Lots of pre-packaged foods already contain salt so remember to check food labels and choose those with less salt.' | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:client/dashboard_screen.dart'; | ||
import 'package:client/models/patient_list_object_model.dart'; | ||
import 'package:client/models/report_model.dart'; | ||
import 'package:client/resources/helper.dart'; | ||
import 'package:client/resources/tips.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:percent_indicator/circular_percent_indicator.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class ViewReportScreen extends StatefulWidget { | ||
final String reportId; | ||
|
||
const ViewReportScreen({this.reportId}); | ||
|
||
@override | ||
_ViewReportScreenState createState() => _ViewReportScreenState(reportId); | ||
} | ||
|
||
class _ViewReportScreenState extends State<ViewReportScreen> { | ||
_ViewReportScreenState(String _tempreportId) { | ||
_reportId = _tempreportId; | ||
} | ||
|
||
String _reportId; | ||
bool _loading = true; | ||
dynamic report; | ||
|
||
void fetchReport() async { | ||
final localStorage = await SharedPreferences.getInstance(); | ||
final userid = localStorage.getString('userId'); | ||
final url = Uri.parse( | ||
"https://nutrihelpb.herokuapp.com/reports/$userid/$_reportId"); | ||
|
||
final res = await http.get( | ||
url, | ||
headers: <String, String>{ | ||
'Content-Type': 'application/json; charset=UTF-8', | ||
}, | ||
); | ||
|
||
if (res.statusCode == 200) { | ||
setState(() { | ||
_loading = false; | ||
report = Report.fromJson(jsonDecode(res.body)); | ||
}); | ||
} | ||
return null; | ||
} | ||
|
||
@override | ||
void initState() { | ||
fetchReport(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final double deviceWidth = MediaQuery.of(context).size.width; | ||
final double deviceHeight = MediaQuery.of(context).size.height; | ||
SizedBox hsb(val) => SizedBox(height: deviceHeight * val); | ||
|
||
return template( | ||
body: ListView( | ||
children: [ | ||
Row( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.only(left: 15.0, top: 10), | ||
child: Container( | ||
width: deviceWidth * 0.9, | ||
child: Text( | ||
'Prediction Report ', | ||
style: GoogleFonts.poppins(fontSize: deviceWidth * 0.08), | ||
), | ||
), | ||
) | ||
], | ||
), | ||
Container( | ||
width: deviceWidth * 0.9, | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: _loading | ||
? Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Container( | ||
width: 50, | ||
height: 50, | ||
child: const CircularProgressIndicator(), | ||
), | ||
], | ||
) | ||
: Container( | ||
width: deviceWidth * 0.5, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
CircularPercentIndicator( | ||
radius: deviceWidth * 0.4, | ||
lineWidth: deviceWidth * 0.02, | ||
percent: report.probability / 100, | ||
center: | ||
Text("${(report.probability).toString()} %"), | ||
progressColor: Colors.green, | ||
), | ||
], | ||
), | ||
Text( | ||
"Diabetic prediction probability of Patient ${report.patientName} is ${(report.probability).toString()} % .", | ||
style: | ||
GoogleFonts.poppins(fontSize: deviceWidth * 0.05), | ||
), | ||
hsb(0.01), | ||
report.probability > 50 == false | ||
? Text( | ||
'Paitent is less prone to diabetes.', | ||
style: GoogleFonts.poppins( | ||
fontSize: deviceWidth * 0.05), | ||
) | ||
: Container( | ||
width: deviceWidth * 0.9, | ||
child: Column( | ||
children: [ | ||
Text('Some Tips for Patient', | ||
style: GoogleFonts.poppins( | ||
fontSize: deviceWidth * 0.05)), | ||
Column( | ||
crossAxisAlignment: | ||
CrossAxisAlignment.start, | ||
children: tips | ||
.map((e) => Card( | ||
child: Padding( | ||
padding: | ||
const EdgeInsets.all(8.0), | ||
child: Column( | ||
crossAxisAlignment: | ||
CrossAxisAlignment.start, | ||
children: [ | ||
Text(e['heading'], | ||
style: | ||
GoogleFonts.poppins( | ||
fontSize: | ||
deviceWidth * | ||
0.05)), | ||
Text(e['detail']) | ||
], | ||
), | ||
))) | ||
.toList(), | ||
), | ||
], | ||
), | ||
) | ||
], | ||
), | ||
), | ||
), | ||
), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Container( | ||
width: deviceWidth * 0.3, | ||
child: TextButton( | ||
onPressed: () { | ||
Navigator.pushReplacement( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => const DashBoardScreen())); | ||
}, | ||
style: TextButton.styleFrom( | ||
primary: Colors.white, | ||
minimumSize: Size(deviceWidth * 0.25, deviceHeight * 0.07), | ||
shape: const RoundedRectangleBorder( | ||
borderRadius: BorderRadius.all(Radius.circular(15)), | ||
), | ||
backgroundColor: const Color(0xff05483F), | ||
), | ||
child: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceAround, | ||
children: [ | ||
const Icon(Icons.arrow_back_ios), | ||
Text('Back', | ||
style: TextStyle(fontSize: deviceWidth * 0.05)), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
], | ||
), | ||
hsb(0.01), | ||
], | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters