diff --git a/lib/containers/discovery.dart b/lib/containers/discovery.dart index 5636656..e4dbffd 100644 --- a/lib/containers/discovery.dart +++ b/lib/containers/discovery.dart @@ -158,22 +158,23 @@ class _DiscoveryState extends State with AutomaticKeepAliveClientMixi const opacityCurve = Interval(0.0, 0.75, curve: Curves.fastOutSlowIn); // 过渡动画 return AnimatedBuilder( - animation: animation, - builder: (BuildContext context, Widget? child) => Opacity( - opacity: opacityCurve.transform(animation.value), - child: DiscoveryDetail( - tag: '$index TAG${data.imgId}', - url: data.url, - ), - )); + animation: animation, + builder: (BuildContext context, Widget? child) => Opacity( + opacity: opacityCurve.transform(animation.value), + child: DiscoveryDetail( + tag: '$index TAG${data.imgId}', + url: data.url, + ), + ), + ); }), ), behavior: HitTestBehavior.opaque, child: FadeInImage.assetNetwork( placeholder: 'assets/images/loading.gif', image: data.url, - imageCacheWidth: 80, fit: BoxFit.cover, + imageCacheWidth: 80, ), ), ); diff --git a/lib/containers/entrance.dart b/lib/containers/entrance.dart index 3407850..7a61afe 100644 --- a/lib/containers/entrance.dart +++ b/lib/containers/entrance.dart @@ -42,10 +42,12 @@ class _EntranceState extends State { int activeIndex = 0; final UniLinksType _type = UniLinksType.string; late StreamSubscription _sub; + late PageController controller; @override void initState() { super.initState(); + controller = PageController(initialPage: activeIndex); // scheme初始化,保证有上下文,需要跳转页面 initPlatformState(); } @@ -98,8 +100,9 @@ class _EntranceState extends State { child: Column( children: [ Expanded( - child: IndexedStack( - index: activeIndex, + child: PageView( + controller: controller, + physics: const NeverScrollableScrollPhysics(), children: [ const Home(), const Discovery(), @@ -115,6 +118,7 @@ class _EntranceState extends State { activeKey: Entrance.navList[activeIndex]['key'] as String, onChange: (int index) => setState(() { activeIndex = index; + controller.jumpToPage(index); }), ), ],