123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:common_project/common_project.dart';
- import 'package:module_home/navigation/routers.dart';
- import 'package:module_home/view/home_room_list_page.dart';
- import 'package:module_home/view_model/home_index_cubit.dart';
- import 'package:common_project/public_model/init_config_model.dart';
- class HomeIndexPage extends StatefulWidget {
- @override
- _HomeIndexPageState createState() => _HomeIndexPageState();
- }
- class _HomeIndexPageState extends State<HomeIndexPage> with TickerProviderStateMixin{
- @override
- Widget build(BuildContext context) {
- return BlocProvider(
- create: (context) => HomeIndexCubit(this,context),
- child: BlocListener<ConfigCubit,ConfigState>(
- listener: (context,state){
- if(state.timeTemp != 0 && state.configselect){
- HomeIndexCubit homeIndexCubit = BlocProvider.of<HomeIndexCubit>(context);
- homeIndexCubit.setTabString(state.configModelData.channelConfig!.rtcRoomCategories!);
- }
- },
- child: Builder(builder: (context){
- HomeIndexCubit homeIndexCubit = BlocProvider.of<HomeIndexCubit>(context);
- context.select((HomeIndexCubit bloc) => bloc.state.tabController);
- context.select((HomeIndexCubit bloc) => bloc.state.tabList);
- context.select((HomeIndexCubit bloc) => bloc.state.bannerList);
- return Scaffold(
- body: homeIndexCubit.state.tabList != [] ?
- ExtendedNestedScrollView(
- onlyOneScrollInBody: false,
- headerSliverBuilder: (BuildContext context,bool innerBoxIsScrolled){
- return <Widget>[
- SliverAppBar(
- pinned: true,
- floating: true,
- expandedHeight:400.w + 200.h,
- backgroundColor: Colors.white,
- flexibleSpace: FlexibleSpaceBar(
- collapseMode: CollapseMode.pin,
- background: Container(//头部整个背景颜色
- height: double.infinity,
- child: Column(
- children: <Widget>[
- SizedBox(height: Sizes.statusBarHeight+10.w,),
- InkWell(
- onTap: (){
- XLog.d('点击了搜索');
- Application.navigateTo(context: context, route: HomeRouters().searchIndex);
- },
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: Container(
- margin: EdgeInsets.only(left: 24.w,right: 24.w),
- height: 75.w,
- padding: EdgeInsets.only(left: 24.w),
- alignment: Alignment.centerLeft,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(40.w)),
- color: HexColor.fromHex("#F7F7FA")
- ),
- child: Row(
- children: [
- ImageUtil.loadImage(ImageUtil.getImgPath('icon_search'),package: ModuleName.Module_project,width: 32.w,height: 32.w),
- SizedBox(width: 10.w,),
- Text('搜索昵称、ID'),
- ],
- ),
- ),)
- ],
- ),
- ),
- SizedBox(height: 20.w),
- Container(
- margin: EdgeInsets.only(left: 20.w,right: 20.w),
- height: 180.w,
- child: Swiper(
- itemBuilder: (BuildContext context, int index) {
- return InkWell(child: ImageUtil.loadImage(homeIndexCubit.state.bannerList[index].bannerPic,fit: BoxFit.fill,),
- onTap: (){
- Application.navigateTo(context: context, route: RouterPath().webPage,params: {"url":homeIndexCubit.state.bannerList[index].bannerUrl});
- },
- );
- },
- itemCount: homeIndexCubit.state.bannerList.length,
- // viewportFraction: 0.8,
- pagination: new SwiperPagination(),
- controller: homeIndexCubit.state.swiperController,
- scale: 0.9,
- autoplay: false,
- loop: false,
- ),
- ),
- Container(
- height: 200.h,
- padding: EdgeInsets.only(left: 20.w,right: 20.w),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- width: 344.w,
- height: 108.h,
- child: Stack(
- children: [
- ImageUtil.loadImage(ImageUtil.getImgPath("home_club"),package: ModuleName.Module_Home,width: 344.w,height: 108.h)
- ],
- ),
- ),
- Container(
- width: 344.w,
- height: 108.h,
- child: Stack(
- children: [
- ImageUtil.loadImage(ImageUtil.getImgPath("home_send"),package: ModuleName.Module_Home,width: 344.w,height: 108.h)
- ],
- ),
- ),
- ],
- ),
- color: Colors.orange,
- ),
- SizedBox(height: 20.w),
- ],
- ),
- ),
- ),
- bottom: ButtonsTabBar(
- height: 75.w,
- controller: homeIndexCubit.state.tabController,
- backgroundColor: Color(0xffec2e2e),
- unselectedBackgroundColor: Color(0xd000000),
- labelStyle:
- TextStyle(color: Colors.white, fontWeight: FontWeight.w400),
- unselectedLabelStyle: TextStyle(
- color: Color(0xff827979), fontWeight: FontWeight.w400),
- radius: 100.w,
- tabs: homeIndexCubit.state.tabList != [] ?
- homeIndexCubit.state.tabList.map<Tab>((RtcRoomCategories tab) {
- return Tab(
- text: tab.categoryName,
- );
- }).toList() :
- <Widget>[
- ],
- ) ,
- )
- ];
- },
- body: Container(
- margin: EdgeInsets.only(top: 20.w,right: 20.w,left: 20.w),
- child: TabBarView(
- controller: homeIndexCubit.state.tabController,
- children: homeIndexCubit.state.tabList.map((RtcRoomCategories tab){
- return new HomeRoomListPage(tab.categoryId!,tab.layout);
- }).toList(),
- ),
- ),
- ) : Container(),
- );
- }),),
- );
- }
- @override
- void dispose() {
- // TODO: implement dispose
- HomeIndexCubit homeIndexCubit = BlocProvider.of<HomeIndexCubit>(context);
- homeIndexCubit.state.swiperController.stopAutoplay();
- homeIndexCubit.state.swiperController.dispose();
- super.dispose();
- }
- }
|