mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -10,6 +10,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/num_utils.dart';
|
||||
@@ -17,13 +18,13 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
with SingleTickerProviderStateMixin {
|
||||
CommonDynController get controller;
|
||||
|
||||
late final scrollController = ScrollController()..addListener(listener);
|
||||
late final ScrollController scrollController;
|
||||
|
||||
bool get horizontalPreview => !isPortrait && controller.horizontalPreview;
|
||||
|
||||
@@ -37,15 +38,27 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
|
||||
final fabOffset = const Offset(0, 1);
|
||||
|
||||
late final AnimationController fabAnimationCtr = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
)..forward();
|
||||
late final AnimationController _fabAnimationCtr;
|
||||
late final CurvedAnimation _curvedAnimation;
|
||||
late final Animation<Offset> fabAnim;
|
||||
|
||||
late final Animation<Offset> fabAnim = Tween<Offset>(
|
||||
begin: fabOffset,
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(parent: fabAnimationCtr, curve: Curves.easeInOut));
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fabAnimationCtr = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
)..forward();
|
||||
_curvedAnimation = CurvedAnimation(
|
||||
parent: _fabAnimationCtr,
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
fabAnim = Tween<Offset>(
|
||||
begin: fabOffset,
|
||||
end: Offset.zero,
|
||||
).animate(_curvedAnimation);
|
||||
scrollController = ScrollController()..addListener(listener);
|
||||
}
|
||||
|
||||
void listener() {
|
||||
final pos = scrollController.positions;
|
||||
@@ -60,14 +73,14 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
void showFab() {
|
||||
if (!_showFab) {
|
||||
_showFab = true;
|
||||
fabAnimationCtr.forward();
|
||||
_fabAnimationCtr.forward();
|
||||
}
|
||||
}
|
||||
|
||||
void hideFab() {
|
||||
if (_showFab) {
|
||||
_showFab = false;
|
||||
fabAnimationCtr.reverse();
|
||||
_fabAnimationCtr.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +98,8 @@ abstract class CommonDynPageState<T extends StatefulWidget> extends State<T>
|
||||
scrollController
|
||||
..removeListener(listener)
|
||||
..dispose();
|
||||
_curvedAnimation.dispose();
|
||||
_fabAnimationCtr.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user