mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +08:00
opt topic scroll
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -27,7 +27,6 @@ class SelectTopicPanel extends StatefulWidget {
|
|||||||
|
|
||||||
class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
||||||
final _controller = Get.put(SelectTopicController());
|
final _controller = Get.put(SelectTopicController());
|
||||||
late double offset;
|
|
||||||
final StreamController<String> _ctr = StreamController<String>();
|
final StreamController<String> _ctr = StreamController<String>();
|
||||||
late StreamSubscription<String> _sub;
|
late StreamSubscription<String> _sub;
|
||||||
|
|
||||||
@@ -37,7 +36,6 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
|||||||
if (_controller.loadingState.value is Error) {
|
if (_controller.loadingState.value is Error) {
|
||||||
_controller.onReload();
|
_controller.onReload();
|
||||||
}
|
}
|
||||||
offset = widget.scrollController?.initialScrollOffset ?? 0;
|
|
||||||
_sub = _ctr.stream
|
_sub = _ctr.stream
|
||||||
.debounce(const Duration(milliseconds: 300), trailing: true)
|
.debounce(const Duration(milliseconds: 300), trailing: true)
|
||||||
.listen((value) {
|
.listen((value) {
|
||||||
@@ -50,7 +48,6 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
widget.callback?.call(offset);
|
|
||||||
_sub.cancel();
|
_sub.cancel();
|
||||||
_ctr.close();
|
_ctr.close();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -155,10 +152,13 @@ class _SelectTopicPanelState extends State<SelectTopicPanel> {
|
|||||||
response?.isNotEmpty == true
|
response?.isNotEmpty == true
|
||||||
? NotificationListener<ScrollNotification>(
|
? NotificationListener<ScrollNotification>(
|
||||||
onNotification: (notification) {
|
onNotification: (notification) {
|
||||||
if (_controller.focusNode.hasFocus) {
|
if (notification is ScrollStartNotification) {
|
||||||
_controller.focusNode.unfocus();
|
if (_controller.focusNode.hasFocus) {
|
||||||
|
_controller.focusNode.unfocus();
|
||||||
|
}
|
||||||
|
} else if (notification is ScrollEndNotification) {
|
||||||
|
widget.callback?.call(notification.metrics.pixels);
|
||||||
}
|
}
|
||||||
offset = notification.metrics.pixels;
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
|||||||
Reference in New Issue
Block a user