Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
SachitMisra committed Jul 15, 2020
1 parent a0ff614 commit 7c720e6
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"firebase_core","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_database","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_database-3.1.6\\\\","dependencies":["firebase_core"]},{"name":"firebase_messaging","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_messaging-6.0.16\\\\","dependencies":[]},{"name":"flutter_webview_plugin","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_webview_plugin-0.3.11\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+3\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.11\\\\","dependencies":[]}],"android":[{"name":"firebase_core","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_database","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_database-3.1.6\\\\","dependencies":["firebase_core"]},{"name":"firebase_messaging","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_messaging-6.0.16\\\\","dependencies":[]},{"name":"flutter_webview_plugin","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_webview_plugin-0.3.11\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+3\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.11\\\\","dependencies":[]}],"macos":[{"name":"firebase_core","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+10\\\\","dependencies":[]},{"name":"url_launcher_macos","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-0.0.1+7\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"firebase_core_web","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core_web-0.1.1+2\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+7\\\\","dependencies":[]},{"name":"url_launcher_web","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-0.1.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_database","dependencies":["firebase_core"]},{"name":"firebase_messaging","dependencies":[]},{"name":"flutter_webview_plugin","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-07-15 00:09:30.778820","version":"1.17.5"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"firebase_core","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_database","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_database-3.1.6\\\\","dependencies":["firebase_core"]},{"name":"firebase_messaging","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_messaging-6.0.16\\\\","dependencies":[]},{"name":"flutter_pdfview","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_pdfview-1.0.3\\\\","dependencies":[]},{"name":"flutter_webview_plugin","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_webview_plugin-0.3.11\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.11\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+3\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.11\\\\","dependencies":[]}],"android":[{"name":"firebase_core","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"firebase_database","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_database-3.1.6\\\\","dependencies":["firebase_core"]},{"name":"firebase_messaging","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_messaging-6.0.16\\\\","dependencies":[]},{"name":"flutter_pdfview","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_pdfview-1.0.3\\\\","dependencies":[]},{"name":"flutter_webview_plugin","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_webview_plugin-0.3.11\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.11\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+3\\\\","dependencies":[]},{"name":"url_launcher","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-5.4.11\\\\","dependencies":[]}],"macos":[{"name":"firebase_core","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.5\\\\","dependencies":[]},{"name":"path_provider_macos","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+3\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+10\\\\","dependencies":[]},{"name":"url_launcher_macos","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-0.0.1+7\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[],"web":[{"name":"firebase_core_web","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core_web-0.1.1+2\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+7\\\\","dependencies":[]},{"name":"url_launcher_web","path":"C:\\\\Users\\\\vidit\\\\AppData\\\\Roaming\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-0.1.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_database","dependencies":["firebase_core"]},{"name":"firebase_messaging","dependencies":[]},{"name":"flutter_pdfview","dependencies":[]},{"name":"flutter_webview_plugin","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-07-15 14:51:32.688794","version":"1.17.5"}
2 changes: 2 additions & 0 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".Application"
android:label="Here for You"
Expand Down
Binary file added assets/Consent Form.pdf
Binary file not shown.
Binary file added assets/Get Help Now.pdf
Binary file not shown.
Binary file added assets/Know the Team.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
11 changes: 8 additions & 3 deletions lib/ResultPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ResultPage extends StatefulWidget {

class _ResultPageState extends State<ResultPage> {
String res, msg, title, endMsg, imgUrl;

String assetPDFPath2= "";
Map<String, HighlightedWord> words;
HighlightMap highlightMap;

Expand Down Expand Up @@ -239,8 +239,13 @@ class _ResultPageState extends State<ResultPage> {
),
GestureDetector(
onTap: () async {
launch(
"https://github.com/MSPC-Tech/MentalHealthApp/raw/master/static/Get%20Help%20Now.pdf");
if (assetPDFPath2 != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PdfViewPage(path: assetPDFPath2)));
}
},
child: Text(
"Click here to Get Help Now!",
Expand Down
2 changes: 1 addition & 1 deletion lib/Showup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class _ShowUpState extends State<ShowUp> with TickerProviderStateMixin {
super.initState();

_animController =
AnimationController(vsync: this, duration: Duration(milliseconds: 100));
AnimationController(vsync: this, duration: Duration(milliseconds:0));
final curve =
CurvedAnimation(curve: Curves.decelerate, parent: _animController);
_animOffset =
Expand Down
173 changes: 170 additions & 3 deletions lib/onboarding.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:mental_health_app/question.dart';
import 'package:mental_health_app/quiz.dart';
Expand All @@ -7,13 +8,22 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:link/link.dart';
import 'package:url_launcher/url_launcher.dart';
import 'Showup.dart';
import 'package:flutter_pdfview/flutter_pdfview.dart';
import 'package:path_provider/path_provider.dart';
import 'package:http/http.dart' as http;
import 'dart:io';

class Onboarding extends StatefulWidget {
@override
_OnboardingState createState() => _OnboardingState();
}

class _OnboardingState extends State<Onboarding> {
String assetPDFPath1 = "";
String assetPDFPath2= "";

String assetPDFPath3 = "";

SwiperController _controller = SwiperController();
List<Question> SDRS_Questions = [
Question(),
Expand Down Expand Up @@ -45,11 +55,70 @@ class _OnboardingState extends State<Onboarding> {
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) {
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<File> getFileFromAsset1(String asset) async {
try {
var data = await rootBundle.load(asset);
var bytes = data.buffer.asUint8List();
var dir = await getApplicationDocumentsDirectory();
File file = File("${dir.path}/Know the Team.pdf");

File assetFile = await file.writeAsBytes(bytes);
return assetFile;
} catch (e) {
throw Exception("Error opening asset file");
}
}
Future<File> getFileFromAsset2(String asset) async {
try {
var data = await rootBundle.load(asset);
var bytes = data.buffer.asUint8List();
var dir = await getApplicationDocumentsDirectory();
File file = File("${dir.path}/Get Help Now.pdf");

File assetFile = await file.writeAsBytes(bytes);
return assetFile;
} catch (e) {
throw Exception("Error opening asset file");
}
}
Future<File> getFileFromAsset3(String asset) async {
try {
var data = await rootBundle.load(asset);
var bytes = data.buffer.asUint8List();
var dir = await getApplicationDocumentsDirectory();
File file = File("${dir.path}/Consent Form.pdf");

File assetFile = await file.writeAsBytes(bytes);
return assetFile;
} catch (e) {
throw Exception("Error opening asset file");
}
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(context, allowFontScaling: true);
Expand Down Expand Up @@ -121,7 +190,14 @@ class _OnboardingState extends State<Onboarding> {
elevation: 5,
child: GestureDetector(
onTap: () async {
launch('https://github.com/MSPC-Tech/MentalHealthApp/raw/master/static/Know%20the%20Team.pdf');
print("PDF poof");
if (assetPDFPath1 != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PdfViewPage(path: assetPDFPath1)));
}
},
child: Text(
"Know the Team",
Expand Down Expand Up @@ -249,7 +325,13 @@ class _OnboardingState extends State<Onboarding> {
elevation: 5,
child: GestureDetector(
onTap: () async {
launch("https://github.com/MSPC-Tech/MentalHealthApp/raw/master/static/Get%20Help%20Now.pdf");
if (assetPDFPath2 != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PdfViewPage(path: assetPDFPath2)));
}
},
child: Text(
"I want help now!",
Expand Down Expand Up @@ -370,7 +452,13 @@ class _OnboardingState extends State<Onboarding> {
elevation: 5,
child: GestureDetector(
onTap: () async {
launch("https://github.com/MSPC-Tech/MentalHealthApp/raw/master/static/Consent%20Form.pdf");
if (assetPDFPath3 != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
PdfViewPage(path: assetPDFPath3)));
}
},
child: Text(
"Consent Form!",
Expand Down Expand Up @@ -551,3 +639,82 @@ class _OnboardingState extends State<Onboarding> {
);
}
}

class PdfViewPage extends StatefulWidget {
final String path;

const PdfViewPage({Key key, this.path}) : super(key: key);
@override
_PdfViewPageState createState() => _PdfViewPageState();
}

class _PdfViewPageState extends State<PdfViewPage> {
int _totalPages = 0;
int _currentPage = 0;
bool pdfReady = false;
PDFViewController _pdfViewController;

@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
PDFView(
filePath: widget.path,
autoSpacing: true,
enableSwipe: true,
pageSnap: true,
swipeHorizontal: true,
nightMode: false,
onError: (e) {
print(e);
},
onRender: (_pages) {
setState(() {
_totalPages = _pages;
pdfReady = true;
});
},
onViewCreated: (PDFViewController vc) {
_pdfViewController = vc;
},
onPageChanged: (int page, int total) {
setState(() {});
},
onPageError: (page, e) {},
),
!pdfReady
? Center(
child: CircularProgressIndicator(),
)
: Offstage()
],
),
floatingActionButton: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
_currentPage > 0
? FloatingActionButton.extended(
backgroundColor: Colors.red,
label: Text("Go to ${_currentPage - 1}"),
onPressed: () {
_currentPage -= 1;
_pdfViewController.setPage(_currentPage);
},
)
: Offstage(),
_currentPage+1 < _totalPages
? FloatingActionButton.extended(
backgroundColor: Colors.green,
label: Text("Go to ${_currentPage + 1}"),
onPressed: () {
_currentPage += 1;
_pdfViewController.setPage(_currentPage);
},
)
: Offstage(),
],
),
);
}
}
Loading

0 comments on commit 7c720e6

Please sign in to comment.