diff --git a/api/diagnosis/breast-deployment/breastmodelsdgp/app.py b/api/diagnosis/breast-deployment/breastmodelsdgp/app.py index 7fc3cc6..d96f87c 100644 --- a/api/diagnosis/breast-deployment/breastmodelsdgp/app.py +++ b/api/diagnosis/breast-deployment/breastmodelsdgp/app.py @@ -2,14 +2,14 @@ import numpy as np import tensorflow as tf from .breastDiagModule import BreastDiagModule - +import logging breastDiagModule = BreastDiagModule() scriptpath = os.path.abspath(__file__) scriptdir = os.path.dirname(scriptpath) BREAST_MODEL_PATH = os.path.join(scriptdir, 'breast_model.h5') -# Calculate Prediction Percentage of result (cancer / normal percentage) +# Calculate Prediction Percentage of result cancer def calculate_prediction_percent_breast(prediction, result): return str(np.amax(prediction[0][0] * 100)) diff --git a/ui/images/exerciseImages/bicyclecrunches.jpg b/ui/images/bicyclecrunches.jpg similarity index 100% rename from ui/images/exerciseImages/bicyclecrunches.jpg rename to ui/images/bicyclecrunches.jpg diff --git a/ui/images/exerciseImages/calfraises.jpg b/ui/images/calfraises.jpg similarity index 100% rename from ui/images/exerciseImages/calfraises.jpg rename to ui/images/calfraises.jpg diff --git a/ui/images/deadlift.gif b/ui/images/deadlift.gif new file mode 100644 index 0000000..24a1ab9 Binary files /dev/null and b/ui/images/deadlift.gif differ diff --git a/ui/images/exerciseImages/highknees.jpg b/ui/images/exerciseImages/highknees.jpg deleted file mode 100644 index 3a6494f..0000000 Binary files a/ui/images/exerciseImages/highknees.jpg and /dev/null differ diff --git a/ui/images/exerciseImages/squats.jpg b/ui/images/exerciseImages/squats.jpg deleted file mode 100644 index 12e4d23..0000000 Binary files a/ui/images/exerciseImages/squats.jpg and /dev/null differ diff --git a/ui/images/highknees.jpg b/ui/images/highknees.jpg new file mode 100644 index 0000000..ae971ec Binary files /dev/null and b/ui/images/highknees.jpg differ diff --git a/ui/images/jacks.gif b/ui/images/jacks.gif new file mode 100644 index 0000000..ddf4b7c Binary files /dev/null and b/ui/images/jacks.gif differ diff --git a/ui/images/exerciseImages/jumpingjacks.jpg b/ui/images/jumpingjacks.jpg similarity index 100% rename from ui/images/exerciseImages/jumpingjacks.jpg rename to ui/images/jumpingjacks.jpg diff --git a/ui/images/exerciseImages/jumpsquats.jpg b/ui/images/jumpsquats.jpg similarity index 100% rename from ui/images/exerciseImages/jumpsquats.jpg rename to ui/images/jumpsquats.jpg diff --git a/ui/images/legstretch.gif b/ui/images/legstretch.gif new file mode 100644 index 0000000..5d7cf3a Binary files /dev/null and b/ui/images/legstretch.gif differ diff --git a/ui/images/exerciseImages/planks.jpg b/ui/images/planks.jpg similarity index 100% rename from ui/images/exerciseImages/planks.jpg rename to ui/images/planks.jpg diff --git a/ui/images/pullups.gif b/ui/images/pullups.gif new file mode 100644 index 0000000..09f5a9e Binary files /dev/null and b/ui/images/pullups.gif differ diff --git a/ui/images/exerciseImages/pushups.jpg b/ui/images/pushups.jpg similarity index 100% rename from ui/images/exerciseImages/pushups.jpg rename to ui/images/pushups.jpg diff --git a/ui/images/exerciseImages/situps.jpg b/ui/images/situps.jpg similarity index 100% rename from ui/images/exerciseImages/situps.jpg rename to ui/images/situps.jpg diff --git a/ui/images/squats.jpg b/ui/images/squats.jpg new file mode 100644 index 0000000..475c857 Binary files /dev/null and b/ui/images/squats.jpg differ diff --git a/ui/images/thighlunges.gif b/ui/images/thighlunges.gif new file mode 100644 index 0000000..862e881 Binary files /dev/null and b/ui/images/thighlunges.gif differ diff --git a/ui/images/exerciseImages/thighlunges.jpg b/ui/images/thighlunges.jpg similarity index 100% rename from ui/images/exerciseImages/thighlunges.jpg rename to ui/images/thighlunges.jpg diff --git a/ui/lib/components/alert_widget.dart b/ui/lib/components/alert_widget.dart index df81d12..fc2eab7 100644 --- a/ui/lib/components/alert_widget.dart +++ b/ui/lib/components/alert_widget.dart @@ -1,12 +1,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:ui/components/reports_card.dart'; import 'package:ui/screens/Personal%20Manager/reportManager/diagnosis_reports_screen.dart'; import 'package:ui/screens/Personal%20Manager/reportManager/prognosis_reports_screen.dart'; -import 'package:ui/screens/Personal%20Manager/reportManager/report_widgets/ReportListWidget.dart'; import 'package:ui/screens/current_screen.dart'; -import 'package:ui/screens/settings_screen.dart'; +// ignore: must_be_immutable class AlertWidget extends StatelessWidget { // Variables final String title; @@ -54,7 +52,9 @@ class AlertWidget extends StatelessWidget { borderSide: BorderSide(color: Colors.red), ), enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xFF637477)), + borderSide: BorderSide( + color: Color(0xFF637477), + ), ), ), ); @@ -122,22 +122,29 @@ class AlertWidget extends StatelessWidget { Navigator.pop(context); // pop the alert Navigator.push( context, - MaterialPageRoute(builder: (context) => DiagnosisReports()), + MaterialPageRoute( + builder: (context) => DiagnosisReports(), + ), ); - } - else if (_status == 202) { + } else if (_status == 203) { // Remove the alert widget and direct to prognosis report list Navigator.pop(context); // pop the alert Navigator.push( context, - MaterialPageRoute(builder: (context) => PrognosisReports()), + MaterialPageRoute( + builder: (context) => PrognosisReports(), + ), ); } if (_status == 200) { Navigator.pop(context); // pop the alert - Navigator.push(context, - MaterialPageRoute(builder: (_) => PrognosisReports())); + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => CurrentScreen(), + ), + ); } else if (confirmChangePrimitiveWrapper != null) { confirmChangePrimitiveWrapper.setConfirmChange(true); Navigator.pop(context); @@ -209,8 +216,10 @@ class TextPrimitiveWrapper { TextPrimitiveWrapper(this._text); + // ignore: unnecessary_getters_setters String get text => _text; + // ignore: unnecessary_getters_setters set text(String value) { _text = value; } diff --git a/ui/lib/components/cancer_card.dart b/ui/lib/components/cancer_card.dart index 5be24b6..3076274 100644 --- a/ui/lib/components/cancer_card.dart +++ b/ui/lib/components/cancer_card.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -//TODO - need to add functionality for passing colors into card, add font and finishing touches. - // This is the Cancer Card generator that accepts parameters to build a custom card for each cancer class CancerCard extends StatelessWidget { @@ -11,7 +9,11 @@ class CancerCard extends StatelessWidget { final String cardColor2; final String textColor; - CancerCard({@required this.cardTitle, @required this.cardColor,@required this.cardColor2, @required this.textColor}); //constructor to init values + CancerCard( + {@required this.cardTitle, + @required this.cardColor, + @required this.cardColor2, + @required this.textColor}); //constructor to init values @override Widget build(BuildContext context) { @@ -20,15 +22,21 @@ class CancerCard extends StatelessWidget { borderRadius: BorderRadius.circular(18), gradient: LinearGradient( colors: [ - Color(int.parse(cardColor)), - Color(int.parse(cardColor2)), + Color( + int.parse(cardColor), + ), + Color( + int.parse(cardColor2), + ), ], - begin: Alignment(1.2,1), - end: Alignment(0.8,-2), + begin: Alignment(1.2, 1), + end: Alignment(0.8, -2), ), boxShadow: [ BoxShadow( - color: Color(int.parse(cardColor)).withOpacity(0.5), + color: Color( + int.parse(cardColor), + ).withOpacity(0.5), spreadRadius: 3, blurRadius: 15, offset: Offset(7, 9), // changes position of shadow @@ -52,4 +60,4 @@ class CancerCard extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/ui/lib/components/chatbot_message_bubble.dart b/ui/lib/components/chatbot_message_bubble.dart index 506a2c9..3d3afac 100644 --- a/ui/lib/components/chatbot_message_bubble.dart +++ b/ui/lib/components/chatbot_message_bubble.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ui/constants.dart'; +// bot message bubbles class MessageBubble extends StatelessWidget { final String messageSender; final String messageText; diff --git a/ui/lib/components/custom_app_bar.dart b/ui/lib/components/custom_app_bar.dart index 57a33ea..648fea0 100644 --- a/ui/lib/components/custom_app_bar.dart +++ b/ui/lib/components/custom_app_bar.dart @@ -1,35 +1,36 @@ import 'package:flutter/material.dart'; import 'package:ui/screens/settings_screen.dart'; - +// ignore: must_be_immutable class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { - var iconButton; // This Variable holds the Icon type required for the left part of the App Bar // Constructor for the RoundedAppBar Component CustomAppBar.arrow(BuildContext context) { - - this.iconButton = new IconButton( - - icon: Icon(Icons.arrow_back_sharp, + this.iconButton = new IconButton( + icon: Icon( + Icons.arrow_back_sharp, color: Colors.white, - size: 25.0,), - onPressed: () { - Navigator.pop(context); - }, - ); + size: 25.0, + ), + onPressed: () { + Navigator.pop(context); + }, + ); } - CustomAppBar.settings(String userName, String email, String gender, BuildContext context) { - + CustomAppBar.settings( + String userName, String email, String gender, BuildContext context) { this.iconButton = new IconButton( - icon: Icon(Icons.settings, + icon: Icon( + Icons.settings, color: Colors.white, - size: 25.0,), + size: 25.0, + ), onPressed: () { Navigator.push( context, MaterialPageRoute( - builder: (context)=> SettingsScreen(userName, email, gender) + builder: (context) => SettingsScreen(userName, email, gender), ), ); }, @@ -38,41 +39,30 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { - return new SizedBox.fromSize( - - size: preferredSize, child: ClipPath( - clipper: CustomShape(), child: Container( - height: 120, decoration: BoxDecoration( - color: Color(0xff01CDFA), - + color: Color(0xff01CDFA), ), child: Row( - //Setting MainAxisAlignment to spaceBetween as it creates an equal amount of space between two nodes + //Setting MainAxisAlignment to spaceBetween as it creates an equal amount of space between two nodes mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - - child: iconButton, - padding: EdgeInsets.only(left: 20, bottom: 30)), - + child: iconButton, + padding: EdgeInsets.only(left: 20, bottom: 30), + ), Container( - - child: Image( - image: AssetImage('images/officialLogo.png'), - width: 65), - padding: EdgeInsets.only(right: 30, bottom: 30) + child: Image( + image: AssetImage('images/officialLogo.png'), width: 65), + padding: EdgeInsets.only(right: 30, bottom: 30), ) - ] - ), + ]), ), ), ); @@ -83,10 +73,8 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { } class CustomShape extends CustomClipper { - @override getClip(Size size) { - var path = Path(); path.lineTo(0, size.height * .5); @@ -112,7 +100,6 @@ class CustomShape extends CustomClipper { @override bool shouldReclip(CustomClipper oldClipper) { - return true; } } diff --git a/ui/lib/components/exercise_card.dart b/ui/lib/components/exercise_card.dart index d6f0f1f..812f95f 100644 --- a/ui/lib/components/exercise_card.dart +++ b/ui/lib/components/exercise_card.dart @@ -1,10 +1,8 @@ - - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +// cards in exercise plan class ExerciseCard extends StatelessWidget { - final String cardTitle; final String cardImage; @@ -16,39 +14,46 @@ class ExerciseCard extends StatelessWidget { child: Padding( padding: const EdgeInsets.only( left: 20, - right: 20, - bottom: 80, + right: 0, + bottom: 20, top: 20, ), child: Container( child: Container( - height: 180.0, - width: 250.0, - child: Align( - alignment: Alignment.topLeft, - child:Padding( - padding: const EdgeInsets.only(left: 12.0, top: 10.0), - child: Text( - cardTitle, - style: TextStyle( - fontSize: 19.0, - color: Colors.black, - fontFamily: 'Poppins-SemiBold', - ), - ), + height: 180.0, + width: 250.0, + child: Align( + alignment: Alignment.topLeft, + child: Padding( + padding: const EdgeInsets.only(left: 20.0, top: 20.0), + child: Text( + cardTitle, + style: TextStyle( + fontSize: 20, + color: Colors.black, + fontFamily: 'Poppins-SemiBold', ), ), ), - decoration:BoxDecoration( - image: DecorationImage( - image: AssetImage("images/ExerciseImages/" + cardImage), - fit: BoxFit.fitHeight, - alignment: Alignment.topCenter - ), - borderRadius: BorderRadius.circular(22.0), - color: Colors.white, + ), + ), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("images/" + cardImage), + fit: BoxFit.cover, + alignment: Alignment.topCenter), + borderRadius: BorderRadius.circular(22.0), + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Color(0xFF7D7D7D).withOpacity(0.4), + spreadRadius: 3, + blurRadius: 16, + offset: Offset(4, 9), // changes position of shadow ), + ], ), + ), ), ); } diff --git a/ui/lib/components/homepage_card.dart b/ui/lib/components/homepage_card.dart index ba02a5f..3cdbcc3 100644 --- a/ui/lib/components/homepage_card.dart +++ b/ui/lib/components/homepage_card.dart @@ -3,57 +3,59 @@ import 'package:flutter/material.dart'; // This is the Home Page Card generator that accepts parameters to build a custom card for each item in the home page class HomeCard extends StatelessWidget { - final String cardTitle; final String cardColor; final String textColor; final String cardImage; - HomeCard({@required this.cardTitle, @required this.cardColor, @required this.textColor, @required this.cardImage}); //constructor to init values + HomeCard( + {@required this.cardTitle, + @required this.cardColor, + @required this.textColor, + @required this.cardImage}); //constructor to init values @override Widget build(BuildContext buildContext) => Padding( - padding: const EdgeInsets.fromLTRB(22,15,0,35), - child: Container( - decoration: BoxDecoration( - color: Color(int.parse(cardColor)), + padding: const EdgeInsets.fromLTRB(22, 15, 0, 35), + child: Container( + decoration: BoxDecoration( + color: Color( + int.parse(cardColor), + ), borderRadius: BorderRadius.circular(19), image: DecorationImage( - image: AssetImage( - cardImage - ), + image: AssetImage(cardImage), fit: BoxFit.cover, ), - boxShadow: [ - BoxShadow( - color: Color(0xFF7D7D7D).withOpacity(0.4), - spreadRadius: 3, - blurRadius: 16, - offset: Offset(4, 9), // changes position of shadow - ), - ], - ), - child: Container( - width: 290.0, - height: 480.0, - - child: Padding( - padding: const EdgeInsets.only(bottom: 20, left: 20), - - child: Align( - alignment: Alignment.bottomLeft, - child:Text( - cardTitle, - style: TextStyle( - fontSize: 20.0, - color: Color(int.parse(textColor)), - fontFamily: 'Poppins-SemiBold', + boxShadow: [ + BoxShadow( + color: Color(0xFF7D7D7D).withOpacity(0.4), + spreadRadius: 3, + blurRadius: 16, + offset: Offset(4, 9), // changes position of shadow ), - ), + ], ), + child: Container( + width: 290.0, + height: 480.0, + child: Padding( + padding: const EdgeInsets.only(bottom: 20, left: 20), + child: Align( + alignment: Alignment.bottomLeft, + child: Text( + cardTitle, + style: TextStyle( + fontSize: 20.0, + color: Color( + int.parse(textColor), + ), + fontFamily: 'Poppins-SemiBold', + ), + ), + ), + ), ), ), - - ), - ); + ); } diff --git a/ui/lib/components/medication_card.dart b/ui/lib/components/medication_card.dart index b2cf225..1abd6e5 100644 --- a/ui/lib/components/medication_card.dart +++ b/ui/lib/components/medication_card.dart @@ -2,9 +2,8 @@ import 'package:flutter/material.dart'; import 'package:ui/screens/Personal%20Manager/medicationManager/editMedication_Screen.dart'; import 'package:ui/screens/Personal%20Manager/medicationManager/models/medication_model.dart'; - +// all medication cards class MedicationCard extends StatelessWidget { - final Medication medication; const MedicationCard({ @@ -16,55 +15,48 @@ class MedicationCard extends StatelessWidget { return GestureDetector( onTap: () => editMedication(context, medication), child: Padding( - padding: const EdgeInsets.symmetric( - vertical:5.0, - horizontal: 0 - ), + padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 0), child: Container( width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), - color: Color(0xFFCDDDF6) + color: Color(0xFFCDDDF6), ), child: Container( child: Padding( - padding: const EdgeInsets.only( - left: 14.0, - top: 15, - bottom: 15 - ), + padding: const EdgeInsets.only(left: 14.0, top: 15, bottom: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( medication.medicationName, style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 17, - color: Color(0xFF3A6B8D) + fontFamily: 'Poppins-SemiBold', + fontSize: 17, + color: Color(0xFF3A6B8D), ), ), Text( - medication.dosage + " "+ medication.doseTime, + medication.dosage + " " + medication.doseTime, style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13, - color: Color(0xFF5C87A4) + fontFamily: 'Poppins-SemiBold', + fontSize: 13, + color: Color(0xFF5C87A4), ), ) ], ), ), ), - ), ), ); } } -void editMedication(BuildContext context, Medication medication) => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => EditMedication(medication: medication), - ), -); +void editMedication(BuildContext context, Medication medication) => + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => EditMedication(medication: medication), + ), + ); diff --git a/ui/lib/components/personal_manager_card.dart b/ui/lib/components/personal_manager_card.dart index 8e75372..2299b8c 100644 --- a/ui/lib/components/personal_manager_card.dart +++ b/ui/lib/components/personal_manager_card.dart @@ -1,66 +1,77 @@ import 'package:flutter/material.dart'; +// all personal manager cards class PersonalCard extends StatelessWidget { - final String cardTitle; final String cardColor1; final String cardColor2; final String textColor; - PersonalCard({@required this.cardTitle, @required this.cardColor1, @required this.cardColor2, @required this.textColor}); + PersonalCard( + {@required this.cardTitle, + @required this.cardColor1, + @required this.cardColor2, + @required this.textColor}); @override Widget build(BuildContext context) { return Container( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 15, - vertical: 7, - ), - child: Container( - - child: Container( - height: 130.0, - child: Padding( - padding: const EdgeInsets.only( - bottom: 18, - left:21,), - - child: Align( - alignment: Alignment.bottomLeft, - child:Text( - cardTitle, - style: TextStyle( - fontSize: 19.0, - color: Color(int.parse(textColor)), - fontFamily: 'Poppins-SemiBold', - ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 15, + vertical: 7, + ), + child: Container( + child: Container( + height: 130.0, + child: Padding( + padding: const EdgeInsets.only( + bottom: 18, + left: 21, + ), + child: Align( + alignment: Alignment.bottomLeft, + child: Text( + cardTitle, + style: TextStyle( + fontSize: 19.0, + color: Color( + int.parse(textColor), ), + fontFamily: 'Poppins-SemiBold', ), ), - decoration:BoxDecoration( - borderRadius: BorderRadius.circular(22.0), - gradient: LinearGradient( - colors: [ - Color(int.parse(cardColor2)), - Color(int.parse(cardColor1)), - ], - begin: Alignment(1.2,1), - end: Alignment(0.8,-2), - ), - boxShadow: [ - BoxShadow( - color: Color(int.parse(cardColor2)).withOpacity(0.5), - spreadRadius: 3, - blurRadius: 15, - offset: Offset(7, 9), // changes position of shadow - ), - ], - ) ), - // color: Color(int.parse(cardColor)), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(22.0), + gradient: LinearGradient( + colors: [ + Color( + int.parse(cardColor2), + ), + Color( + int.parse(cardColor1), + ), + ], + begin: Alignment(1.2, 1), + end: Alignment(0.8, -2), + ), + boxShadow: [ + BoxShadow( + color: Color( + int.parse(cardColor2), + ).withOpacity(0.5), + spreadRadius: 3, + blurRadius: 15, + offset: Offset(7, 9), // changes position of shadow + ), + ], ), ), + // color: Color(int.parse(cardColor)), + ), + ), ); } } diff --git a/ui/lib/components/reports_card.dart b/ui/lib/components/reports_card.dart index 5cd10b8..12f0a00 100644 --- a/ui/lib/components/reports_card.dart +++ b/ui/lib/components/reports_card.dart @@ -1,9 +1,9 @@ -import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:ui/screens/Personal%20Manager/reportManager/models/report.dart'; import 'package:intl/intl.dart'; import 'package:ui/screens/Personal%20Manager/reportManager/viewReport_screen.dart'; +// all report cards class ReportCard extends StatelessWidget { final Report report; @@ -31,8 +31,9 @@ class ReportCard extends StatelessWidget { child: Container( width: double.infinity, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: Color(0xFF034D5D)), + borderRadius: BorderRadius.circular(15), + color: Color(0xFF034D5D), + ), child: Container( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -45,16 +46,18 @@ class ReportCard extends StatelessWidget { Text( formattedDate, style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 17, - color: Color(0xFFECECEC)), + fontFamily: 'Poppins-SemiBold', + fontSize: 17, + color: Color(0xFFECECEC), + ), ), Text( report.cancerType.toUpperCase(), style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13, - color: Color(0xFFA6D6F7)), + fontFamily: 'Poppins-SemiBold', + fontSize: 13, + color: Color(0xFFA6D6F7), + ), ) ], ), @@ -66,9 +69,10 @@ class ReportCard extends StatelessWidget { child: Text( "View", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 17, - color: Color(0xFFA6D6F7)), + fontFamily: 'Poppins-SemiBold', + fontSize: 17, + color: Color(0xFFA6D6F7), + ), ), ), ), diff --git a/ui/lib/components/rounded_button.dart b/ui/lib/components/rounded_button.dart index af91f69..b6f94c8 100644 --- a/ui/lib/components/rounded_button.dart +++ b/ui/lib/components/rounded_button.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; +// the common rounded button class RoundedButton extends StatelessWidget { // Variable attributes related to the Rounded Button final Color colour; @@ -23,7 +24,10 @@ class RoundedButton extends StatelessWidget { height: 20.0, child: Text( title, - style: TextStyle(color: Colors.white, fontSize: 15, fontFamily: "Poppins-SemiBold"), + style: TextStyle( + color: Colors.white, + fontSize: 15, + fontFamily: "Poppins-SemiBold"), ), ), ), diff --git a/ui/lib/components/treatment_card.dart b/ui/lib/components/treatment_card.dart index 4ae4da0..2f208bd 100644 --- a/ui/lib/components/treatment_card.dart +++ b/ui/lib/components/treatment_card.dart @@ -1,6 +1,6 @@ - import 'package:flutter/material.dart'; +// select cancer screen card class TreatmentCard extends StatelessWidget { final String cardTitle; @@ -18,7 +18,10 @@ class TreatmentCard extends StatelessWidget { colors: [Color(0xFFC6E7EE), Color(0xFF637477)], begin: Alignment.bottomLeft, end: Alignment.topRight, - ), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18),), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18), + ), ), padding: EdgeInsets.only(top: 100, left: 25), width: 322.0, @@ -34,4 +37,4 @@ class TreatmentCard extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/ui/lib/components/widgets.dart b/ui/lib/components/widgets.dart index 40f2cce..65cd450 100644 --- a/ui/lib/components/widgets.dart +++ b/ui/lib/components/widgets.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -class ScrollEffectBehaviour extends ScrollBehavior{ +class ScrollEffectBehaviour extends ScrollBehavior { @override Widget buildViewportChrome( - BuildContext context, Widget child, AxisDirection axisDirection){ + BuildContext context, Widget child, AxisDirection axisDirection) { return child; } -} \ No newline at end of file +} diff --git a/ui/lib/main.dart b/ui/lib/main.dart index b9a1f60..cbf2577 100644 --- a/ui/lib/main.dart +++ b/ui/lib/main.dart @@ -17,7 +17,6 @@ import 'package:ui/screens/login_screen.dart'; import 'package:ui/screens/registration_screen.dart'; import 'package:ui/screens/welcome_screen.dart'; - Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); @@ -29,69 +28,35 @@ Future main() async { } class MyApp extends StatelessWidget { - @override Widget build(BuildContext context) => MultiProvider( - providers: [ - ChangeNotifierProvider(create: (context) => ReportProvider()), - ChangeNotifierProvider(create: (context) => MedicationProvider()), - ChangeNotifierProvider(create: (context) => AppointmentsProvider()), - ], - child: MaterialApp( - debugShowCheckedModeBanner: false, - - // This is the first screen which will be displayed for the user when he opens the app - home: WelcomeScreen(), - - // This is the initial route for the app - initialRoute: WelcomeScreen.id, - - // Creating Named routes for all the pages (we used named routes when we deal with multiple routes 'more than 2') - routes: { - WelcomeScreen.id: (context) => WelcomeScreen(), - LoginScreen.id: (context) => LoginScreen(), - RegistrationScreen.id: (context) => RegistrationScreen(), - ForgetPassword.id: (context) => ForgetPassword(), - CurrentScreen.id: (context) => CurrentScreen(), - LungCancerDiagnosis.id: (context) => LungCancerDiagnosis(), - BreastCancerDiagnosis.id: (context) => BreastCancerDiagnosis(), - SkinCancerDiagnosis.id: (context) => SkinCancerDiagnosis(), - AllMealScreen.id: (context) => AllMealScreen(), - MealDetailScreen.id: (context) => MealDetailScreen(), - ExerciseScreen.id: (context) => ExerciseScreen(), - } - ), - ); + providers: [ + ChangeNotifierProvider(create: (context) => ReportProvider()), + ChangeNotifierProvider(create: (context) => MedicationProvider()), + ChangeNotifierProvider(create: (context) => AppointmentsProvider()), + ], + child: MaterialApp( + debugShowCheckedModeBanner: false, + + // This is the first screen which will be displayed for the user when he opens the app + home: WelcomeScreen(), + + // This is the initial route for the app + initialRoute: WelcomeScreen.id, + + // Creating Named routes for all the pages (we used named routes when we deal with multiple routes 'more than 2') + routes: { + WelcomeScreen.id: (context) => WelcomeScreen(), + LoginScreen.id: (context) => LoginScreen(), + RegistrationScreen.id: (context) => RegistrationScreen(), + ForgetPassword.id: (context) => ForgetPassword(), + CurrentScreen.id: (context) => CurrentScreen(), + LungCancerDiagnosis.id: (context) => LungCancerDiagnosis(), + BreastCancerDiagnosis.id: (context) => BreastCancerDiagnosis(), + SkinCancerDiagnosis.id: (context) => SkinCancerDiagnosis(), + AllMealScreen.id: (context) => AllMealScreen(), + MealDetailScreen.id: (context) => MealDetailScreen(), + ExerciseScreen.id: (context) => ExerciseScreen(), + }), + ); } - -// // Main method CALLED at which the APP STARTS INITIALLY -// void main() { -// // String name = ""; -// runApp(MyApp()); -// } -// -// // This is the Main MyApp class for the navigation lists -// class MyApp extends StatelessWidget { -// @override -// Widget build(BuildContext context) { -// return MaterialApp( -// // This is the first screen which will be displayed for the user when he opens the app -// home: WelcomeScreen(), -// -// // This is the initial route for the app -// initialRoute: WelcomeScreen.id, -// -// // Creating Named routes for all the pages (we used named routes when we deal with multiple routes 'more than 2') -// routes: { -// WelcomeScreen.id: (context) => WelcomeScreen(), -// LoginScreen.id: (context) => LoginScreen(), -// RegistrationScreen.id: (context) => RegistrationScreen(), -// ForgetPassword.id: (context) => ForgetPassword(), -// CurrentScreen.id: (context) => CurrentScreen(), -// LungCancerDiagnosis.id: (context) => LungCancerDiagnosis(), -// BreastCancerDiagnosis.id: (context) => BreastCancerDiagnosis(), -// SkinCancerDiagnosis.id: (context) => SkinCancerDiagnosis(), -// }, -// ); -// } -// } diff --git a/ui/lib/screens/Exercise Plan/exerciseScreen.dart b/ui/lib/screens/Exercise Plan/exerciseScreen.dart index afdff2c..5894f96 100644 --- a/ui/lib/screens/Exercise Plan/exerciseScreen.dart +++ b/ui/lib/screens/Exercise Plan/exerciseScreen.dart @@ -1,4 +1,5 @@ import 'dart:math'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/components/exercise_card.dart'; @@ -7,12 +8,9 @@ class ExerciseScreen extends StatefulWidget { @override _ExerciseScreenState createState() => _ExerciseScreenState(); static var id = "exercisePlanScreen"; - - } class _ExerciseScreenState extends State { - final rand = new Random(); static var exerciseNames = [ "Bicycle Crunches", @@ -26,9 +24,18 @@ class _ExerciseScreenState extends State { "Squats", "Thigh Lunges" ]; + + static var quotes = [ + "Strength does not come from the physical capacity. It comes from an indomitable will. – Mahatma Gandhi", + "Training gives us an outlet for suppressed energies created by stress and thus tones the spirit just as exercise conditions the body. – Arnold Schwarzenegger", + "If you have a body, you are an athlete! – Bill Bowerman", + "Someone busier than you is working our right now.” – Unknown", + "You can either suffer the pain of discipline or the pain of regret. –Jim Rohn" + ]; + var selectedNames = []; String randomExercise() { - if(selectedNames.length == exerciseNames.length) { + if (selectedNames.length == exerciseNames.length) { selectedNames = []; } String ex = exerciseNames[rand.nextInt(exerciseNames.length)]; @@ -39,11 +46,18 @@ class _ExerciseScreenState extends State { return ex; } + String randomQuote() { + return quotes[rand.nextInt(quotes.length)]; + } + @override Widget build(BuildContext context) { var name_1 = randomExercise(); var name_2 = randomExercise(); var name_3 = randomExercise(); + var name_4 = randomExercise(); + var name_5 = randomExercise(); + var name_6 = randomExercise(); return Scaffold( body: SafeArea( @@ -51,15 +65,13 @@ class _ExerciseScreenState extends State { children: [ CustomAppBar.arrow(context), Column( - children : [ - + children: [ Padding( padding: const EdgeInsets.only( left: 20, bottom: 8, ), child: Align( - alignment: Alignment.topLeft, child: Text( "Exercise Plan", @@ -70,21 +82,17 @@ class _ExerciseScreenState extends State { ), ), ), - Padding( - padding: const EdgeInsets.only( - left: 20, - bottom: 14, - right: 20 - ), + padding: + const EdgeInsets.only(left: 20, bottom: 14, right: 20), child: Align( alignment: Alignment.topLeft, child: Text( "Here you can find exercises specifically tailored for you", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF959595), + fontFamily: 'Poppins-SemiBold', + fontSize: 15, + color: Color(0xFF959595), ), ), ), @@ -92,50 +100,97 @@ class _ExerciseScreenState extends State { ], ), Expanded( - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - child: GestureDetector( - onTap: (){ - }, - child: ExerciseCard(cardTitle: name_1, cardImage: name_1.replaceAll(' ', '').toLowerCase() + ".jpg"), + child: Padding( + padding: const EdgeInsets.only(left: 20), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(37), + bottomLeft: Radius.circular(37), + ), + color: Color(0xFF91C77E), + ), + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + Container( + child: GestureDetector( + onTap: () {}, + child: ExerciseCard( + cardTitle: name_1, + cardImage: + name_1.replaceAll(' ', '').toLowerCase() + + ".jpg"), + ), ), - ), - Container( - child: GestureDetector( - onTap: (){ - }, - child: ExerciseCard(cardTitle: name_2, cardImage: name_2.replaceAll(' ', '').toLowerCase() + ".jpg"), + Container( + child: GestureDetector( + onTap: () {}, + child: ExerciseCard( + cardTitle: name_2, + cardImage: + name_2.replaceAll(' ', '').toLowerCase() + + ".jpg"), + ), ), - ), - Container( - child: GestureDetector( - onTap: (){ - }, - child: ExerciseCard(cardTitle: name_3, cardImage: name_3.replaceAll(' ', '').toLowerCase() + ".jpg"), + Container( + child: GestureDetector( + onTap: () {}, + child: ExerciseCard( + cardTitle: name_3, + cardImage: + name_3.replaceAll(' ', '').toLowerCase() + + ".jpg"), + ), ), - ), - ] + Container( + child: GestureDetector( + onTap: () {}, + child: ExerciseCard( + cardTitle: name_4, + cardImage: + name_4.replaceAll(' ', '').toLowerCase() + + ".jpg"), + ), + ), + Container( + child: GestureDetector( + onTap: () {}, + child: ExerciseCard( + cardTitle: name_5, + cardImage: + name_5.replaceAll(' ', '').toLowerCase() + + ".jpg"), + ), + ), + Padding( + padding: const EdgeInsets.only(right: 20), + child: Container( + child: GestureDetector( + onTap: () {}, + child: ExerciseCard( + cardTitle: name_6, + cardImage: + name_6.replaceAll(' ', '').toLowerCase() + + ".jpg"), + ), + ), + ), + ]), ), + ), ), - Align( - alignment: Alignment.center, - child: Padding( - padding: const EdgeInsets.only(bottom: 50.0), - child: Container( - child: RaisedButton( - child: Text("Start Workout."), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), - ), - onPressed: () { - - }, - ), + Padding( + padding: const EdgeInsets.only( + bottom: 30.0, left: 20, right: 20, top: 20.0), + child: Container( + child: Text( + randomQuote(), + style: + TextStyle(fontSize: 13.0, fontFamily: 'Poppins-SemiBold'), ), ), - ), + ) ], ), ), diff --git a/ui/lib/screens/Meal Plan/meal_detail_screen.dart b/ui/lib/screens/Meal Plan/meal_detail_screen.dart index 203b1d9..31cf95d 100644 --- a/ui/lib/screens/Meal Plan/meal_detail_screen.dart +++ b/ui/lib/screens/Meal Plan/meal_detail_screen.dart @@ -50,10 +50,6 @@ class MealDetailScreen extends StatelessWidget { title, style: kTextStyle.copyWith(fontSize: 16, color: Colors.white), ), -// background: Image.network( -// imgUrl, -// fit: BoxFit.cover, -// ), background: CachedNetworkImage( progressIndicatorBuilder: (context, url, downloadProgress) => SizedBox( diff --git a/ui/lib/screens/Personal Manager/appointmentsManager/addAppointments_screen.dart b/ui/lib/screens/Personal Manager/appointmentsManager/addAppointments_screen.dart index 16ca290..acce1d0 100644 --- a/ui/lib/screens/Personal Manager/appointmentsManager/addAppointments_screen.dart +++ b/ui/lib/screens/Personal Manager/appointmentsManager/addAppointments_screen.dart @@ -6,7 +6,6 @@ import 'package:ui/screens/Personal%20Manager/appointmentsManager/api/appointmen import 'package:ui/screens/Personal%20Manager/appointmentsManager/models/appointment_model.dart'; class AddAppointments extends StatefulWidget { - AddAppointments(); // Constructor @override @@ -14,7 +13,6 @@ class AddAppointments extends StatefulWidget { } class _AddAppointmentsState extends State { - // Variables used within file String _doctorName = ""; String _notes = ""; @@ -23,24 +21,13 @@ class _AddAppointmentsState extends State { DateTime newDate; TimeOfDay newTime; - FocusNode _nameFocus; - FocusNode _doseFocus; - FocusNode _timeFocus; - @override void initState() { - - // initializing focus nodes - _nameFocus = FocusNode(); - _doseFocus = FocusNode(); - _timeFocus = FocusNode(); - super.initState(); } @override Widget build(BuildContext context) { - return SafeArea( child: Scaffold( appBar: CustomAppBar.arrow(context), @@ -60,7 +47,7 @@ class _AddAppointmentsState extends State { child: Align( alignment: Alignment.topLeft, child: Text( - "Add Appointment", + "Add Appointment", style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 24, @@ -68,268 +55,262 @@ class _AddAppointmentsState extends State { ), ), ), - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20 - ), + padding: const EdgeInsets.only(left: 20, right: 20), child: Align( alignment: Alignment.topLeft, child: Text( "Enter the details of the Appointment", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), ), ], ), - Expanded( - child:Padding( - padding: const EdgeInsets.symmetric( - horizontal: 17, - vertical: 0 - ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 17, vertical: 0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + // color: Color(0xFF57994D) + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - // color: Color(0xFF57994D) + borderRadius: BorderRadius.circular(10), ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical:8.0), - child: Container( - - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), + child: ListView( + children: [ + SizedBox( + height: 15, ), - child: ListView( - children: [ - SizedBox( - height: 15, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) - ), - child: Padding( - padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextField( - maxLength: 20, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _doctorName = value; - }); - _doseFocus.requestFocus(); // to move focus to description node - } - }, - decoration: InputDecoration( - hintText: "Name of Doctor", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ),), - ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE)), + child: Padding( + padding: const EdgeInsets.only( + left: 18, + top: 5, + bottom: 10, + right: 10), + child: TextField( + maxLength: 20, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _doctorName = value; + }); + } + }, + decoration: InputDecoration( + hintText: + "Name of Doctor", // temporary text + border: InputBorder.none, + ), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), ), - - SizedBox( - height: 11, ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) + ), + ), + SizedBox( + height: 11, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18, + top: 5, + bottom: 10, + right: 10), + child: TextField( + maxLength: 30, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _notes = value; + }); + } + }, + decoration: InputDecoration( + hintText: "Notes", // temporary text + border: InputBorder.none, ), - child: Padding( - padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextField( - maxLength: 15, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _notes = value; - }); - _timeFocus.requestFocus(); // to move focus to description node - } - }, - decoration: InputDecoration( - hintText: "Notes", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ),), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), ), ), - - SizedBox( - height: 11, + ), + ), + SizedBox( + height: 11, + ), + GestureDetector( + onTap: () async { + _appointmentDate = DateTime.now(); + newDate = await showDatePicker( + context: context, + initialDate: _appointmentDate, + firstDate: DateTime.now(), + lastDate: DateTime(2022), + helpText: 'Select a date', + ); + }, + child: Container( + decoration: BoxDecoration( + color: Color(0xff01CDFA), + borderRadius: BorderRadius.circular(18), ), - - GestureDetector( - onTap: () async { - - _appointmentDate = DateTime.now(); - newDate = await showDatePicker( - context: context, - initialDate: _appointmentDate, - firstDate: DateTime.now(), - lastDate: DateTime(2022), - helpText: 'Select a date',); - }, - child: Container( - decoration: BoxDecoration( - color: Color(0xff01CDFA), - borderRadius: BorderRadius.circular(18), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 0), - child: Center( - child: Text( - "Set Date", - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Colors.white, - ), - ), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 0), + child: Center( + child: Text( + "Set Date", + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Colors.white, ), ), ), ), - SizedBox( - height: 11, - ), - GestureDetector( - onTap: () async { - - _appointmentTime = TimeOfDay.fromDateTime(DateTime.now()); - - newTime = await showTimePicker( - context: context, - initialTime: _appointmentTime, - ); - }, - child: Container( - decoration: BoxDecoration( - color: Color(0xff01CDFA), - borderRadius: BorderRadius.circular(18), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50), + ), + ), + SizedBox( + height: 11, + ), + GestureDetector( + onTap: () async { + _appointmentTime = + TimeOfDay.fromDateTime(DateTime.now()); - child: Center( - child: Text( - "Set Time", - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Colors.white, - ), - ), + newTime = await showTimePicker( + context: context, + initialTime: _appointmentTime, + ); + }, + child: Container( + decoration: BoxDecoration( + color: Color(0xff01CDFA), + borderRadius: BorderRadius.circular(18), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 50), + child: Center( + child: Text( + "Set Time", + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Colors.white, ), ), ), ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: (){ - if(_appointmentTime != null && _appointmentDate != null) { - - setState(() { - _appointmentTime = newTime; - _appointmentDate = newDate; - }); - - Appointment newApplication = Appointment( - doctorName: _doctorName, - notes: _notes, - time: _appointmentTime.toString(), - date: _appointmentDate.toString(), - ); + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + // Making sure all Inputs are selected + if (_appointmentTime != null && + _appointmentDate != null && + _doctorName != null && + _notes != null) { + setState(() { + _appointmentTime = newTime; + _appointmentDate = newDate; + }); - AppointmentsFirebaseApi.createAppointment(newApplication); + // Creating new Appointment Object to be stored to Firebase + Appointment newApplication = Appointment( + doctorName: _doctorName, + notes: _notes, + time: _appointmentTime.toString(), + date: _appointmentDate.toString(), + ); - print(_appointmentTime); - print("NONO"); - print(_appointmentDate); - print("LESGO"); - print(new DateTime( - _appointmentDate.year, _appointmentDate.month, _appointmentDate.day, - _appointmentTime.hour, _appointmentTime.minute)); + AppointmentsFirebaseApi.createAppointment( + newApplication); - // add an event to systems default calendar - final Event event = Event( - title: _doctorName, - description: _notes, - timeZone: _appointmentDate.timeZoneName, - startDate: _appointmentDate, - endDate: new DateTime( - _appointmentDate.year, _appointmentDate.month, _appointmentDate.day, - _appointmentTime.hour, _appointmentTime.minute), - ); - Add2Calendar.addEvent2Cal(event); - } - Navigator.pop(context); - }, - child: Center( - child: Container( - width: 200, - decoration: BoxDecoration( - color: Color(0xFFE84848), - borderRadius: BorderRadius.circular(18), - ), - child: Padding( - padding: const EdgeInsets.only( - top:20, - bottom: 20 - ), - child: Center( - child: Text( - "Add Appointment", - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Colors.white, - ), - ), + // add an event to systems default calendar + final Event event = Event( + title: _doctorName, + description: _notes, + startDate: new DateTime( + _appointmentDate.year, + _appointmentDate.month, + _appointmentDate.day, + _appointmentTime.hour, + _appointmentTime.minute), + endDate: new DateTime( + _appointmentDate.year, + _appointmentDate.month, + _appointmentDate.day, + _appointmentTime.hour, + _appointmentTime.minute), + ); + Add2Calendar.addEvent2Cal(event); + } + Navigator.pop(context); + }, + child: Center( + child: Container( + width: 200, + decoration: BoxDecoration( + color: Color(0xFFE84848), + borderRadius: BorderRadius.circular(18), + ), + child: Padding( + padding: const EdgeInsets.only( + top: 20, bottom: 20), + child: Center( + child: Text( + "Add Appointment", + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Colors.white, ), ), ), ), - ) - ], - ), - ), + ), + ), + ) + ], ), ), - ) - ), + ), + ), + )), ], ), ], diff --git a/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsFirebaseAPI.dart b/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsFirebaseAPI.dart index 27af69f..6071761 100644 --- a/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsFirebaseAPI.dart +++ b/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsFirebaseAPI.dart @@ -9,10 +9,9 @@ final _firestore = FirebaseFirestore.instance; final user = FirebaseAuth.instance.currentUser; var loggedInUserEP = user.email; -var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; +var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; class AppointmentsFirebaseApi { - static Future createAppointment(Appointment appointment) async { final docAppointment = _firestore .collection("appointment") @@ -21,17 +20,21 @@ class AppointmentsFirebaseApi { .doc(); appointment.id = docAppointment.id; - await docAppointment.set(appointment.toJson()); + await docAppointment.set( + appointment.toJson(), + ); return docAppointment.id; } - static Stream> readAppointment() => FirebaseFirestore.instance - .collection("appointment") - .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) - .collection("appointments") - .snapshots() - .transform(Utils.transformer(Appointment.fromJson) - ); + static Stream> readAppointment() => + FirebaseFirestore.instance + .collection("appointment") + .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) + .collection("appointments") + .snapshots() + .transform( + Utils.transformer(Appointment.fromJson), + ); static Future deleteAppointment(Appointment appointment) async { final docAppointment = FirebaseFirestore.instance @@ -42,4 +45,4 @@ class AppointmentsFirebaseApi { await docAppointment.delete(); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsProvider.dart b/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsProvider.dart index 21d0344..79afa90 100644 --- a/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsProvider.dart +++ b/ui/lib/screens/Personal Manager/appointmentsManager/api/appointmentsProvider.dart @@ -3,10 +3,8 @@ import 'package:ui/screens/Personal%20Manager/appointmentsManager/api/appointmen import 'package:ui/screens/Personal%20Manager/appointmentsManager/models/appointment_model.dart'; class AppointmentsProvider extends ChangeNotifier { - List _appointments = []; - List get appointments => _appointments; void setAppointments(List appointment) => @@ -15,7 +13,9 @@ class AppointmentsProvider extends ChangeNotifier { notifyListeners(); }); - void addMedication(Appointment appointment) => AppointmentsFirebaseApi.createAppointment(appointment); + void addMedication(Appointment appointment) => + AppointmentsFirebaseApi.createAppointment(appointment); - void removeAppointment(Appointment appointment) => AppointmentsFirebaseApi.deleteAppointment(appointment); -} \ No newline at end of file + void removeAppointment(Appointment appointment) => + AppointmentsFirebaseApi.deleteAppointment(appointment); +} diff --git a/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/AppointmentListWidget.dart b/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/AppointmentListWidget.dart index 12e365d..a592978 100644 --- a/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/AppointmentListWidget.dart +++ b/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/AppointmentListWidget.dart @@ -9,26 +9,29 @@ class AppointmentsListWidget extends StatelessWidget { final provider = Provider.of(context); final appointments = provider.appointments; + /* Returning Either a ListView with all Appointments from Firebase + * or either a Text with no Appointments if nothing has been added (isEmpty) + */ return appointments.isEmpty ? Center( - child: Text( - 'No Appointments.', - style: TextStyle( - color: Color(0xffaaaaaa), - fontFamily: 'Poppins-SemiBold', - fontSize: 17, + child: Text( + 'No Appointments.', + style: TextStyle( + color: Color(0xffaaaaaa), + fontFamily: 'Poppins-SemiBold', + fontSize: 17, + ), ), - ), - ) + ) : ListView.separated( - physics: BouncingScrollPhysics(), - separatorBuilder: (context, index) => Container(height: 5), - itemCount: appointments.length, - itemBuilder: (context, index) { - final appointment = appointments[index]; + physics: BouncingScrollPhysics(), + separatorBuilder: (context, index) => Container(height: 5), + itemCount: appointments.length, + itemBuilder: (context, index) { + final appointment = appointments[index]; - return AppointmentsCard(appointment: appointment); - }, - ); + return AppointmentsCard(appointment: appointment); + }, + ); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/appointment_card.dart b/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/appointment_card.dart index 9d28df9..6e63ee5 100644 --- a/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/appointment_card.dart +++ b/ui/lib/screens/Personal Manager/appointmentsManager/appointmentWidgets/appointment_card.dart @@ -4,7 +4,6 @@ import 'package:ui/screens/Personal%20Manager/appointmentsManager/api/appointmen import 'package:ui/screens/Personal%20Manager/appointmentsManager/models/appointment_model.dart'; class AppointmentsCard extends StatelessWidget { - final Appointment appointment; const AppointmentsCard({ @@ -14,27 +13,19 @@ class AppointmentsCard extends StatelessWidget { @override Widget build(BuildContext context) { return GestureDetector( - // onTap: () => editMedication(context, appointment), child: Padding( - padding: const EdgeInsets.symmetric( - vertical:5.0, - horizontal: 0 - ), + padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 0), child: Container( width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(12), - color: Color(0xFFCDDDF6) + color: Color(0xFFCDDDF6), ), child: Container( child: Padding( - padding: const EdgeInsets.only( - left: 14.0, - top: 15, - bottom: 15 - ), + padding: const EdgeInsets.only(left: 14.0, top: 15, bottom: 15), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -42,32 +33,35 @@ class AppointmentsCard extends StatelessWidget { Text( appointment.doctorName, style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 17, - color: Color(0xFF3A6B8D) + fontFamily: 'Poppins-SemiBold', + fontSize: 17, + color: Color(0xFF3A6B8D), ), ), Text( appointment.notes, style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13, - color: Color(0xFF5C87A4) + fontFamily: 'Poppins-SemiBold', + fontSize: 13, + color: Color(0xFF5C87A4), ), ) ], ), IconButton( - color: Colors.red, + color: Colors.red, icon: Icon(Icons.delete), - onPressed: () - { - final provider = Provider.of(context, listen: false); + onPressed: () { + /* Connecting to Provider and using removeAppointment method to remove + * the Appointment from Firebase + */ + final provider = Provider.of( + context, + listen: false); provider.removeAppointment(appointment); Navigator.pop(context); - } - ) + }) ], ), ), @@ -76,4 +70,4 @@ class AppointmentsCard extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/appointmentsManager/appointmentsManager_screen.dart b/ui/lib/screens/Personal Manager/appointmentsManager/appointmentsManager_screen.dart index d8ccac7..d478bf8 100644 --- a/ui/lib/screens/Personal Manager/appointmentsManager/appointmentsManager_screen.dart +++ b/ui/lib/screens/Personal Manager/appointmentsManager/appointmentsManager_screen.dart @@ -7,6 +7,7 @@ import 'api/appointmentsProvider.dart'; import 'models/appointment_model.dart'; import 'package:ui/screens/Personal%20Manager/appointmentsManager/appointmentWidgets/AppointmentListWidget.dart'; +// ignore: must_be_immutable class AppointmentsManager extends StatefulWidget { @override _AppointmentsManagerState createState() => _AppointmentsManagerState(); @@ -16,144 +17,134 @@ class AppointmentsManager extends StatefulWidget { } class _AppointmentsManagerState extends State { - - @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - appBar: CustomAppBar.arrow(context), - body: SafeArea( - child: Stack( - children: [ - Column( - children: [ - Column( - children: [ - - Padding( - padding: const EdgeInsets.only( - left: 20, - bottom: 8, - ), - child: Align( - - alignment: Alignment.topLeft, - child: Text( - "Appointments", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 24, - ), + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: CustomAppBar.arrow(context), + body: SafeArea( + child: Stack( + children: [ + Column( + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 20, + bottom: 8, + ), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Appointments", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 24, ), ), ), - - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20 - ), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Here you can manage your Appointments, click add a medication to create one and drag the Appointment to delete it", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) - ), + ), + Padding( + padding: const EdgeInsets.only(left: 20, right: 20), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Here you can manage your Appointments, click on the bottom right '+' Icon to create one and click on the Trash Bin Icon" + "to delete an Appointment", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), - ], - ), - - Expanded( + ), + ], + ), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 17, vertical: 0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + // color: Color(0xFF57994D) + ), child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 17, - vertical: 0 - ), + padding: const EdgeInsets.symmetric(vertical: 8.0), child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - // color: Color(0xFF57994D) - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Container( - - child: StreamBuilder>( - stream: AppointmentsFirebaseApi.readAppointment(), - builder: (context, snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return Center( - child: CircularProgressIndicator()); - default: - if (snapshot.hasError) { - return buildText( - 'Something went wrong, Try later'); - } else { - final appointments = snapshot.data; + child: StreamBuilder>( + stream: + AppointmentsFirebaseApi.readAppointment(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Center( + child: CircularProgressIndicator(), + ); + default: + if (snapshot.hasError) { + return buildText( + 'Something went wrong, Try later'); + } else { + final appointments = snapshot.data; - final provider = Provider.of(context); - provider.setAppointments(appointments); + final provider = + Provider.of( + context); + provider.setAppointments(appointments); - return AppointmentsListWidget(); - } + return AppointmentsListWidget(); } - } - ), - - ), - ), + } + }), ), ), + ), ), - ], - ), - Positioned( - bottom: 17, - right: 17, - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - AddAppointments() // Navigates to Task Page - ), - ).then((value) { - setState(() {}); // Setting and Refreshing State - }); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Color(0xFF1c374a), - borderRadius: BorderRadius.circular(18) + ), + ], + ), + Positioned( + bottom: 17, + right: 17, + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + AddAppointments() // Navigates to Task Page ), - child: Image( - image: AssetImage('images/add_icon.png') // Add icon - ), - ), - ), + ).then((value) { + setState(() {}); // Setting and Refreshing State + }); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Color(0xFF1c374a), + borderRadius: BorderRadius.circular(18), ), - ], - ), + child: Image( + image: AssetImage('images/add_icon.png') // Add icon + ), + ), + ), + ), + ], ), ), - ); - - } + ), + ); } -// } +} Widget buildText(String text) => Center( - child: Text( - text, - style: TextStyle(fontSize: 24, color: Colors.white), - ), -); \ No newline at end of file + child: Text( + text, + style: TextStyle(fontSize: 24, color: Colors.white), + ), + ); diff --git a/ui/lib/screens/Personal Manager/medicationManager/addMedication_screen.dart b/ui/lib/screens/Personal Manager/medicationManager/addMedication_screen.dart index a3e6a1b..a033f6c 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/addMedication_screen.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/addMedication_screen.dart @@ -5,7 +5,6 @@ import 'package:ui/screens/Personal%20Manager/medicationManager/api/medicationFi import 'package:ui/screens/Personal%20Manager/medicationManager/models/medication_model.dart'; class AddMedication extends StatefulWidget { - final Medication medication; AddMedication({@required this.medication}); // Constructor @@ -14,27 +13,22 @@ class AddMedication extends StatefulWidget { } class _AddMedicationState extends State { - // Variables used within file - String _medicationId = ""; String _medicationName = ""; String _medicationDose = ""; String _medicationTime = ""; - FocusNode _nameFocus; FocusNode _doseFocus; FocusNode _timeFocus; @override void initState() { - if(widget.medication !=null){ + if (widget.medication != null) { _medicationName = widget.medication.medicationName; - _medicationId = widget.medication.id; _medicationDose = widget.medication.dosage; } // initializing focus nodes - _nameFocus = FocusNode(); _doseFocus = FocusNode(); _timeFocus = FocusNode(); @@ -61,7 +55,7 @@ class _AddMedicationState extends State { child: Align( alignment: Alignment.topLeft, child: Text( - "Add Medication", + "Add Medication", style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 24, @@ -69,210 +63,197 @@ class _AddMedicationState extends State { ), ), ), - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20 - ), + padding: const EdgeInsets.only(left: 20, right: 20), child: Align( alignment: Alignment.topLeft, child: Text( "Enter the details of the medication", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), ), ], ), - Expanded( - child:Padding( - padding: const EdgeInsets.symmetric( - horizontal: 17, - vertical: 0 - ), + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 17, vertical: 0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + // color: Color(0xFF57994D) + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - // color: Color(0xFF57994D) + borderRadius: BorderRadius.circular(10), ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical:8.0), - child: Container( - - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), + child: ListView( + children: [ + SizedBox( + height: 15, ), - child: ListView( - children: [ - SizedBox( - height: 15, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) - ), - child: Padding( - padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextField( - maxLength: 20, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _medicationName = value; - }); - _doseFocus.requestFocus(); // to move focus to description node - } - }, - decoration: InputDecoration( - hintText: "Name of Medication", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ),), - ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18, top: 5, bottom: 10, right: 10), + child: TextField( + maxLength: 20, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _medicationName = value; + }); + _doseFocus + .requestFocus(); // to move focus to description node + } + }, + decoration: InputDecoration( + hintText: + "Name of Medication", // temporary text + border: InputBorder.none, + ), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), ), - - SizedBox( - height: 11, ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) + ), + ), + SizedBox( + height: 11, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18, top: 5, bottom: 10, right: 10), + child: TextField( + maxLength: 15, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _medicationDose = value; + }); + _timeFocus + .requestFocus(); // to move focus to description node + } + }, + decoration: InputDecoration( + hintText: + "Dose - eg: 'Two tablets', '5 ml'", // temporary text + border: InputBorder.none, ), - child: Padding( - padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextField( - maxLength: 15, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _medicationDose = value; - }); - _timeFocus.requestFocus(); // to move focus to description node - } - }, - decoration: InputDecoration( - hintText: "Dose - eg: 'Two tablets', '5 ml'", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ),), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), ), ), - - SizedBox( - height: 11, + ), + ), + SizedBox( + height: 11, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18, top: 5, bottom: 10, right: 10), + child: TextField( + maxLength: 35, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _medicationTime = value; + }); + _doseFocus + .requestFocus(); // to move focus to description node + } + }, + decoration: InputDecoration( + hintText: + "Time - eg: 'every 5 hours','after lunch'", // placeholder text + border: InputBorder.none, + ), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), + ), ), - - Container( + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + if (_medicationName != "") { + Medication _newMedication = Medication( + medicationName: _medicationName, + dosage: _medicationDose, + doseTime: _medicationTime, + ); + MedicationFirebaseApi.createMedication( + _newMedication); + } + Navigator.pop(context); + }, + child: Center( + child: Container( + width: 200, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) + color: Color(0xFFE84848), + borderRadius: BorderRadius.circular(18), ), child: Padding( padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextField( - maxLength: 35, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _medicationTime = value; - }); - _doseFocus.requestFocus(); // to move focus to description node - } - }, - decoration: InputDecoration( - hintText: "Time - eg: 'every 5 hours','after lunch'", // placeholder text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ), - ), - ), - ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: (){ - if(_medicationName !="") { - Medication _newMedication = Medication( - medicationName: _medicationName, - dosage: _medicationDose, - doseTime: _medicationTime, - ); - MedicationFirebaseApi.createMedication(_newMedication); - } - Navigator.pop(context); - }, - child: Center( - child: Container( - width: 200, - decoration: BoxDecoration( - color: Color(0xFFE84848), - borderRadius: BorderRadius.circular(18), - ), - child: Padding( - padding: const EdgeInsets.only( - top:20, - bottom: 20 - ), - child: Center( - child: Text( - "Add Medication", - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Colors.white, - ), - ), + top: 20, bottom: 20), + child: Center( + child: Text( + "Add Medication", + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Colors.white, ), ), ), ), - ) - ], - ), - ), + ), + ), + ) + ], ), ), - ) - ), + ), + ), + )), ], ), ], diff --git a/ui/lib/screens/Personal Manager/medicationManager/api/medicationFirebaseAPI.dart b/ui/lib/screens/Personal Manager/medicationManager/api/medicationFirebaseAPI.dart index 462d8a4..e5ae8fc 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/api/medicationFirebaseAPI.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/api/medicationFirebaseAPI.dart @@ -9,10 +9,9 @@ final _firestore = FirebaseFirestore.instance; final user = FirebaseAuth.instance.currentUser; var loggedInUserEP = user.email; -var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; +var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; class MedicationFirebaseApi { - static Future createMedication(Medication medication) async { final docMedication = _firestore .collection("medication") @@ -20,7 +19,9 @@ class MedicationFirebaseApi { .collection("medications") .doc(); medication.id = docMedication.id; - await docMedication.set(medication.toJson()); + await docMedication.set( + medication.toJson(), + ); return docMedication.id; } @@ -29,9 +30,9 @@ class MedicationFirebaseApi { .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) .collection("medications") .snapshots() - .transform(Utils.transformer(Medication.fromJson) - ); - + .transform( + Utils.transformer(Medication.fromJson), + ); static Future updateMedication(Medication medication) async { final docMedication = FirebaseFirestore.instance @@ -40,7 +41,9 @@ class MedicationFirebaseApi { .collection("medications") .doc(medication.id); - await docMedication.update(medication.toJson()); + await docMedication.update( + medication.toJson(), + ); } static Future deleteMedication(Medication medication) async { @@ -52,4 +55,4 @@ class MedicationFirebaseApi { await docMedication.delete(); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/medicationManager/api/medicationsProvider.dart b/ui/lib/screens/Personal Manager/medicationManager/api/medicationsProvider.dart index 7185ec6..39c97ed 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/api/medicationsProvider.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/api/medicationsProvider.dart @@ -12,14 +12,17 @@ class MedicationProvider extends ChangeNotifier { notifyListeners(); }); - void addMedication(Medication medication) => MedicationFirebaseApi.createMedication(medication); + void addMedication(Medication medication) => + MedicationFirebaseApi.createMedication(medication); - void removeMedication(Medication medication) => MedicationFirebaseApi.deleteMedication(medication); + void removeMedication(Medication medication) => + MedicationFirebaseApi.deleteMedication(medication); - void updateMedication(Medication medication, String medicationName, String dosage, String doseTime) { + void updateMedication(Medication medication, String medicationName, + String dosage, String doseTime) { medication.medicationName = medicationName; medication.dosage = dosage; medication.doseTime = doseTime; MedicationFirebaseApi.updateMedication(medication); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/medicationManager/editMedication_Screen.dart b/ui/lib/screens/Personal Manager/medicationManager/editMedication_Screen.dart index 5288b04..19b1553 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/editMedication_Screen.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/editMedication_Screen.dart @@ -1,15 +1,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:ui/components/custom_app_bar.dart'; -import 'package:ui/components/medication_card.dart'; import 'package:ui/screens/Personal%20Manager/medicationManager/api/medicationFirebaseAPI.dart'; import 'package:ui/screens/Personal%20Manager/medicationManager/api/medicationsProvider.dart'; import 'package:ui/screens/Personal%20Manager/medicationManager/models/medication_model.dart'; class EditMedication extends StatefulWidget { - final Medication medication; EditMedication({@required this.medication}); // Constructor @@ -18,7 +15,6 @@ class EditMedication extends StatefulWidget { } class _EditMedicationState extends State { - // Variables used within file String _medicationName; String _medicationDose; @@ -30,7 +26,6 @@ class _EditMedicationState extends State { _medicationName = widget.medication.medicationName; _medicationDose = widget.medication.dosage; _medicationTime = widget.medication.doseTime; - } @override @@ -52,7 +47,6 @@ class _EditMedicationState extends State { bottom: 8, ), child: Align( - alignment: Alignment.topLeft, child: Text( "Edit Medication", @@ -63,247 +57,240 @@ class _EditMedicationState extends State { ), ), ), - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20 - ), + padding: const EdgeInsets.only(left: 20, right: 20), child: Align( alignment: Alignment.topLeft, child: Text( "Edit the details of the medication, Click on the delete icon to delete the medication", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), ), - ], ), - Expanded( - child:Padding( - padding: const EdgeInsets.symmetric( - horizontal: 17, - vertical: 0 - ), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 17, vertical: 0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + // color: Color(0xFF57994D) + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - // color: Color(0xFF57994D) + borderRadius: BorderRadius.circular(10), ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical:8.0), - child: Container( - - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), + child: ListView( + children: [ + SizedBox( + height: 15, ), - child: ListView( - children: [ - SizedBox( - height: 15, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE)), + child: Padding( + padding: const EdgeInsets.only( + left: 18, + top: 5, + bottom: 10, + right: 10), + child: TextFormField( + initialValue: _medicationName, + maxLength: 20, + onChanged: (value) async { + final provider = + Provider.of( + context, + listen: false); + provider.removeMedication( + widget.medication); + //Check if the field is not empty + if (value != "") { + setState(() { + _medicationName = value; + }); + } + }, + decoration: InputDecoration( + hintText: + "Name of Medication", // temporary text + border: InputBorder.none, ), - child: Padding( - padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextFormField( - initialValue: _medicationName, - maxLength: 20, - onChanged: (value) async{ - final provider = Provider.of(context, listen: false); - provider.removeMedication(widget.medication); - //Check if the field is not empty - if(value !="") { - setState(() { - _medicationName = value; - }); - - } - }, - decoration: InputDecoration( - hintText: "Name of Medication", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ),), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), ), ), - - SizedBox( - height: 11, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) + ), + ), + SizedBox( + height: 11, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18, + top: 5, + bottom: 10, + right: 10), + child: TextFormField( + initialValue: _medicationDose, + maxLength: 15, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _medicationDose = value; + }); + } + }, + decoration: InputDecoration( + hintText: + "Dose - eg: 'Two tablets', '5 ml'", // temporary text + border: InputBorder.none, ), - child: Padding( - padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextFormField( - initialValue: _medicationDose, - maxLength: 15, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _medicationDose = value; - }); - - } - }, - decoration: InputDecoration( - hintText: "Dose - eg: 'Two tablets', '5 ml'", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ),), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), ), ), - - SizedBox( - height: 11, + ), + ), + SizedBox( + height: 11, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Color(0xFFEEEEEE), + ), + child: Padding( + padding: const EdgeInsets.only( + left: 18, + top: 5, + bottom: 10, + right: 10), + child: TextFormField( + initialValue: _medicationTime, + maxLength: 35, + onChanged: (value) async { + //Check if the field is not empty + if (value != "") { + setState(() { + _medicationTime = value; + }); + } + }, + decoration: InputDecoration( + hintText: + "Time - eg: 'every 5 hours','after lunch'", // temporary text + border: InputBorder.none, + ), + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Color(0xFF1F1F1F), + ), ), - - Container( + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + if (_medicationName != "") { + Medication medication = Medication( + medicationName: _medicationName, + dosage: _medicationDose, + doseTime: _medicationTime, + ); + final provider = + Provider.of( + context, + listen: false); + provider + .removeMedication(widget.medication); + MedicationFirebaseApi.createMedication( + medication); + } + Navigator.pop(context); + }, + child: Center( + child: Container( + width: 200, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Color(0xFFEEEEEE) + color: Color(0xFF1F1F1F), + borderRadius: BorderRadius.circular(18), ), child: Padding( padding: const EdgeInsets.only( - left:18, - top:5, - bottom: 10, - right: 10 - ), - child: TextFormField( - initialValue: _medicationTime, - maxLength: 35, - onChanged: (value) async{ - //Check if the field is not empty - if(value !="") { - setState(() { - _medicationTime = value; - }); - } - }, - decoration: InputDecoration( - hintText: "Time - eg: 'every 5 hours','after lunch'", // temporary text - border:InputBorder.none, - ), - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Color(0xFF1F1F1F), - ), - ), - ), - ), - SizedBox( - height: 10, - ), - GestureDetector( - onTap: (){ - - if(_medicationName !="") { - Medication medication = Medication( - medicationName: _medicationName, - dosage: _medicationDose, - doseTime: _medicationTime, - ); - final provider = Provider.of(context, listen: false); - provider.removeMedication(widget.medication); - MedicationFirebaseApi.createMedication(medication); - } - Navigator.pop(context); - }, - child: Center( - child: Container( - width: 200, - decoration: BoxDecoration( - color: Color(0xFF1F1F1F), - borderRadius: BorderRadius.circular(18), - ), - child: Padding( - padding: const EdgeInsets.only( - top:20, - bottom: 20 - ), - child: Center( - child: Text( - "Save", - style: TextStyle( // text style - fontSize: 15, - fontFamily: 'Poppins-Semibold', - color:Colors.white, - ), - ), + top: 20, bottom: 20), + child: Center( + child: Text( + "Save", + style: TextStyle( + // text style + fontSize: 15, + fontFamily: 'Poppins-Semibold', + color: Colors.white, ), ), ), ), ), - ], + ), ), - ), + ], ), ), - ) - ), + ), + ), + )), ], ), - Positioned( bottom: 17, right: 17, child: GestureDetector( onTap: () { - final provider = Provider.of(context, listen: false); + final provider = Provider.of(context, + listen: false); provider.removeMedication(widget.medication); Navigator.pop(context); setState(() {}); // Setting and Refreshing State }, child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Color(0xFFE84848), - borderRadius: BorderRadius.circular(18) - ), - child: Icon( - Icons.delete, - color: Colors.white, - ) - ), + width: 60, + height: 60, + decoration: BoxDecoration( + color: Color(0xFFE84848), + borderRadius: BorderRadius.circular(18)), + child: Icon( + Icons.delete, + color: Colors.white, + )), ), ), - ], ), ), diff --git a/ui/lib/screens/Personal Manager/medicationManager/medicationManager_screen.dart b/ui/lib/screens/Personal Manager/medicationManager/medicationManager_screen.dart index eeac88e..27d9b96 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/medicationManager_screen.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/medicationManager_screen.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:ui/components/custom_app_bar.dart'; -import 'package:ui/components/medication_card.dart'; -import 'package:ui/components/widgets.dart'; import 'addMedication_screen.dart'; import 'api/medicationFirebaseAPI.dart'; import 'api/medicationsProvider.dart'; @@ -14,157 +12,141 @@ class MedicationManager extends StatefulWidget { @override _MedicationManagerState createState() => _MedicationManagerState(); - final Medication medication; + final Medication medication; MedicationManager({@required this.medication}); // Constructor } class _MedicationManagerState extends State { - - @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - appBar: CustomAppBar.arrow(context), - body: SafeArea( - child: Stack( - children: [ - - Column( - children: [ - Column( - children: [ - - Padding( - padding: const EdgeInsets.only( - left: 20, - bottom: 8, - ), - child: Align( - - alignment: Alignment.topLeft, - child: Text( - "Medications", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 24, - ), + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + appBar: CustomAppBar.arrow(context), + body: SafeArea( + child: Stack( + children: [ + Column( + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 20, + bottom: 8, + ), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Medications", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 24, ), ), ), - - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20 - ), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Here you can manage your medications, click add a medication to create one and drag the medication to delete it", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) - ), - ), + ), + Padding( + padding: const EdgeInsets.only(left: 20, right: 20), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Here you can manage your medications, click add a medication to create one and drag the medication to delete it", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B)), ), ), - - ], - ), - - Expanded( + ), + ], + ), + Expanded( + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 17, vertical: 0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + // color: Color(0xFF57994D) + ), child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 17, - vertical: 0 - ), + padding: const EdgeInsets.symmetric(vertical: 8.0), child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - // color: Color(0xFF57994D) - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Container( - - child: StreamBuilder>( - stream: MedicationFirebaseApi.readMedication(), - builder: (context, snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return Center( - child: CircularProgressIndicator()); - default: - if (snapshot.hasError) { - return buildText( - 'Something went wrong, Try later'); - } else { - final medications = snapshot.data; - - final provider = Provider.of(context); - provider.setMedications(medications); - - return MedicationListWidget(); - } + child: StreamBuilder>( + stream: MedicationFirebaseApi.readMedication(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Center( + child: CircularProgressIndicator()); + default: + if (snapshot.hasError) { + return buildText( + 'Something went wrong, Try later'); + } else { + final medications = snapshot.data; + + final provider = + Provider.of( + context); + provider.setMedications(medications); + + return MedicationListWidget(); } - } - ), - - ), - ), + } + }), ), - ) - ), - - ], - ), - Positioned( - bottom: 17, - right: 17, - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - AddMedication() // Navigates to Task Page ), - ).then((value) { - setState(() {}); // Setting and Refreshing State - }); - }, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Color(0xFF1c374a), - borderRadius: BorderRadius.circular(18) - ), - child: Image( - image: AssetImage('images/add_icon.png') // Add icon ), ), ), + ], + ), + Positioned( + bottom: 17, + right: 17, + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + AddMedication() // Navigates to Task Page + ), + ).then((value) { + setState(() {}); // Setting and Refreshing State + }); + }, + child: Container( + width: 60, + height: 60, + decoration: BoxDecoration( + color: Color(0xFF1c374a), + borderRadius: BorderRadius.circular(18)), + child: Image( + image: AssetImage('images/add_icon.png') // Add icon + ), + ), ), - ], - ), + ), + ], ), ), - ); - } + ), + ); } -// } +} Widget buildText(String text) => Center( - child: Text( - text, - style: TextStyle(fontSize: 24, color: Colors.white), - ), -); - -void editMedication(BuildContext context, Medication medication) => Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => EditMedication(medication: medication), - ), -); \ No newline at end of file + child: Text( + text, + style: TextStyle(fontSize: 24, color: Colors.white), + ), + ); + +void editMedication(BuildContext context, Medication medication) => + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => EditMedication(medication: medication), + ), + ); diff --git a/ui/lib/screens/Personal Manager/medicationManager/medicationWidgets/MedicationListWidget.dart b/ui/lib/screens/Personal Manager/medicationManager/medicationWidgets/MedicationListWidget.dart index 8fb692f..c1590d9 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/medicationWidgets/MedicationListWidget.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/medicationWidgets/MedicationListWidget.dart @@ -11,24 +11,24 @@ class MedicationListWidget extends StatelessWidget { return medications.isEmpty ? Center( - child: Text( - 'No Medications.', - style: TextStyle( - color: Color(0xffaaaaaa), - fontFamily: 'Poppins-SemiBold', - fontSize: 17, + child: Text( + 'No Medications.', + style: TextStyle( + color: Color(0xffaaaaaa), + fontFamily: 'Poppins-SemiBold', + fontSize: 17, + ), ), - ), - ) + ) : ListView.separated( - physics: BouncingScrollPhysics(), - separatorBuilder: (context, index) => Container(height: 5), - itemCount: medications.length, - itemBuilder: (context, index) { - final medication = medications[index]; + physics: BouncingScrollPhysics(), + separatorBuilder: (context, index) => Container(height: 5), + itemCount: medications.length, + itemBuilder: (context, index) { + final medication = medications[index]; - return MedicationCard(medication: medication); - }, - ); + return MedicationCard(medication: medication); + }, + ); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/medicationManager/models/medication_model.dart b/ui/lib/screens/Personal Manager/medicationManager/models/medication_model.dart index 846d10b..27d5513 100644 --- a/ui/lib/screens/Personal Manager/medicationManager/models/medication_model.dart +++ b/ui/lib/screens/Personal Manager/medicationManager/models/medication_model.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -class Medication { +class Medication { String id; String medicationName; String dosage; @@ -9,22 +9,21 @@ class Medication { Medication({ @required this.medicationName, this.dosage = '', - this.doseTime='', + this.doseTime = '', this.id, }); // Constructor static Medication fromJson(Map json) => Medication( - medicationName: json['medicationName'], - dosage: json['dosage'], - doseTime: json['doseTime'], - id: json['id'], - ); + medicationName: json['medicationName'], + dosage: json['dosage'], + doseTime: json['doseTime'], + id: json['id'], + ); Map toJson() => { - 'medicationName': medicationName, - 'dosage': dosage, - 'doseTime': doseTime, - 'id': id, - }; - -} \ No newline at end of file + 'medicationName': medicationName, + 'dosage': dosage, + 'doseTime': doseTime, + 'id': id, + }; +} diff --git a/ui/lib/screens/Personal Manager/personalManager_screen.dart b/ui/lib/screens/Personal Manager/personalManager_screen.dart index 48abd1a..66c2b19 100644 --- a/ui/lib/screens/Personal Manager/personalManager_screen.dart +++ b/ui/lib/screens/Personal Manager/personalManager_screen.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/components/personal_manager_card.dart'; @@ -20,15 +19,13 @@ class _PersonalManagerState extends State { children: [ CustomAppBar.arrow(context), Column( - children : [ - + children: [ Padding( padding: const EdgeInsets.only( left: 20, bottom: 8, ), child: Align( - alignment: Alignment.topLeft, child: Text( "Personal Manager", @@ -39,21 +36,17 @@ class _PersonalManagerState extends State { ), ), ), - Padding( - padding: const EdgeInsets.only( - left: 20, - bottom: 14, - right: 20 - ), + padding: + const EdgeInsets.only(left: 20, bottom: 14, right: 20), child: Align( alignment: Alignment.topLeft, child: Text( "Here you can manage your medications, view previous reports and save doctors appointment notes.", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), @@ -61,52 +54,66 @@ class _PersonalManagerState extends State { ], ), Expanded( - child: ListView( - scrollDirection: Axis.vertical, - children: [ - Container( - child: GestureDetector( - onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context)=> MedicationManager() - ), - ); - }, - child: PersonalCard(cardTitle: 'Medications', cardColor1: '0xFF91C77E', cardColor2:'0xFF146314' , textColor: '0xFFFFFFFF', ) + child: + ListView(scrollDirection: Axis.vertical, children: [ + Container( + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => MedicationManager(), ), - ), - Container( - child: GestureDetector( - onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context)=> ReportManager() - ), - ); - }, - child: PersonalCard(cardTitle: 'Reports', cardColor1: '0xFF7EC794', cardColor2:'0xFF0D886B', textColor: '0xFFFFFFFF', ) + ); + }, + child: PersonalCard( + cardTitle: 'Medications', + cardColor1: '0xFF91C77E', + cardColor2: '0xFF146314', + textColor: '0xFFFFFFFF', + ), + ), + ), + Container( + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ReportManager(), ), - ), - Container( - child: GestureDetector( - onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context)=> AppointmentsManager() - ), - ); - }, - child: PersonalCard(cardTitle: 'Appointments', cardColor1: '0xFF7EC5C7', cardColor2:'0xFF145663', textColor: '0xFFFFFFFF', )) - ), - SizedBox( - height: 20, - ), - ] - ) + ); + }, + child: PersonalCard( + cardTitle: 'Reports', + cardColor1: '0xFF7EC794', + cardColor2: '0xFF0D886B', + textColor: '0xFFFFFFFF', + ), + ), + ), + Container( + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AppointmentsManager(), + ), + ); + }, + child: PersonalCard( + cardTitle: 'Appointments', + cardColor1: '0xFF7EC5C7', + cardColor2: '0xFF145663', + textColor: '0xFFFFFFFF', + ), + ), + ), + SizedBox( + height: 20, + ), + ]), ), ], ), diff --git a/ui/lib/screens/Personal Manager/reportManager/api/ReportFirebaseApi.dart b/ui/lib/screens/Personal Manager/reportManager/api/ReportFirebaseApi.dart index c9f45c1..22a2666 100644 --- a/ui/lib/screens/Personal Manager/reportManager/api/ReportFirebaseApi.dart +++ b/ui/lib/screens/Personal Manager/reportManager/api/ReportFirebaseApi.dart @@ -7,24 +7,26 @@ import 'package:ui/services/GoogleUserSignInDetails.dart'; final user = FirebaseAuth.instance.currentUser; var loggedInUserEP = user.email; -var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; +var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; class ReportFirebaseApi { + static Stream> readDiagnosisReports() => + FirebaseFirestore.instance + .collection("users") + .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) + .collection("imageDetections") + .snapshots() + .transform( + Utils.transformer(Report.fromDiagnosisJson), + ); - static Stream> readDiagnosisReports() => FirebaseFirestore.instance - .collection("users") - .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) - .collection("imageDetections") - .snapshots() - .transform(Utils.transformer(Report.fromDiagnosisJson) - ); - - static Stream> readPrognosisReports() => FirebaseFirestore.instance - .collection("users") - .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) - .collection("InputPrognosis") - .snapshots() - .transform(Utils.transformer(Report.fromPrognosisJson) - ); - -} \ No newline at end of file + static Stream> readPrognosisReports() => + FirebaseFirestore.instance + .collection("users") + .doc(loggedInUserEP != null ? loggedInUserEP : loggedInUserGoogle) + .collection("InputPrognosis") + .snapshots() + .transform( + Utils.transformer(Report.fromPrognosisJson), + ); +} diff --git a/ui/lib/screens/Personal Manager/reportManager/api/ReportProvider.dart b/ui/lib/screens/Personal Manager/reportManager/api/ReportProvider.dart index 2e8d881..1edb8c7 100644 --- a/ui/lib/screens/Personal Manager/reportManager/api/ReportProvider.dart +++ b/ui/lib/screens/Personal Manager/reportManager/api/ReportProvider.dart @@ -5,9 +5,9 @@ class ReportProvider extends ChangeNotifier { List _reports = []; List get reports => _reports.toList(); - void setReports(List reports) => WidgetsBinding.instance.addPostFrameCallback((_) { - _reports = reports; - notifyListeners(); - }); - + void setReports(List reports) => + WidgetsBinding.instance.addPostFrameCallback((_) { + _reports = reports; + notifyListeners(); + }); } diff --git a/ui/lib/screens/Personal Manager/reportManager/diagnosis_reports_screen.dart b/ui/lib/screens/Personal Manager/reportManager/diagnosis_reports_screen.dart index f28d15f..7277588 100644 --- a/ui/lib/screens/Personal Manager/reportManager/diagnosis_reports_screen.dart +++ b/ui/lib/screens/Personal Manager/reportManager/diagnosis_reports_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/screens/Personal%20Manager/reportManager/report_widgets/ReportListWidget.dart'; +import 'package:ui/screens/current_screen.dart'; import 'api/ReportFirebaseApi.dart'; import 'api/ReportProvider.dart'; import 'models/report.dart'; @@ -20,88 +21,139 @@ class _DiagnosisReportsState extends State { body: SafeArea( child: Expanded( child: Container( - child:Column( - children: [ - Column( - children: [ - Column( - children: [ - Padding( - padding: const EdgeInsets.only( - left: 20, - bottom: 8, - ), - child: Align( - - alignment: Alignment.topLeft, - child: Text( - "Diagnosis Reports", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 32, - color: Color(0xFF00404E) - ), - ), - ), + child: Column( + children: [ + Column( + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 20, + bottom: 8, ), - - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20, - bottom:15 + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Diagnosis Reports", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 32, + color: Color(0xFF00404E)), ), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Here you can view the reports created after a diagnosis", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) - ), + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 20, right: 20, bottom: 15), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Here you can view the reports created after a diagnosis", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), - ], - ), - ], - ), - - Expanded( - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - child: StreamBuilder>( - stream: ReportFirebaseApi.readDiagnosisReports(), - builder: (context, snapshot) { - switch (snapshot.connectionState) { - - case ConnectionState.waiting: - - return Center( - child: CircularProgressIndicator()); - default: - - if (snapshot.hasError) { - return buildText( - 'Something went wrong, Try later'); - } else { - final reports = snapshot.data; + ), + ], + ), + ], + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + child: StreamBuilder>( + stream: ReportFirebaseApi.readDiagnosisReports(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Center( + child: CircularProgressIndicator(), + ); + default: + if (snapshot.hasError) { + return buildText( + 'Something went wrong, Try later'); + } else { + final reports = snapshot.data; - final provider = Provider.of(context); - provider.setReports(reports); + final provider = + Provider.of(context); + provider.setReports(reports); - return ReportListWidget(); - } - } + return ReportListWidget(); + } } + }), + ), + ), + ), + SizedBox( + height: 40, + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CurrentScreen(), + ), + ); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30.0), + ), + child: Container( + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 1, + blurRadius: 7, + offset: + Offset(0, 3), // changes position of shadow + ), + ], + borderRadius: BorderRadius.circular(18), + color: Colors.lightBlueAccent, + ), + padding: EdgeInsets.only(left: 10.0, right: 10.0), + width: 250.0, + height: 65.0, + child: Row( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: new Icon( + Icons.arrow_back, + color: Colors.white, + ), + ), + SizedBox( + width: 10, + ), + Text( + "Back To Home Page", + style: TextStyle( + fontSize: 17.0, + fontFamily: 'Poppins-Regular', + color: Colors.white), + ) + ], ), ), ), ), - ], - ) + ) + ], + ), ), ), ), @@ -111,8 +163,8 @@ class _DiagnosisReportsState extends State { } Widget buildText(String text) => Center( - child: Text( - text, - style: TextStyle(fontSize: 24, color: Colors.black), - ), -); \ No newline at end of file + child: Text( + text, + style: TextStyle(fontSize: 24, color: Colors.black), + ), + ); diff --git a/ui/lib/screens/Personal Manager/reportManager/models/report.dart b/ui/lib/screens/Personal Manager/reportManager/models/report.dart index 0636da7..384c9a1 100644 --- a/ui/lib/screens/Personal Manager/reportManager/models/report.dart +++ b/ui/lib/screens/Personal Manager/reportManager/models/report.dart @@ -1,45 +1,41 @@ import 'package:cloud_firestore/cloud_firestore.dart'; class Report { - String id; String cancerType; + String inputImageUrl; String imageUrl; String result; - String result_string; + String resultString; String percentage; String reportType; Timestamp reportDate; Map prognosisInputs; - Report({ - this.reportType = '', - this.reportDate, - this.imageUrl='', - this.percentage='', - this.cancerType='', - this.result='', - this.result_string='', - this.prognosisInputs - }); // Constructor + Report( + {this.reportType = '', + this.reportDate,this.inputImageUrl = '', + this.imageUrl = '', + this.percentage = '', + this.cancerType = '', + this.result = '', + this.resultString = '', + this.prognosisInputs}); // Constructor static Report fromDiagnosisJson(Map json) => Report( - reportType: json['reportType'], - reportDate: json['timestamp'], - result: json['result'], - result_string: json['result_string'], - cancerType: json['cancerType'], - imageUrl: json['imageUrl'], - percentage: json['percentage'] - ); + reportType: json['reportType'], + reportDate: json['timestamp'], + result: json['result'], + resultString: json['result_string'], + cancerType: json['cancerType'], + inputImageUrl: json['cancerType'] != "skin cancer" ? json['inputImageUrl'] : "", + imageUrl: json['imageUrl'], + percentage: json['percentage']); static Report fromPrognosisJson(Map json) => Report( reportType: json['reportType'], reportDate: json['timestamp'], result: json['result'], cancerType: json['cancerType'], - prognosisInputs: json['prognosisInputs'] - ); - + prognosisInputs: json['prognosisInputs']); } - diff --git a/ui/lib/screens/Personal Manager/reportManager/prognosis_reports_screen.dart b/ui/lib/screens/Personal Manager/reportManager/prognosis_reports_screen.dart index 71935c6..2aae35c 100644 --- a/ui/lib/screens/Personal Manager/reportManager/prognosis_reports_screen.dart +++ b/ui/lib/screens/Personal Manager/reportManager/prognosis_reports_screen.dart @@ -1,13 +1,11 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:ui/components/custom_app_bar.dart'; -import 'package:ui/components/reports_card.dart'; import 'package:ui/screens/Personal%20Manager/reportManager/report_widgets/ReportListWidget.dart'; - +import 'package:ui/screens/current_screen.dart'; import 'api/ReportFirebaseApi.dart'; import 'api/ReportProvider.dart'; import 'models/report.dart'; -import 'viewReport_screen.dart'; class PrognosisReports extends StatefulWidget { @override @@ -23,90 +21,139 @@ class _PrognosisReportsState extends State { body: SafeArea( child: Expanded( child: Container( - child:Column( - children: [ - Column( - children: [ - Column( - children: [ - Padding( - padding: const EdgeInsets.only( - left: 20, - bottom: 8, - ), - child: Align( - - alignment: Alignment.topLeft, - child: Text( - "Prognosis Reports", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 32, - color: Color(0xFF00404E) - ), - ), - ), + child: Column( + children: [ + Column( + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.only( + left: 20, + bottom: 8, ), - - Padding( - padding: const EdgeInsets.only( - left: 20, - right: 20, - bottom:15 + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Prognosis Reports", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 32, + color: Color(0xFF00404E)), ), - child: Align( - alignment: Alignment.topLeft, - child: Text( - "Here you can view the reports created after a prognosis.", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 13.0, - color: Color(0xFF3C707B) - ), + ), + ), + Padding( + padding: const EdgeInsets.only( + left: 20, right: 20, bottom: 15), + child: Align( + alignment: Alignment.topLeft, + child: Text( + "Here you can view the reports created after a prognosis.", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 13.0, + color: Color(0xFF3C707B), ), ), ), - ], - ), - ], - ), - - Expanded( - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - - child: StreamBuilder>( - stream: ReportFirebaseApi.readPrognosisReports(), - builder: (context, snapshot) { - switch (snapshot.connectionState) { - - case ConnectionState.waiting: - - return Center( - child: CircularProgressIndicator()); - default: - - if (snapshot.hasError) { - return buildText( - 'Something went wrong, Try later'); - } else { - final reports = snapshot.data; + ), + ], + ), + ], + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + child: StreamBuilder>( + stream: ReportFirebaseApi.readPrognosisReports(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Center( + child: CircularProgressIndicator(), + ); + default: + if (snapshot.hasError) { + return buildText( + 'Something went wrong, Try later'); + } else { + final reports = snapshot.data; - final provider = Provider.of(context); - provider.setReports(reports); + final provider = + Provider.of(context); + provider.setReports(reports); - return ReportListWidget(); - } - } + return ReportListWidget(); + } } + }), + ), + ), + ), + SizedBox( + height: 40, + ), + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CurrentScreen(), + ), + ); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 20), + child: Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30.0), + ), + child: Container( + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 1, + blurRadius: 7, + offset: + Offset(0, 3), // changes position of shadow + ), + ], + borderRadius: BorderRadius.circular(18), + color: Colors.lightBlueAccent, + ), + padding: EdgeInsets.only(left: 10.0, right: 10.0), + width: 250.0, + height: 65.0, + child: Row( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: new Icon( + Icons.arrow_back, + color: Colors.white, + ), + ), + SizedBox( + width: 10, + ), + Text( + "Back To Home Page", + style: TextStyle( + fontSize: 17.0, + fontFamily: 'Poppins-Regular', + color: Colors.white), + ) + ], ), ), ), ), - - ], - ) + ) + ], + ), ), ), ), @@ -116,8 +163,8 @@ class _PrognosisReportsState extends State { } Widget buildText(String text) => Center( - child: Text( - text, - style: TextStyle(fontSize: 24, color: Colors.black), - ), -); \ No newline at end of file + child: Text( + text, + style: TextStyle(fontSize: 24, color: Colors.black), + ), + ); diff --git a/ui/lib/screens/Personal Manager/reportManager/report_widgets/ReportListWidget.dart b/ui/lib/screens/Personal Manager/reportManager/report_widgets/ReportListWidget.dart index da3d0e6..31d2638 100644 --- a/ui/lib/screens/Personal Manager/reportManager/report_widgets/ReportListWidget.dart +++ b/ui/lib/screens/Personal Manager/reportManager/report_widgets/ReportListWidget.dart @@ -8,7 +8,9 @@ class ReportListWidget extends StatelessWidget { Widget build(BuildContext context) { final provider = Provider.of(context); final reports = provider.reports; - reports.sort((a,b) => b.reportDate.compareTo(a.reportDate)); + reports.sort( + (a, b) => b.reportDate.compareTo(a.reportDate), + ); return reports.isEmpty ? Center( diff --git a/ui/lib/screens/Personal Manager/reportManager/reports_screen.dart b/ui/lib/screens/Personal Manager/reportManager/reports_screen.dart index 6474934..c0e8186 100644 --- a/ui/lib/screens/Personal Manager/reportManager/reports_screen.dart +++ b/ui/lib/screens/Personal Manager/reportManager/reports_screen.dart @@ -17,106 +17,97 @@ class _ReportManagerState extends State { appBar: CustomAppBar.arrow(context), body: SafeArea( child: Container( - child:Column( - children: [ - - Padding( - padding: const EdgeInsets.only( - bottom: 50, + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + bottom: 50, + ), + child: Align( + alignment: Alignment.topCenter, + child: Text( + "Select Report Type", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 24, + color: Color(0xFF354042), + ), ), - child: Align( - - alignment: Alignment.topCenter, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DiagnosisReports(), + ), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + gradient: LinearGradient( + colors: [Color(0xFFC6E7EE), Color(0xFF637477)], + begin: Alignment.bottomLeft, + end: Alignment.topRight, + ), + ), + padding: EdgeInsets.only(top: 100, left: 25), + width: (MediaQuery.of(context).size.width), + height: 150, child: Text( - "Select Report Type", + "Diagnosis Reports", style: TextStyle( + fontSize: 20, + color: Color(0xFF63888F), fontFamily: 'Poppins-SemiBold', - fontSize: 24, - color: Color(0xFF354042), ), ), ), ), - - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 20 - ), - child: GestureDetector( - onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context)=> DiagnosisReports() - ), - ); - }, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), - gradient: LinearGradient( - colors: [Color(0xFFC6E7EE), Color(0xFF637477)], - begin: Alignment.bottomLeft, - end: Alignment.topRight, - ), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 20, vertical: 20), + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PrognosisReports(), ), - padding: EdgeInsets.only(top: 100, left: 25), - width: (MediaQuery.of(context).size.width), - height: 150, - child: Text( - "Diagnosis Reports", - style: TextStyle( - fontSize: 20, - color: Color(0xFF63888F), - fontFamily: 'Poppins-SemiBold', - ), + ); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + gradient: LinearGradient( + colors: [Color(0xFFC6E7EE), Color(0xFF637477)], + begin: Alignment.bottomLeft, + end: Alignment.topRight, ), ), - ), - ), - - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 20 - ), - child: GestureDetector( - onTap: (){ - Navigator.push( - context, - MaterialPageRoute( - builder: (context)=> PrognosisReports() - ), - ); - }, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), - gradient: LinearGradient( - colors: [Color(0xFFC6E7EE), Color(0xFF637477)], - begin: Alignment.bottomLeft, - end: Alignment.topRight, - ), - ), - padding: EdgeInsets.only(top: 100, left: 25), - width: (MediaQuery.of(context).size.width), - height: 150, - child: Text( - "Prognosis Reports", - style: TextStyle( - fontSize: 20, - color: Color(0xFF63888F), - fontFamily: 'Poppins-SemiBold', - ), + padding: EdgeInsets.only(top: 100, left: 25), + width: (MediaQuery.of(context).size.width), + height: 150, + child: Text( + "Prognosis Reports", + style: TextStyle( + fontSize: 20, + color: Color(0xFF63888F), + fontFamily: 'Poppins-SemiBold', ), ), ), ), - ], - ) - ), + ), + ], + )), ), ), ); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/Personal Manager/reportManager/viewReport_screen.dart b/ui/lib/screens/Personal Manager/reportManager/viewReport_screen.dart index da279bf..420c43e 100644 --- a/ui/lib/screens/Personal Manager/reportManager/viewReport_screen.dart +++ b/ui/lib/screens/Personal Manager/reportManager/viewReport_screen.dart @@ -18,6 +18,7 @@ class _ViewReportState extends State { String _cancerType; String _reportPercentage; String _reportResult; + String imageInputURL; String imageURL; var _reportDate; @@ -38,10 +39,11 @@ class _ViewReportState extends State { DateTime.fromMillisecondsSinceEpoch(_reportDate.millisecondsSinceEpoch); formattedDate = DateFormat.yMMMd().format(date); _reportPercentage = widget.report.percentage; + imageInputURL = widget.report.inputImageUrl; imageURL = widget.report.imageUrl; _cancerType = widget.report.cancerType; if (widget.report.result == "CANCER") { - _reportResult = widget.report.result_string; + _reportResult = widget.report.resultString; } else { _reportResult = widget.report.result; } @@ -61,93 +63,100 @@ class _ViewReportState extends State { } void getPostsData(Map prognosisBody) { - List responseList = new List(); + List responseList = []; prognosisBody.forEach((k, v) => {responseList.add(k + " : " + v)}); List listItems = []; - listItems.add(Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only( - top: 10, - left: 20, - ), - child: Align( - alignment: Alignment.topLeft, - child: Text( - formattedDate, - style: TextStyle( + listItems.add( + Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only( + top: 10, + left: 20, + ), + child: Align( + alignment: Alignment.topLeft, + child: Text( + formattedDate, + style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 27, - color: Color(0xFF00404E)), + color: Color(0xFF00404E), + ), + ), ), ), - ), - Padding( - padding: const EdgeInsets.only(left: 20, right: 20, bottom: 15), - child: Align( - alignment: Alignment.topLeft, - child: Text( - _cancerType.toUpperCase() + " " + _reportType.toUpperCase(), - style: TextStyle( + Padding( + padding: const EdgeInsets.only(left: 20, right: 20, bottom: 15), + child: Align( + alignment: Alignment.topLeft, + child: Text( + _cancerType.toUpperCase() + " " + _reportType.toUpperCase(), + style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 19, - color: Color(0xFF3C707B)), + color: Color(0xFF3C707B), + ), + ), ), ), - ), - ], - ), - Padding( - padding: const EdgeInsets.only( - left: 20, - top: 15, + ], ), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - "Result :", - style: TextStyle( + Padding( + padding: const EdgeInsets.only( + left: 20, + top: 15, + ), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "Result :", + style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 18, - color: Color(0xFF7CC2C4)), + color: Color(0xFF7CC2C4), + ), + ), ), ), - ), - Padding( - padding: const EdgeInsets.only( - left: 20, - top: 5, - ), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - _reportResult.toString().toUpperCase(), - style: TextStyle( + Padding( + padding: const EdgeInsets.only( + left: 20, + top: 5, + ), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + _reportResult.toString().toUpperCase(), + style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 14, - color: Color(0xFF1F1F1F)), + color: Color(0xFF1F1F1F), + ), + ), ), ), - ), - Padding( - padding: const EdgeInsets.only(left: 20, top: 20, bottom: 10), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - "INPUTS PROVIDED", - style: TextStyle( + Padding( + padding: const EdgeInsets.only(left: 20, top: 20, bottom: 10), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "INPUTS PROVIDED", + style: TextStyle( fontFamily: 'Poppins-SemiBold', fontSize: 18, - color: Color(0xFF7CC2C4)), + color: Color(0xFF7CC2C4), + ), + ), ), ), - ), - ], - )); + ], + ), + ); responseList.forEach((post) { listItems.add( @@ -158,9 +167,10 @@ class _ViewReportState extends State { child: Text( post.toString().toUpperCase(), style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 14, - color: Color(0xFF1F1F1F)), + fontFamily: 'Poppins-SemiBold', + fontSize: 14, + color: Color(0xFF1F1F1F), + ), ), ), ), @@ -185,6 +195,7 @@ class _ViewReportState extends State { _cancerType, _reportResult, _reportPercentage, + imageInputURL, imageURL, prognosisVariables, controller, @@ -211,9 +222,10 @@ Widget percentageContainer(String percentages) { child: Text( "Percentage : ", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 18, - color: Color(0xFF7CC2C4)), + fontFamily: 'Poppins-SemiBold', + fontSize: 18, + color: Color(0xFF7CC2C4), + ), ), ), ), @@ -225,11 +237,12 @@ Widget percentageContainer(String percentages) { child: Align( alignment: Alignment.centerLeft, child: Text( - percentages, + double.parse(percentages).floor().toString(), style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 14, - color: Color(0xFF1F1F1F)), + fontFamily: 'Poppins-SemiBold', + fontSize: 14, + color: Color(0xFF1F1F1F), + ), ), ), ), @@ -249,6 +262,7 @@ Widget cancerDetails( String cancerType, String reportResult, String percentage, + String inputImageUrl, String imageUrl, Map prognosisBody, ScrollController controller, @@ -270,7 +284,8 @@ Widget cancerDetails( animation: true, animationDuration: 1000, percent: double.parse(percentage) / 100, - center: new Text(percentage + "%"), + center: new Text( + double.parse(percentage).floor().toString() + "%"), progressColor: color, ), ), @@ -290,9 +305,10 @@ Widget cancerDetails( child: Text( date, style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 27, - color: Color(0xFF00404E)), + fontFamily: 'Poppins-SemiBold', + fontSize: 27, + color: Color(0xFF00404E), + ), ), ), ), @@ -306,9 +322,10 @@ Widget cancerDetails( " " + reportType.toUpperCase(), style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 19, - color: Color(0xFF3C707B)), + fontFamily: 'Poppins-SemiBold', + fontSize: 19, + color: Color(0xFF3C707B), + ), ), ), ), @@ -325,9 +342,10 @@ Widget cancerDetails( child: Text( "Result :", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 18, - color: Color(0xFF7CC2C4)), + fontFamily: 'Poppins-SemiBold', + fontSize: 18, + color: Color(0xFF7CC2C4), + ), ), ), ), @@ -341,9 +359,10 @@ Widget cancerDetails( child: Text( reportResult.toUpperCase(), style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 14, - color: Color(0xFF1F1F1F)), + fontFamily: 'Poppins-SemiBold', + fontSize: 14, + color: Color(0xFF1F1F1F), + ), ), ), ), @@ -354,27 +373,91 @@ Widget cancerDetails( child: Text( "INPUTS PROVIDED", style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 18, - color: Color(0xFF7CC2C4)), + fontFamily: 'Poppins-SemiBold', + fontSize: 18, + color: Color(0xFF7CC2C4), + ), ), ), ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 18), - child: CachedNetworkImage( - progressIndicatorBuilder: - (context, url, downloadProgress) => SizedBox( - width: MediaQuery.of(context).size.width / 2, - height: 100, - child: Center( - child: CircularProgressIndicator( - value: downloadProgress.progress), + cancerType != "skin cancer" + ? Padding( + padding: const EdgeInsets.symmetric(horizontal: 18), + child: CachedNetworkImage( + progressIndicatorBuilder: + (context, url, downloadProgress) => SizedBox( + width: MediaQuery.of(context).size.width / 2, + height: 100, + child: Center( + child: CircularProgressIndicator( + value: downloadProgress.progress), + ), ), - ), - imageUrl: imageUrl, - width: MediaQuery.of(context).size.width, - ), + imageUrl: inputImageUrl, + width: MediaQuery.of(context).size.width, + ), + ) + : Padding( + padding: const EdgeInsets.symmetric(horizontal: 18), + child: CachedNetworkImage( + progressIndicatorBuilder: + (context, url, downloadProgress) => SizedBox( + width: MediaQuery.of(context).size.width / 2, + height: 100, + child: Center( + child: CircularProgressIndicator( + value: downloadProgress.progress), + ), + ), + imageUrl: imageUrl, + width: MediaQuery.of(context).size.width, + ), + ), + SizedBox( + height: 30, + ), + cancerType != "skin cancer" + ? Padding( + padding: const EdgeInsets.only( + left: 20, top: 20, bottom: 10), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + "OUTPUTS OBTAINED", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 18, + color: Color(0xFF7CC2C4)), + ), + ), + ) + : Container( + height: 0, + ), + cancerType != "skin cancer" + ? Padding( + padding: const EdgeInsets.symmetric(horizontal: 18), + child: CachedNetworkImage( + progressIndicatorBuilder: + (context, url, downloadProgress) => SizedBox( + width: MediaQuery.of(context).size.width / 2, + height: 100, + child: Center( + child: CircularProgressIndicator( + value: downloadProgress.progress), + ), + ), + imageUrl: imageUrl, + height: 450, + fit: BoxFit.fill, + width: MediaQuery.of(context).size.width, + ), + ) + : Container( + height: 0, + ), + SizedBox( + height: 30, ), ], ), diff --git a/ui/lib/screens/Personal Manager/utils.dart b/ui/lib/screens/Personal Manager/utils.dart index 8a868c7..3e397c6 100644 --- a/ui/lib/screens/Personal Manager/utils.dart +++ b/ui/lib/screens/Personal Manager/utils.dart @@ -5,13 +5,14 @@ import 'package:flutter/material.dart'; class Utils { static void showSnackBar(BuildContext context, String text) => - Scaffold.of(context) - ..removeCurrentSnackBar() - ..showSnackBar(SnackBar(content: Text(text))); - + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(text), + ), + ); static StreamTransformer transformer( - T Function(Map json) fromJson) => + T Function(Map json) fromJson) => StreamTransformer>.fromHandlers( handleData: (QuerySnapshot data, EventSink> sink) { final snaps = data.docs.map((doc) => doc.data()).toList(); @@ -20,4 +21,4 @@ class Utils { sink.add(objects); }, ); -} \ No newline at end of file +} diff --git a/ui/lib/screens/chatbot_screen.dart b/ui/lib/screens/chatbot_screen.dart index abf1021..568f559 100644 --- a/ui/lib/screens/chatbot_screen.dart +++ b/ui/lib/screens/chatbot_screen.dart @@ -8,6 +8,7 @@ import 'package:ui/services/GoogleUserSignInDetails.dart'; import 'package:ui/components/alert_widget.dart'; import 'package:ui/components/chatbot_message_bubble.dart'; import 'package:ui/constants.dart'; +import 'package:ui/services/endPoints.dart'; final _firestore = FirebaseFirestore.instance; @@ -120,9 +121,8 @@ class _ChatBotScreenState extends State { //send data to chat bot api and get back response try { - Response response = await dio.post( - 'https://chatbot-deployment.azurewebsites.net/api/chatbot-deployment', - data: {'UserIn': messageText}); + Response response = + await dio.post(postChatBotMessage_API, data: {'UserIn': messageText}); setState(() { responseText = response.toString(); }); @@ -219,12 +219,15 @@ class _ChatBotScreenState extends State { ? false : true, controller: messageTextController, - decoration: kTextFieldDecoration.copyWith( - suffixIcon: IconButton( - icon: Icon(Icons.send), - onPressed: handleSendMessage, - color: Colors.lightBlueAccent), - hintText: 'Write a message'), + decoration: + kTextFieldDecoration.copyWith( + suffixIcon: IconButton( + icon: Icon(Icons.send), + onPressed: + handleSendMessage, + color: Colors + .lightBlueAccent), + hintText: 'Write a message'), ), ), ), diff --git a/ui/lib/screens/current_screen.dart b/ui/lib/screens/current_screen.dart index 0fea00a..b6a7d30 100644 --- a/ui/lib/screens/current_screen.dart +++ b/ui/lib/screens/current_screen.dart @@ -9,6 +9,7 @@ import 'package:ui/screens/mainCancer_screen.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/services/UserDetails.dart'; +// ignore: must_be_immutable class CurrentScreen extends StatefulWidget { // static 'id' variable for the naming convention for the routes static String id = "navigationBottom"; @@ -17,18 +18,18 @@ class CurrentScreen extends StatefulWidget { String updatedGender; CurrentScreen(); - CurrentScreen.settingsNavigatorPush(this.updatedUsername, this.updatedEmail, this.updatedGender); - + CurrentScreen.settingsNavigatorPush( + this.updatedUsername, this.updatedEmail, this.updatedGender); @override _CurrentScreenState createState() { - - if (updatedUsername != null && updatedEmail != null && updatedGender != null ) - - return _CurrentScreenState.settingsNavigatorPush(updatedUsername, updatedEmail, updatedGender); - - - else return _CurrentScreenState(); + if (updatedUsername != null && + updatedEmail != null && + updatedGender != null) + return _CurrentScreenState.settingsNavigatorPush( + updatedUsername, updatedEmail, updatedGender); + else + return _CurrentScreenState(); } } @@ -44,37 +45,24 @@ class _CurrentScreenState extends State { List swipeScreen; _CurrentScreenState() { - // getting the current user details on loading of the screen getCurrentUser(); - if (username == null) + if (username == null) username = UserDetails.getUserData()["username"]; - username = UserDetails.getUserData()["username"]; + if (gender == null) gender = UserDetails.getUserData()["gender"]; - if (gender == null) - - gender = UserDetails.getUserData()["gender"]; - - if (email == null) - - email = UserDetails.getUserData()["email"]; + if (email == null) email = UserDetails.getUserData()["email"]; swipeScreen = [HomeScreen(), MainCancerTypesScreen(), ChatBotScreen()]; } - _CurrentScreenState.settingsNavigatorPush(this.username, this.email, this.gender) - { - swipeScreen = [HomeScreen.settingsNavigatorPush(username), MainCancerTypesScreen(), ChatBotScreen()]; - } - - _CurrentScreenState.settingsNavigatorPushEmail(this.email) - { - print(email + " HEREEEE"); - swipeScreen = [HomeScreen(), MainCancerTypesScreen(), ChatBotScreen()]; - } - _CurrentScreenState.settingsNavigatorPushGender(this.gender) - { - swipeScreen = [HomeScreen(), MainCancerTypesScreen(), ChatBotScreen()]; + _CurrentScreenState.settingsNavigatorPush( + this.username, this.email, this.gender) { + swipeScreen = [ + HomeScreen.settingsNavigatorPush(username), + MainCancerTypesScreen(), + ChatBotScreen() + ]; } // using this User instance we can access the details of the logged user using @@ -98,14 +86,14 @@ class _CurrentScreenState extends State { //fetch username var userDocument = await _firestore .collection("users") - .doc(loggedInUser.email != null ? loggedInUser.email : loggedInUserGoogle) + .doc(loggedInUser.email != null + ? loggedInUser.email + : loggedInUserGoogle) .get(); - setState(() { username = userDocument["username"]; email = userDocument["email"]; - print(email + " ARE U THE ISSUE"); gender = userDocument["gender"]; }); } catch (e) { @@ -123,7 +111,6 @@ class _CurrentScreenState extends State { return SafeArea( child: WillPopScope( onWillPop: () async { - print(email); return true; }, child: Stack( @@ -179,42 +166,41 @@ class _CurrentScreenState extends State { // ], // ), ), - Align( alignment: Alignment.bottomCenter, child: CurvedNavigationBar( - height:52, - color: Color(0xff01CDFA), - backgroundColor: Colors.transparent, - index: currentIndex, - - // Logic for the switching of MAIN SCREENS (HOME, CANCER, CHATBOT) - onTap: (index) { - setState(() { - currentIndex = index; - _pageController.jumpToPage( - index, - ); - }); - }, - items: [ - Icon( - Icons.home, - size: 27, - color: Colors.white, - ), - Icon( - Icons.widgets, - size: 27, - color: Colors.white, - ), - Icon( - Icons.chat, - size: 27, - color: Colors.white, - ), - ], - ), + height: 52, + color: Color(0xff01CDFA), + backgroundColor: Colors.transparent, + index: currentIndex, + + // Logic for the switching of MAIN SCREENS (HOME, CANCER, CHATBOT) + onTap: (index) { + setState(() { + currentIndex = index; + _pageController.jumpToPage( + index, + ); + }); + }, + items: [ + Icon( + Icons.home, + size: 27, + color: Colors.white, + ), + Icon( + Icons.widgets, + size: 27, + color: Colors.white, + ), + Icon( + Icons.chat, + size: 27, + color: Colors.white, + ), + ], + ), ), ], ), diff --git a/ui/lib/screens/diagnosis/breastDiagnosis_screen.dart b/ui/lib/screens/diagnosis/breastDiagnosis_screen.dart index 245f288..2221f58 100644 --- a/ui/lib/screens/diagnosis/breastDiagnosis_screen.dart +++ b/ui/lib/screens/diagnosis/breastDiagnosis_screen.dart @@ -11,6 +11,7 @@ import 'dart:async'; import 'package:modal_progress_hud/modal_progress_hud.dart'; import 'package:progress_dialog/progress_dialog.dart'; import 'package:ui/services/UserDetails.dart'; +import 'package:ui/services/endPoints.dart'; class BreastCancerDiagnosis extends StatefulWidget { // static 'id' variable for the naming convention for the routes @@ -75,8 +76,11 @@ class BreastCancerDiagnosisState extends State { // RESPONSE RESULT FROM THE BACKEND // responseBody = response.data[0]; String resultPrediction = responseBody['predition']; - String resultImageURL = responseBody['regular_image_url']; - String resultPercentage = responseBody['prediction_percentage']; + String inputImageURL = responseBody['regular_image_url']; + String resultImageURL = responseBody['superimposed_image_url']; + String resultPercentage = + (100 - double.parse(responseBody['prediction_percentage']).floor()) + .toString(); // Adding the response data into the database for report creation purpose _firestore @@ -84,10 +88,11 @@ class BreastCancerDiagnosisState extends State { .doc(UserDetails.getUserData()["email"]) .collection("imageDetections") .add({ - "cancerType": "Breast", + "cancerType": "breast cancer", "reportType": "diagnosis", "result": resultPrediction, "result_string": "$resultPrediction was detected", + "inputImageUrl": inputImageURL, "imageUrl": resultImageURL, "percentage": resultPercentage, 'timestamp': Timestamp.now(), @@ -111,7 +116,7 @@ class BreastCancerDiagnosisState extends State { } } catch (e) { // Displaying alert to the user - createAlertDialog(context, "Error", e._message, 404); + createAlertDialog(context, "Error", e.toString(), 404); progressDialog.hide(); } @@ -121,7 +126,7 @@ class BreastCancerDiagnosisState extends State { // Getting the detection response getResponse(FormData formData) async { Response response = await dio.post( - "https://breastmodelsdgp.azurewebsites.net/api/breastmodelsdgp?model=breast", + postBreastCancerDetection_API, data: formData, ); responseBody = response.data[0]; @@ -323,8 +328,9 @@ class BreastCancerDiagnosisState extends State { decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.only( - topRight: Radius.circular(20.0), - topLeft: Radius.circular(20.0)), + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), + ), ), width: double.infinity, padding: const EdgeInsets.only( diff --git a/ui/lib/screens/diagnosis/lungDiagnosis_screen.dart b/ui/lib/screens/diagnosis/lungDiagnosis_screen.dart index dc2f2d0..2ee4974 100644 --- a/ui/lib/screens/diagnosis/lungDiagnosis_screen.dart +++ b/ui/lib/screens/diagnosis/lungDiagnosis_screen.dart @@ -10,6 +10,7 @@ import 'package:ui/components/alert_widget.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; import 'package:ui/services/UserDetails.dart'; +import 'package:ui/services/endPoints.dart'; class LungCancerDiagnosis extends StatefulWidget { // static 'id' variable for the naming convention for the routes @@ -69,6 +70,7 @@ class LungCancerDiagnosisState extends State { // RESPONSE RESULT FROM THE BACKEND // responseBody = response.data[0]; String resultPrediction = responseBody['predition']; + String inputImageURL = responseBody['regular_image_url']; String resultImageURL = responseBody['superimposed_image_url']; String resultPercentage = responseBody['prediction_percentage']; @@ -78,10 +80,11 @@ class LungCancerDiagnosisState extends State { .doc(UserDetails.getUserData()["email"]) .collection("imageDetections") .add({ - "cancerType": "lung", + "cancerType": "lung cancer", "reportType": "diagnosis", "result": resultPrediction, "result_string": "$resultPrediction was detected", + "inputImageUrl": inputImageURL, "imageUrl": resultImageURL, "percentage": resultPercentage, 'timestamp': Timestamp.now(), @@ -115,7 +118,7 @@ class LungCancerDiagnosisState extends State { // Getting the detection response getResponse(FormData formData) async { Response response = await dio.post( - "https://lungmodelsdgp.azurewebsites.net/api/lungmodelsdgp?model=lung", + postLungCancerDetection_API, data: formData, ); responseBody = response.data[0]; @@ -154,29 +157,30 @@ class LungCancerDiagnosisState extends State { // Styling Progress Dialog progressDialog.style( - message: ' Scanning\n Image', - padding: EdgeInsets.all(20), - borderRadius: 10.0, - backgroundColor: Colors.white, - progressWidget: LinearProgressIndicator( - backgroundColor: Colors.lightBlueAccent, - ), - elevation: 10.0, - insetAnimCurve: Curves.easeInCubic, - progress: 0.0, - maxProgress: 100.0, - progressTextStyle: TextStyle( - color: Color(0xFF565D5E), - fontSize: 13.0, - fontWeight: FontWeight.w400, - fontFamily: 'Poppins-SemiBold', - ), - messageTextStyle: TextStyle( - color: Color(0xFF565D5E), - fontSize: 19.0, - fontWeight: FontWeight.w600, - fontFamily: 'Poppins-SemiBold', - )); + message: ' Scanning\n Image', + padding: EdgeInsets.all(20), + borderRadius: 10.0, + backgroundColor: Colors.white, + progressWidget: LinearProgressIndicator( + backgroundColor: Colors.lightBlueAccent, + ), + elevation: 10.0, + insetAnimCurve: Curves.easeInCubic, + progress: 0.0, + maxProgress: 100.0, + progressTextStyle: TextStyle( + color: Color(0xFF565D5E), + fontSize: 13.0, + fontWeight: FontWeight.w400, + fontFamily: 'Poppins-SemiBold', + ), + messageTextStyle: TextStyle( + color: Color(0xFF565D5E), + fontSize: 19.0, + fontWeight: FontWeight.w600, + fontFamily: 'Poppins-SemiBold', + ), + ); return SafeArea( child: ModalProgressHUD( @@ -243,8 +247,7 @@ class LungCancerDiagnosisState extends State { padding: const EdgeInsets.all(20.0), child: FadeInImage.assetNetwork( placeholder: 'images/loading.gif', - image: - responseBody["regular_image_url"], + image: responseBody["regular_image_url"], ), ), ), @@ -318,8 +321,9 @@ class LungCancerDiagnosisState extends State { decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.only( - topRight: Radius.circular(20.0), - topLeft: Radius.circular(20.0)), + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), + ), ), width: double.infinity, padding: const EdgeInsets.only( @@ -347,7 +351,7 @@ class LungCancerDiagnosisState extends State { ), ), shape: const StadiumBorder(), - onPressed: () { + onPressed: () { _detect(progressDialog); }, ), @@ -364,12 +368,3 @@ class LungCancerDiagnosisState extends State { ); } } - -// IMPORTANT REFERENCE USED TO CONNECT FLUTTER AND FLASK FOR (MOBILE PHONE) -// https://medium.com/@podcoder/connecting-flutter-application-to-localhost-a1022df63130 -// MAKE SURE THE python script is running on this: -// app.run(host="0.0.0.0", port=80) -// 192.168.1.4 <--- this is the ip address in my machine -// to get your ip address go to cmd and hit ipconfig to get ur LAN ip -// Remember to connect to the same Wifi else ip will a problem -// (NOTE: Nazhim 192.168.1.4 this was the ip for ur SLT wifi) diff --git a/ui/lib/screens/diagnosis/skinDiagnosis_screen.dart b/ui/lib/screens/diagnosis/skinDiagnosis_screen.dart index c986570..839304a 100644 --- a/ui/lib/screens/diagnosis/skinDiagnosis_screen.dart +++ b/ui/lib/screens/diagnosis/skinDiagnosis_screen.dart @@ -10,6 +10,7 @@ import 'package:ui/components/alert_widget.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:modal_progress_hud/modal_progress_hud.dart'; import 'package:ui/services/UserDetails.dart'; +import 'package:ui/services/endPoints.dart'; class SkinCancerDiagnosis extends StatefulWidget { // static 'id' variable for the naming convention for the routes @@ -74,7 +75,7 @@ class SkinCancerDiagnosisState extends State { .doc(UserDetails.getUserData()["email"]) .collection("imageDetections") .add({ - "cancerType": "skin", + "cancerType": "skin cancer", "reportType": "diagnosis", "result": resultPrediction, "result_string": resultString, @@ -108,7 +109,7 @@ class SkinCancerDiagnosisState extends State { // Getting the detection response getResponse(FormData formData) async { Response response = await dio.post( - "https://skinmodelsdgp.azurewebsites.net/api/skinmodelsdgp?model=skin", + postSkinCancerDetection_API, data: formData, ); // RESPONSE DATA FROM THE BACKEND @@ -300,8 +301,9 @@ class SkinCancerDiagnosisState extends State { decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.only( - topRight: Radius.circular(20.0), - topLeft: Radius.circular(20.0)), + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), + ), ), width: double.infinity, padding: const EdgeInsets.only( diff --git a/ui/lib/screens/home_screen.dart b/ui/lib/screens/home_screen.dart index 3e12379..f5900d9 100644 --- a/ui/lib/screens/home_screen.dart +++ b/ui/lib/screens/home_screen.dart @@ -16,6 +16,7 @@ var username = ""; var loggedInUserEP; var loggedInUserGoogle; +// ignore: must_be_immutable class HomeScreen extends StatefulWidget { // static 'id' variable for the naming convention for the routes static String id = "homeScreen"; @@ -26,12 +27,10 @@ class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() { - if (updatedUsername != null) - return _HomeScreenState.settingsNavigatorPush(updatedUsername); - - else return _HomeScreenState(); + else + return _HomeScreenState(); } } @@ -41,14 +40,9 @@ class _HomeScreenState extends State { String username; _HomeScreenState() { - getCurrentUser(); - if(username == null) - - username = UserDetails.getUserData()["username"]; - - print(UserDetails.getUserData()["username"]); + if (username == null) username = UserDetails.getUserData()["username"]; } _HomeScreenState.settingsNavigatorPush(this.username); @@ -78,121 +72,127 @@ class _HomeScreenState extends State { @override Widget build(BuildContext context) { return SafeArea( - child: WillPopScope( - onWillPop: () async => false, - child: Scaffold( - body: Container( - child: Center( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(20, 0, 0, 0), - child: Align( - alignment: Alignment.topLeft, - child: Container( - child: Text( - 'Hello,\n' + username + '!', - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 27.0, - ), + child: WillPopScope( + onWillPop: () async => false, + child: Scaffold( + body: Container( + child: Center( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 0, 0), + child: Align( + alignment: Alignment.topLeft, + child: Container( + child: Text( + 'Hello,\n' + username + '!', + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 27.0, ), ), ), ), - SizedBox( - height: 15, - ), - Padding( - padding: const EdgeInsets.fromLTRB(20, 0, 0, 0), - child: Align( - alignment: Alignment.topLeft, - child: Container( - child: Text( - 'How can we help you?', - style: TextStyle( - color: Color(0xff59939F), - fontFamily: 'Poppins-SemiBold', - fontSize: 16.0, - ), + ), + SizedBox( + height: 15, + ), + Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 0, 0), + child: Align( + alignment: Alignment.topLeft, + child: Container( + child: Text( + 'How can we help you?', + style: TextStyle( + color: Color(0xff59939F), + fontFamily: 'Poppins-SemiBold', + fontSize: 16.0, ), ), ), ), - SizedBox( - height: 20, - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only(right: 10, bottom: 5), - child: ScrollConfiguration( - behavior: ScrollEffectBehaviour(), - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => PersonalManager()), - ); - }, - child: HomeCard( - cardTitle: 'Personal Manager', - cardColor: '0xFFdb5682', - textColor: '0xFFFFFFFF', - cardImage: 'images/CardImages/personalManager.jpg', - ), + ), + SizedBox( + height: 20, + ), + Expanded( + child: Padding( + padding: const EdgeInsets.only(right: 10, bottom: 5), + child: ScrollConfiguration( + behavior: ScrollEffectBehaviour(), + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + Container( + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PersonalManager(), + ), + ); + }, + child: HomeCard( + cardTitle: 'Personal Manager', + cardColor: '0xFFdb5682', + textColor: '0xFFFFFFFF', + cardImage: + 'images/CardImages/personalManager.jpg', ), ), - Container( - child: GestureDetector( - onTap: () { - Navigator.push( - context, MaterialPageRoute(builder: (context) => ExerciseScreen()), - ); - }, - child: HomeCard( - cardTitle: 'Exercise Plan', - cardColor: '0xFFa4d44a', - textColor: '0xFFFFFFFF', - cardImage: 'images/CardImages/exercisePlan.jpg', - ), + ), + Container( + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ExerciseScreen(), + ), + ); + }, + child: HomeCard( + cardTitle: 'Exercise Plan', + cardColor: '0xFFa4d44a', + textColor: '0xFFFFFFFF', + cardImage: + 'images/CardImages/exercisePlan.jpg', ), ), - - Container( - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AllMealScreen()), - ); - }, - child: HomeCard( - cardTitle: 'Meal Plan', - cardColor: '0xFF4ad4b1', - textColor: '0xFFFFFFFF', - cardImage: 'images/CardImages/mealPlan.jpg', - ), + ), + Container( + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AllMealScreen(), + ), + ); + }, + child: HomeCard( + cardTitle: 'Meal Plan', + cardColor: '0xFF4ad4b1', + textColor: '0xFFFFFFFF', + cardImage: 'images/CardImages/mealPlan.jpg', ), ), - ]), - ), + ), + ]), ), ), - SizedBox( - height: 50, - ), - ], - ), + ), + SizedBox( + height: 50, + ), + ], ), ), - ) - ) + ), + ), + ), ); } } diff --git a/ui/lib/screens/login_screen.dart b/ui/lib/screens/login_screen.dart index 5471f42..4a560f6 100644 --- a/ui/lib/screens/login_screen.dart +++ b/ui/lib/screens/login_screen.dart @@ -340,21 +340,21 @@ class _LoginScreenState extends State { colour: Colors.lightBlueAccent, title: 'LOG IN', ), - Text( - "Or connect using", - textAlign: TextAlign.center, - style: kTextStyle.copyWith( - fontSize: 12, - ), - ), - RoundedButton( - onPressed: () { - //Implement login functionality using google auth - googleAuthLogin(context); - }, - colour: Colors.redAccent, - title: 'GOOGLE', - ), +// Text( +// "Or connect using", +// textAlign: TextAlign.center, +// style: kTextStyle.copyWith( +// fontSize: 12, +// ), +// ), +// RoundedButton( +// onPressed: () { +// //Implement login functionality using google auth +// googleAuthLogin(context); +// }, +// colour: Colors.redAccent, +// title: 'GOOGLE', +// ), Padding( padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 5.0), @@ -378,11 +378,13 @@ class _LoginScreenState extends State { Navigator.pushNamed( context, RegistrationScreen.id); }, - child: Text("Sign Up", - style: kTextStyle.copyWith( - color: Color(0xff01CDFA), - fontSize: 13, - )), + child: Text( + "Sign Up", + style: kTextStyle.copyWith( + color: Color(0xff01CDFA), + fontSize: 13, + ), + ), ), ], ), diff --git a/ui/lib/screens/mainCancer_screen.dart b/ui/lib/screens/mainCancer_screen.dart index 2fad719..a9efea1 100644 --- a/ui/lib/screens/mainCancer_screen.dart +++ b/ui/lib/screens/mainCancer_screen.dart @@ -6,8 +6,6 @@ import 'package:ui/screens/diagnosis/skinDiagnosis_screen.dart'; import 'package:ui/screens/prognosis/prognosis_screen.dart'; import 'package:ui/screens/selectService_screen.dart'; -//TODO - Add nav to bottom also add passing colors into card. Might need to adjust padding after(Appbar done only for nav) - /* This is the Cancer Page that displays an appbar with a gradient and a logo, three cards that allow the user to click on a certain cancer and be redirected to that page and the nav at the bottom. */ @@ -56,9 +54,10 @@ class _MainCancerTypesScreenState extends State { context, MaterialPageRoute( builder: (context) => SelectServiceScreen( - cancerType: 'Skin Cancer', - diagnosisRoute: SkinCancerDiagnosis(), - prognosisRoute: CancerPrognosis("Skin Cancer")), + cancerType: 'Skin Cancer', + diagnosisRoute: SkinCancerDiagnosis(), + prognosisRoute: CancerPrognosis("Skin Cancer"), + ), ), ); }, @@ -78,16 +77,17 @@ class _MainCancerTypesScreenState extends State { context, MaterialPageRoute( builder: (context) => SelectServiceScreen( - cancerType: 'Lung Cancer', - diagnosisRoute: LungCancerDiagnosis(), - prognosisRoute: CancerPrognosis("Lung Cancer")), + cancerType: 'Lung Cancer', + diagnosisRoute: LungCancerDiagnosis(), + prognosisRoute: CancerPrognosis("Lung Cancer"), + ), ), ); }, child: CancerCard( cardTitle: 'Lung Cancer', cardColor: '0xFF66b9ed', - cardColor2:'0xFF2d81b5', + cardColor2: '0xFF2d81b5', textColor: '0xFFFFFFFF', ), ), @@ -100,9 +100,10 @@ class _MainCancerTypesScreenState extends State { context, MaterialPageRoute( builder: (context) => SelectServiceScreen( - cancerType: 'Breast Cancer', - diagnosisRoute: BreastCancerDiagnosis(), - prognosisRoute: CancerPrognosis("Breast Cancer")), + cancerType: 'Breast Cancer', + diagnosisRoute: BreastCancerDiagnosis(), + prognosisRoute: CancerPrognosis("Breast Cancer"), + ), ), ); }, diff --git a/ui/lib/screens/prognosis/prognosis_screen.dart b/ui/lib/screens/prognosis/prognosis_screen.dart index f343c0b..9b97e1c 100644 --- a/ui/lib/screens/prognosis/prognosis_screen.dart +++ b/ui/lib/screens/prognosis/prognosis_screen.dart @@ -8,71 +8,70 @@ import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/constants.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:ui/services/UserDetails.dart'; +import 'package:ui/services/endPoints.dart'; import 'dart:convert'; import 'dart:io'; +// ignore: must_be_immutable class CancerPrognosis extends StatefulWidget { - var cancerType; - var url = "https://onco-prognosis-backend.herokuapp.com/"; - var cancerPrognosisAttributes; - var skinCancerAnswers; + var _cancerType; + var _url; + var _cancerPrognosisAttributes; + var _skinCancerAnswers; CancerPrognosis(String cancerType) { - this.cancerType = cancerType; + this._cancerType = cancerType; if (cancerType == "Breast Cancer") { - cancerPrognosisAttributes = BREAST_CANCER_PROGNOSIS_QUESTIONS; - url += "prognosis_breast"; + _cancerPrognosisAttributes = BREAST_CANCER_PROGNOSIS_QUESTIONS; + _url = postBreastCancerPrediction_API; } else if (cancerType == "Lung Cancer") { - cancerPrognosisAttributes = LUNG_CANCER_PROGNOSIS_QUESTIONS; - url += "prognosis_lung"; + _cancerPrognosisAttributes = LUNG_CANCER_PROGNOSIS_QUESTIONS; + _url = postLungCancerPrediction_API; } else if (cancerType == "Skin Cancer") { - url += "prognosis_skin"; + _url = postSkinCancerPrediction_API; if (UserDetails.getUserData()['gender'] == "male") { - cancerPrognosisAttributes = SKIN_CANCER_PROGNOSIS_QUESTIONS_MALE; - skinCancerAnswers = SKIN_CANCER_PROGNOSIS_ANSWER_OPTIONS_MALE; + _cancerPrognosisAttributes = SKIN_CANCER_PROGNOSIS_QUESTIONS_MALE; + _skinCancerAnswers = SKIN_CANCER_PROGNOSIS_ANSWER_OPTIONS_MALE; } else if (UserDetails.getUserData()['gender'] == "female") { - cancerPrognosisAttributes = SKIN_CANCER_PROGNOSIS_QUESTIONS_FEMALE; - skinCancerAnswers = SKIN_CANCER_PROGNOSIS_ANSWER_OPTIONS_FEMALE; + _cancerPrognosisAttributes = SKIN_CANCER_PROGNOSIS_QUESTIONS_FEMALE; + _skinCancerAnswers = SKIN_CANCER_PROGNOSIS_ANSWER_OPTIONS_FEMALE; } } } @override CancerPrognosisState createState() => CancerPrognosisState( - cancerType, cancerPrognosisAttributes, skinCancerAnswers, url); + _cancerType, _cancerPrognosisAttributes, _skinCancerAnswers, _url); } class CancerPrognosisState extends State { - ScrollController controller = ScrollController(); - bool closeTopContainer = false; - double topContainer = 0; - List itemsData = []; - List textFieldControllers = []; - List skinCancerUserAnswers = []; + ScrollController _controller = ScrollController(); + List _itemsData = []; + List _textFieldControllers = []; + List _skinCancerUserAnswers = []; Map prognosisBody; final _firestore = FirebaseFirestore.instance; final GlobalKey _formKey = GlobalKey(); - var cancerType; - var cancerPrognosisAttributes; - var skinCancerAnswers; - var url; - var count = 0; - var skinGroupValue = 0; + var _cancerType; + var _cancerPrognosisAttributes; + var _skinCancerAnswers; + var _url; + var _count = 0; CancerPrognosisState(var cancerType, var cancerPrognosisAttributes, var skinCancerAnswers, var url) { - this.cancerType = cancerType; - this.cancerPrognosisAttributes = cancerPrognosisAttributes; - this.skinCancerAnswers = skinCancerAnswers; - this.url = url; + this._cancerType = cancerType; + this._cancerPrognosisAttributes = cancerPrognosisAttributes; + this._skinCancerAnswers = skinCancerAnswers; + this._url = url; } // https://stackoverflow.com/questions/50278258/http-post-with-json-on-body-flutter-dart <- REFERENCE Future apiRequest() async { HttpClient httpClient = new HttpClient(); - HttpClientRequest request = await httpClient.postUrl(Uri.parse(url)); + HttpClientRequest request = await httpClient.postUrl(Uri.parse(_url)); request.headers.set('content-type', 'application/json'); request.add(utf8.encode(json.encode(prognosisBody))); HttpClientResponse response = await request.close(); @@ -81,149 +80,111 @@ class CancerPrognosisState extends State { return reply; } - void getPostsDataSkin() { - for (String question in cancerPrognosisAttributes) { - if (question != "Age") { - skinCancerUserAnswers.add(""); + void _getPostsDataSkin() { + // for (String question in cancerPrognosisAttributes) { + // if (question != "Age") { + // skinCancerUserAnswers.add(""); + // } + // } + + if (UserDetails.getUserData()['gender'] == "male") { + for (List answer in SKIN_CANCER_PROGNOSIS_ANSWER_OPTIONS_MALE) { + _skinCancerUserAnswers.add(answer[0]); + } + } else { + for (List answer in SKIN_CANCER_PROGNOSIS_ANSWER_OPTIONS_FEMALE) { + _skinCancerUserAnswers.add(answer[0]); } } - List responseList = cancerPrognosisAttributes; + List responseList = _cancerPrognosisAttributes; List listItems = []; responseList.forEach((post) { - if (count == 0) { - textFieldControllers.add(new TextEditingController()); - listItems.add(Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(18)), + if (_count == 0) { + _textFieldControllers.add( + new TextEditingController(), + ); + listItems.add( + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), + padding: + const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), + child: Container( child: Container( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 10, horizontal: 10), - margin: EdgeInsets.only(top: 0, bottom: 10), - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - color: Color(0xFFABD8E2), + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + margin: EdgeInsets.only(top: 0, bottom: 10), + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + color: Color(0xFFABD8E2), + ), + child: Column(children: [ + Container( + margin: EdgeInsets.only(bottom: 10), + child: Text( + post, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + color: Colors.blueGrey, + fontSize: 16, + ), + ), ), - child: Column(children: [ - Container( - margin: EdgeInsets.only(bottom: 10), - child: Text( - post, - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - color: Colors.blueGrey, - fontSize: 16, + Form( + key: _formKey, + child: TextFormField( + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter some Input'; + } else if (int.parse(value) < 26 || + int.parse(value) > 70) + return 'Please make sure User Input is between 25 and 70'; + + return null; + }, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly + ], + keyboardType: TextInputType.number, + controller: _textFieldControllers[_count], + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + focusedBorder: OutlineInputBorder( + borderSide: new BorderSide(color: Colors.white), + borderRadius: new BorderRadius.circular(16), ), - )), - Form( - key: _formKey, - child: TextFormField( - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter some Input'; - } else if (int.parse(value) < 26 || - int.parse(value) > 70) - return 'Please make sure User Input is between 25 and 70'; - - return null; - }, - inputFormatters: [ - WhitelistingTextInputFormatter.digitsOnly - ], - keyboardType: TextInputType.number, - controller: textFieldControllers[count], - decoration: InputDecoration( - filled: true, - fillColor: Colors.white, - focusedBorder: OutlineInputBorder( - borderSide: - new BorderSide(color: Colors.white), - borderRadius: new BorderRadius.circular(16), - ), - enabledBorder: UnderlineInputBorder( - borderSide: - new BorderSide(color: Colors.white), - borderRadius: new BorderRadius.circular(16), - ), - hintText: 'Enter the Value for the Input'), - ), + enabledBorder: UnderlineInputBorder( + borderSide: new BorderSide(color: Colors.white), + borderRadius: new BorderRadius.circular(16), + ), + hintText: 'Enter the Value for the Input'), ), - ])), - )))); + ), + ])), + ), + ), + ), + ); } else { List skinCancerOptions = []; - for (int i = 0; i < skinCancerAnswers[count - 1].length; i++) - skinCancerOptions.add(skinCancerAnswers[count - 1][i]); + for (int i = 0; i < _skinCancerAnswers[_count - 1].length; i++) + skinCancerOptions.add(_skinCancerAnswers[_count - 1][i]); int currentQuestion = 0; - currentQuestion = count - 1; + currentQuestion = _count - 1; - listItems.add(Container( + listItems.add( + Container( margin: EdgeInsets.only(bottom: 10), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(18)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), - child: Container( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 10, horizontal: 10), - margin: EdgeInsets.only(top: 0, bottom: 10), - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - color: Color(0xFFABD8E2), - ), - child: Column(children: [ - Container( - margin: EdgeInsets.only(bottom: 10), - child: Text( - post, - textAlign: TextAlign.center, - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - color: Colors.blueGrey, - fontSize: 16, - ), - )), - Column( - children: [ - GroupButton( - selectedTextStyle: TextStyle(color: Colors.white), - selectedColor: Colors.redAccent, - spacing: 20, - onSelected: (index, isSelected) => - skinCancerUserAnswers[currentQuestion] = - skinCancerAnswers[currentQuestion][index], - buttons: List.from(skinCancerOptions), - selectedButtons: [], - ) - ], - ) - ])), - )))); - } - if (count != 7) count++; - }); - setState(() { - itemsData = listItems; - }); - } - - void getPostsData() { - List responseList = cancerPrognosisAttributes; - List listItems = []; - responseList.forEach((post) { - textFieldControllers.add(new TextEditingController()); - listItems.add(Container( - // margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(18)), - child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), child: Container( @@ -237,48 +198,111 @@ class CancerPrognosisState extends State { ), child: Column(children: [ Container( - margin: EdgeInsets.only(bottom: 10), - child: Text( - post, - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - color: Colors.blueGrey, - fontSize: 20, - ), - )), - TextFormField( - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter some Input'; - } - - return null; - }, - inputFormatters: [ - WhitelistingTextInputFormatter.digitsOnly - ], - controller: textFieldControllers[count], - keyboardType: TextInputType.number, - decoration: InputDecoration( - filled: true, - fillColor: Colors.white, - focusedBorder: OutlineInputBorder( - borderSide: new BorderSide(color: Colors.white), - borderRadius: new BorderRadius.circular(16), - ), - enabledBorder: UnderlineInputBorder( - borderSide: new BorderSide(color: Colors.white), - borderRadius: new BorderRadius.circular(16), - ), - hintText: 'Enter the Value for the Input'), + margin: EdgeInsets.only(bottom: 10), + child: Text( + post, + textAlign: TextAlign.center, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + color: Colors.blueGrey, + fontSize: 16, + ), + ), ), + Column( + children: [ + GroupButton( + selectedTextStyle: TextStyle(color: Colors.white), + selectedColor: Colors.redAccent, + spacing: 20, + onSelected: (index, isSelected) => + _skinCancerUserAnswers[currentQuestion] = + _skinCancerAnswers[currentQuestion][index], + buttons: List.from(skinCancerOptions), + selectedButtons: [], + ) + ], + ) ])), - )))); + ), + ), + ), + ); + } + if (_count != 7) _count++; + }); + setState(() { + _itemsData = listItems; + }); + } + + void _getPostsData() { + List responseList = _cancerPrognosisAttributes; + List listItems = []; + responseList.forEach((post) { + _textFieldControllers.add(new TextEditingController()); + listItems.add( + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 10), + child: Container( + child: Container( + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + margin: EdgeInsets.only(top: 0, bottom: 10), + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + color: Color(0xFFABD8E2), + ), + child: Column(children: [ + Container( + margin: EdgeInsets.only(bottom: 10), + child: Text( + post, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + color: Colors.blueGrey, + fontSize: 20, + ), + ), + ), + TextFormField( + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter some Input'; + } + + return null; + }, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + controller: _textFieldControllers[_count], + keyboardType: TextInputType.number, + decoration: InputDecoration( + filled: true, + fillColor: Colors.white, + focusedBorder: OutlineInputBorder( + borderSide: new BorderSide(color: Colors.white), + borderRadius: new BorderRadius.circular(16), + ), + enabledBorder: UnderlineInputBorder( + borderSide: new BorderSide(color: Colors.white), + borderRadius: new BorderRadius.circular(16), + ), + hintText: 'Enter the Value for the Input'), + ), + ])), + ), + ), + ), + ); - count++; + _count++; }); setState(() { - itemsData = listItems; + _itemsData = listItems; }); } @@ -286,10 +310,13 @@ class CancerPrognosisState extends State { void initState() { super.initState(); - if (cancerType == "Skin Cancer") - getPostsDataSkin(); + /* If Cancer Type is Skin then a Separate Post Data Method for the Construction of the ListView + * due to the fact that Skin Cancer uses Grouped Buttons + */ + if (_cancerType == "Skin Cancer") + _getPostsDataSkin(); else - getPostsData(); + _getPostsData(); } @override @@ -303,17 +330,47 @@ class CancerPrognosisState extends State { height: size.height, child: Column( children: [ - Container( - alignment: Alignment.topLeft, - padding: EdgeInsets.only(left: 20), - child: Text( - cancerType, - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 27, - color: Color(0xFF93ACB1), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + alignment: Alignment.topLeft, + padding: EdgeInsets.only(left: 20), + child: Text( + _cancerType, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 27, + color: Color(0xFF93ACB1), + ), + ), ), - ), + IconButton( + icon: Icon(Icons.help), + onPressed: () { + // Setting the Help Message on the Alert Dialog based on the Cancer Type + String helpMessage; + + if (_cancerType == "Breast Cancer") + helpMessage = + "Fine needle aspiration is a type of biopsy " + "procedure. In fine needle aspiration, a thin needle " + "is inserted into an area of abnormal-appearing tissue or body fluid"; + else if (_cancerType == "Lung Cancer") + helpMessage = + "You need to enter values based on your own scale for all these inputs " + "based on how much you think this factor is involved in your life. i.e for Alcohol Use " + "you but a Higher number if you think you consume or are exposed to large amounts of alcohol"; + else if (_cancerType == "Skin Cancer") + helpMessage = + "Simply Toggle a Button for each Question based on your Answer to calculate" + " your Risk of Skin Cancer over the next 5 Years"; + + // Displaying the help alert dialog + createAlertDialog(context, "Help", helpMessage, 404); + }, + ) + ], ), Container( alignment: Alignment.topLeft, @@ -330,31 +387,34 @@ class CancerPrognosisState extends State { const SizedBox( height: 10, ), - if (cancerType != "Skin Cancer") + if (_cancerType != "Skin Cancer") + Expanded( + child: Form( + key: _formKey, + child: ListView.builder( + controller: _controller, + itemCount: _itemsData.length, + itemBuilder: (context, index) { + return _itemsData[index]; + }), + ), + ), + if (_cancerType == "Skin Cancer") Expanded( - child: Form( - key: _formKey, child: ListView.builder( - controller: controller, - itemCount: itemsData.length, + controller: _controller, + itemCount: _itemsData.length, itemBuilder: (context, index) { - return itemsData[index]; + return _itemsData[index]; }), - )), - if (cancerType == "Skin Cancer") - Expanded( - child: ListView.builder( - controller: controller, - itemCount: itemsData.length, - itemBuilder: (context, index) { - return itemsData[index]; - })), + ), Container( decoration: BoxDecoration( color: Colors.blueGrey, borderRadius: BorderRadius.only( - topRight: Radius.circular(20.0), - topLeft: Radius.circular(20.0)), + topRight: Radius.circular(20.0), + topLeft: Radius.circular(20.0), + ), ), width: double.infinity, padding: const EdgeInsets.only( @@ -398,159 +458,160 @@ class CancerPrognosisState extends State { print(genderIndex); - if (cancerType == "Lung Cancer") { + if (_cancerType == "Lung Cancer") { prognosisBody = { - "Age": textFieldControllers[0].text, + "Age": _textFieldControllers[0].text, "Gender": genderIndex, "AirPollution": - ((int.parse(textFieldControllers[1].text) / + ((int.parse(_textFieldControllers[1].text) / 10) * 8) .toString(), "Alcoholuse": - ((int.parse(textFieldControllers[2].text) / + ((int.parse(_textFieldControllers[2].text) / 10) * 8) .toString(), "DustAllergy": - ((int.parse(textFieldControllers[3].text) / + ((int.parse(_textFieldControllers[3].text) / 10) * 8) .toString(), "OccuPationalHazards": - ((int.parse(textFieldControllers[4].text) / + ((int.parse(_textFieldControllers[4].text) / 10) * 8) .toString(), "GeneticRisk": - ((int.parse(textFieldControllers[5].text) / + ((int.parse(_textFieldControllers[5].text) / 10) * 7) .toString(), "chronicLungDisease": - ((int.parse(textFieldControllers[6].text) / + ((int.parse(_textFieldControllers[6].text) / 10) * 7) .toString(), "BalancedDiet": - ((int.parse(textFieldControllers[7].text) / + ((int.parse(_textFieldControllers[7].text) / 10) * 7) .toString(), "Obesity": - ((int.parse(textFieldControllers[8].text) / + ((int.parse(_textFieldControllers[8].text) / 10) * 7) .toString(), "Smoking": - ((int.parse(textFieldControllers[9].text) / + ((int.parse(_textFieldControllers[9].text) / 10) * 8) .toString(), "PassiveSmoker": - ((int.parse(textFieldControllers[10].text) / + ((int.parse(_textFieldControllers[10].text) / 10) * 8) .toString(), "ChestPain": - ((int.parse(textFieldControllers[11].text) / + ((int.parse(_textFieldControllers[11].text) / 10) * 9) .toString(), "CoughingofBlood": - ((int.parse(textFieldControllers[12].text) / + ((int.parse(_textFieldControllers[12].text) / 10) * 9) .toString(), "Fatigue": - ((int.parse(textFieldControllers[13].text) / + ((int.parse(_textFieldControllers[13].text) / 10) * 9) .toString(), "WeightLoss": - ((int.parse(textFieldControllers[14].text) / + ((int.parse(_textFieldControllers[14].text) / 10) * 8) .toString(), "ShortnessofBreath": - ((int.parse(textFieldControllers[15].text) / + ((int.parse(_textFieldControllers[15].text) / 10) * 9) .toString(), "Wheezing": - ((int.parse(textFieldControllers[16].text) / + ((int.parse(_textFieldControllers[16].text) / 10) * 8) .toString(), "SwallowingDifficulty": - ((int.parse(textFieldControllers[17].text) / + ((int.parse(_textFieldControllers[17].text) / 10) * 8) .toString(), "ClubbingofFingerNails": - ((int.parse(textFieldControllers[18].text) / + ((int.parse(_textFieldControllers[18].text) / 10) * 9) .toString(), "FrequentCold": - ((int.parse(textFieldControllers[19].text) / + ((int.parse(_textFieldControllers[19].text) / 10) * 7) .toString(), "DryCough": - ((int.parse(textFieldControllers[20].text) / + ((int.parse(_textFieldControllers[20].text) / 10) * 7) .toString(), "Snoring": - ((int.parse(textFieldControllers[21].text) / + ((int.parse(_textFieldControllers[21].text) / 10) * 7) .toString(), }; - } else if (cancerType == "Breast Cancer") { + } else if (_cancerType == "Breast Cancer") { prognosisBody = { - "radius_mean": textFieldControllers[0].text, - "texture_mean": textFieldControllers[1].text, - "perimeter_mean": textFieldControllers[2].text, - "compactness_mean": textFieldControllers[3].text, - "concavity_mean": textFieldControllers[4].text, - "concave points_mean": textFieldControllers[5].text, + "radius_mean": _textFieldControllers[0].text, + "texture_mean": _textFieldControllers[1].text, + "perimeter_mean": _textFieldControllers[2].text, + "compactness_mean": _textFieldControllers[3].text, + "concavity_mean": _textFieldControllers[4].text, + "concave points_mean": + _textFieldControllers[5].text, "fractal_dimension_mean": - textFieldControllers[6].text, - "radius_se": textFieldControllers[7].text, - "texture_se": textFieldControllers[8].text, - "perimeter_se": textFieldControllers[9].text, - "compactness_se": textFieldControllers[10].text, - "concavity_se": textFieldControllers[11].text, - "concave points_se": textFieldControllers[12].text, - "symmetry_se": textFieldControllers[13].text, + _textFieldControllers[6].text, + "radius_se": _textFieldControllers[7].text, + "texture_se": _textFieldControllers[8].text, + "perimeter_se": _textFieldControllers[9].text, + "compactness_se": _textFieldControllers[10].text, + "concavity_se": _textFieldControllers[11].text, + "concave points_se": _textFieldControllers[12].text, + "symmetry_se": _textFieldControllers[13].text, "fractal_dimension_se": - textFieldControllers[14].text, - "compactness_worst": textFieldControllers[15].text, - "concavity_worst": textFieldControllers[16].text, + _textFieldControllers[14].text, + "compactness_worst": _textFieldControllers[15].text, + "concavity_worst": _textFieldControllers[16].text, "concave points_worst": - textFieldControllers[17].text, - "symmetry_worst": textFieldControllers[18].text, + _textFieldControllers[17].text, + "symmetry_worst": _textFieldControllers[18].text, "fractal_dimension_worst": - textFieldControllers[19].text, - "tumor_size": textFieldControllers[20].text, + _textFieldControllers[19].text, + "tumor_size": _textFieldControllers[20].text, "positive_axillary_lymph_node": - textFieldControllers[21].text + _textFieldControllers[21].text }; - } else if (cancerType == "Skin Cancer") { + } else if (_cancerType == "Skin Cancer") { List skinCancerUserAnswersIndices = []; int questionCount = 0; int answerInQuestionCount; - for (String userAnswer in skinCancerUserAnswers) { + for (String userAnswer in _skinCancerUserAnswers) { answerInQuestionCount = 0; if (userAnswer == "") { skinCancerUserAnswersIndices.add(0); continue; } for (String answer - in skinCancerAnswers[questionCount]) { + in _skinCancerAnswers[questionCount]) { if (userAnswer == answer) { skinCancerUserAnswersIndices .add(answerInQuestionCount); @@ -565,7 +626,7 @@ class CancerPrognosisState extends State { if (UserDetails.getUserData()['gender'] == "male") prognosisBody = { - "age": textFieldControllers[0].text, + "age": _textFieldControllers[0].text, "gender": "male", "sunburn": skinCancerUserAnswersIndices[1], "complexion": skinCancerUserAnswersIndices[0], @@ -578,7 +639,7 @@ class CancerPrognosisState extends State { else if (UserDetails.getUserData()['gender'] == "female") prognosisBody = { - "age": textFieldControllers[0].text, + "age": _textFieldControllers[0].text, "gender": "female", "sunburn": 0, "complexion": skinCancerUserAnswersIndices[0], @@ -601,29 +662,30 @@ class CancerPrognosisState extends State { // Styling Progress Dialog progressDialog.style( - message: ' Analyzing\n Input', - padding: EdgeInsets.all(20), - borderRadius: 10.0, - backgroundColor: Colors.white, - progressWidget: LinearProgressIndicator( - backgroundColor: Colors.lightBlueAccent, - ), - elevation: 10.0, - insetAnimCurve: Curves.easeInCubic, - progress: 0.0, - maxProgress: 100.0, - progressTextStyle: TextStyle( - color: Color(0xFF565D5E), - fontSize: 13.0, - fontWeight: FontWeight.w400, - fontFamily: 'Poppins-SemiBold', - ), - messageTextStyle: TextStyle( - color: Color(0xFF565D5E), - fontSize: 19.0, - fontWeight: FontWeight.w600, - fontFamily: 'Poppins-SemiBold', - )); + message: ' Analyzing\n Input', + padding: EdgeInsets.all(20), + borderRadius: 10.0, + backgroundColor: Colors.white, + progressWidget: LinearProgressIndicator( + backgroundColor: Colors.lightBlueAccent, + ), + elevation: 10.0, + insetAnimCurve: Curves.easeInCubic, + progress: 0.0, + maxProgress: 100.0, + progressTextStyle: TextStyle( + color: Color(0xFF565D5E), + fontSize: 13.0, + fontWeight: FontWeight.w400, + fontFamily: 'Poppins-SemiBold', + ), + messageTextStyle: TextStyle( + color: Color(0xFF565D5E), + fontSize: 19.0, + fontWeight: FontWeight.w600, + fontFamily: 'Poppins-SemiBold', + ), + ); // Showing the Progress Dialog and Dismissing it After the API Request is Received progressDialog.show(); @@ -649,7 +711,7 @@ class CancerPrognosisState extends State { "Something's wrong on our end :( please try again !", 404); else { - if (cancerType != "Skin Cancer") + if (_cancerType != "Skin Cancer") prognosisResult = body["Prediction"]; else { prognosisResult = body['result_string']; @@ -661,15 +723,15 @@ class CancerPrognosisState extends State { * message */ if (prognosisResult == "N" && - cancerType == "Breast Cancer") + _cancerType == "Breast Cancer") prognosisResult = "Non-Recurring"; else if (prognosisResult == "R" && - cancerType == "Breast Cancer") + _cancerType == "Breast Cancer") prognosisResult = "Recurring"; // Displaying the alert dialog createAlertDialog( - context, "Prognosis", prognosisResult, 202); + context, "Prognosis", prognosisResult, 203); // Adding the response data into the database for report creation purpose // initially, convert all inputs into strings for the report @@ -689,7 +751,7 @@ class CancerPrognosisState extends State { .collection("InputPrognosis") .add({ "prognosisInputs": firebasePrognosisBody, - "cancerType": cancerType, + "cancerType": _cancerType, "reportType": "prognosis", "result": prognosisResult, 'timestamp': Timestamp.now(), diff --git a/ui/lib/screens/registration_screen.dart b/ui/lib/screens/registration_screen.dart index 961d37e..daae3c1 100644 --- a/ui/lib/screens/registration_screen.dart +++ b/ui/lib/screens/registration_screen.dart @@ -78,16 +78,15 @@ class _RegistrationScreenState extends State { horizontal: 20.0, ), child: ListView( - children: [ SizedBox( - height: 8.0, + height: 100.0, ), Flexible( child: Hero( tag: "logo", child: Container( - height: 20, + height: 25, child: Image.asset('images/officialLogo.png'), ), ), @@ -123,6 +122,9 @@ class _RegistrationScreenState extends State { fontSize: 15, ), ), + SizedBox( + height: 20, + ), TextField( cursorColor: Colors.lightBlueAccent, onEditingComplete: () => { @@ -143,6 +145,9 @@ class _RegistrationScreenState extends State { ), ), ), + SizedBox( + height: 10, + ), TextField( autofillHints: [AutofillHints.email], cursorColor: Colors.lightBlueAccent, @@ -164,6 +169,9 @@ class _RegistrationScreenState extends State { ), ), ), + SizedBox( + height: 10, + ), TextField( cursorColor: Colors.lightBlueAccent, maxLength: 20, @@ -237,96 +245,104 @@ class _RegistrationScreenState extends State { ), ), ), - RoundedButton( - onPressed: () async { - if (username == null || - email == null || - password == null || - username == "" || - email == "" || - password == "") { - createAlertDialog(context, "Error", - "Please fill all the given fields to proceed", 404); - } else { - bool emailValid = RegExp( - r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") - .hasMatch(email); - - if (!emailValid) { - // Alerts invalid email + Padding( + padding: EdgeInsets.only(top: 20), + child: RoundedButton( + onPressed: () async { + if (username == null || + email == null || + password == null || + username == "" || + email == "" || + password == "") { createAlertDialog( - context, "Error", "Invalid email format", 404); + context, + "Error", + "Please fill all the given fields to proceed", + 404); } else { - // If details for all the fields are filled then proceed - // Display the spinner - setState(() { - showSpinner = true; - }); - - // register the user in firebase - try { - // created the user and returns a user once created - final newUser = - await _auth.createUserWithEmailAndPassword( - email: email, password: password); + bool emailValid = RegExp( + r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") + .hasMatch(email); - // Adding the user details to the cloud fire store - _firestore.collection("users").doc(email).set({ - "userEmail": email, - "username": username, - "gender": gender, - 'timestamp': Timestamp.now(), + if (!emailValid) { + // Alerts invalid email + createAlertDialog( + context, "Error", "Invalid email format", 404); + } else { + // If details for all the fields are filled then proceed + // Display the spinner + setState(() { + showSpinner = true; }); - //clear chat bot messages on login/register - _firestore - .collection("chatbot-messages") - .doc(email) - .collection("chatbot-messages") - .get() - .then((value) => { - for (var msg in value.docs) - {msg.reference.delete()} - }); + // register the user in firebase + try { + // created the user and returns a user once created + final newUser = + await _auth.createUserWithEmailAndPassword( + email: email, password: password); - // displaying alerts according to the progress - if (newUser != null) { - // Adding the new registered user details to the global variable - UserDetails.setUserData(email, username, gender); + // Adding the user details to the cloud fire store + _firestore.collection("users").doc(email).set({ + "userEmail": email, + "username": username, + "gender": gender, + 'timestamp': Timestamp.now(), + }); - // Displaying the alert dialog - createAlertDialog(context, "Success", - "Account Registered Successfully!", 200); - } else { - // Displaying the alert dialog - createAlertDialog( - context, - "Error", - "Something went wrong, try again later!", - 404); - } + //clear chat bot messages on login/register + _firestore + .collection("chatbot-messages") + .doc(email) + .collection("chatbot-messages") + .get() + .then((value) => { + for (var msg in value.docs) + {msg.reference.delete()} + }); - // stops displaying the spinner once the result comes back - setState(() { - showSpinner = false; - }); + // displaying alerts according to the progress + if (newUser != null) { + // Adding the new registered user details to the global variable + UserDetails.setUserData( + email, username, gender); - // clearing the content of the field once submitted - _emailAddressController.clear(); - _usernameController.clear(); - _passwordTextFieldController.clear(); - } catch (e) { - createAlertDialog(context, "Error", e.message, 404); - // stops displaying the spinner once the result comes back - setState(() { - showSpinner = false; - }); + // Displaying the alert dialog + createAlertDialog(context, "Success", + "Account Registered Successfully!", 200); + } else { + // Displaying the alert dialog + createAlertDialog( + context, + "Error", + "Something went wrong, try again later!", + 404); + } + + // stops displaying the spinner once the result comes back + setState(() { + showSpinner = false; + }); + + // clearing the content of the field once submitted + _emailAddressController.clear(); + _usernameController.clear(); + _passwordTextFieldController.clear(); + } catch (e) { + createAlertDialog( + context, "Error", e.message, 404); + // stops displaying the spinner once the result comes back + setState(() { + showSpinner = false; + }); + } } } - } - }, - colour: Colors.lightBlueAccent, - title: 'REGISTER ACCOUNT', + }, + colour: Colors.lightBlueAccent, + title: 'REGISTER ACCOUNT', + ), ), SizedBox( height: 8.0, diff --git a/ui/lib/screens/selectService_screen.dart b/ui/lib/screens/selectService_screen.dart index 7182ae4..75cdfa4 100644 --- a/ui/lib/screens/selectService_screen.dart +++ b/ui/lib/screens/selectService_screen.dart @@ -1,31 +1,23 @@ import 'dart:ui'; - import 'package:flutter/material.dart'; import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/components/treatment_card.dart'; -import 'package:ui/screens/diagnosis/breastDiagnosis_screen.dart'; -import 'package:ui/screens/diagnosis/lungDiagnosis_screen.dart'; -import 'package:ui/screens/diagnosis/skinDiagnosis_screen.dart'; -import 'package:ui/screens/home_screen.dart'; -import 'package:ui/screens/mainCancer_screen.dart'; -import 'diagnosis/skinDiagnosis_screen.dart'; class SelectServiceScreen extends StatefulWidget { final diagnosisRoute; final prognosisRoute; final String cancerType; - const SelectServiceScreen({@required this.diagnosisRoute, @required this.prognosisRoute, @required this.cancerType}); - + const SelectServiceScreen( + {@required this.diagnosisRoute, + @required this.prognosisRoute, + @required this.cancerType}); @override _SelectServiceScreenState createState() => _SelectServiceScreenState(); - - } class _SelectServiceScreenState extends State { - @override Widget build(BuildContext context) { return SafeArea( @@ -100,14 +92,10 @@ class _SelectServiceScreenState extends State { ), GestureDetector( onTap: () { - Navigator.pop( - context - ); + Navigator.pop(context); }, child: Padding( - padding: const EdgeInsets.only( - bottom: 20 - ), + padding: const EdgeInsets.only(bottom: 20), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.0), @@ -119,7 +107,8 @@ class _SelectServiceScreenState extends State { color: Colors.grey.withOpacity(0.5), spreadRadius: 1, blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow + offset: + Offset(0, 3), // changes position of shadow ), ], borderRadius: BorderRadius.circular(18), @@ -132,7 +121,10 @@ class _SelectServiceScreenState extends State { children: [ Padding( padding: const EdgeInsets.all(8.0), - child: new Icon(Icons.arrow_back, color: Colors.white,), + child: new Icon( + Icons.arrow_back, + color: Colors.white, + ), ), SizedBox( width: 10, @@ -158,4 +150,4 @@ class _SelectServiceScreenState extends State { ), ); } -} \ No newline at end of file +} diff --git a/ui/lib/screens/settings_screen.dart b/ui/lib/screens/settings_screen.dart index 56f2904..67a98d6 100644 --- a/ui/lib/screens/settings_screen.dart +++ b/ui/lib/screens/settings_screen.dart @@ -6,8 +6,6 @@ import 'package:ui/components/custom_app_bar.dart'; import 'package:ui/components/rounded_button.dart'; import 'package:ui/constants.dart'; import 'package:ui/screens/current_screen.dart'; -import 'package:group_button/group_button.dart'; -import 'package:ui/screens/forgetPassword_screen.dart'; import 'package:ui/screens/login_screen.dart'; import 'package:ui/services/GoogleUserSignInDetails.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; @@ -15,16 +13,16 @@ import 'package:ui/services/UserDetails.dart'; void main() => runApp(MyApp()); - class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - // home: SettingsScreen("abc", "abc@gmail.com"), - ); + // home: SettingsScreen("abc", "abc@gmail.com"), + ); } } +// ignore: must_be_immutable class SettingsScreen extends StatefulWidget { // static 'id' variable for the naming convention for the routes static String id = "settingsScreen"; @@ -35,49 +33,42 @@ class SettingsScreen extends StatefulWidget { SettingsScreen(this.userName, this.email, this.gender); @override - _SettingsScreenState createState() => _SettingsScreenState(userName, email, gender); - + _SettingsScreenState createState() => + _SettingsScreenState(userName, email, gender); } class _SettingsScreenState extends State { - String _userName; String _email; String _gender; String newGender; final _userNameController = TextEditingController(); final _emailController = new TextEditingController(); - final _passwordController = new TextEditingController(); final user = FirebaseAuth.instance.currentUser; final GlobalKey _scaffoldKey = new GlobalKey(); final GlobalKey _formKey = GlobalKey(); - _SettingsScreenState(this._userName, this._email, this._gender) - { - print(_email + " EMAIL"); + _SettingsScreenState(this._userName, this._email, this._gender) { _userNameController.text = _userName; _emailController.text = _email; - print(_gender + " GENDER"); } void _changeUserName(String newDisplayName) async { - var user = FirebaseAuth.instance.currentUser; var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; var error = false; // Updating the Username in Firebase Authentication - user.updateProfile(displayName: newDisplayName).then((value){ - - }).catchError((e){ - - createAlertDialog(context, "Error", "There was an error updating profile", 404); + user + .updateProfile(displayName: newDisplayName) + .then((value) {}) + .catchError((e) { + createAlertDialog( + context, "Error", "There was an error updating profile", 404); error = true; }); if (error != true) { - - print("im here"); var userDocument = await FirebaseFirestore.instance .collection("users") .doc(user.email != null ? user.email : loggedInUserGoogle) @@ -90,7 +81,6 @@ class _SettingsScreenState extends State { "username": newDisplayName }; - // Updating the username Field of the Document of a Specific User in Collections user FirebaseFirestore.instance .collection("users") @@ -100,7 +90,6 @@ class _SettingsScreenState extends State { } void _changeEmail(String newEmail, String password) async { - var user = FirebaseAuth.instance.currentUser; var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; var error = false; @@ -109,16 +98,14 @@ class _SettingsScreenState extends State { FirebaseAuth.instance .signInWithEmailAndPassword(email: _email, password: password) .then((userCredential) { + userCredential.user.updateEmail(newEmail); + }).catchError((e) { + createAlertDialog( + context, "Error", "There Password that you've Entered is Wrong", 404); + error = true; + }); - userCredential.user.updateEmail(newEmail); - }).catchError((e) { - - createAlertDialog(context, "Error", "There Password that you've Entered is Wrong", 404); - error = true; - }); - - if (! error) { - + if (!error) { var userDocument = await FirebaseFirestore.instance .collection("users") .doc(user.email != null ? user.email : loggedInUserGoogle) @@ -139,22 +126,23 @@ class _SettingsScreenState extends State { .doc(user.email != null ? user.email : loggedInUserGoogle) .get() .then((doc) { - - if (doc.exists) { - - // saves the data to 'name' - firestore.collection("users").doc(newEmail).set(updatedUser).then((value){ - // deletes the old document - firestore.collection("users").doc(_email).delete(); - UserDetails.setUserData(newEmail, _userName, _gender); - }); - } + if (doc.exists) { + // saves the data to 'name' + firestore + .collection("users") + .doc(newEmail) + .set(updatedUser) + .then((value) { + // deletes the old document + firestore.collection("users").doc(_email).delete(); + UserDetails.setUserData(newEmail, _userName, _gender); }); + } + }); } } void _changeGender(String newGender) async { - var user = FirebaseAuth.instance.currentUser; var loggedInUserGoogle = GoogleUserSignInDetails.googleSignInUserEmail; @@ -180,338 +168,366 @@ class _SettingsScreenState extends State { @override Widget build(BuildContext context) { return SafeArea( - child: Scaffold( - key: _scaffoldKey, - resizeToAvoidBottomInset: true, - appBar: CustomAppBar.arrow(context), - body: ListView( - children: [ - Center( - child: Column( - children: [ - Container( - alignment: Alignment.topLeft, - padding: EdgeInsets.only(left: 20, bottom: 20), - child: Text( - "Settings", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 27, - color: Color(0xFF637477), - ), + child: Scaffold( + key: _scaffoldKey, + resizeToAvoidBottomInset: true, + appBar: CustomAppBar.arrow(context), + body: ListView(children: [ + Center( + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + padding: EdgeInsets.only(left: 20, bottom: 20), + child: Text( + "Settings", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 27, + color: Color(0xFF637477), ), ), - Card( - margin: EdgeInsets.symmetric(horizontal: 20), + ), + Card( + margin: EdgeInsets.symmetric(horizontal: 20), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30.0), + ), + child: Container( + decoration: ShapeDecoration( + color: Color(0xFFABD8E2), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30.0), + borderRadius: BorderRadius.circular(18), ), - child: - Container( - decoration: ShapeDecoration( - color: Color(0xFFABD8E2), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18),), + ), + width: double.infinity, + height: 100, + child: Row( + children: [ + Expanded( + child: Icon( + Icons.account_box, + color: Colors.white, + size: 64, + ), + flex: 1, ), - width: double.infinity, - height: 100, - child: Row( - children: [ - Expanded( - - child: Icon( - Icons.account_box, - color: Colors.white, - size: 64, + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + _userName, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 16.0, + color: Color(0xFF008B99), + ), ), - flex: 1, - ), - Expanded( - - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Text( - _userName, - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 16.0, - color: Color(0xFF008B99), - ), - ), - Text( - _email, - style:TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 14.0, - color: Color(0xFF565D5E), - ), - ), - GestureDetector( - onTap: () { - - FirebaseAuth.instance.sendPasswordResetEmail(email: _email); - _scaffoldKey.currentState.showSnackBar( - SnackBar( - content: Text( - 'Reset Password Email has been Sent !', - style: TextStyle( - color: Colors.black54, - fontFamily: "Poppins-SemiBold" - ), - ), - backgroundColor: Color(0xFFABD8E2), - duration: Duration(seconds: 2), - )); - - }, - child: Text( - "Reset Password?", - style: kTextStyle.copyWith( - fontSize: 12, + Text( + _email, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 14.0, + color: Color(0xFF565D5E), + ), + ), + GestureDetector( + onTap: () { + FirebaseAuth.instance + .sendPasswordResetEmail(email: _email); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + 'Reset Password Email has been Sent !', + style: TextStyle( + color: Colors.black54, + fontFamily: "Poppins-SemiBold"), ), + backgroundColor: Color(0xFFABD8E2), + duration: Duration(seconds: 2), ), + ); + }, + child: Text( + "Reset Password?", + style: kTextStyle.copyWith( + fontSize: 12, ), - ], + ), ), - flex: 2, - ), - ], + ], + ), + flex: 2, ), - ) + ], + ), ), - Container( - margin: EdgeInsets.all(20), - child: Form( - key: _formKey, - child: Column( - children: [ - TextFormField( - maxLength: 30, - controller: _userNameController, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter some text'; - } - return null; - }, - style:TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 16.0, - color: Color(0xFF565D5E), - ), - cursorColor: Theme.of(context).cursorColor, - decoration: InputDecoration( - labelText: 'Username', - labelStyle: TextStyle( - color: Color(0xff00b3d9), - fontSize: 15, - fontFamily: 'Poppins-SemiBold' - ), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xff00b3d9),), + ), + Container( + margin: EdgeInsets.all(20), + child: Form( + key: _formKey, + child: Column( + children: [ + TextFormField( + maxLength: 30, + controller: _userNameController, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter some text'; + } + return null; + }, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 16.0, + color: Color(0xFF565D5E), + ), + cursorColor: TextSelectionThemeData().cursorColor, + decoration: InputDecoration( + labelText: 'Username', + labelStyle: TextStyle( + color: Color(0xff00b3d9), + fontSize: 15, + fontFamily: 'Poppins-SemiBold'), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: Color(0xff00b3d9), ), - suffixIcon: IconButton( - onPressed: () async { - - if (_formKey.currentState.validate()) { - ConfirmChangePrimitiveWrapper confirmChangePrimitiveWrapper = new ConfirmChangePrimitiveWrapper( - confirmChange: false); - - await createConfirmDialog(context, - "Confirmation", - "Are you Sure you want to Change your Username ?\n\n(Click outside the Alert Box to Cancel)", - confirmChangePrimitiveWrapper); - - if (confirmChangePrimitiveWrapper - .getConfirmChange()) { - _changeUserName(_userNameController.text); - - Navigator.push( - context, MaterialPageRoute(builder: - (_) => - CurrentScreen.settingsNavigatorPush( - _userNameController.text, _email, - _gender))); - } + ), + suffixIcon: IconButton( + onPressed: () async { + if (_formKey.currentState.validate()) { + ConfirmChangePrimitiveWrapper + confirmChangePrimitiveWrapper = + new ConfirmChangePrimitiveWrapper( + confirmChange: false); + + await createConfirmDialog( + context, + "Confirmation", + "Are you Sure you want to Change your Username ?\n\n(Click outside the Alert Box to Cancel)", + confirmChangePrimitiveWrapper); + + if (confirmChangePrimitiveWrapper + .getConfirmChange()) { + _changeUserName(_userNameController.text); + + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => + CurrentScreen.settingsNavigatorPush( + _userNameController.text, + _email, + _gender), + ), + ); } - }, - icon: Icon(Icons.edit, color: Color(0xff00b3d9),), + } + }, + icon: Icon( + Icons.edit, + color: Color(0xff00b3d9), ), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xFF637477)), + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: Color(0xFF637477), ), ), ), - TextFormField( - maxLength: 30, - controller: _emailController, - validator: (value) { - - if (value == null || value.isEmpty) { - - return 'Please enter some text'; - } - else if (RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$" - r"%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(_emailController.text) == false) { - - return 'Please enter a Valid Email'; - } - return null; - }, - style:TextStyle( - fontFamily: 'Poppins-SemiBold', - fontSize: 16.0, - color: Color(0xFF565D5E), + ), + TextFormField( + maxLength: 30, + controller: _emailController, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter some text'; + } else if (RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$" + r"%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") + .hasMatch(_emailController.text) == + false) { + return 'Please enter a Valid Email'; + } + return null; + }, + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + fontSize: 16.0, + color: Color(0xFF565D5E), + ), + cursorColor: TextSelectionThemeData().cursorColor, + decoration: InputDecoration( + labelText: 'Email', + labelStyle: TextStyle( + color: Color(0xff00b3d9), + fontSize: 15, + fontFamily: 'Poppins-SemiBold'), + focusedBorder: UnderlineInputBorder( + borderSide: BorderSide(color: Color(0xff00b3d9)), ), - cursorColor: Theme.of(context).cursorColor, - decoration: InputDecoration( - labelText: 'Email', - labelStyle: TextStyle( - color: Color(0xff00b3d9), - fontSize: 15, - fontFamily: 'Poppins-SemiBold' - ), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xff00b3d9)), - ), - suffixIcon: IconButton( - onPressed: () async { - - if (_formKey.currentState.validate()) { - TextPrimitiveWrapper textPrimitiveWrapper = new TextPrimitiveWrapper(""); - await createTextFieldDialog(context, - "Confirmation", - "Are you Sure you want to Change your Email ?\n\n(Click outside the Alert Box to Cancel)", - textPrimitiveWrapper); - - // ignore: unrelated_type_equality_checks - if (textPrimitiveWrapper != "") { - _changeEmail(_emailController.text, textPrimitiveWrapper.text); - - print(_emailController.text + " ASIOdjasiodasiodasioda"); - - Navigator.push(context, MaterialPageRoute(builder: - (_) => - CurrentScreen.settingsNavigatorPush( - _userName, _emailController.text, _gender))); - } + suffixIcon: IconButton( + onPressed: () async { + if (_formKey.currentState.validate()) { + TextPrimitiveWrapper textPrimitiveWrapper = + new TextPrimitiveWrapper(""); + await createTextFieldDialog( + context, + "Confirmation", + "Are you Sure you want to Change your Email ?\n\n(Click outside the Alert Box to Cancel)", + textPrimitiveWrapper); + + // ignore: unrelated_type_equality_checks + if (textPrimitiveWrapper != "") { + _changeEmail(_emailController.text, + textPrimitiveWrapper.text); + + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => + CurrentScreen.settingsNavigatorPush( + _userName, + _emailController.text, + _gender), + ), + ); } - }, - icon: Icon(Icons.edit, color: Color(0xff00b3d9),), + } + }, + icon: Icon( + Icons.edit, + color: Color(0xff00b3d9), ), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xFF637477)), + ), + enabledBorder: UnderlineInputBorder( + borderSide: BorderSide( + color: Color(0xFF637477), ), ), ), - - Container( - margin: EdgeInsets.only(top: 20), - // margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(18)), - child: Padding( - padding: - const EdgeInsets.symmetric(vertical: 10), - child: Container( - child: Container( - padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), - margin: EdgeInsets.only(top: 0, bottom: 10), - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(18), - color: Color(0xFFABD8E2), - ), - child: Column( - children: [ - Container( - margin: EdgeInsets.only(bottom: 12), - child:GroupButton( - - unselectedTextStyle: TextStyle(color: Colors.blueGrey, fontFamily: "Poppins-SemiBold"), - selectedTextStyle: TextStyle(color: Colors.white, fontFamily: "Poppins-SemiBold"), - selectedColor: Color(0xff00b3d9), - spacing: 20, - onSelected: (index, isSelected) async { - - if (index == 0) - - newGender = "male"; - - else newGender = "female"; - }, - buttons: ["Male", "Female"], - selectedButtons: ["${_gender[0].toUpperCase()}${_gender.substring(1)}"], - ) - ), - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: RawMaterialButton( - onPressed: () async { - - ConfirmChangePrimitiveWrapper confirmChangePrimitiveWrapper = new ConfirmChangePrimitiveWrapper(confirmChange: false); - - await createConfirmDialog(context, - "Confirmation", "Are you Sure you want to Change your Gender ?\n\n(Click outside the Alert Box to Cancel)", - confirmChangePrimitiveWrapper); - - if (confirmChangePrimitiveWrapper.getConfirmChange()) - { - _changeGender(newGender); - - Navigator.push(context, MaterialPageRoute(builder: - (_) => CurrentScreen.settingsNavigatorPush(_userName, _email, newGender))); - } - }, - fillColor: Colors.white, - child: Padding( - padding: EdgeInsets.all(10.0), - child: Row( - mainAxisSize: MainAxisSize.min, - children: const [ - Text( - "Update Gender ", - style: TextStyle( - fontFamily: 'Poppins-SemiBold', - color: Colors.blueGrey, - fontSize: 16, - ), - ), - Icon( - Icons.update, - color: Colors.blueGrey, - ), - ], - ), - ), - shape: const StadiumBorder(), - ), + ), + Container( + margin: EdgeInsets.only(top: 20), + // margin: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: Container( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 10, horizontal: 10), + margin: EdgeInsets.only(top: 0, bottom: 10), + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + color: Color(0xFFABD8E2), + ), + child: Column(children: [ + Container( + margin: EdgeInsets.only(bottom: 12), + child: GroupButton( + unselectedTextStyle: TextStyle( + color: Colors.blueGrey, + fontFamily: "Poppins-SemiBold"), + selectedTextStyle: TextStyle( + color: Colors.white, + fontFamily: "Poppins-SemiBold"), + selectedColor: Color(0xff00b3d9), + spacing: 20, + onSelected: (index, isSelected) async { + if (index == 0) + newGender = "male"; + else + newGender = "female"; + }, + buttons: ["Male", "Female"], + selectedButtons: [ + "${_gender[0].toUpperCase()}${_gender.substring(1)}" + ], + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: RawMaterialButton( + onPressed: () async { + ConfirmChangePrimitiveWrapper + confirmChangePrimitiveWrapper = + new ConfirmChangePrimitiveWrapper( + confirmChange: false); + + await createConfirmDialog( + context, + "Confirmation", + "Are you Sure you want to Change your Gender ?\n\n(Click outside the Alert Box to Cancel)", + confirmChangePrimitiveWrapper); + + if (confirmChangePrimitiveWrapper + .getConfirmChange()) { + _changeGender(newGender); + + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => CurrentScreen + .settingsNavigatorPush( + _userName, + _email, + newGender), + ), + ); + } + }, + fillColor: Colors.white, + child: Padding( + padding: EdgeInsets.all(10.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: const [ + Text( + "Update Gender ", + style: TextStyle( + fontFamily: 'Poppins-SemiBold', + color: Colors.blueGrey, + fontSize: 16, ), - ] - ) + ), + Icon( + Icons.update, + color: Colors.blueGrey, + ), + ], + ), + ), + shape: const StadiumBorder(), ), - ) - ) - ), - RoundedButton( - - onPressed: () { - - Navigator.pushNamed(context, LoginScreen.id); - }, - colour: Colors.redAccent, - title: 'Log Out', + ), + ]), + ), + ), ), - ], - ), + ), + RoundedButton( + onPressed: () { + Navigator.pushNamed(context, LoginScreen.id); + }, + colour: Colors.redAccent, + title: 'Log Out', + ), + ], ), - ) - ], - ), + ), + ) + ], ), - ] ), - ) + ]), + ), ); } } diff --git a/ui/lib/screens/welcome_screen.dart b/ui/lib/screens/welcome_screen.dart index 31ca1f6..1039bfd 100644 --- a/ui/lib/screens/welcome_screen.dart +++ b/ui/lib/screens/welcome_screen.dart @@ -13,7 +13,6 @@ class WelcomeScreen extends StatefulWidget { class _WelcomeScreenState extends State with SingleTickerProviderStateMixin { - // We are creating Animation Controller in order to create our own custom Animations AnimationController controller; Animation animation; @@ -47,17 +46,16 @@ class _WelcomeScreenState extends State goToLoginScreen(); } - void goToLoginScreen(){ - + void goToLoginScreen() { // Go to Login Screen after a given time duration Future.delayed(const Duration(milliseconds: 3500), () { - Navigator.push( - context, - PageRouteBuilder( - transitionDuration: Duration(seconds: 5), - pageBuilder: (_, __, ___) => LoginScreen(), - )); + context, + PageRouteBuilder( + transitionDuration: Duration(seconds: 5), + pageBuilder: (_, __, ___) => LoginScreen(), + ), + ); }); } diff --git a/ui/lib/services/GoogleUserSignInDetails.dart b/ui/lib/services/GoogleUserSignInDetails.dart index f7b3c2f..3377d27 100644 --- a/ui/lib/services/GoogleUserSignInDetails.dart +++ b/ui/lib/services/GoogleUserSignInDetails.dart @@ -1,17 +1,15 @@ // import 'package:google_sign_in/google_sign_in.dart'; -class GoogleUserSignInDetails{ - +class GoogleUserSignInDetails { static String googleSignInUserEmail; // setter - static void setGoogleSignInUser(String email){ + static void setGoogleSignInUser(String email) { googleSignInUserEmail = email; } // getter - static String getGoogleSignInUser(){ - return googleSignInUserEmail; + static String getGoogleSignInUser() { + return googleSignInUserEmail; } - -} \ No newline at end of file +} diff --git a/ui/lib/services/UserDetails.dart b/ui/lib/services/UserDetails.dart index d4e0f85..74df2eb 100644 --- a/ui/lib/services/UserDetails.dart +++ b/ui/lib/services/UserDetails.dart @@ -1,23 +1,16 @@ - -class UserDetails{ - +class UserDetails { static Map _userData; // setter - static void setUserData(String email, String username, String gender){ - _userData = { - "email": email, - "username": username, - "gender": gender - }; + static void setUserData(String email, String username, String gender) { + _userData = {"email": email, "username": username, "gender": gender}; // print("---------------------------------------------------------"); // print(_userData); // print("---------------------------------------------------------"); } // getter - static Map getUserData(){ + static Map getUserData() { return _userData; } - -} \ No newline at end of file +} diff --git a/ui/lib/services/endPoints.dart b/ui/lib/services/endPoints.dart index a5e9451..74cc34a 100644 --- a/ui/lib/services/endPoints.dart +++ b/ui/lib/services/endPoints.dart @@ -1,9 +1,16 @@ // API END POINTS -const postLungCancerPrediction_API = ""; -const postSkinCancerPrediction_API = ""; -const postBreastCancerPrediction_API = ""; +const postLungCancerPrediction_API = + "https://onco-prognosis-backend.herokuapp.com/prognosis_lung"; +const postSkinCancerPrediction_API = + "https://onco-prognosis-backend.herokuapp.com/prognosis_skin"; +const postBreastCancerPrediction_API = + "https://onco-prognosis-backend.herokuapp.com/prognosis_breast"; -const postLungCancerDetection_API = ""; -const postSkinCancerDetection_API = ""; -const postBreastCancerDetection_API = ""; -const postChatBotMessage_API = ""; +const postLungCancerDetection_API = + "https://lungmodelsdgp.azurewebsites.net/api/lungmodelsdgp?model=lung"; +const postSkinCancerDetection_API = + "https://skinmodelsdgp.azurewebsites.net/api/skinmodelsdgp?model=skin"; +const postBreastCancerDetection_API = + "https://breastmodelsdgp.azurewebsites.net/api/breastmodelsdgp?model=breast"; +const postChatBotMessage_API = + "https://chatbot-deployment.azurewebsites.net/api/chatbot-deployment"; diff --git a/ui/pubspec.lock b/ui/pubspec.lock index 5b201c1..18868a5 100644 --- a/ui/pubspec.lock +++ b/ui/pubspec.lock @@ -70,14 +70,14 @@ packages: name: built_collection url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "4.3.2" built_value: dependency: transitive description: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.0.5" + version: "7.1.0" cached_network_image: dependency: "direct main" description: @@ -105,7 +105,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.2.0" clock: dependency: transitive description: @@ -175,7 +175,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.0" curved_navigation_bar: dependency: "direct main" description: @@ -210,14 +210,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "0.1.3" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "5.2.1" firebase: dependency: transitive description: @@ -238,7 +238,7 @@ packages: name: firebase_analytics_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.0.3" firebase_analytics_web: dependency: transitive description: @@ -315,7 +315,7 @@ packages: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "0.10.11" flutter: dependency: "direct main" description: flutter @@ -355,7 +355,7 @@ packages: name: flutter_slidable url: "https://pub.dartlang.org" source: hosted - version: "0.6.0" + version: "0.5.7" flutter_test: dependency: "direct dev" description: flutter @@ -372,7 +372,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "1.2.0" google_sign_in: dependency: "direct main" description: @@ -400,7 +400,7 @@ packages: name: group_button url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "1.3.0" grouped_buttons: dependency: "direct main" description: @@ -463,7 +463,7 @@ packages: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "0.11.4" matcher: dependency: transitive description: @@ -498,7 +498,21 @@ packages: name: nested url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "0.0.4" + node_interop: + dependency: transitive + description: + name: node_interop + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" + node_io: + dependency: transitive + description: + name: node_io + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" octo_image: dependency: transitive description: @@ -526,42 +540,42 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "1.6.28" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "0.0.1+2" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "0.0.4+8" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "1.0.4" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "0.0.4+3" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.9.2" percent_indicator: dependency: "direct main" description: @@ -582,7 +596,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "2.2.1" plugin_platform_interface: dependency: transitive description: @@ -596,7 +610,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "3.0.13" progress_dialog: dependency: "direct main" description: @@ -610,14 +624,14 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "4.3.3" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "1.4.4" quiver: dependency: transitive description: @@ -664,14 +678,14 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "2.0.0+3" + version: "1.3.2+4" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "2.0.0+2" + version: "1.0.3+3" stack_trace: dependency: transitive description: @@ -699,7 +713,7 @@ packages: name: synchronized url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "2.2.0+2" term_glyph: dependency: transitive description: @@ -741,21 +755,21 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "0.9.7+15" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "1.7.4+1" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.1.2" xml: dependency: transitive description: @@ -771,5 +785,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.24.0-10" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.22.2" diff --git a/ui/pubspec.yaml b/ui/pubspec.yaml index 029e0c3..b08973c 100644 --- a/ui/pubspec.yaml +++ b/ui/pubspec.yaml @@ -51,7 +51,6 @@ flutter: assets: - images/ - images/CardImages/ - - images/ExerciseImages/ fonts: - family: Poppins-Regular diff --git a/ui/test/unit_test.dart b/ui/test/unit_test.dart index 7bf4046..1d2663b 100644 --- a/ui/test/unit_test.dart +++ b/ui/test/unit_test.dart @@ -13,13 +13,11 @@ void main() { String expected; test("Testing lung cancer diagnosis (Healthy lung)", () async { - // ACTUAL LungCancerDiagnosisState lungCancerDiagnosisState = new LungCancerDiagnosisState(); FormData formData = new FormData.fromMap({ - "file": await MultipartFile.fromFile( - "images/healthy-lung-test.jpeg", + "file": await MultipartFile.fromFile("images/healthy-lung-test.jpeg", filename: "testingImage"), }); @@ -31,17 +29,14 @@ void main() { // TEST expect(actual, expected); - }); test("Testing lung cancer diagnosis (Infected lung)", () async { - // ACTUAL LungCancerDiagnosisState lungCancerDiagnosisState = - new LungCancerDiagnosisState(); + new LungCancerDiagnosisState(); FormData formData = new FormData.fromMap({ - "file": await MultipartFile.fromFile( - "images/infected-lung-test.png", + "file": await MultipartFile.fromFile("images/infected-lung-test.png", filename: "testingImage"), }); @@ -53,17 +48,14 @@ void main() { // TEST expect(actual, expected); - }); test("Testing skin cancer diagnosis", () async { - // ACTUAL SkinCancerDiagnosisState skinCancerDiagnosisState = - new SkinCancerDiagnosisState(); + new SkinCancerDiagnosisState(); FormData formData = new FormData.fromMap({ - "file": await MultipartFile.fromFile( - "images/skin-infected-test.jpg", + "file": await MultipartFile.fromFile("images/skin-infected-test.jpg", filename: "testingImage"), }); @@ -75,17 +67,14 @@ void main() { // TEST expect(actual, expected); - }); test("Testing beast cancer diagnosis (Healthy Breast)", () async { - // ACTUAL BreastCancerDiagnosisState breastCancerDiagnosisState = - new BreastCancerDiagnosisState(); + new BreastCancerDiagnosisState(); FormData formData = new FormData.fromMap({ - "file": await MultipartFile.fromFile( - "images/normal-breast-test.png", + "file": await MultipartFile.fromFile("images/normal-breast-test.png", filename: "testingImage"), }); @@ -97,17 +86,14 @@ void main() { // TEST expect(actual, expected); - }); test("Testing beast cancer diagnosis (Infected Breast)", () async { - // ACTUAL BreastCancerDiagnosisState breastCancerDiagnosisState = - new BreastCancerDiagnosisState(); + new BreastCancerDiagnosisState(); FormData formData = new FormData.fromMap({ - "file": await MultipartFile.fromFile( - "images/infected-breast-test.png", + "file": await MultipartFile.fromFile("images/infected-breast-test.png", filename: "testingImage"), }); @@ -119,14 +105,15 @@ void main() { // TEST expect(actual, expected); - }); test("Testing lung cancer prognosis ", () async { - // ACTUAL - CancerPrognosisState cancerPrognosisState = new CancerPrognosisState("Lung Cancer",LUNG_CANCER_PROGNOSIS_QUESTIONS, null, - "https://onco-prognosis-backend.herokuapp.com/prognosis_lung"); + CancerPrognosisState cancerPrognosisState = new CancerPrognosisState( + "Lung Cancer", + LUNG_CANCER_PROGNOSIS_QUESTIONS, + null, + "https://onco-prognosis-backend.herokuapp.com/prognosis_lung"); cancerPrognosisState.prognosisBody = { "Age": 44, "Gender": 1, @@ -155,17 +142,50 @@ void main() { actual = await cancerPrognosisState.apiRequest(); // EXPECTED - expected = '{"Prediction": "Medium"}\n'''; + expected = '{"Prediction": "Medium"}\n' ''; // TEST expect(actual, expected); + }); + + test("Testing skin cancer prognosis", () async { + // ACTUAL + CancerPrognosisState cancerPrognosisState = new CancerPrognosisState( + "Skin Cancer", + SKIN_CANCER_PROGNOSIS_QUESTIONS_MALE, + null, + "https://onco-prognosis-backend.herokuapp.com/prognosis_skin"); + + // EXPECTED + cancerPrognosisState.prognosisBody = { + "age": 30, + "gender": "male", + "sunburn": 1, + "complexion": 0, + "big-moles": 1, + "small-moles": 0, + "freckling": 0, + "damage": 1, + "tan": 0 + }; + + // TEST + actual = await cancerPrognosisState.apiRequest(); + + // EXPECTED + expected = + '{"absolute_risk": "3.0%", "result_string": "A 3.0% estimated risk of developing melanoma over the next 5 years.", "gender": "male", "ratio": 0, "status": 200}\n'; + // TEST + expect(actual, expected); }); test("Testing breast cancer prognosis", () async { - // ACTUAL - CancerPrognosisState cancerPrognosisState = new CancerPrognosisState("Breast Cancer",BREAST_CANCER_PROGNOSIS_QUESTIONS, null, + CancerPrognosisState cancerPrognosisState = new CancerPrognosisState( + "Breast Cancer", + BREAST_CANCER_PROGNOSIS_QUESTIONS, + null, "https://onco-prognosis-backend.herokuapp.com/prognosis_breast"); cancerPrognosisState.prognosisBody = { "radius_mean": 2, @@ -198,6 +218,5 @@ void main() { // TEST expect(actual, expected); - }); }