qa.dart 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. import 'package:flutter/material.dart';
  2. import 'package:jmrh/constant/styles.dart';
  3. import 'package:jmrh/widget/item_post.dart';
  4. import 'package:jmrh/widget/item_qa.dart';
  5. class Qa extends StatefulWidget {
  6. Qa({Key key}) : super(key: key);
  7. @override
  8. _QaState createState() => _QaState();
  9. }
  10. class _QaState extends State<Qa> {
  11. @override
  12. Widget build(BuildContext context) {
  13. return Scaffold(
  14. body: CustomScrollView(
  15. slivers: [
  16. SliverAppBar(
  17. pinned: true,
  18. floating: true,
  19. title: appbarTitle('学习交流', color: Colors.white),
  20. centerTitle: true,
  21. elevation: 0,
  22. bottom: PreferredSize(
  23. child: Container(
  24. decoration: BoxDecoration(color: COLOR_PRIMARY),
  25. child: Container(
  26. height: 32,
  27. margin: EdgeInsets.fromLTRB(16, 9, 16, 9),
  28. padding: EdgeInsets.only(left: 10),
  29. decoration: BoxDecoration(color: Colors.white.withAlpha((255 * 0.2).toInt())),
  30. child: InkWell(
  31. child: Row(
  32. children: <Widget>[
  33. Image.asset('img/icon_search_white.png'),
  34. Container(
  35. child: Text(
  36. '搜索...',
  37. style: TextStyle(fontSize: 12, color: Colors.white),
  38. ),
  39. margin: EdgeInsets.only(left: 6),
  40. ),
  41. ],
  42. ),
  43. onTap: () {
  44. Navigator.pushNamed(context, '/search');
  45. },
  46. ),
  47. ),
  48. ),
  49. preferredSize: Size.fromHeight(50)),
  50. ),
  51. SliverPadding(
  52. padding: EdgeInsets.only(left: 16, right: 16, top: 20),
  53. sliver: SliverGrid.count(
  54. crossAxisCount: 2,
  55. childAspectRatio: 2,
  56. crossAxisSpacing: 15,
  57. children: [
  58. InkWell(
  59. child: Container(
  60. decoration: BoxDecoration(color: Color(0xFFF2F7FF)),
  61. padding: EdgeInsets.fromLTRB(14, 18, 14, 18),
  62. height: 80,
  63. child: Row(
  64. children: [
  65. Expanded(
  66. child: Column(
  67. crossAxisAlignment: CrossAxisAlignment.start,
  68. mainAxisAlignment: MainAxisAlignment.center,
  69. children: [
  70. Text(
  71. '政民互动',
  72. style: TextStyle(color: Color(0xFF4074DB), fontWeight: FontWeight.bold),
  73. ),
  74. Container(
  75. margin: EdgeInsets.only(top: 3),
  76. child: Text(
  77. '有问题及时沟通',
  78. style: TextStyle(color: Color(0x804175DB), fontSize: 10),
  79. ),
  80. )
  81. ],
  82. ),
  83. ),
  84. Image.asset('img/hudong_icon_01.png')
  85. ],
  86. ),
  87. ),
  88. onTap: () {
  89. Navigator.of(context).pushNamed('/qaList');
  90. },
  91. ),
  92. InkWell(
  93. child: Container(
  94. decoration: BoxDecoration(color: Color(0xFFFEF2EC)),
  95. padding: EdgeInsets.fromLTRB(14, 18, 14, 18),
  96. height: 80,
  97. child: Row(
  98. children: [
  99. Expanded(
  100. child: Column(
  101. crossAxisAlignment: CrossAxisAlignment.start,
  102. mainAxisAlignment: MainAxisAlignment.center,
  103. children: [
  104. Text(
  105. '知识文库',
  106. style: TextStyle(color: Color(0xFFF47C4E), fontWeight: FontWeight.bold),
  107. ),
  108. Container(
  109. margin: EdgeInsets.only(top: 3),
  110. child: Text(
  111. '学习必备常识',
  112. style: TextStyle(color: Color(0xB3F47C4E), fontSize: 10),
  113. ),
  114. )
  115. ],
  116. ),
  117. ),
  118. Image.asset('img/hudong_icon_02.png')
  119. ],
  120. ),
  121. ),
  122. onTap: () {
  123. Navigator.of(context).pushNamed('/itemList');
  124. },
  125. )
  126. ],
  127. ),
  128. ),
  129. SliverPadding(
  130. padding: EdgeInsets.fromLTRB(16, 20, 16, 10),
  131. sliver: SliverToBoxAdapter(
  132. child: Column(
  133. crossAxisAlignment: CrossAxisAlignment.start,
  134. children: [
  135. Text(
  136. '官方问答',
  137. style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
  138. ),
  139. ClipRRect(
  140. borderRadius: BorderRadius.all(Radius.circular(4)),
  141. child: Container(
  142. child: Image.asset('img/img_02.png'),
  143. margin: EdgeInsets.only(top: 10),
  144. ),
  145. )
  146. ],
  147. ),
  148. ),
  149. ),
  150. SliverList(
  151. delegate: SliverChildBuilderDelegate(
  152. (BuildContext context, int index) {
  153. if (index.isOdd) {
  154. return Divider(indent: 16, endIndent: 16, height: 1);
  155. }
  156. return ItemQa();
  157. },
  158. childCount: 5,
  159. ),
  160. ),
  161. SliverToBoxAdapter(
  162. child: Container(
  163. alignment: Alignment.center,
  164. margin: EdgeInsets.only(top: 10),
  165. child: Container(
  166. padding: EdgeInsets.only(left: 6),
  167. width: 110,
  168. height: 30,
  169. decoration: BoxDecoration(
  170. color: COLOR_BORDER,
  171. borderRadius: BorderRadius.all(
  172. Radius.circular(15),
  173. ),
  174. ),
  175. child: InkWell(
  176. child: Row(
  177. mainAxisAlignment: MainAxisAlignment.center,
  178. children: [
  179. Text(
  180. '查看更多',
  181. style: TextStyle(color: COLOR_TEXT_HINT, fontSize: 13),
  182. ),
  183. Image.asset('img/icon_inter.png')
  184. ],
  185. ),
  186. onTap: () {
  187. Navigator.of(context).pushNamed('/qaList');
  188. },
  189. ),
  190. ),
  191. ),
  192. ),
  193. SliverToBoxAdapter(
  194. child: Container(
  195. child: Text(
  196. '热议话题',
  197. style: TextStyle(color: COLOR_TEXT_1, fontSize: 18, fontWeight: FontWeight.bold),
  198. ),
  199. padding: EdgeInsets.fromLTRB(16, 24, 0, 8),
  200. ),
  201. ),
  202. SliverList(
  203. delegate: SliverChildBuilderDelegate((context, index) {
  204. if (index.isOdd) {
  205. return Divider(color: COLOR_BORDER, indent: 16, endIndent: 16, height: 1);
  206. }
  207. return ItemPost();
  208. }, childCount: 5),
  209. )
  210. ],
  211. ),
  212. );
  213. }
  214. }