forked from coronavirus-diary/coronavirus-diary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
442 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.", | ||
), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.