diff --git a/lib/pages/custom_page/custom_page.dart b/lib/pages/custom_page/custom_page.dart index 03930a0..b3c645b 100644 --- a/lib/pages/custom_page/custom_page.dart +++ b/lib/pages/custom_page/custom_page.dart @@ -23,9 +23,7 @@ class CustomPage extends StatelessWidget { @override Widget build(BuildContext context) { - // return MultiProvider( - // providers: [], - // child: + // return NestedScrollDemoPage(); return BlocProvider( create: (_) => CustomPageBloc(CustomPageRepository(data: data))..add(CustomPageInitEvent()), child: _CommonPageContainer(), @@ -41,6 +39,7 @@ class _CommonPageContainer extends StatefulWidget { class __CommonPageContainerState extends State<_CommonPageContainer> with SingleTickerProviderStateMixin { ScrollController _controller; + ScrollController _controller2; RefreshController _refreshController; TabController _tabController; bool _isEnded = false; @@ -48,7 +47,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single /// 回到顶点 void _scrollTop() { // _controller.jumpTo(0); - _controller.animateTo(0, duration: Duration(seconds: 1), curve: Curves.linear); + _controller.animateTo(0, duration: Duration(milliseconds: 200), curve: Curves.linear); } /// 刷新 @@ -62,6 +61,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single @override void initState() { _controller = ScrollController(); + _controller2 = ScrollController(); _refreshController = RefreshController(initialRefresh: false); _tabController = TabController(length: 10, vsync: this); super.initState(); @@ -72,6 +72,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single _controller?.dispose(); _refreshController?.dispose(); _tabController?.dispose(); + _controller2?.dispose(); super.dispose(); } @@ -86,7 +87,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single return false; } if (current is CustomPageRefreshSuccessState) { - _refreshController.refreshCompleted(resetFooterState: true); + _refreshController.refreshCompleted(resetFooterState: true); return false; } if (current is CustomPageRefreshErrorState) { @@ -96,13 +97,15 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single return true; }, builder: (context, state) { - if (state is CustomPageLoadedState) { - return _buildMainWidget(); - } - if (state is CustomPageInitErrorState) { - return _buildMainWidget(); - } - return _buildSkeletonWidget(); + // if (state is CustomPageLoadedState) { + // return _buildMain2Widget(); + // } + // if (state is CustomPageInitErrorState) { + // return _buildMain2Widget(); + // } + // return _buildMain2Widget(); + + return _buildMain2Widget(); }, ), ); @@ -116,7 +119,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single floatingActionButton: _buildFloatWidget(), floatingActionButtonLocation: _CustomFloatingActionButtonLocation(FloatingActionButtonLocation.endFloat, 0, -100), body: SmartRefresher( - enablePullDown: false, + enablePullDown: true, enablePullUp: false, header: RefreshHeader( offsetY: top, @@ -125,6 +128,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single onLoading: _onLoadEvent, onRefresh: _onRefreshEvent, child: CustomScrollView( + key: UniqueKey(), controller: _controller, slivers: [ /// 标题 @@ -134,69 +138,178 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single pinned: true, ), + + /// 轮播图 + _buildSliverBanner(), + /// 搜索 - SliverPersistentHeader( - delegate: CustomSliverPersistentHeaderDelegate( - max: 40, - min: 40, - child: Container( - height: double.infinity, - width: double.infinity, - color: Colors.yellowAccent, - ), - ), - // pinned: true, - ), + _buildSearch(), /// TAB BAR - SliverPersistentHeader( - delegate: CustomSliverPersistentHeaderDelegate( - max: 40, - min: 40, - child: Container( + _buildTabbar(), + + SliverFillRemaining( + child: TabBarView( + controller: _tabController, + children: List.generate(10, (index) => Container( height: double.infinity, width: double.infinity, - color: Colors.redAccent, - child: TabBar( - isScrollable: true, - controller: _tabController, - tabs: List.generate(10, (index) => Text('$index')), + color: Colors.white, + child: MediaQuery.removePadding( + context: context, + removeTop: true, + child: CustomScrollView( + controller: _controller2, + key: UniqueKey(), + slivers: [ + _buildQucikEntry(), + _buildSearch(), + _buildSliverBanner(), + _buildGoodsList(), + + ], + ), ), - ), + )), ), - // pinned: true, - ), + ) - /// 轮播图 - SliverToBoxAdapter( - child: Container( - height: 140, - width: double.infinity, - color: Colors.blueAccent, - ), - ), + ], + ), + ), + ); + } - /// 多眼导航 - SliverToBoxAdapter( - child: Container( - height: 70, - width: double.infinity, - color: Colors.yellowAccent, + /// 有数据2 + Widget _buildMain2Widget(){ + return Scaffold( + appBar: AppBar(title: Text('标题'),centerTitle: true,), + backgroundColor: HexColor.fromHex('#F9F9F9'), + floatingActionButton: _buildFloatWidget(), + floatingActionButtonLocation: _CustomFloatingActionButtonLocation(FloatingActionButtonLocation.endFloat, 0, -100), + body: Column( + children: [ + Container(height: 40, width: double.infinity, color: Colors.green,), + Container( + height: 40, + width: double.infinity, + color: Colors.red, + child: TabBar( + isScrollable: true, + controller: _tabController, + tabs: List.generate(10, (index) => Text('$index')), ), ), + Expanded( + child: TabBarView( + controller: _tabController, + children: List.generate(10, (index) => Container( + height: double.infinity, + width: double.infinity, + color: Colors.white, + child: MediaQuery.removePadding( + context: context, + removeTop: true, + child: CustomScrollView( + controller: _controller, + key: UniqueKey(), + slivers: [ + _buildQucikEntry(), + _buildSearch(), + _buildSliverBanner(), + _buildSearch(title: '商品列表'), + _buildGoodsList(), - /// 商品列表 - SliverList( - delegate: SliverChildBuilderDelegate((context, index) { - return Container( - height: 50, - width: double.infinity, - color: Colors.green[(index % 9 + 1) * 100], - ); - }, childCount: 50)), + ], + ), + ), + )), + ), + ) ], ), + ); + } + + /// tabBar + Widget _buildTabbar(){ + return SliverPersistentHeader( + delegate: CustomSliverPersistentHeaderDelegate( + max: 40, + min: 40, + child: Container( + height: double.infinity, + width: double.infinity, + color: Colors.redAccent, + child: TabBar( + isScrollable: true, + controller: _tabController, + tabs: List.generate(10, (index) => Text('$index')), + ), + ), + ), + pinned: true, + ); + } + + /// 多眼导航 + Widget _buildQucikEntry(){ + return SliverToBoxAdapter( + child: Container( + alignment: Alignment.center, + child: Text('多眼导航'), + height: 70, + width: double.infinity, + color: Colors.green, + ), + ); + } + + /// 搜索 + Widget _buildSearch({String title}){ + return SliverPersistentHeader( + delegate: CustomSliverPersistentHeaderDelegate( + max: 40, + min: 40, + child: Container( + alignment: Alignment.center, + child: Text(title ?? '搜索'), + height: double.infinity, + width: double.infinity, + color: Colors.blueAccent, + ), + ), + pinned: true, + ); + } + + /// 商品列表 + Widget _buildGoodsList(){ + return SliverList( + delegate: SliverChildBuilderDelegate((context, index) { + return Container( + height: 50, + width: double.infinity, + color: Colors.green[(index % 9 + 1) * 100], + ); + }, childCount: 50)); + } + + /// 轮播图 + Widget _buildSliverBanner(){ + return SliverPersistentHeader( + delegate: CustomSliverPersistentHeaderDelegate( + max: 140, + min: 140, + child: Container( + child: Text('轮播图'), + alignment: Alignment.center, + height: double.infinity, + width: double.infinity, + color: Colors.yellowAccent, + ), ), + pinned: false, ); } diff --git a/lib/pages/favorites_page/favorites_page.dart b/lib/pages/favorites_page/favorites_page.dart index 1cf4d85..80b8605 100644 --- a/lib/pages/favorites_page/favorites_page.dart +++ b/lib/pages/favorites_page/favorites_page.dart @@ -128,7 +128,7 @@ class _FavoritesPageContainerState extends State<_FavoritesPageContainer> with T body: Column( children: [ /// 搜索框 - Padding(padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 4), child: _buildSearchWidget(model)), + Padding(padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 0), child: _buildSearchWidget(model)), /// tabBar Padding(padding: const EdgeInsets.only(top: 4), child: _buildTabBarWidget(model)), diff --git a/lib/pages/invited_friends/invited_friends.dart b/lib/pages/invited_friends/invited_friends.dart index 59bb2a3..a06e29b 100644 --- a/lib/pages/invited_friends/invited_friends.dart +++ b/lib/pages/invited_friends/invited_friends.dart @@ -53,13 +53,22 @@ class _InvitedFriendsContainerState extends State<_InvitedFriendsContainer> { int _currentIndex = 0; // 邀请海报下标 List _contentKeys; + SwiperController _controller; + @override void initState() { _bloc = BlocProvider.of(context); _bloc.loadData(widget.data['skip_identifier']); + _controller = SwiperController(); super.initState(); } + @override + void dispose() { + _controller?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return StreamBuilder( @@ -160,6 +169,7 @@ class _InvitedFriendsContainerState extends State<_InvitedFriendsContainer> { return Container( width: double.infinity, child: Swiper( + controller: _controller, onIndexChanged: (index) { _currentIndex = index; }, diff --git a/lib/pages/vip_center_page/vip_center_page.dart b/lib/pages/vip_center_page/vip_center_page.dart index 5a2601e..6a957a6 100644 --- a/lib/pages/vip_center_page/vip_center_page.dart +++ b/lib/pages/vip_center_page/vip_center_page.dart @@ -33,6 +33,10 @@ class _VipCenterPageContainer extends StatefulWidget { } class __VipCenterPageContainerState extends State<_VipCenterPageContainer> { + + + SwiperController _swiperController; + /// 分享 void _onShareClick() {} @@ -48,6 +52,18 @@ class __VipCenterPageContainerState extends State<_VipCenterPageContainer> { }); } + @override + void initState() { + _swiperController = SwiperController(); + super.initState(); + } + + @override + void dispose() { + _swiperController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BlocConsumer( @@ -154,6 +170,7 @@ class __VipCenterPageContainerState extends State<_VipCenterPageContainer> { height: 123, // color: HexColor.fromHex('#eeF0D199'), child: Swiper( + controller: _swiperController, itemCount: 4, itemBuilder: (context, index) { return Container( diff --git a/lib/register.dart b/lib/register.dart index 846408f..79c30b3 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -203,7 +203,7 @@ class BaseWidgetRegister { 'pub.flutter.my_wallet_detail', (model) => BilDetailPage(model)); /// 通用模块 - PageFactory.regist('pub.flutter.custom', (model) => CustomPage(model)); + PageFactory.regist('pub.flutter.custom', (model) => EmptyPage()); } // 注册控件 diff --git a/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart b/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart index a7c08db..32df501 100644 --- a/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart +++ b/lib/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart @@ -51,13 +51,22 @@ class _GoodsDetailsSlideBannerContainerState } } + SwiperController _control; + @override void initState() { BlocProvider.of(context) .add(GoodsDetailsSlideBannerInitEvent(model: widget?.model)); + _control = SwiperController(); super.initState(); } + @override + void dispose() { + _control?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BlocConsumer { RouterUtil.route(model, model.toJson(), context); } + SwiperController _controller; + + @override + void initState() { + _controller = SwiperController(); + super.initState(); + } + + @override + void dispose() { + _controller?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BlocConsumer( @@ -109,6 +123,7 @@ class _HomeQuickEntryContianerState extends State { width: double.infinity, color: Colors.white, child: Swiper( + controller: _controller, itemCount: totalPage, loop: false, itemBuilder: (context, index) { diff --git a/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart b/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart index e474c04..25d605d 100644 --- a/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart +++ b/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart @@ -35,6 +35,21 @@ class HomeQuickEntryWidgetContianer extends StatefulWidget { class _HomeQuickEntryWidgetContianerState extends State { + + SwiperController _swiperController; + + @override + void initState() { + _swiperController = SwiperController(); + super.initState(); + } + + @override + void dispose() { + _swiperController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BlocConsumer( @@ -101,6 +116,7 @@ class _HomeQuickEntryWidgetContianerState child: Container( // color: Colors.yellowAccent, child: Swiper( + controller: _swiperController, itemHeight: double.infinity, itemWidth: double.infinity, duration: 100, diff --git a/lib/widgets/home/home_slide_banner/home_slide_banner.dart b/lib/widgets/home/home_slide_banner/home_slide_banner.dart index a60dc1a..c945ffe 100644 --- a/lib/widgets/home/home_slide_banner/home_slide_banner.dart +++ b/lib/widgets/home/home_slide_banner/home_slide_banner.dart @@ -40,6 +40,7 @@ class _HomeSlideBannerState extends State { } class HomeSlideBannerContainer extends StatefulWidget { + @override _HomeSlideBannerContainerState createState() => _HomeSlideBannerContainerState(); @@ -53,6 +54,20 @@ class _HomeSlideBannerContainerState extends State { // Navigator.push(context, CupertinoPageRoute(builder: (_) => VipCenterPage(null))); } + SwiperController _swiperController; + + @override + void initState() { + _swiperController = SwiperController(); + super.initState(); + } + + @override + void dispose() { + _swiperController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BlocConsumer( @@ -97,6 +112,7 @@ class _HomeSlideBannerContainerState extends State { width: double.infinity, height: 140, child: Swiper( + controller: _swiperController, itemBuilder: (BuildContext context, int index) { IndexCarousel items = datas.index_carousel_list[index]; return Container( @@ -129,7 +145,7 @@ class _HomeSlideBannerContainerState extends State { /// 获取进度样式 SwiperPlugin _getSwiperStyleByType( HomeSlideBannerModel model, int pageCount) { - if ('type_null' != model.pagination) { + if ('type_null' == model.pagination) { return null; } @@ -154,12 +170,12 @@ class _HomeSlideBannerContainerState extends State { return SwiperCustomPagination( builder: (BuildContext context, SwiperPluginConfig config) { return Align( - alignment: Alignment(0.0, 0.9), + alignment: Alignment(0.9, 0.9), child: Container( padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 18), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(13), - color: HexColor.fromHex('#4D000000')), + borderRadius: BorderRadius.circular(3), + color: HexColor.fromHex('#80333333')), child: RichText( text: TextSpan( text: '${config.activeIndex + 1}', diff --git a/lib/widgets/home/home_slide_banner/model/home_slide_banner_model.dart b/lib/widgets/home/home_slide_banner/model/home_slide_banner_model.dart index 63c134f..a8e7006 100644 --- a/lib/widgets/home/home_slide_banner/model/home_slide_banner_model.dart +++ b/lib/widgets/home/home_slide_banner/model/home_slide_banner_model.dart @@ -44,7 +44,7 @@ class IndexCarousel extends SkipModel { IndexCarousel({this.img, this.skip_identifier}); IndexCarousel.fromJson(Map json) { - super.toJson(); + super.fromJson(json); img = json['img']; skip_identifier = json['skip_identifier']; }