mod: 取消页面切换动画
This commit is contained in:
@ -25,10 +25,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
final MediaController _mediaController = Get.put(MediaController());
|
final MediaController _mediaController = Get.put(MediaController());
|
||||||
|
|
||||||
PageController? _pageController;
|
PageController? _pageController;
|
||||||
|
|
||||||
late AnimationController? _animationController;
|
|
||||||
late Animation<double>? _fadeAnimation;
|
|
||||||
late Animation<double>? _slideAnimation;
|
|
||||||
int selectedIndex = 0;
|
int selectedIndex = 0;
|
||||||
int? _lastSelectTime; //上次点击时间
|
int? _lastSelectTime; //上次点击时间
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -37,16 +33,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_animationController = AnimationController(
|
|
||||||
duration: const Duration(milliseconds: 800),
|
|
||||||
reverseDuration: const Duration(milliseconds: 0),
|
|
||||||
value: 1,
|
|
||||||
vsync: this,
|
|
||||||
);
|
|
||||||
_fadeAnimation =
|
|
||||||
Tween<double>(begin: 0.8, end: 1.0).animate(_animationController!);
|
|
||||||
_slideAnimation =
|
|
||||||
Tween(begin: 0.8, end: 1.0).animate(_animationController!);
|
|
||||||
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
_lastSelectTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
_pageController = PageController(initialPage: selectedIndex);
|
_pageController = PageController(initialPage: selectedIndex);
|
||||||
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||||
@ -54,14 +40,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
|
|
||||||
void setIndex(int value) async {
|
void setIndex(int value) async {
|
||||||
feedBack();
|
feedBack();
|
||||||
if (selectedIndex != value) {
|
|
||||||
selectedIndex = value;
|
|
||||||
_animationController!.reverse().then((_) {
|
|
||||||
selectedIndex = value;
|
|
||||||
_animationController!.forward();
|
|
||||||
});
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
_pageController!.jumpToPage(value);
|
_pageController!.jumpToPage(value);
|
||||||
var currentPage = _mainController.pages[value];
|
var currentPage = _mainController.pages[value];
|
||||||
if (currentPage is HomePage) {
|
if (currentPage is HomePage) {
|
||||||
@ -119,29 +97,14 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
onPopInvoked: (bool status) => _mainController.onBackPressed(context),
|
onPopInvoked: (bool status) => _mainController.onBackPressed(context),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
body: FadeTransition(
|
body: PageView(
|
||||||
opacity: _fadeAnimation!,
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
child: SlideTransition(
|
controller: _pageController,
|
||||||
position: Tween<Offset>(
|
onPageChanged: (index) {
|
||||||
begin: const Offset(0, 0.5),
|
selectedIndex = index;
|
||||||
end: Offset.zero,
|
setState(() {});
|
||||||
).animate(
|
},
|
||||||
CurvedAnimation(
|
children: _mainController.pages,
|
||||||
parent: _slideAnimation!,
|
|
||||||
curve: Curves.fastOutSlowIn,
|
|
||||||
reverseCurve: Curves.linear,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: PageView(
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
controller: _pageController,
|
|
||||||
onPageChanged: (index) {
|
|
||||||
selectedIndex = index;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
children: _mainController.pages,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
bottomNavigationBar: StreamBuilder(
|
bottomNavigationBar: StreamBuilder(
|
||||||
stream: _mainController.hideTabBar
|
stream: _mainController.hideTabBar
|
||||||
|
Reference in New Issue
Block a user