demo.dart 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/consts/styles.dart';
  3. class DashboardDemoView extends StatelessWidget {
  4. const DashboardDemoView({super.key});
  5. @override
  6. Widget build(BuildContext context) {
  7. const borderRadius = GlobalStyles.borderRadiusValue;
  8. return ListView(
  9. children: [
  10. Container(
  11. height: 150,
  12. padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
  13. decoration: const BoxDecoration(
  14. color: Colors.white,
  15. borderRadius: BorderRadius.all(borderRadius),
  16. ),
  17. child: Row(
  18. mainAxisAlignment: MainAxisAlignment.spaceAround,
  19. children: const [
  20. _CountCircleWidget(
  21. count: 100,
  22. title: "日新增签约人数",
  23. color: Colors.red,
  24. ),
  25. _CountCircleWidget(
  26. count: 100,
  27. title: "已随访总人数",
  28. color: Colors.purple,
  29. ),
  30. _CountCircleWidget(
  31. count: 100,
  32. title: "累计签约总人数",
  33. color: Colors.green,
  34. ),
  35. _CountCircleWidget(
  36. count: 100,
  37. title: "签约逾期总数",
  38. color: Colors.blue,
  39. ),
  40. ],
  41. ),
  42. ),
  43. const SizedBox(height: 10),
  44. Column(
  45. children: [
  46. Container(
  47. height: 40,
  48. padding: const EdgeInsets.symmetric(horizontal: 14),
  49. decoration: BoxDecoration(
  50. color: Theme.of(context).primaryColor,
  51. borderRadius: const BorderRadius.only(
  52. topLeft: borderRadius,
  53. topRight: borderRadius,
  54. ),
  55. ),
  56. child: Row(
  57. children: const [
  58. Icon(Icons.notifications_active_outlined,
  59. color: Colors.white),
  60. Text(
  61. "工作提醒",
  62. style: TextStyle(
  63. color: Colors.white,
  64. fontSize: 18,
  65. fontWeight: FontWeight.bold,
  66. ),
  67. ),
  68. ],
  69. ),
  70. ),
  71. Container(
  72. padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
  73. decoration: const BoxDecoration(
  74. color: Colors.white,
  75. borderRadius: BorderRadius.only(
  76. bottomLeft: borderRadius,
  77. bottomRight: borderRadius,
  78. ),
  79. ),
  80. // height: 100,
  81. child: _DemoTable(),
  82. ),
  83. ],
  84. ),
  85. ],
  86. );
  87. }
  88. }
  89. class _DemoTable extends StatelessWidget {
  90. @override
  91. Widget build(BuildContext context) {
  92. final source = [
  93. "肺结核",
  94. "冠心病",
  95. "脑卒中",
  96. "严重精神病",
  97. "糖尿病",
  98. "高血压",
  99. "老年人",
  100. "月产妇",
  101. "儿童",
  102. ];
  103. final rows = <TableRow>[];
  104. for (var i = 0; i < source.length; i++) {
  105. rows.add(_buildRow(source[i], i));
  106. }
  107. return Table(
  108. children: [
  109. TableRow(
  110. decoration: const BoxDecoration(
  111. color: Color.fromRGBO(215, 234, 255, 1),
  112. ),
  113. children: [
  114. _buildHeaderCell("重点人群"),
  115. _buildHeaderCell("首次随访未进行"),
  116. _buildHeaderCell("本日应随访"),
  117. _buildHeaderCell("本周应随访"),
  118. _buildHeaderCell("逾期随访"),
  119. ],
  120. ),
  121. ...rows,
  122. ],
  123. );
  124. }
  125. TableRow _buildRow(String title, int index) {
  126. return TableRow(
  127. decoration: index % 2 == 0
  128. ? null
  129. : const BoxDecoration(
  130. color: Color.fromRGBO(233, 244, 255, 1),
  131. ),
  132. children: [
  133. _buildDataCell(title),
  134. _buildDataCell("0"),
  135. _buildDataCell("0"),
  136. _buildDataCell("0"),
  137. _buildDataCell("0"),
  138. ],
  139. );
  140. }
  141. TableCell _buildHeaderCell(String title) {
  142. return TableCell(
  143. child: Container(
  144. alignment: Alignment.center,
  145. height: 37,
  146. child: Text(
  147. title,
  148. style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
  149. ),
  150. ),
  151. );
  152. }
  153. TableCell _buildDataCell(String title) {
  154. return TableCell(
  155. child: Container(
  156. alignment: Alignment.center,
  157. height: 37,
  158. child: Text(
  159. title,
  160. style: const TextStyle(fontSize: 14),
  161. ),
  162. ),
  163. );
  164. }
  165. }
  166. class _CountCircleWidget extends StatelessWidget {
  167. final int count;
  168. final String title;
  169. final Color color;
  170. const _CountCircleWidget({
  171. required this.count,
  172. required this.title,
  173. required this.color,
  174. });
  175. @override
  176. Widget build(BuildContext context) {
  177. return Column(
  178. crossAxisAlignment: CrossAxisAlignment.center,
  179. mainAxisAlignment: MainAxisAlignment.center,
  180. children: [
  181. Container(
  182. width: 94,
  183. height: 94,
  184. decoration: BoxDecoration(
  185. border: Border.all(
  186. width: 5,
  187. color: color,
  188. ),
  189. borderRadius: BorderRadius.circular(94 / 2),
  190. ),
  191. alignment: Alignment.center,
  192. child: Text(
  193. count.toString(),
  194. style: TextStyle(
  195. color: color,
  196. fontSize: 20,
  197. fontWeight: FontWeight.bold,
  198. ),
  199. ),
  200. ),
  201. const SizedBox(height: 8),
  202. Text(
  203. title,
  204. style: const TextStyle(fontSize: 14),
  205. ),
  206. ],
  207. );
  208. }
  209. }