|
|
@@ -35,7 +35,9 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
_tabController = TabController(initialIndex: 0, vsync: this, length: 2);
|
|
|
- DefaultAssetBundle.of(context).loadString('mockdata/news.json').then((value) {
|
|
|
+ DefaultAssetBundle.of(context)
|
|
|
+ .loadString('mockdata/news.json')
|
|
|
+ .then((value) {
|
|
|
var data = JsonDecoder().convert(value);
|
|
|
print(data);
|
|
|
setState(() {
|
|
|
@@ -53,16 +55,16 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Scaffold(
|
|
|
- backgroundColor: COLOR_PAGE_BG,
|
|
|
body: CustomScrollView(
|
|
|
slivers: <Widget>[
|
|
|
SliverAppBar(
|
|
|
- expandedHeight: 355,
|
|
|
+ expandedHeight: 395,
|
|
|
pinned: true,
|
|
|
elevation: 0,
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
background: Container(
|
|
|
color: Colors.white,
|
|
|
+ margin: EdgeInsets.only(bottom: 40),
|
|
|
child: Stack(
|
|
|
children: [
|
|
|
Image.asset(
|
|
|
@@ -83,23 +85,29 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
borderRadius: BorderRadius.all(
|
|
|
Radius.circular(4),
|
|
|
)),
|
|
|
- child: Row(
|
|
|
- children: [
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(left: 10),
|
|
|
- child: Image.asset(
|
|
|
- 'img/icon_search.png',
|
|
|
- width: 16,
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- margin: EdgeInsets.only(left: 5),
|
|
|
- child: Text(
|
|
|
- '请输入关键字搜索',
|
|
|
- style: TextStyle(fontSize: 11, color: COLOR_TEXT_3),
|
|
|
+ child: InkWell(
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 10),
|
|
|
+ child: Image.asset(
|
|
|
+ 'img/icon_search.png',
|
|
|
+ width: 16,
|
|
|
+ ),
|
|
|
),
|
|
|
- )
|
|
|
- ],
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 5),
|
|
|
+ child: Text(
|
|
|
+ '请输入关键字搜索',
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 11, color: COLOR_TEXT_3),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ onTap: () {
|
|
|
+ Navigator.pushNamed(context, '/search');
|
|
|
+ },
|
|
|
),
|
|
|
),
|
|
|
Container(
|
|
|
@@ -107,8 +115,14 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
margin: EdgeInsets.fromLTRB(16, 0, 16, 20),
|
|
|
decoration: BoxDecoration(
|
|
|
color: Colors.white,
|
|
|
- borderRadius: BorderRadius.all(Radius.circular(4)),
|
|
|
- boxShadow: [BoxShadow(color: Color(0x1FEE4444), offset: Offset(0, 6), blurRadius: 16)]),
|
|
|
+ borderRadius:
|
|
|
+ BorderRadius.all(Radius.circular(4)),
|
|
|
+ boxShadow: [
|
|
|
+ BoxShadow(
|
|
|
+ color: Color(0x1FEE4444),
|
|
|
+ offset: Offset(0, 6),
|
|
|
+ blurRadius: 16)
|
|
|
+ ]),
|
|
|
child: ClipRRect(
|
|
|
child: Column(
|
|
|
children: [
|
|
|
@@ -116,7 +130,8 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
height: 160,
|
|
|
child: Swiper(
|
|
|
itemCount: banners.length,
|
|
|
- itemBuilder: (BuildContext context, int index) {
|
|
|
+ itemBuilder:
|
|
|
+ (BuildContext context, int index) {
|
|
|
return CachedNetworkImage(
|
|
|
imageUrl: banners[index]['pic'],
|
|
|
fit: BoxFit.cover,
|
|
|
@@ -127,16 +142,22 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
_bannerIndex = index;
|
|
|
});
|
|
|
},
|
|
|
- pagination: SwiperCustomPagination(
|
|
|
- builder: (BuildContext context, SwiperPluginConfig config) {
|
|
|
+ pagination: SwiperCustomPagination(builder:
|
|
|
+ (BuildContext context,
|
|
|
+ SwiperPluginConfig config) {
|
|
|
List<Widget> list = [];
|
|
|
- for (int i = 0; i < config.itemCount; i++) {
|
|
|
+ for (int i = 0;
|
|
|
+ i < config.itemCount;
|
|
|
+ i++) {
|
|
|
list.add(Container(
|
|
|
width: 8,
|
|
|
height: 2,
|
|
|
- margin: EdgeInsets.only(left: 3, right: 3),
|
|
|
+ margin: EdgeInsets.only(
|
|
|
+ left: 3, right: 3),
|
|
|
decoration: BoxDecoration(
|
|
|
- color: i == config.activeIndex ? Colors.white : Color(0x75FFFFFF)),
|
|
|
+ color: i == config.activeIndex
|
|
|
+ ? Colors.white
|
|
|
+ : Color(0x75FFFFFF)),
|
|
|
));
|
|
|
}
|
|
|
return Container(
|
|
|
@@ -144,7 +165,8 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
margin: EdgeInsets.only(bottom: 6),
|
|
|
child: Row(
|
|
|
children: list,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ mainAxisAlignment:
|
|
|
+ MainAxisAlignment.center,
|
|
|
),
|
|
|
);
|
|
|
}),
|
|
|
@@ -155,7 +177,8 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
alignment: Alignment.centerLeft,
|
|
|
padding: EdgeInsets.only(left: 12, right: 12),
|
|
|
child: Text(banners[_bannerIndex]['title'],
|
|
|
- maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
|
+ maxLines: 1,
|
|
|
+ overflow: TextOverflow.ellipsis),
|
|
|
)
|
|
|
],
|
|
|
),
|
|
|
@@ -174,39 +197,76 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
alignment: Alignment.center,
|
|
|
),
|
|
|
centerTitle: true,
|
|
|
- ),
|
|
|
- SliverToBoxAdapter(
|
|
|
- child: Container(
|
|
|
- width: 150,
|
|
|
- height: 40,
|
|
|
- margin: EdgeInsets.only(bottom: 10),
|
|
|
- child: TabBar(
|
|
|
- isScrollable: true,
|
|
|
- indicatorSize: TabBarIndicatorSize.label,
|
|
|
- indicatorColor: COLOR_PRIMARY,
|
|
|
- labelColor: COLOR_PRIMARY,
|
|
|
- unselectedLabelColor: Color(0xFF939599),
|
|
|
- labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
|
|
- unselectedLabelStyle: TextStyle(fontWeight: FontWeight.normal, fontSize: 14),
|
|
|
- tabs: [
|
|
|
- Container(
|
|
|
- width: 80,
|
|
|
- child: Tab(text: '通知公告'),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- width: 80,
|
|
|
- child: Tab(text: '政策法规'),
|
|
|
- ),
|
|
|
- ],
|
|
|
- controller: _tabController,
|
|
|
- onTap: (index) {
|
|
|
- setState(() {
|
|
|
- _tabIndex = index;
|
|
|
- });
|
|
|
- },
|
|
|
+ bottom: PreferredSize(
|
|
|
+ child: Container(
|
|
|
+ height: 40,
|
|
|
+ width: double.infinity,
|
|
|
+ color: Colors.white,
|
|
|
+ child: TabBar(
|
|
|
+ isScrollable: true,
|
|
|
+ indicatorSize: TabBarIndicatorSize.label,
|
|
|
+ indicatorColor: Color(0xFFEA2D2F),
|
|
|
+ labelColor: COLOR_PRIMARY,
|
|
|
+ unselectedLabelColor: Color(0xFF939599),
|
|
|
+ labelStyle:
|
|
|
+ TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
|
|
+ unselectedLabelStyle:
|
|
|
+ TextStyle(fontWeight: FontWeight.normal, fontSize: 14),
|
|
|
+ tabs: [
|
|
|
+ Container(
|
|
|
+ width: 80,
|
|
|
+ child: Tab(text: '通知公告'),
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ width: 80,
|
|
|
+ child: Tab(text: '政策法规'),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ controller: _tabController,
|
|
|
+ onTap: (index) {
|
|
|
+ setState(() {
|
|
|
+ _tabIndex = index;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ ),
|
|
|
),
|
|
|
+ preferredSize: Size.fromHeight(50),
|
|
|
),
|
|
|
),
|
|
|
+// SliverToBoxAdapter(
|
|
|
+// child: Container(
|
|
|
+// width: 150,
|
|
|
+// height: 40,
|
|
|
+// margin: EdgeInsets.only(bottom: 10),
|
|
|
+// child: TabBar(
|
|
|
+// isScrollable: true,
|
|
|
+// indicatorSize: TabBarIndicatorSize.label,
|
|
|
+// indicatorColor: COLOR_PRIMARY,
|
|
|
+// labelColor: COLOR_PRIMARY,
|
|
|
+// unselectedLabelColor: Color(0xFF939599),
|
|
|
+// labelStyle:
|
|
|
+// TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
|
|
+// unselectedLabelStyle:
|
|
|
+// TextStyle(fontWeight: FontWeight.normal, fontSize: 14),
|
|
|
+// tabs: [
|
|
|
+// Container(
|
|
|
+// width: 80,
|
|
|
+// child: Tab(text: '通知公告'),
|
|
|
+// ),
|
|
|
+// Container(
|
|
|
+// width: 80,
|
|
|
+// child: Tab(text: '政策法规'),
|
|
|
+// ),
|
|
|
+// ],
|
|
|
+// controller: _tabController,
|
|
|
+// onTap: (index) {
|
|
|
+// setState(() {
|
|
|
+// _tabIndex = index;
|
|
|
+// });
|
|
|
+// },
|
|
|
+// ),
|
|
|
+// ),
|
|
|
+// ),
|
|
|
SliverList(
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
(context, index) {
|
|
|
@@ -218,9 +278,11 @@ class _NewsState extends State<News> with SingleTickerProviderStateMixin {
|
|
|
endIndent: 16,
|
|
|
);
|
|
|
}
|
|
|
- return ItemNewsList((_tabIndex == 0 ? news1 : news2)[index ~/ 2]);
|
|
|
+ return ItemNewsList(
|
|
|
+ (_tabIndex == 0 ? news1 : news2)[index ~/ 2]);
|
|
|
},
|
|
|
- childCount: (_tabIndex == 0 ? news1.length : news2.length) * 2 - 1,
|
|
|
+ childCount:
|
|
|
+ (_tabIndex == 0 ? news1.length : news2.length) * 2 - 1,
|
|
|
),
|
|
|
),
|
|
|
],
|