mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 12:25:11 +00:00
fix: More stable scroll up to event
This commit is contained in:
parent
d31a1957b4
commit
c0ee1bbdfc
2 changed files with 22 additions and 26 deletions
|
@ -275,9 +275,19 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
if (timeline?.allowNewEvent == false ||
|
||||
scrollController.position.pixels > 0 && _scrolledUp == false) {
|
||||
setState(() => _scrolledUp = true);
|
||||
} else if (scrollController.position.pixels == 0 && _scrolledUp == true) {
|
||||
} else if (scrollController.position.pixels <= 0 && _scrolledUp == true) {
|
||||
setState(() => _scrolledUp = false);
|
||||
}
|
||||
|
||||
if (scrollController.position.pixels == 0 ||
|
||||
scrollController.position.pixels == 64) {
|
||||
requestFuture();
|
||||
} else if (scrollController.position.pixels ==
|
||||
scrollController.position.maxScrollExtent ||
|
||||
scrollController.position.pixels + 64 ==
|
||||
scrollController.position.maxScrollExtent) {
|
||||
requestHistory();
|
||||
}
|
||||
}
|
||||
|
||||
void _loadDraft() async {
|
||||
|
@ -904,7 +914,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
|||
}
|
||||
await scrollController.scrollToIndex(
|
||||
eventIndex,
|
||||
preferPosition: AutoScrollPosition.end,
|
||||
preferPosition: AutoScrollPosition.middle,
|
||||
);
|
||||
_updateScrollController();
|
||||
}
|
||||
|
|
|
@ -53,19 +53,12 @@ class ChatEventList extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
if (controller.timeline!.canRequestFuture) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => controller.requestFuture(),
|
||||
);
|
||||
return Center(
|
||||
child: IconButton(
|
||||
onPressed: controller.requestFuture,
|
||||
icon: const Icon(Icons.refresh_outlined),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -84,19 +77,12 @@ class ChatEventList extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
if (controller.timeline!.canRequestHistory) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => controller.requestHistory(),
|
||||
);
|
||||
return Center(
|
||||
child: IconButton(
|
||||
onPressed: controller.requestHistory,
|
||||
icon: const Icon(Icons.refresh_outlined),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue