You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.1 KiB

3 years ago
import 'package:flutter/material.dart';
3 years ago
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';
3 years ago
3 years ago
import 'community_course.dart';
import 'headlines/article_page.dart';
3 years ago
3 years ago
class CommunityPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _CommunityPage();
}
}
3 years ago
class _CommunityPage extends State<CommunityPage>
with SingleTickerProviderStateMixin {
3 years ago
TabController tabcontroller;
List<String> lables = [
"关注",
"推荐",
"头条",
3 years ago
"课程",
3 years ago
"关于我们",
// "直播",
];
3 years ago
@override
3 years ago
void initState() {
super.initState();
if (tabcontroller == null)
3 years ago
tabcontroller = TabController(length: lables.length, vsync: this, initialIndex: 1);
3 years ago
}
3 years ago
_toRelease() async {
3 years ago
int tmpIndex = tabcontroller.index;
setState(() {
tabcontroller.index = (tabcontroller.index == lables.length -1)?0:tabcontroller.index+1;
});
3 years ago
var result = await Navigator.of(context).pushNamed('/router/release_dynamic');
3 years ago
setState(() {
tabcontroller.index = tmpIndex;
});
3 years ago
}
3 years ago
@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(),
),
),
3 years ago
onTap: () {
3 years ago
_toRelease();
3 years ago
},
3 years ago
action: 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();
3 years ago
}else if(e == "头条"){
return ArticlePage();
3 years ago
}else if(e == "课程"){
return CommunityCourse();
}
else {
3 years ago
return CommunityChildPage(e);
3 years ago
}
}).toList(),
controller: tabcontroller,
),
),
);
}
}