Skip to content

Commit 9a91743

Browse files
committed
firebase view loads CBC/BMP fishbones
1 parent 8f48c76 commit 9a91743

File tree

1 file changed

+138
-1
lines changed

1 file changed

+138
-1
lines changed

lib/screens/fhir/firebase.dart

Lines changed: 138 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,145 @@
11
import 'package:flutter/material.dart';
2+
import 'package:symptom_tracker/services/services.dart';
23

34
class FirebaseView extends StatelessWidget {
45
@override
56
Widget build(BuildContext context) {
6-
return Center(child: Text('Firebase'));
7+
return Column(
8+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
9+
children: <Widget>[
10+
_buildLabBMP(),
11+
_buildLabCBC(),
12+
],
13+
);
714
}
15+
16+
Widget _buildLabBMP() {
17+
return Center(
18+
child: StreamBuilder(
19+
stream: FirebaseService.to.fbStreamBMP,
20+
builder: (context, snapshot) {
21+
if (!snapshot.hasData) {
22+
return CircularProgressIndicator();
23+
}
24+
25+
ModelBMP _bmp = snapshot.data;
26+
return Padding(
27+
padding: EdgeInsets.all(8.0),
28+
child: Row(
29+
children: <Widget>[
30+
Expanded(
31+
child: Table(
32+
border:
33+
TableBorder(horizontalInside: BorderSide(width: 4.0), verticalInside: BorderSide(width: 4.0)),
34+
children: [
35+
TableRow(
36+
children: [
37+
_labText('${_bmp.na}'),
38+
_labText('${_bmp.cl}'),
39+
_labText('${_bmp.bun}'),
40+
],
41+
),
42+
TableRow(
43+
children: [
44+
_labText('${_bmp.k}'),
45+
_labText('${_bmp.co2}'),
46+
_labText('${_bmp.creat}'),
47+
],
48+
),
49+
],
50+
),
51+
),
52+
_labTextWithV('${_bmp.glc}'),
53+
],
54+
),
55+
);
56+
},
57+
),
58+
);
59+
}
60+
61+
Widget _buildLabCBC() {
62+
return Center(
63+
child: StreamBuilder(
64+
stream: FirebaseService.to.fbStreamCBC,
65+
builder: (context, snapshot) {
66+
if (!snapshot.hasData) {
67+
return CircularProgressIndicator();
68+
}
69+
ModelCBC _cbc = snapshot.data;
70+
return Row(
71+
mainAxisAlignment: MainAxisAlignment.center,
72+
mainAxisSize: MainAxisSize.min,
73+
children: <Widget>[
74+
_labTextWithV('${_cbc.wbc}', Colors.blue, true),
75+
IntrinsicWidth(
76+
child: Column(
77+
mainAxisSize: MainAxisSize.min,
78+
children: <Widget>[
79+
_labText('${_cbc.hb}'),
80+
Divider(
81+
color: Colors.black,
82+
thickness: 4.0,
83+
),
84+
_labText('${_cbc.hct}'),
85+
],
86+
),
87+
),
88+
_labTextWithV('${_cbc.plt}', Colors.orange),
89+
],
90+
);
91+
},
92+
),
93+
);
94+
}
95+
}
96+
97+
_labText(String s, [Color c = Colors.red]) {
98+
return Container(
99+
alignment: Alignment.center,
100+
margin: EdgeInsets.all(8.0),
101+
// color: c,
102+
child: Text(s),
103+
);
104+
}
105+
106+
_labTextWithV(String s, [Color c = Colors.red, bool onLeft = false]) {
107+
return Container(
108+
// margin: EdgeInsets.all(8.0),
109+
// color: c,
110+
child: CustomPaint(
111+
painter: _PaintV(onLeft: onLeft),
112+
child: Container(
113+
margin: EdgeInsets.symmetric(horizontal: 8.0, vertical: 48.0),
114+
padding: (onLeft) ? EdgeInsets.only(right: 32.0) : EdgeInsets.only(left: 32.0),
115+
child: Text(s)),
116+
),
117+
);
118+
}
119+
120+
class _PaintV extends CustomPainter {
121+
bool onLeft;
122+
123+
_PaintV({this.onLeft = false});
124+
125+
@override
126+
void paint(Canvas canvas, Size size) {
127+
final paint = Paint();
128+
129+
paint.color = Colors.black;
130+
paint.strokeWidth = 4.0;
131+
132+
// top line
133+
(onLeft)
134+
? canvas.drawLine(Offset(0, 0), Offset(size.width, size.height / 2), paint)
135+
: canvas.drawLine(Offset(size.width, 0), Offset(0, size.height / 2), paint);
136+
137+
// bottom line
138+
(onLeft)
139+
? canvas.drawLine(Offset(0, size.height), Offset(size.width, size.height / 2), paint)
140+
: canvas.drawLine(Offset(size.width, size.height), Offset(0, size.height / 2), paint);
141+
}
142+
143+
@override
144+
bool shouldRepaint(CustomPainter oldDelegate) => false;
8145
}

0 commit comments

Comments
 (0)