four_page.dart 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. import 'package:flutter/material.dart';
  2. import 'package:luojigou_thinking_core/src/view/ljg_defined_app_bar/ljg_defined_app_bar.dart';
  3. class FourPage extends StatefulWidget {
  4. @override
  5. FourPageState createState() => new FourPageState();
  6. }
  7. class FourPageState extends State<FourPage> {
  8. late List<CheckTestModel> _mdoelList;
  9. @override
  10. void initState() {
  11. // TODO: implement initState
  12. super.initState();
  13. _mdoelList = List.generate(10, (index) {
  14. return CheckTestModel(index % 2 == 0, "王小二" + index.toString());
  15. }).toList();
  16. }
  17. @override
  18. Widget build(BuildContext context) {
  19. return Scaffold(
  20. backgroundColor: Color(0xFFF5F6FA),
  21. appBar: LJGDefinedAppBar(
  22. navigationBarBackgroundColor: Colors.white,
  23. title: '发送给家长',
  24. trailingWidget: GestureDetector(
  25. onTap: () {},
  26. child: Container(
  27. padding: EdgeInsets.symmetric(horizontal: 16),
  28. alignment: Alignment.center,
  29. color: Colors.transparent,
  30. child: Text(
  31. '确定',
  32. style: TextStyle(
  33. fontSize: 14,
  34. height: 1,
  35. color: Color(0xFF5F87F0),
  36. fontWeight: FontWeight.w600),
  37. ),
  38. ),
  39. ),
  40. ),
  41. body: Container(
  42. // color: Color(0xFFF5F6FA),
  43. margin: EdgeInsets.symmetric(horizontal: 16),
  44. child: Column(
  45. children: [
  46. HeaderView(),
  47. Expanded(
  48. child: ListView.separated(
  49. padding: EdgeInsets.only(bottom: 15),
  50. itemBuilder: (_, index) {
  51. if (index == 0) {
  52. return FirstCell();
  53. } else if (index == _mdoelList.length - 1) {
  54. return LastCell();
  55. }
  56. return NormalCell(
  57. model: _mdoelList[index - 1],
  58. );
  59. },
  60. separatorBuilder: (_, index) {
  61. return DividingLinesView(index: index);
  62. },
  63. itemCount: _mdoelList.length + 2)),
  64. ],
  65. ),
  66. ),
  67. );
  68. }
  69. }
  70. class HeaderView extends StatelessWidget {
  71. @override
  72. Widget build(BuildContext context) {
  73. return Container(
  74. margin: EdgeInsets.symmetric(vertical: 12),
  75. padding: EdgeInsets.only(top: 20, bottom: 20, left: 12, right: 10),
  76. decoration: BoxDecoration(
  77. color: Colors.white,
  78. borderRadius: BorderRadius.circular(10),
  79. ),
  80. child: Row(
  81. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  82. children: [
  83. Text(
  84. "全部家长",
  85. style: TextStyle(
  86. color: Colors.black,
  87. fontSize: 16,
  88. height: 22 / 16,
  89. fontWeight: FontWeight.w500),
  90. ),
  91. CheckedIcon(WH: 23)
  92. ],
  93. ),
  94. );
  95. }
  96. }
  97. class FirstCell extends StatelessWidget {
  98. @override
  99. Widget build(BuildContext context) {
  100. return Container(
  101. padding: EdgeInsets.only(top: 25, bottom: 22, left: 12, right: 18),
  102. decoration: BoxDecoration(
  103. color: Colors.white,
  104. borderRadius: BorderRadius.only(
  105. topLeft: Radius.circular(10), topRight: Radius.circular(10)),
  106. ),
  107. child: Row(
  108. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  109. children: [
  110. Column(
  111. crossAxisAlignment: CrossAxisAlignment.start,
  112. children: [
  113. Text(
  114. "指定家长(93个家长)",
  115. style: TextStyle(
  116. color: Colors.black,
  117. fontSize: 16,
  118. height: 22 / 16,
  119. fontWeight: FontWeight.w500),
  120. ),
  121. SizedBox(height: 4),
  122. Text(
  123. "选择家长分享评估报告",
  124. style: TextStyle(
  125. color: Color(0xFF9C9AAB),
  126. fontSize: 12,
  127. height: 17 / 12,
  128. fontWeight: FontWeight.w400),
  129. ),
  130. ],
  131. ),
  132. Container(
  133. width: 14,
  134. height: 8,
  135. child: CustomPaint(
  136. painter: TrianglePainter(),
  137. ),
  138. )
  139. ],
  140. ),
  141. );
  142. }
  143. }
  144. class NormalCell extends StatelessWidget {
  145. final CheckTestModel model;
  146. const NormalCell({
  147. Key? key,
  148. required this.model,
  149. }) : super(key: key);
  150. @override
  151. Widget build(BuildContext context) {
  152. return Container(
  153. color: Colors.white,
  154. // margin: EdgeInsets.symmetric(vertical: 12),
  155. padding: EdgeInsets.only(left: 18, top: 21, bottom: 21),
  156. child: Row(
  157. children: [
  158. model.state
  159. ? CheckedIcon(WH: 18)
  160. : UncheckedIcon(
  161. WH: 18,
  162. ),
  163. SizedBox(width: 15),
  164. Text(
  165. "王小二",
  166. style: TextStyle(
  167. color: Colors.black,
  168. fontSize: 16,
  169. height: 22 / 16,
  170. fontWeight: FontWeight.w400),
  171. ),
  172. ],
  173. ),
  174. );
  175. }
  176. }
  177. class LastCell extends StatelessWidget {
  178. @override
  179. Widget build(BuildContext context) {
  180. return Container(
  181. height: 49,
  182. decoration: BoxDecoration(
  183. color: Colors.white,
  184. borderRadius: BorderRadius.only(
  185. bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10)),
  186. ),
  187. );
  188. }
  189. }
  190. class TrianglePainter extends CustomPainter {
  191. @override
  192. void paint(Canvas canvas, Size size) {
  193. // TODO: implement paint
  194. Paint paint = Paint()
  195. ..color = Color(0xFFCACACA)
  196. ..strokeWidth = 1.5
  197. ..style = PaintingStyle.stroke;
  198. Path path = Path();
  199. path.moveTo(0, size.height);
  200. path.lineTo(size.width / 2, 0);
  201. path.lineTo(size.width, size.height);
  202. // path.close();
  203. canvas.drawPath(path, paint);
  204. }
  205. @override
  206. bool shouldRepaint(covariant CustomPainter oldDelegate) {
  207. // TODO: implement shouldRepaint
  208. return true;
  209. }
  210. }
  211. class DividingLinesView extends StatelessWidget {
  212. final int index;
  213. const DividingLinesView({
  214. Key? key,
  215. required this.index,
  216. }) : super(key: key);
  217. @override
  218. Widget build(BuildContext context) {
  219. return Row(
  220. children: [
  221. Container(
  222. width: index == 0 ? 0 : 16,
  223. height: 1,
  224. color: Colors.white,
  225. ),
  226. Expanded(
  227. child: Container(
  228. height: 1,
  229. color: Color(0xFFEEEEEE),
  230. ),
  231. ),
  232. ],
  233. );
  234. }
  235. }
  236. //未选中Icon
  237. class UncheckedIcon extends StatelessWidget {
  238. final double WH;
  239. const UncheckedIcon({
  240. Key? key,
  241. required this.WH,
  242. }) : super(key: key);
  243. @override
  244. Widget build(BuildContext context) {
  245. return Container(
  246. width: WH,
  247. height: WH,
  248. decoration: BoxDecoration(
  249. borderRadius: BorderRadius.circular(WH / 2),
  250. border: Border.all(color: Color(0xFFD1D1D1), width: 1.3)),
  251. );
  252. }
  253. }
  254. //选中Icon
  255. class CheckedIcon extends StatelessWidget {
  256. final double WH;
  257. const CheckedIcon({
  258. Key? key,
  259. required this.WH,
  260. }) : super(key: key);
  261. @override
  262. Widget build(BuildContext context) {
  263. return Container(
  264. width: WH,
  265. height: WH,
  266. decoration: BoxDecoration(
  267. borderRadius: BorderRadius.circular(WH / 2),
  268. color: Color(0xFF5F87F0)),
  269. child: Icon(
  270. Icons.check_rounded,
  271. color: Colors.white,
  272. size: WH - 6,
  273. ),
  274. );
  275. }
  276. }
  277. class CheckTestModel {
  278. final bool state;
  279. final String title;
  280. CheckTestModel(this.state, this.title);
  281. }