mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-08 18:28:53 +01:00
Change page switch animation in home
To better handle >2 pages
This commit is contained in:
parent
a2e0dbabe3
commit
363382271f
1 changed files with 31 additions and 4 deletions
|
@ -45,7 +45,7 @@ class Home extends StatefulWidget {
|
||||||
final Account account;
|
final Account account;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeState extends State<Home> {
|
class _HomeState extends State<Home> with TickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -56,6 +56,13 @@ class _HomeState extends State<Home> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
_animationController.value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
dispose() {
|
||||||
|
_animationController.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -90,7 +97,16 @@ class _HomeState extends State<Home> {
|
||||||
controller: _pageController,
|
controller: _pageController,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemCount: 2,
|
itemCount: 2,
|
||||||
itemBuilder: _buildPage,
|
itemBuilder: (context, index) => SlideTransition(
|
||||||
|
position: Tween(
|
||||||
|
begin: const Offset(0, .05),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(_animation),
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: _animation,
|
||||||
|
child: _buildPage(context, index),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +136,13 @@ class _HomeState extends State<Home> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTapNavItem(int index) {
|
void _onTapNavItem(int index) {
|
||||||
_pageController.animateToPage(index,
|
_pageController.jumpToPage(index);
|
||||||
duration: k.animationDurationNormal, curve: Curves.easeInOut);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_nextPage = index;
|
_nextPage = index;
|
||||||
});
|
});
|
||||||
|
_animationController
|
||||||
|
..reset()
|
||||||
|
..forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Album>> _importPotentialSharedAlbum() async {
|
Future<List<Album>> _importPotentialSharedAlbum() async {
|
||||||
|
@ -148,5 +166,14 @@ class _HomeState extends State<Home> {
|
||||||
final _pageController = PageController(initialPage: 0, keepPage: false);
|
final _pageController = PageController(initialPage: 0, keepPage: false);
|
||||||
int _nextPage = 0;
|
int _nextPage = 0;
|
||||||
|
|
||||||
|
late final _animationController = AnimationController(
|
||||||
|
duration: k.animationDurationLong,
|
||||||
|
vsync: this,
|
||||||
|
);
|
||||||
|
late final _animation = CurvedAnimation(
|
||||||
|
parent: _animationController,
|
||||||
|
curve: Curves.easeIn,
|
||||||
|
);
|
||||||
|
|
||||||
static final _log = Logger("widget.home._HomeState");
|
static final _log = Logger("widget.home._HomeState");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue