|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import 'package:huixiang/community/community_child_page.dart';
|
|
|
|
import 'package:huixiang/home/huixiang_brand_page.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_tab.dart';
|
|
|
|
|
|
|
|
import 'community_course.dart';
|
|
|
|
import 'headlines/article_page.dart';
|
|
|
|
|
|
|
|
class CommunityPage extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _CommunityPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CommunityPage extends State<CommunityPage>
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
TabController tabcontroller;
|
|
|
|
|
|
|
|
CommunityChildPage guanzhu,tuijian ;
|
|
|
|
final GlobalKey tuijianKey = GlobalKey();
|
|
|
|
final GlobalKey guanzhuKey = GlobalKey();
|
|
|
|
|
|
|
|
List<String> lables = [
|
|
|
|
"关注",
|
|
|
|
"分享健康",
|
|
|
|
"了解健康",
|
|
|
|
"学习健康",
|
|
|
|
"关于回乡",
|
|
|
|
// "直播",
|
|
|
|
];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
if (tabcontroller == null)
|
|
|
|
tabcontroller = TabController(length: lables.length, vsync: this, initialIndex: 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
_toRelease() async {
|
|
|
|
await Navigator.of(context).pushNamed('/router/release_dynamic');
|
|
|
|
if(tabcontroller.index == 0){
|
|
|
|
CommunityChildPageState page = guanzhuKey.currentState;
|
|
|
|
page.onRefresh();
|
|
|
|
}else if(tabcontroller.index == 1){
|
|
|
|
CommunityChildPageState page = tuijianKey.currentState;
|
|
|
|
page.onRefresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: MyAppBar(
|
|
|
|
leading: false,
|
|
|
|
titleChild: PreferredSize(
|
|
|
|
preferredSize: Size(
|
|
|
|
MediaQuery.of(context).size.width - 60,
|
|
|
|
38.h,
|
|
|
|
),
|
|
|
|
child: TabBar(
|
|
|
|
controller: tabcontroller,
|
|
|
|
automaticIndicatorColorAdjustment: true,
|
|
|
|
isScrollable: true,
|
|
|
|
indicatorWeight: 2,
|
|
|
|
indicatorColor: Color(0xFF39B54A),
|
|
|
|
labelPadding: EdgeInsets.only(left: 8.w, right: 8.w),
|
|
|
|
indicatorSize: TabBarIndicatorSize.label,
|
|
|
|
unselectedLabelStyle: TextStyle(
|
|
|
|
fontSize: 15.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 18.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
labelColor: Colors.black,
|
|
|
|
tabs: lables.map((e) => MyTab(text: e)).toList(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
_toRelease();
|
|
|
|
},
|
|
|
|
action: GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
child: Container(color: Colors.transparent,
|
|
|
|
padding: EdgeInsets.only(left: 20,right: 20),
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
"assets/svg/shequ_fabu.svg",
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
),)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
body: Container(
|
|
|
|
padding: EdgeInsets.only(bottom: 76.h),
|
|
|
|
child: TabBarView(
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
children: lables.map((e) {
|
|
|
|
if (e == "关于回乡") {
|
|
|
|
return BrandPage();
|
|
|
|
}else if(e == "了解健康"){
|
|
|
|
return ArticlePage();
|
|
|
|
}else if(e == "学习健康"){
|
|
|
|
return CommunityCourse();
|
|
|
|
}
|
|
|
|
else if(e == "分享健康"){
|
|
|
|
if (tuijian == null){
|
|
|
|
tuijian = CommunityChildPage(tuijianKey,"分享健康");
|
|
|
|
}
|
|
|
|
return tuijian;
|
|
|
|
}else if(e == "关注"){
|
|
|
|
if (guanzhu == null){
|
|
|
|
guanzhu = CommunityChildPage(guanzhuKey,"关注");
|
|
|
|
}
|
|
|
|
return guanzhu;
|
|
|
|
}
|
|
|
|
}).toList(),
|
|
|
|
controller: tabcontroller,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|