Skip to content

Commit

Permalink
Add positive and negative assessment screens
Browse files Browse the repository at this point in the history
  • Loading branch information
ferndot committed Mar 21, 2020
1 parent 512283e commit 4a811a1
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 49 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PODS:
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- share (0.5.2):
- Flutter
- SQLCipher (4.1.0):
- SQLCipher/standard (= 4.1.0)
- SQLCipher/common (4.1.0)
Expand All @@ -23,6 +25,7 @@ DEPENDENCIES:
- location_permissions (from `.symlinks/plugins/location_permissions/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- share (from `.symlinks/plugins/share/ios`)
- SQLCipher (~> 4.1.0)

SPEC REPOS:
Expand All @@ -42,6 +45,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider/ios"
path_provider_macos:
:path: ".symlinks/plugins/path_provider_macos/ios"
share:
:path: ".symlinks/plugins/share/ios"

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
Expand All @@ -50,6 +55,7 @@ SPEC CHECKSUMS:
location_permissions: 4a49d4e5bec5b653643e551ab77963cc99bb0e4a
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
share: bae0a282aab4483288913fc4dc0b935d4b491f2e
SQLCipher: efbdb52cdbe340bcd892b1b14297df4e07241b7f

PODFILE CHECKSUM: c1f56ec578e7dc933512aa9b9b86b80eb2a5b47d
Expand Down
2 changes: 1 addition & 1 deletion lib/src/data/repositories/checkups.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CheckupsRepository {
}

Future<Assessment> completeCheckup(String id) async {
await Future.delayed(Duration(seconds: 1));
await Future.delayed(Duration(seconds: 2));
return Assessment(
processed: DateTime.now(),
matchesPuiSymptoms: Random().nextBool(),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/router.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'screens/checkup/assessment.dart';
import 'screens/assessment/assessment.dart';
import 'screens/checkup/checkup.dart';
import 'screens/home/home.dart';

export 'screens/checkup/assessment.dart';
export 'screens/assessment/assessment.dart';
export 'screens/checkup/checkup.dart';
export 'screens/home/home.dart';

Expand Down
44 changes: 44 additions & 0 deletions lib/src/ui/screens/assessment/assessment.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_hud/flutter_hud.dart';

import 'package:coronavirus_diary/src/blocs/checkup/checkup.dart';
import 'assessments/index.dart';
import 'share.dart';

class AssessmentScreen extends StatelessWidget {
static const routeName = '/assessment';

@override
Widget build(BuildContext context) {
return BlocBuilder<CheckupBloc, CheckupState>(
builder: (context, state) {
Widget body;
if (state is CheckupStateInProgress) {
context.bloc<CheckupBloc>().add(CompleteCheckup());
} else if (state is CheckupStateCompleted) {
switch (state.assessment.matchesPuiSymptoms) {
case true:
body = PositiveAssessment();
break;
case false:
body = NegativeAssessment();
break;
}
}
return WidgetHUD(
showHUD: state is CheckupStateCompleting,
hud: HUD(label: 'Loading your assessment'),
builder: (context) {
return Scaffold(
appBar: AppBar(
title: Text('Your Personalized Assessment'),
),
body: body,
);
},
);
},
);
}
}
2 changes: 2 additions & 0 deletions lib/src/ui/screens/assessment/assessments/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'positive.dart';
export 'negative.dart';
60 changes: 60 additions & 0 deletions lib/src/ui/screens/assessment/assessments/negative.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:coronavirus_diary/src/ui/screens/assessment/share.dart';

class NegativeAssessment extends StatefulWidget {
@override
_NegativeAssessmentState createState() => _NegativeAssessmentState();
}

class _NegativeAssessmentState extends State<NegativeAssessment> {
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 10),
padding: EdgeInsets.symmetric(horizontal: 40),
child: FaIcon(
FontAwesomeIcons.solidSmile,
color: Colors.white,
size: 70,
),
),
Container(
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"You don't meet testing criteria",
style: Theme.of(context).textTheme.title,
textAlign: TextAlign.center,
),
),
Container(
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"If you continue to experience symptoms, please check in tomorrow. ",
style: Theme.of(context).textTheme.body2.copyWith(fontSize: 16),
textAlign: TextAlign.center,
),
),
Container(
margin: EdgeInsets.only(bottom: 40),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"If they become serious, please consult a physician.",
style: Theme.of(context).textTheme.body2.copyWith(fontSize: 16),
textAlign: TextAlign.center,
),
),
ShareApp(),
],
),
);
}
}
59 changes: 59 additions & 0 deletions lib/src/ui/screens/assessment/assessments/positive.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';

import 'package:coronavirus_diary/src/ui/screens/assessment/share.dart';

class PositiveAssessment extends StatefulWidget {
@override
_PositiveAssessmentState createState() => _PositiveAssessmentState();
}

class _PositiveAssessmentState extends State<PositiveAssessment> {
@override
Widget build(BuildContext context) {
return Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 5),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
'🤔',
style: TextStyle(fontSize: 70),
),
),
Container(
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"Please contact your physician",
style: Theme.of(context).textTheme.title,
textAlign: TextAlign.center,
),
),
Container(
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"You are showing symptoms that may be of concern. "
"Please limit your contact with other people until you have a chance to follow up with a physician",
style: Theme.of(context).textTheme.body2.copyWith(fontSize: 16),
textAlign: TextAlign.center,
),
),
Container(
margin: EdgeInsets.only(bottom: 40),
padding: EdgeInsets.symmetric(horizontal: 40),
child: Text(
"Do not panic. This is only a preliminary assessment and not a formal medical diagnosis.",
style: Theme.of(context).textTheme.body2.copyWith(fontSize: 16),
textAlign: TextAlign.center,
),
),
ShareApp(),
],
),
);
}
}
59 changes: 59 additions & 0 deletions lib/src/ui/screens/assessment/share.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/fa_icon.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:share/share.dart';

class ShareApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
void _shareApp() {
Share.share(
'Worried that you might have COVID-19? '
'Download this app to checkup on your health and support your community: APP_LINK',
);
}

return Container(
color: Colors.white.withOpacity(0.2),
padding: EdgeInsets.symmetric(
horizontal: 40,
vertical: 20,
),
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 10),
child: FaIcon(
FontAwesomeIcons.heartbeat,
color: Colors.red,
size: 40,
),
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Text(
"Protect Your Community",
style: Theme.of(context).textTheme.title,
textAlign: TextAlign.center,
),
),
Container(
margin: EdgeInsets.only(bottom: 20),
child: Text(
"Share this app with your friends, coworkers, and family (especially grandparents).",
style: Theme.of(context).textTheme.body1.copyWith(
fontSize: 16,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
RaisedButton(
onPressed: _shareApp,
child: Text('Share now'),
),
],
),
);
}
}
14 changes: 0 additions & 14 deletions lib/src/ui/screens/checkup/assessment.dart

This file was deleted.

4 changes: 4 additions & 0 deletions lib/src/ui/screens/checkup/checkup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class _CheckupScreenState extends State<CheckupScreen> {
child: Scaffold(
appBar: AppBar(
title: Text('Your Health Checkup'),
leading: IconButton(
icon: Icon(Icons.close),
onPressed: () => Navigator.pop(context),
),
),
backgroundColor: Theme.of(context).primaryColor,
body: _getBody(checkupState),
Expand Down
23 changes: 0 additions & 23 deletions lib/src/ui/screens/checkup/checkup_completing_hud.dart

This file was deleted.

7 changes: 2 additions & 5 deletions lib/src/ui/screens/checkup/checkup_loaded_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,14 @@ class _CheckupLoadedBodyState extends State<CheckupLoadedBody> {
if (checkupState.checkup.dataContributionPreference == true) {
await _saveCurrentLocation(checkupState);
}
} else if (currentIndex > 0 && currentIndex < steps.length - 1) {
context.bloc<CheckupBloc>().add(UpdateRemoteCheckup());
}

setState(() {
currentIndex = index;
currentStep = steps[index];
});

// Destination-specific actions
if (currentIndex > 1 && currentIndex < steps.length - 1) {
context.bloc<CheckupBloc>().add(UpdateRemoteCheckup());
}
}

@override
Expand Down
5 changes: 1 addition & 4 deletions lib/src/ui/screens/checkup/checkup_progress_bar.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';

import 'package:coronavirus_diary/src/blocs/checkup/checkup.dart';
import 'package:coronavirus_diary/src/ui/router.dart';

class CheckupProgressBar extends StatelessWidget {
Expand All @@ -17,8 +15,7 @@ class CheckupProgressBar extends StatelessWidget {
_handleNextButton(BuildContext context) {
bool isLastPage = currentIndex == stepsLength - 1;
if (isLastPage) {
context.bloc<CheckupBloc>().add(CompleteCheckup());
Navigator.pushNamed(context, AssessmentScreen.routeName);
Navigator.pushReplacementNamed(context, AssessmentScreen.routeName);
} else {
Provider.of<PageController>(context, listen: false).nextPage(
duration: Duration(milliseconds: 400),
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.23.1"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3+6"
shelf:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
path_provider: ^1.6.5
path: ^1.6.4
provider: ^4.0.4
share: ^0.6.3+6
uuid: ^2.0.4

dev_dependencies:
Expand Down

0 comments on commit 4a811a1

Please sign in to comment.