@@ -23,9 +23,7 @@ class CustomPage extends StatelessWidget { | |||
@override | |||
Widget build(BuildContext context) { | |||
// return MultiProvider( | |||
// providers: [], | |||
// child: | |||
// return NestedScrollDemoPage(); | |||
return BlocProvider<CustomPageBloc>( | |||
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: <Widget>[ | |||
_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: <Widget>[ | |||
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: <Widget>[ | |||
_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, | |||
); | |||
} | |||
@@ -128,7 +128,7 @@ class _FavoritesPageContainerState extends State<_FavoritesPageContainer> with T | |||
body: Column( | |||
children: <Widget>[ | |||
/// 搜索框 | |||
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)), | |||
@@ -53,13 +53,22 @@ class _InvitedFriendsContainerState extends State<_InvitedFriendsContainer> { | |||
int _currentIndex = 0; // 邀请海报下标 | |||
List<GlobalKey> _contentKeys; | |||
SwiperController _controller; | |||
@override | |||
void initState() { | |||
_bloc = BlocProvider.of<InvitedFriendshBloc>(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<InvitedFriendsModel>( | |||
@@ -160,6 +169,7 @@ class _InvitedFriendsContainerState extends State<_InvitedFriendsContainer> { | |||
return Container( | |||
width: double.infinity, | |||
child: Swiper( | |||
controller: _controller, | |||
onIndexChanged: (index) { | |||
_currentIndex = index; | |||
}, | |||
@@ -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<VipCenterBloc, VipCenterState>( | |||
@@ -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( | |||
@@ -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()); | |||
} | |||
// 注册控件 | |||
@@ -51,13 +51,22 @@ class _GoodsDetailsSlideBannerContainerState | |||
} | |||
} | |||
SwiperController _control; | |||
@override | |||
void initState() { | |||
BlocProvider.of<GoodsDetailsSlideBannerBloc>(context) | |||
.add(GoodsDetailsSlideBannerInitEvent(model: widget?.model)); | |||
_control = SwiperController(); | |||
super.initState(); | |||
} | |||
@override | |||
void dispose() { | |||
_control?.dispose(); | |||
super.dispose(); | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocConsumer<GoodsDetailsSlideBannerBloc, | |||
@@ -94,6 +103,7 @@ class _GoodsDetailsSlideBannerContainerState | |||
width: double.infinity, | |||
height: 375, | |||
child: Swiper( | |||
controller: _control, | |||
itemBuilder: (BuildContext context, int index) { | |||
String items = datas.image_list[index]; | |||
return Container( | |||
@@ -37,6 +37,20 @@ class _HomeQuickEntryContianerState extends State<HomeQuickEntryContianer> { | |||
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<HomeQuickEntryBloc, HomeQuickEntryState>( | |||
@@ -109,6 +123,7 @@ class _HomeQuickEntryContianerState extends State<HomeQuickEntryContianer> { | |||
width: double.infinity, | |||
color: Colors.white, | |||
child: Swiper( | |||
controller: _controller, | |||
itemCount: totalPage, | |||
loop: false, | |||
itemBuilder: (context, index) { | |||
@@ -35,6 +35,21 @@ class HomeQuickEntryWidgetContianer extends StatefulWidget { | |||
class _HomeQuickEntryWidgetContianerState | |||
extends State<HomeQuickEntryWidgetContianer> { | |||
SwiperController _swiperController; | |||
@override | |||
void initState() { | |||
_swiperController = SwiperController(); | |||
super.initState(); | |||
} | |||
@override | |||
void dispose() { | |||
_swiperController?.dispose(); | |||
super.dispose(); | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
return BlocConsumer<HomeQuickEntryBloc, HomeQuickEntryState>( | |||
@@ -101,6 +116,7 @@ class _HomeQuickEntryWidgetContianerState | |||
child: Container( | |||
// color: Colors.yellowAccent, | |||
child: Swiper( | |||
controller: _swiperController, | |||
itemHeight: double.infinity, | |||
itemWidth: double.infinity, | |||
duration: 100, | |||
@@ -40,6 +40,7 @@ class _HomeSlideBannerState extends State<HomeSlideBanner> { | |||
} | |||
class HomeSlideBannerContainer extends StatefulWidget { | |||
@override | |||
_HomeSlideBannerContainerState createState() => | |||
_HomeSlideBannerContainerState(); | |||
@@ -53,6 +54,20 @@ class _HomeSlideBannerContainerState extends State<HomeSlideBannerContainer> { | |||
// 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<HomeSlideBannerBloc, HomeSlideBannerState>( | |||
@@ -97,6 +112,7 @@ class _HomeSlideBannerContainerState extends State<HomeSlideBannerContainer> { | |||
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<HomeSlideBannerContainer> { | |||
/// 获取进度样式 | |||
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<HomeSlideBannerContainer> { | |||
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}', | |||
@@ -44,7 +44,7 @@ class IndexCarousel extends SkipModel { | |||
IndexCarousel({this.img, this.skip_identifier}); | |||
IndexCarousel.fromJson(Map<String, dynamic> json) { | |||
super.toJson(); | |||
super.fromJson(json); | |||
img = json['img']; | |||
skip_identifier = json['skip_identifier']; | |||
} | |||