-
Notifications
You must be signed in to change notification settings - Fork 11
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
11 changed files
with
591 additions
and
101 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
101 changes: 101 additions & 0 deletions
101
app/lib/screens/study/report/sections/results_descriptive_statistics.dart
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,101 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
// Row 6: Descriptive Statistics | ||
class DescriptiveStatisticsWidget extends StatelessWidget { | ||
|
||
const DescriptiveStatisticsWidget({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
child: Column( | ||
children: <Widget>[ | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: <Widget>[ | ||
Icon( | ||
true ? Icons.arrow_drop_up : Icons.arrow_drop_down, | ||
), | ||
], | ||
), | ||
if (true) | ||
Padding( | ||
padding: const EdgeInsets.only(top: 8.0), | ||
child: Column( | ||
children: [ | ||
_buildStatisticsTable(), | ||
const Padding( | ||
padding: EdgeInsets.only(top: 8.0), | ||
child: Text( | ||
'p-value: 0.01\nLevel of significance: α = 0.05', | ||
style: TextStyle(fontSize: 8, color: Colors.black), | ||
textAlign: TextAlign.center, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
Widget _buildStatisticsTable() { | ||
return Container( | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(8.0), | ||
color: Colors.grey[200], | ||
boxShadow: [ | ||
BoxShadow( | ||
color: Colors.grey.withOpacity(0.5), | ||
spreadRadius: 2, | ||
blurRadius: 5, | ||
offset: Offset(0, 3), | ||
), | ||
], | ||
), | ||
child: Table( | ||
border: TableBorder.all(color: Colors.grey), | ||
columnWidths: const { | ||
0: FixedColumnWidth(65), | ||
1: FixedColumnWidth(65), | ||
2: FixedColumnWidth(50), | ||
3: FixedColumnWidth(50), | ||
4: FixedColumnWidth(50), | ||
5: FixedColumnWidth(65), | ||
}, | ||
children: [ | ||
_buildTableRow( | ||
['Intervention', 'Observations', 'Average', 'Min', 'Max', 'Variance'], | ||
isHeader: true, | ||
), | ||
_buildTableRow(['Tea', '14', '5.0', '4', '3', '1.2']), | ||
_buildTableRow(['No Tea', '14', '7.5', '8', '6', '2']), | ||
], | ||
), | ||
); | ||
} | ||
|
||
TableRow _buildTableRow(List<String> cells, {bool isHeader = false}) { | ||
return TableRow( | ||
children: cells.map((cell) { | ||
return _buildTableCell(cell, isHeader: isHeader); | ||
}).toList(), | ||
); | ||
} | ||
|
||
Widget _buildTableCell(String text, {bool isHeader = false}) { | ||
return Padding( | ||
padding: const EdgeInsets.all(6.0), | ||
child: Text( | ||
text, | ||
style: TextStyle( | ||
fontSize: isHeader ? 8 : 8, | ||
fontWeight: isHeader ? FontWeight.bold : FontWeight.normal, | ||
color: isHeader ? Colors.black : Colors.grey[800], | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
); | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
app/lib/screens/study/report/sections/results_gauge.dart
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,125 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:syncfusion_flutter_gauges/gauges.dart'; | ||
|
||
// Row 3: Gauge title | ||
class GaugeTitleWidget extends StatelessWidget { | ||
const GaugeTitleWidget({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Center( | ||
child: Text( | ||
'Average Sleep Quality', | ||
style: TextStyle(fontSize: 16, color: Colors.blueAccent), | ||
), | ||
); | ||
} | ||
} | ||
|
||
// Row 4: Two gauges | ||
class GaugesWidget extends StatelessWidget { | ||
const GaugesWidget({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
children: <Widget>[ | ||
Expanded( | ||
child: Column( | ||
children: <Widget>[ | ||
Container( | ||
width: 140, // Set the desired width | ||
height: 140, // Set the desired height | ||
child: createGauge(0, 10, 10, 5), // min, max, steps, value | ||
), | ||
Text('With Tea', style: TextStyle(fontSize: 14)), | ||
], | ||
), | ||
), | ||
Expanded( | ||
child: Column( | ||
children: <Widget>[ | ||
Container( | ||
width: 140, // Set the desired width | ||
height: 140, // Set the desired height | ||
child: createGauge(0, 10, 10, 7.5), // min, max, steps, value | ||
), | ||
Text('Without Tea', style: TextStyle(fontSize: 14)), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
|
||
// Create gauge with min and max values, steps to switch colors, value to point at | ||
Widget createGauge(double min, double max, int steps, double value) { | ||
// List of colors | ||
List<Color> colors = [ | ||
Colors.red[900]!, | ||
Colors.red[700]!, | ||
Colors.red[500]!, | ||
Colors.orange[900]!, | ||
Colors.orange[700]!, | ||
Colors.yellow[700]!, | ||
Colors.yellow[500]!, | ||
Colors.green[300]!, | ||
Colors.green[500]!, | ||
Colors.green[700]! | ||
]; | ||
|
||
// Create gauge ranges based on steps and the color list | ||
List<GaugeRange> createRanges() { | ||
double stepValue = (max - min) / steps; | ||
return List.generate(steps, (index) { | ||
double start = min + (index * stepValue); | ||
double end = start + stepValue; | ||
return GaugeRange( | ||
startValue: start, | ||
endValue: end, | ||
color: colors[index], | ||
); | ||
}); | ||
} | ||
|
||
return SfRadialGauge( | ||
axes: <RadialAxis>[ | ||
RadialAxis( | ||
minimum: min, | ||
maximum: max, | ||
pointers: <GaugePointer>[ | ||
NeedlePointer( | ||
value: value, | ||
needleColor: Colors.blue, | ||
needleEndWidth: 7, | ||
), | ||
], | ||
ranges: createRanges(), | ||
annotations: <GaugeAnnotation>[ | ||
GaugeAnnotation( | ||
widget: RichText( | ||
text: TextSpan( | ||
children: <TextSpan>[ | ||
TextSpan( | ||
text: '$value', | ||
style: const TextStyle( | ||
fontSize: 24, | ||
fontWeight: FontWeight.bold, | ||
color: Colors.blue), | ||
), | ||
TextSpan( | ||
text: '/$max', | ||
style: const TextStyle(fontSize: 10, color: Colors.blue), | ||
), | ||
], | ||
), | ||
), | ||
angle: 90, | ||
positionFactor: 0.8, | ||
), | ||
], | ||
), | ||
], | ||
); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
app/lib/screens/study/report/sections/results_textual_summary.dart
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,82 @@ | ||
import 'package:flutter/material.dart'; | ||
// Row 2: Textual Summary | ||
|
||
class TextualSummaryWidget extends StatelessWidget { | ||
const TextualSummaryWidget({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
children: <Widget>[ | ||
Expanded( | ||
child: Column( | ||
children: <Widget>[ | ||
Container( | ||
padding: const EdgeInsets.all(8.0), | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
border: Border.all(color: Colors.grey), | ||
borderRadius: BorderRadius.circular(12.0), | ||
), | ||
child: const Column( | ||
children: <Widget>[ | ||
Text( | ||
'With tea', | ||
style: TextStyle( | ||
fontSize: 16, | ||
color: Colors.green, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
SizedBox(height: 4), // SizedBox for spacing | ||
Text( | ||
'Your sleep quality was slightly better', // Text 1 for box 1 | ||
style: TextStyle( | ||
fontSize: 12, | ||
color: Colors.black, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
Expanded( | ||
child: Column( | ||
children: <Widget>[ | ||
Container( | ||
padding: const EdgeInsets.all(8.0), | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
border: Border.all(color: Colors.grey), | ||
borderRadius: BorderRadius.circular(12.0), | ||
), | ||
child: const Column( | ||
children: <Widget>[ | ||
Text( | ||
'Without tea', | ||
style: TextStyle( | ||
fontSize: 16, | ||
color: Colors.red, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
SizedBox(height: 4), // SizedBox for spacing | ||
Text( | ||
'Your sleep quality was slightly worse', // Text 2 for box 2 | ||
style: TextStyle( | ||
fontSize: 12, | ||
color: Colors.black, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.