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.

120 lines
3.6 KiB

4 years ago
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/home/activity_list_page.dart';
import 'package:huixiang/home/home_page.dart';
import 'package:huixiang/home/points_mall_page.dart';
4 years ago
import 'package:huixiang/main.dart';
import 'package:huixiang/utils/event_type.dart';
4 years ago
import 'package:huixiang/view_widget/my_appbar.dart';
4 years ago
import 'package:huixiang/view_widget/my_tab.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
4 years ago
class MainHomePage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MainHomePage();
}
}
class _MainHomePage extends State<MainHomePage>
4 years ago
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
4 years ago
TabController tabcontroller;
4 years ago
List<Widget> _widgetOptions;
@override
void initState() {
super.initState();
if (tabcontroller == null)
tabcontroller = TabController(length: 3, vsync: this);
tabcontroller.addListener(() => () {});
//NoDataView(),
_widgetOptions = <Widget>[
HomePage(() {
setState(() {
tabcontroller.index = 2;
});
}),
ActivityListPage(),
PointsMallPage()
];
4 years ago
eventBus.on<EventType>().listen((event) {
4 years ago
print("object: MainHomePage");
4 years ago
if (event.type < 3) {
setState(() {});
}
4 years ago
});
4 years ago
}
@override
Widget build(BuildContext context) {
4 years ago
super.build(context);
4 years ago
return DefaultTabController(
length: 3,
child: Scaffold(
4 years ago
appBar: MyAppBar(
background: Color(0xFFFAFAFA),
4 years ago
toolbarHeight: 50.h,
4 years ago
leading: false,
action: Container(
margin: EdgeInsets.only(right: 17.w),
child: GestureDetector(
onTap: () {
// Navigator.of(context).pushNamed("/router/msg_page");
Navigator.of(context).pushNamed('/router/system_msg_page');
},
child: Image.asset(
"assets/image/icon_notices.png",
3 years ago
width: 24,
height: 24,
4 years ago
),
4 years ago
),
),
4 years ago
titleChild: PreferredSize(
preferredSize: Size(double.infinity, 38.h),
child: TabBar(
4 years ago
controller: tabcontroller,
automaticIndicatorColorAdjustment: true,
isScrollable: true,
indicatorWeight: 2,
indicatorColor: Color(0xFF39B54A),
4 years ago
labelPadding: EdgeInsets.only(left: 8.w, right: 8.w),
4 years ago
indicatorSize: TabBarIndicatorSize.label,
unselectedLabelStyle: TextStyle(
fontSize: 15.sp,
fontWeight: FontWeight.w400,
4 years ago
),
labelStyle: TextStyle(
color: Colors.black,
fontSize: 18.sp,
4 years ago
fontWeight: FontWeight.bold,
),
labelColor: Colors.black,
tabs: [
MyTab(text: S.of(context).shouye),
MyTab(
text: S.of(context).huodongliebiao,
),
MyTab(
text: S.of(context).jifenshangcheng,
),
4 years ago
],
),
),
4 years ago
),
4 years ago
body: Container(
padding: EdgeInsets.only(bottom: 76.h),
child: TabBarView(
4 years ago
physics: BouncingScrollPhysics(),
4 years ago
children: _widgetOptions,
controller: tabcontroller,
),
4 years ago
),
));
}
4 years ago
@override
bool get wantKeepAlive => true;
4 years ago
}