mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-24 19:16:44 +08:00
mod: listener
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -82,20 +82,22 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
||||
);
|
||||
|
||||
_animation = Tween<double>(begin: 0, end: -2 * pi).animate(controller!)
|
||||
..addListener(() {
|
||||
setState(() {
|
||||
_hideCircle = _animation?.value == -2 * pi;
|
||||
if (_hideCircle) {
|
||||
controller?.reset();
|
||||
if (_isThumbUp) {
|
||||
widget.onLongPress?.call();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
..addListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
void listener() {
|
||||
setState(() {
|
||||
_hideCircle = _animation?.value == -2 * pi;
|
||||
if (_hideCircle) {
|
||||
controller?.reset();
|
||||
if (_isThumbUp) {
|
||||
widget.onLongPress?.call();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void cancelTimer() {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
@@ -104,7 +106,7 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
||||
@override
|
||||
void dispose() {
|
||||
cancelTimer();
|
||||
_animation?.removeListener(() {});
|
||||
_animation?.removeListener(listener);
|
||||
controller?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -75,27 +75,27 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_videoReplyController.scrollController.removeListener(() {});
|
||||
_videoReplyController.scrollController.removeListener(listener);
|
||||
fabAnimationCtr.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void scrollListener() {
|
||||
_videoReplyController.scrollController.addListener(
|
||||
() {
|
||||
final ScrollDirection direction =
|
||||
_videoReplyController.scrollController.position.userScrollDirection;
|
||||
if (direction == ScrollDirection.forward) {
|
||||
if (mounted) {
|
||||
_showFab();
|
||||
}
|
||||
} else if (direction == ScrollDirection.reverse) {
|
||||
if (mounted) {
|
||||
_hideFab();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
_videoReplyController.scrollController.addListener(listener);
|
||||
}
|
||||
|
||||
void listener() {
|
||||
final ScrollDirection direction =
|
||||
_videoReplyController.scrollController.position.userScrollDirection;
|
||||
if (direction == ScrollDirection.forward) {
|
||||
if (mounted) {
|
||||
_showFab();
|
||||
}
|
||||
} else if (direction == ScrollDirection.reverse) {
|
||||
if (mounted) {
|
||||
_hideFab();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _showFab() {
|
||||
|
||||
@@ -60,19 +60,21 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
||||
|
||||
_autoFocus() async {
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
if (context.mounted) {
|
||||
if (mounted) {
|
||||
FocusScope.of(context).requestFocus(replyContentFocusNode);
|
||||
}
|
||||
}
|
||||
|
||||
_focusListener() {
|
||||
replyContentFocusNode.addListener(() {
|
||||
if (replyContentFocusNode.hasFocus) {
|
||||
setState(() {
|
||||
toolbarType = 'input';
|
||||
});
|
||||
}
|
||||
});
|
||||
replyContentFocusNode.addListener(listener);
|
||||
}
|
||||
|
||||
void listener() {
|
||||
if (replyContentFocusNode.hasFocus) {
|
||||
setState(() {
|
||||
toolbarType = 'input';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future submitReplyAdd() async {
|
||||
@@ -140,7 +142,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
||||
_publishStream.close();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_replyContentController.dispose();
|
||||
replyContentFocusNode.removeListener(() {});
|
||||
replyContentFocusNode.removeListener(listener);
|
||||
replyContentFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user