Skip to content

Commit a257866

Browse files
committed
connected checkin to service, gridview done
1 parent 9a409e8 commit a257866

File tree

2 files changed

+110
-5
lines changed

2 files changed

+110
-5
lines changed

lib/screens/checkin.screen.dart

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:get/get.dart';
33
import 'package:symptom_tracker/screens/screens.dart';
4+
import 'package:symptom_tracker/services/services.dart';
45
import 'package:symptom_tracker/shared/action_button.dart';
56
import 'package:symptom_tracker/shared/shared.dart';
67

@@ -25,7 +26,7 @@ class CheckinScreen extends StatelessWidget {
2526
SizedBox(height: 48),
2627
_buildHeader(),
2728
SizedBox(height: 24),
28-
Text('text'),
29+
_buildSymptomList(),
2930
SizedBox(height: 24),
3031
SharedActionButton(
3132
title: 'Submit',
@@ -55,4 +56,47 @@ class CheckinScreen extends StatelessWidget {
5556
],
5657
);
5758
}
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+
}
58102
}

lib/services/symptom.service.dart

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,73 @@ import 'package:symptom_tracker/services/services.dart';
66
class SymptomService extends GetController {
77
static SymptomService get to => Get.find();
88

9+
void toggleChecked(Symptom item) {
10+
item.isChecked = !item.isChecked;
11+
update(this);
12+
}
13+
914
List<Symptom> get symptomList => _symptomList;
1015

1116
List<Symptom> _symptomList = [
12-
Symptom(icon: FlutterIcons.face_mco, name: 'Cough', id: symptomId.cough),
13-
Symptom(icon: FlutterIcons.face_mco, name: 'SOB', id: symptomId.cough),
14-
Symptom(icon: FlutterIcons.face_mco, name: 'dizzy', id: symptomId.cough),
15-
Symptom(icon: FlutterIcons.face_mco, name: 'get data', id: symptomId.cough),
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+
),
1677
];
1778
}

0 commit comments

Comments
 (0)