demo.dart 5.6 KB

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