diff --git a/lib/SocioDemographic.dart b/lib/SocioDemographic.dart index 73234dc..ec289ac 100644 --- a/lib/SocioDemographic.dart +++ b/lib/SocioDemographic.dart @@ -101,7 +101,8 @@ class _SocioDemoState extends State { "Day Scholar with Family", "Hostel", "Paying Guest", - "Rented accommodation with friends" + "Rented accommodation with friends", + "Other" ]; String livingChosen = "Hostel"; diff --git a/lib/onboarding.dart b/lib/onboarding.dart index 40d7c97..717a941 100644 --- a/lib/onboarding.dart +++ b/lib/onboarding.dart @@ -20,7 +20,7 @@ class Onboarding extends StatefulWidget { class _OnboardingState extends State { String assetPDFPath1 = ""; - String assetPDFPath2= ""; + String assetPDFPath2 = ""; String assetPDFPath3 = ""; @@ -50,37 +50,33 @@ class _OnboardingState extends State { ]; int total = 0; - bool consent = false; + bool consent = false; final snackBar = SnackBar( - content: Text("Please give consent before you proceed"), - duration: Duration(milliseconds: 800), -); + content: Text("Please give consent before you proceed"), + duration: Duration(milliseconds: 800), + ); @override void initState() { super.initState(); - getFileFromAsset1("assets/Know the Team.pdf").then((f1) { + getFileFromAsset1("assets/Know the Team.pdf").then((f1) { setState(() { assetPDFPath1 = f1.path; - }); }); getFileFromAsset2("assets/Get Help Now.pdf").then((f2) { setState(() { assetPDFPath2 = f2.path; - }); }); getFileFromAsset3("assets/Consent Form.pdf").then((f3) { setState(() { assetPDFPath3 = f3.path; - }); }); - - } - Future getFileFromAsset1(String asset) async { + + Future getFileFromAsset1(String asset) async { try { var data = await rootBundle.load(asset); var bytes = data.buffer.asUint8List(); @@ -93,6 +89,7 @@ class _OnboardingState extends State { throw Exception("Error opening asset file"); } } + Future getFileFromAsset2(String asset) async { try { var data = await rootBundle.load(asset); @@ -106,6 +103,7 @@ class _OnboardingState extends State { throw Exception("Error opening asset file"); } } + Future getFileFromAsset3(String asset) async { try { var data = await rootBundle.load(asset); @@ -125,7 +123,7 @@ class _OnboardingState extends State { return Scaffold( backgroundColor: Colors.white, body: Swiper( - itemCount: 4, + itemCount: consent?4:3, curve: Curves.easeInOutCubic, scrollDirection: Axis.horizontal, loop: false, @@ -135,7 +133,7 @@ class _OnboardingState extends State { itemBuilder: (BuildContext context, int index) { if (index == 0) { return SingleChildScrollView( - child: Center( + child: Center( child: SizedBox( //height: MediaQuery.of(context).size.height*10, child: Column( @@ -158,7 +156,8 @@ class _OnboardingState extends State { "Developed in liaison by Professionals", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(75,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(75, allowFontScalingSelf: true), fontWeight: FontWeight.bold, color: Colors.black), ), @@ -170,14 +169,13 @@ class _OnboardingState extends State { "This app has been developed by Mental Health Professionals and is based on Scientific evidence and research. There is a team of eminent mental health professionals in the University who are available to help you.", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, color: Colors.black), ), ), SizedBox(height: 50.h), - - RaisedButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all( @@ -190,20 +188,21 @@ class _OnboardingState extends State { elevation: 5, child: GestureDetector( onTap: () async { - print("PDF poof"); - if (assetPDFPath1 != null) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PdfViewPage(path: assetPDFPath1))); - } + print("PDF poof"); + if (assetPDFPath1 != null) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PdfViewPage(path: assetPDFPath1))); + } }, child: Text( "Know the Team", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, decoration: TextDecoration.underline, color: Colors.blue[700]), @@ -226,7 +225,10 @@ class _OnboardingState extends State { title: Text( "Swipe left or Tap here to Navigate", textAlign: TextAlign.center, - style: TextStyle(fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), color: Colors.white), + style: TextStyle( + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), + color: Colors.white), ), ), ), @@ -235,7 +237,8 @@ class _OnboardingState extends State { height: 80.h, width: MediaQuery.of(context).size.width, child: Padding( - padding: EdgeInsets.symmetric(vertical: 50.h,horizontal: 10.w), + padding: EdgeInsets.symmetric( + vertical: 50.h, horizontal: 10.w), child: StepProgressIndicator( totalSteps: 4, height: 10.h, @@ -243,13 +246,12 @@ class _OnboardingState extends State { selectedColor: randomizecolor[index % 6], unselectedColor: randomizecolorlight[index % 6], customStep: (index, color) { - if(index == 1) - { + if (index == 1) { return Icon( - Icons.check_box_outline_blank, - color: color, - size: 50.w, - ); + Icons.check_box_outline_blank, + color: color, + size: 50.w, + ); } return Icon( Icons.stop, @@ -268,7 +270,7 @@ class _OnboardingState extends State { } if (index == 1) { return SingleChildScrollView( - child: Center( + child: Center( child: SizedBox( //height: MediaQuery.of(context).size.height*10, child: Column( @@ -281,9 +283,8 @@ class _OnboardingState extends State { child: Container( child: Image( image: AssetImage('assets/Onboarding2.png'), - height: 500.h, - - )), + height: 500.h, + )), ), SizedBox(height: 50.h), Padding( @@ -292,7 +293,8 @@ class _OnboardingState extends State { "It's OK to ask for Help!", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(70,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(70, allowFontScalingSelf: true), fontWeight: FontWeight.bold, color: Colors.black), ), @@ -304,12 +306,12 @@ class _OnboardingState extends State { "Going out and asking for help is a good thing. Don’t let others tell you otherwise. If you can’t seem to get help then you might be looking in the wrong place. Let professionals lend you a hand.", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, color: Colors.black), ), ), - SizedBox( height: 30.h, ), @@ -326,18 +328,19 @@ class _OnboardingState extends State { child: GestureDetector( onTap: () async { if (assetPDFPath2 != null) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PdfViewPage(path: assetPDFPath2))); - } + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PdfViewPage(path: assetPDFPath2))); + } }, child: Text( "I want help now!", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, decoration: TextDecoration.underline, color: Colors.red[700]), @@ -358,7 +361,10 @@ class _OnboardingState extends State { color: Colors.white), title: Text( "Next", - style: TextStyle(fontSize: ScreenUtil().setSp(60,allowFontScalingSelf: true), color: Colors.white), + style: TextStyle( + fontSize: ScreenUtil() + .setSp(60, allowFontScalingSelf: true), + color: Colors.white), ), ), ), @@ -367,7 +373,8 @@ class _OnboardingState extends State { height: 80.h, width: MediaQuery.of(context).size.width, child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w,vertical: 50.h), + padding: EdgeInsets.symmetric( + horizontal: 10.w, vertical: 50.h), child: StepProgressIndicator( totalSteps: 4, height: 10.h, @@ -375,13 +382,12 @@ class _OnboardingState extends State { selectedColor: randomizecolor[index % 6], unselectedColor: randomizecolorlight[index % 6], customStep: (index, color) { - if(index == 2) - { + if (index == 2) { return Icon( - Icons.check_box_outline_blank, - color: color, - size: 50.w, - ); + Icons.check_box_outline_blank, + color: color, + size: 50.w, + ); } return Icon( Icons.stop, @@ -400,7 +406,7 @@ class _OnboardingState extends State { } if (index == 2) { return SingleChildScrollView( - child: Center( + child: Center( child: SizedBox( //height: MediaQuery.of(context).size.height*10, child: Column( @@ -422,7 +428,8 @@ class _OnboardingState extends State { "Disclaimer", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(70,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(70, allowFontScalingSelf: true), fontWeight: FontWeight.bold, decoration: TextDecoration.underline, color: Colors.black), @@ -435,7 +442,8 @@ class _OnboardingState extends State { "This is not an alternative to seeking professional help for any acute mental health condition. If you’re currently feeling extremely anxious, suicidal or depressed kindly visit the Emergency of SRM Medical College & Hospital. Help will be provided to you promptly for the same. Please go through the Consent form below.\n", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, color: Colors.black), ), @@ -453,18 +461,19 @@ class _OnboardingState extends State { child: GestureDetector( onTap: () async { if (assetPDFPath3 != null) { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - PdfViewPage(path: assetPDFPath3))); - } + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + PdfViewPage(path: assetPDFPath3))); + } }, child: Text( "Consent Form!", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, decoration: TextDecoration.underline, color: Colors.green[700]), @@ -472,21 +481,40 @@ class _OnboardingState extends State { ), onPressed: () {}, ), - SizedBox(height: 30.h), - InkWell( - onTap: () { - consent = true; - _controller.next(); + SizedBox(height: 10.h), + CheckboxListTile( + onChanged: (bool value) { + setState(() { + consent = !consent; + }); }, + value: consent, + title: Text("I have read the form and I give Consent"), + controlAffinity: ListTileControlAffinity.leading, + ), + SizedBox(height: 10.h), + InkWell( + onTap: consent + ? () { + // consent = true; + _controller.next(); + } + : null, child: Card( elevation: 8, - color: randomizecolor[index % 6], + color: consent?randomizecolor[index % 6]:Colors.grey, child: ListTile( - trailing: Icon(Icons.done, color: Colors.white), + leading: + Icon(Icons.navigate_next, color: Colors.white), + trailing: + Icon(Icons.done, color: Colors.transparent), title: Text( - "I have read the form and I give Consent", - textAlign: TextAlign.center, - style: TextStyle(fontSize: ScreenUtil().setSp(50,allowFontScalingSelf: true), color: Colors.white), + "Next", + // textAlign: TextAlign.center, + style: TextStyle( + fontSize: ScreenUtil() + .setSp(50, allowFontScalingSelf: true), + color: Colors.white), ), ), ), @@ -495,7 +523,8 @@ class _OnboardingState extends State { height: 80.h, width: MediaQuery.of(context).size.width, child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w,vertical: 30.h), + padding: EdgeInsets.symmetric( + horizontal: 10.w, vertical: 30.h), child: StepProgressIndicator( totalSteps: 4, height: 10.h, @@ -503,13 +532,12 @@ class _OnboardingState extends State { selectedColor: randomizecolor[index % 6], unselectedColor: randomizecolorlight[index % 6], customStep: (index, color) { - if(index == 3) - { + if (index == 3) { return Icon( - Icons.check_box_outline_blank, - color: color, - size: 50.w, - ); + Icons.check_box_outline_blank, + color: color, + size: 50.w, + ); } return Icon( Icons.stop, @@ -525,10 +553,9 @@ class _OnboardingState extends State { ), ), ); - } - else if(index == 3){ + } else if (index == 3) { return SingleChildScrollView( - child: Center( + child: Center( child: SizedBox( //height: MediaQuery.of(context).size.height*10, child: Column( @@ -550,7 +577,8 @@ class _OnboardingState extends State { "Privacy Note", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(70,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(70, allowFontScalingSelf: true), fontWeight: FontWeight.bold, decoration: TextDecoration.underline, color: Colors.black), @@ -563,7 +591,8 @@ class _OnboardingState extends State { "Worried about your privacy and/or identity being revealed? Rest assured. The application is anonymous and does not collect any information by which you could be identified (such as your name, e-mail, etc.). The information collected (age, course, etc.) is only to determine and analyse your mental health better. Your data and results are safe with us.\n", textAlign: TextAlign.center, style: TextStyle( - fontSize: ScreenUtil().setSp(55,allowFontScalingSelf: true), + fontSize: ScreenUtil() + .setSp(55, allowFontScalingSelf: true), //fontWeight: FontWeight.bold, color: Colors.black), ), @@ -571,17 +600,15 @@ class _OnboardingState extends State { SizedBox(height: 30.h), InkWell( onTap: () { - if(consent) - { - Navigator.push(context, - MaterialPageRoute(builder: (context) => Quiz())); - } - else - { + if (consent) { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Quiz())); + } else { Scaffold.of(context).showSnackBar(snackBar); _controller.move(2); } - }, child: Card( elevation: 8, @@ -591,7 +618,10 @@ class _OnboardingState extends State { title: Text( "Start", textAlign: TextAlign.center, - style: TextStyle(fontSize: ScreenUtil().setSp(50,allowFontScalingSelf: true), color: Colors.white), + style: TextStyle( + fontSize: ScreenUtil() + .setSp(50, allowFontScalingSelf: true), + color: Colors.white), ), ), ), @@ -600,7 +630,8 @@ class _OnboardingState extends State { height: 80.h, width: MediaQuery.of(context).size.width, child: Padding( - padding: EdgeInsets.symmetric(horizontal: 10.w,vertical: 30.h), + padding: EdgeInsets.symmetric( + horizontal: 10.w, vertical: 30.h), child: StepProgressIndicator( totalSteps: 4, height: 10.h, @@ -608,13 +639,12 @@ class _OnboardingState extends State { selectedColor: randomizecolor[index % 6], unselectedColor: randomizecolorlight[index % 6], customStep: (index, color) { - if(index == 4) - { + if (index == 4) { return Icon( - Icons.check_box_outline_blank, - color: color, - size: 50.w, - ); + Icons.check_box_outline_blank, + color: color, + size: 50.w, + ); } return Icon( Icons.stop, @@ -630,8 +660,7 @@ class _OnboardingState extends State { ), ), ); - } - else { + } else { return null; } }, @@ -703,7 +732,7 @@ class _PdfViewPageState extends State { }, ) : Offstage(), - _currentPage+1 < _totalPages + _currentPage + 1 < _totalPages ? FloatingActionButton.extended( backgroundColor: Colors.green, label: Text("Go to ${_currentPage + 1}"),