Skip to content

Commit

Permalink
Start work on checkup flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ferndot committed Mar 15, 2020
1 parent 23cfddb commit d98e940
Show file tree
Hide file tree
Showing 12 changed files with 442 additions and 22 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PODS:
- Flutter (1.0.0)
- FMDB/SQLCipher (2.7.5):
- SQLCipher
- moor_ffi (0.0.1):
- Flutter
- path_provider (0.0.1):
- Flutter
- path_provider_macos (0.0.1):
Expand All @@ -17,6 +19,7 @@ PODS:

DEPENDENCIES:
- Flutter (from `Flutter`)
- moor_ffi (from `.symlinks/plugins/moor_ffi/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
Expand All @@ -30,6 +33,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
moor_ffi:
:path: ".symlinks/plugins/moor_ffi/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
path_provider_macos:
Expand All @@ -40,6 +45,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
moor_ffi: d66c9470c18e9cb333423bbcb493c105c6c774c6
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
sqflite: dc1dd7fd0c3603c33bd1c0b2e90d38182e3ddb37
Expand Down
3 changes: 3 additions & 0 deletions lib/src/ui/router.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'screens/checkup/checkup.dart';
import 'screens/home/home.dart';

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

var appRoutes = {
HomeScreen.routeName: (context) => HomeScreen(),
CheckupScreen.routeName: (context) => CheckupScreen(),
};

const initialRoute = HomeScreen.routeName;
92 changes: 92 additions & 0 deletions lib/src/ui/screens/checkup/checkup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import 'package:flutter/material.dart';

import 'steps/index.dart';

class CheckupScreen extends StatefulWidget {
static const routeName = '/checkup';

@override
_CheckupScreenState createState() => _CheckupScreenState();
}

class _CheckupScreenState extends State<CheckupScreen> {
PageController _pageController;
int currentIndex = 0;
CheckupStep currentStep = steps[0];

@override
void initState() {
super.initState();
_pageController = PageController();
}

@override
void dispose() {
_pageController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
double percentComplete = currentIndex / steps.length;
String percentCompleteText = (percentComplete * 100).round().toString();

return Scaffold(
appBar: AppBar(
title: Text('Checkup time!'),
),
backgroundColor: Theme.of(context).primaryColor,
body: Stack(
children: <Widget>[
PageView.builder(
controller: _pageController,
onPageChanged: (int index) => setState(() {
currentIndex = index;
currentStep = steps[index];
}),
itemCount: steps.length,
itemBuilder: (BuildContext context, int index) {
return steps[index];
},
),
if (currentStep != null)
Align(
alignment: Alignment.bottomCenter,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () => _pageController.nextPage(
duration: Duration(milliseconds: 400),
curve: Curves.easeInOut,
),
child: Text('Continue'),
),
Padding(
padding: EdgeInsets.all(10),
child: Text(
'$percentCompleteText% Complete',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
),
SizedBox(
height: 20,
child: LinearProgressIndicator(
value: percentComplete,
backgroundColor: Colors.white.withOpacity(0.2),
valueColor: AlwaysStoppedAnimation<Color>(Colors.green),
),
),
],
),
),
],
),
);
}
}
44 changes: 44 additions & 0 deletions lib/src/ui/screens/checkup/steps/breath.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:coronavirus_diary/src/ui/widgets/question_view.dart';
import 'package:coronavirus_diary/src/ui/widgets/simple_slider.dart';
import 'index.dart';

class BreathStep extends StatefulWidget implements CheckupStep {
@override
_BreathStepState createState() => _BreathStepState();
}

class _BreathStepState extends State<BreathStep> {
@override
Widget build(BuildContext context) {
return QuestionView(
questions: [
Question(
title: Text('Are you experiencing shortness of breath?'),
subtitle: Text('Do you feel like you can\'t get enough air?'),
input: SimpleSlider(
value: 1,
labels: [
Label(
child: FaIcon(
FontAwesomeIcons.solidSmile,
color: Colors.white,
),
percent: 0,
),
Label(
child: FaIcon(
FontAwesomeIcons.solidFrown,
color: Colors.white,
),
percent: 100,
),
],
),
),
],
);
}
}
44 changes: 44 additions & 0 deletions lib/src/ui/screens/checkup/steps/cough.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:coronavirus_diary/src/ui/widgets/question_view.dart';
import 'package:coronavirus_diary/src/ui/widgets/simple_slider.dart';
import 'index.dart';

class CoughStep extends StatefulWidget implements CheckupStep {
@override
_CoughStepState createState() => _CoughStepState();
}

class _CoughStepState extends State<CoughStep> {
@override
Widget build(BuildContext context) {
return QuestionView(
questions: [
Question(
title: Text('Do you have a cough?'),
subtitle: Text('How often?'),
input: SimpleSlider(
value: 1,
labels: [
Label(
child: FaIcon(
FontAwesomeIcons.solidSmile,
color: Colors.white,
),
percent: 0,
),
Label(
child: FaIcon(
FontAwesomeIcons.solidFrown,
color: Colors.white,
),
percent: 100,
),
],
),
),
],
);
}
}
11 changes: 11 additions & 0 deletions lib/src/ui/screens/checkup/steps/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';

import 'breath.dart';
import 'cough.dart';
import 'intro.dart';

abstract class CheckupStep extends Widget {
const CheckupStep();
}

final List<CheckupStep> steps = [IntroStep(), BreathStep(), CoughStep()];
37 changes: 37 additions & 0 deletions lib/src/ui/screens/checkup/steps/intro.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'package:coronavirus_diary/src/ui/widgets/question_view.dart';
import 'index.dart';

class IntroStep extends StatefulWidget implements CheckupStep {
@override
_IntroStepState createState() => _IntroStepState();
}

class _IntroStepState extends State<IntroStep> {
@override
Widget build(BuildContext context) {
return QuestionView(
questions: [
Question(
title: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(bottom: 40),
child: FaIcon(
FontAwesomeIcons.check,
color: Colors.white.withOpacity(0.7),
size: 100,
),
),
Text(
"It's time for your checkup. This blurb will prepare you for it and highlight your right to submit only the data that you choose.",
),
],
),
),
],
);
}
}
27 changes: 6 additions & 21 deletions lib/src/ui/screens/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'package:coronavirus_diary/src/blocs/activity/activity.dart';
import 'package:coronavirus_diary/src/ui/widgets/loading_indicator.dart';
import 'activity_list.dart';
import 'package:coronavirus_diary/src/ui/router.dart';

class HomeScreen extends StatefulWidget {
static const routeName = '/';
Expand All @@ -19,23 +16,11 @@ class _HomeScreenState extends State<HomeScreen> {
appBar: AppBar(
title: Text('Coronavirus Diary'),
),
body: BlocProvider(
create: (BuildContext context) => ActivityBloc(),
child: BlocBuilder<ActivityBloc, ActivityState>(
builder: (context, state) {
if (state is ActivityNotLoaded || state is ActivityLoading) {
if (state is ActivityNotLoaded) {
context.bloc<ActivityBloc>().add(RetrieveActivity());
}
return LoadingIndicator('Loading activity');
} else if (state is ActivityLoaded) {
return ActivityList(state.events);
} else {
return Center(
child: Text('There was an error retrieving activity.'),
);
}
},
body: Center(
child: RaisedButton(
onPressed: () =>
Navigator.pushNamed(context, CheckupScreen.routeName),
child: Text('Start checkup'),
),
),
);
Expand Down
69 changes: 69 additions & 0 deletions lib/src/ui/widgets/question_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';

class Question {
final Widget title;
final Widget subtitle;
final Widget input;

const Question({
@required this.title,
this.subtitle,
this.input,
});
}

class QuestionView extends StatefulWidget {
final List<Question> questions;
final Color color;

const QuestionView({@required this.questions, this.color});

@override
_QuestionViewState createState() => _QuestionViewState();
}

class _QuestionViewState extends State<QuestionView> {
List<Widget> _getQuestions() {
return widget.questions.map((Question question) {
return Container(
padding: EdgeInsets.all(50),
child: Column(
children: <Widget>[
DefaultTextStyle(
child: question.title,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.title.copyWith(
color: Colors.white,
),
),
if (question.subtitle != null)
DefaultTextStyle(
child: question.subtitle,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.subtitle.copyWith(
color: Colors.white,
),
),
if (question.input != null)
Padding(
padding: EdgeInsets.only(top: 20),
child: question.input,
),
],
),
);
}).toList();
}

@override
Widget build(BuildContext context) {
return Container(
color: widget.color ?? Theme.of(context).primaryColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: _getQuestions(),
),
);
}
}
Loading

0 comments on commit d98e940

Please sign in to comment.