Skip to content

Commit 24d98ca

Browse files
authored
Merge pull request #1 from FireJuun/demo/5_fire_fhir
Demo/5 fire fhir
2 parents bc3b54c + a257866 commit 24d98ca

14 files changed

+507
-13
lines changed

lib/main.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import 'package:flutter/material.dart';
2+
import 'package:get/get.dart';
3+
import 'package:symptom_tracker/screens/screens.dart';
4+
import 'package:symptom_tracker/theme.dart';
25

36
void main() {
47
runApp(MyApp());
@@ -8,13 +11,10 @@ class MyApp extends StatelessWidget {
811
// This widget is the root of your application.
912
@override
1013
Widget build(BuildContext context) {
11-
return MaterialApp(
14+
return GetMaterialApp(
1215
title: 'Flutter Demo',
13-
theme: ThemeData(
14-
primarySwatch: Colors.green,
15-
visualDensity: VisualDensity.adaptivePlatformDensity,
16-
),
17-
home: Center(child: Text('barebones')),
16+
theme: appTheme(),
17+
home: HomeScreen(),
1818
);
1919
}
2020
}

lib/screens/checkin.screen.dart

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:get/get.dart';
3+
import 'package:symptom_tracker/screens/screens.dart';
4+
import 'package:symptom_tracker/services/services.dart';
5+
import 'package:symptom_tracker/shared/action_button.dart';
6+
import 'package:symptom_tracker/shared/shared.dart';
7+
8+
class CheckinScreen extends StatelessWidget {
9+
@override
10+
Widget build(BuildContext context) {
11+
return Scaffold(
12+
appBar: SharedAppBar(
13+
title: 'Check-in',
14+
actions: [
15+
IconButton(icon: Icon(Icons.close), onPressed: () => Get.offAll(HomeScreen())),
16+
],
17+
),
18+
body: _buildBody(),
19+
);
20+
}
21+
22+
Widget _buildBody() {
23+
return SafeArea(
24+
child: Column(
25+
children: [
26+
SizedBox(height: 48),
27+
_buildHeader(),
28+
SizedBox(height: 24),
29+
_buildSymptomList(),
30+
SizedBox(height: 24),
31+
SharedActionButton(
32+
title: 'Submit',
33+
onPressed: () {
34+
Get.snackbar('Check-in complete', 'Be sure to check-in tomorrow as well!');
35+
Get.back();
36+
},
37+
),
38+
],
39+
),
40+
);
41+
}
42+
43+
Widget _buildHeader() {
44+
return Column(
45+
children: [
46+
Text(
47+
'Please select your symptoms',
48+
style: Get.theme.textTheme.headline4,
49+
),
50+
SizedBox(height: 8),
51+
Text(
52+
'Yesterday, you had cough, short of breath, and body aches',
53+
style: Get.theme.textTheme.headline5,
54+
textAlign: TextAlign.center,
55+
),
56+
],
57+
);
58+
}
59+
60+
Widget _buildSymptomList() {
61+
return GetBuilder<SymptomService>(
62+
init: SymptomService(),
63+
builder: (data) => Expanded(
64+
child: GridView(
65+
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, childAspectRatio: 2),
66+
children: [...data.symptomList.map((item) => _listItem(item))],
67+
),
68+
),
69+
);
70+
}
71+
72+
Widget _listItem(Symptom item) {
73+
return GestureDetector(
74+
onTap: () => SymptomService.to.toggleChecked(item),
75+
child: Container(
76+
margin: const EdgeInsets.all(8),
77+
padding: const EdgeInsets.only(left: 8),
78+
decoration: BoxDecoration(
79+
border: Border.all(color: Get.theme.unselectedWidgetColor), borderRadius: BorderRadius.circular(16)),
80+
child: Row(
81+
children: [
82+
Icon(
83+
item.icon,
84+
color: (item.isChecked) ? Get.theme.primaryColor : Get.theme.disabledColor,
85+
),
86+
Expanded(
87+
child: Text(item.name,
88+
textAlign: TextAlign.center,
89+
style: Get.theme.textTheme.subtitle2
90+
.apply(color: (item.isChecked) ? Get.theme.primaryColor : Get.theme.disabledColor)),
91+
),
92+
Checkbox(
93+
activeColor: Get.theme.primaryColor,
94+
value: item.isChecked,
95+
onChanged: (value) => SymptomService.to.toggleChecked(item),
96+
)
97+
],
98+
),
99+
),
100+
);
101+
}
102+
}

lib/screens/dashboard.screen.dart

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_icons/flutter_icons.dart';
3+
import 'package:get/get.dart';
4+
import 'package:symptom_tracker/screens/screens.dart';
5+
import 'package:symptom_tracker/shared/shared.dart';
6+
7+
class DashboardScreen extends StatelessWidget {
8+
@override
9+
Widget build(BuildContext context) {
10+
return Scaffold(
11+
appBar: SharedAppBar(
12+
title: 'Dashboard',
13+
actions: [
14+
IconButton(icon: Icon(Icons.close), onPressed: () => Get.offAll(HomeScreen())),
15+
],
16+
),
17+
body: SafeArea(
18+
child: _buildBody(),
19+
),
20+
);
21+
}
22+
23+
Widget _buildBody() {
24+
return ListView(
25+
children: [
26+
Padding(
27+
padding: const EdgeInsets.symmetric(vertical: 28),
28+
child: Text(
29+
'Good morning, AMIA',
30+
style: Get.theme.textTheme.headline3,
31+
textAlign: TextAlign.center,
32+
),
33+
),
34+
_listTile(
35+
icon: Icons.check_circle_outline,
36+
title: 'Check-in',
37+
subtitle: 'Enter your temperature, symptoms, and relevant tests',
38+
isGrey: true,
39+
onPressed: () => Get.to(CheckinScreen()),
40+
),
41+
_listTile(
42+
icon: FlutterIcons.calendar_oct,
43+
title: 'History',
44+
subtitle: 'See/edit your past entries',
45+
),
46+
_listTile(
47+
icon: FlutterIcons.map_clock_outline_mco,
48+
title: 'Contact tracing',
49+
subtitle: 'Toggle method:\nlocation / bluetooth / both / off',
50+
),
51+
_listTile(
52+
icon: FlutterIcons.information_variant_mco,
53+
title: 'Info',
54+
subtitle: 'Learn more about COVID-19',
55+
),
56+
],
57+
);
58+
}
59+
60+
Widget _listTile(
61+
{@required IconData icon,
62+
@required String title,
63+
@required String subtitle,
64+
bool isGrey,
65+
void Function() onPressed}) {
66+
var _txtTheme = Get.theme.textTheme;
67+
return Container(
68+
margin: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
69+
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
70+
decoration: BoxDecoration(
71+
border: Border.all(color: Get.theme.unselectedWidgetColor), borderRadius: BorderRadius.circular(16)),
72+
child: ListTile(
73+
leading: Icon(
74+
icon,
75+
size: 24,
76+
color: (isGrey ?? false) ? Get.theme.disabledColor : Get.theme.primaryColor,
77+
),
78+
title: Text(title, style: _txtTheme.subtitle1),
79+
subtitle: Text(subtitle, style: _txtTheme.subtitle2),
80+
onTap: onPressed,
81+
),
82+
);
83+
}
84+
}

lib/screens/home.screen.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:get/get.dart';
3+
import 'package:symptom_tracker/screens/screens.dart';
4+
import 'package:symptom_tracker/shared/action_button.dart';
5+
import 'package:symptom_tracker/shared/app_bar.dart';
6+
7+
class HomeScreen extends StatelessWidget {
8+
@override
9+
Widget build(BuildContext context) {
10+
return Scaffold(
11+
appBar: SharedAppBar(title: 'Hello AMIA'),
12+
body: SafeArea(
13+
child: _buildBody(),
14+
),
15+
drawer: Drawer(
16+
child: RaisedButton(
17+
child: Text('Click Here!'),
18+
onPressed: () {
19+
Get.snackbar('you clicked', 'the button');
20+
Get.back();
21+
},
22+
),
23+
),
24+
);
25+
}
26+
27+
Widget _buildBody() {
28+
return Center(
29+
child: Column(
30+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
31+
children: [
32+
SharedActionButton(
33+
title: 'Dashboard',
34+
onPressed: () => Get.to(DashboardScreen()),
35+
),
36+
SharedActionButton(
37+
title: 'Check-in',
38+
onPressed: () => Get.to(CheckinScreen()),
39+
),
40+
SharedActionButton(title: 'FHIR'),
41+
Text('Obligatory FHIR pun'),
42+
],
43+
),
44+
);
45+
}
46+
}

lib/screens/screens.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export 'checkin.screen.dart';
2+
export 'dashboard.screen.dart';
3+
export 'home.screen.dart';

lib/services/services.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export 'symptom.model.dart';
2+
export 'symptom.service.dart';

lib/services/symptom.model.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Symptom {
4+
bool isChecked;
5+
String name;
6+
IconData icon;
7+
symptomId id;
8+
9+
Symptom({this.isChecked = false, @required this.icon, @required this.name, @required this.id});
10+
}
11+
12+
enum symptomId {
13+
bodyAches,
14+
cough,
15+
diarrhea,
16+
feelingIll,
17+
headache,
18+
runnyNose,
19+
smell,
20+
sneezing,
21+
sob,
22+
soreThroat,
23+
taste,
24+
vomiting
25+
}

lib/services/symptom.service.dart

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_icons/flutter_icons.dart';
3+
import 'package:get/get.dart';
4+
import 'package:symptom_tracker/services/services.dart';
5+
6+
class SymptomService extends GetController {
7+
static SymptomService get to => Get.find();
8+
9+
void toggleChecked(Symptom item) {
10+
item.isChecked = !item.isChecked;
11+
update(this);
12+
}
13+
14+
List<Symptom> get symptomList => _symptomList;
15+
16+
List<Symptom> _symptomList = [
17+
Symptom(
18+
name: 'Cough',
19+
id: symptomId.cough,
20+
icon: FlutterIcons.face_mco,
21+
),
22+
Symptom(
23+
name: 'Short of Breath',
24+
id: symptomId.sob,
25+
icon: FlutterIcons.ambulance_faw,
26+
),
27+
Symptom(
28+
name: 'Feeling Ill',
29+
id: symptomId.feelingIll,
30+
icon: FlutterIcons.thermometer_faw,
31+
),
32+
Symptom(
33+
name: 'Headache',
34+
id: symptomId.headache,
35+
icon: FlutterIcons.keybase_faw5d,
36+
),
37+
Symptom(
38+
name: 'Body Aches',
39+
id: symptomId.bodyAches,
40+
icon: FlutterIcons.md_body_ion,
41+
),
42+
Symptom(
43+
name: 'Sore Throat',
44+
id: symptomId.soreThroat,
45+
icon: FlutterIcons.pills_faw5s,
46+
),
47+
Symptom(
48+
name: 'Weird/No Taste',
49+
id: symptomId.taste,
50+
icon: FlutterIcons.hamburger_faw5s,
51+
),
52+
Symptom(
53+
name: 'Weird/No Smell',
54+
id: symptomId.smell,
55+
icon: FlutterIcons.flower_ent,
56+
),
57+
Symptom(
58+
name: 'Vomiting',
59+
id: symptomId.vomiting,
60+
icon: FlutterIcons.food_off_mco,
61+
),
62+
Symptom(
63+
name: 'Diarrhea',
64+
id: symptomId.diarrhea,
65+
icon: FlutterIcons.emoticon_poop_mco,
66+
),
67+
Symptom(
68+
name: 'Sneezing',
69+
id: symptomId.sneezing,
70+
icon: FlutterIcons.wind_fea,
71+
),
72+
Symptom(
73+
name: 'Runny Nose',
74+
id: symptomId.runnyNose,
75+
icon: FlutterIcons.run_fast_mco,
76+
),
77+
];
78+
}

lib/shared/action_button.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:get/get.dart';
3+
4+
class SharedActionButton extends StatelessWidget {
5+
final String title;
6+
final void Function() onPressed;
7+
8+
const SharedActionButton({Key key, @required this.title, this.onPressed}) : super(key: key);
9+
10+
@override
11+
Widget build(BuildContext context) {
12+
return ButtonTheme.fromButtonThemeData(
13+
data: Get.theme.buttonTheme.copyWith(minWidth: Get.width / 2),
14+
child: RaisedButton(
15+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
16+
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 24),
17+
child: Text(title),
18+
onPressed: onPressed),
19+
);
20+
}
21+
}

0 commit comments

Comments
 (0)