four_page.dart 7.1 KB

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