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 ||
|
if (timeline?.allowNewEvent == false ||
|
||||||
scrollController.position.pixels > 0 && _scrolledUp == false) {
|
scrollController.position.pixels > 0 && _scrolledUp == false) {
|
||||||
setState(() => _scrolledUp = true);
|
setState(() => _scrolledUp = true);
|
||||||
} else if (scrollController.position.pixels == 0 && _scrolledUp == true) {
|
} else if (scrollController.position.pixels <= 0 && _scrolledUp == true) {
|
||||||
setState(() => _scrolledUp = false);
|
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 {
|
void _loadDraft() async {
|
||||||
|
@ -904,7 +914,7 @@ class ChatController extends State<ChatPageWithRoom> {
|
||||||
}
|
}
|
||||||
await scrollController.scrollToIndex(
|
await scrollController.scrollToIndex(
|
||||||
eventIndex,
|
eventIndex,
|
||||||
preferPosition: AutoScrollPosition.end,
|
preferPosition: AutoScrollPosition.middle,
|
||||||
);
|
);
|
||||||
_updateScrollController();
|
_updateScrollController();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,18 +53,11 @@ class ChatEventList extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (controller.timeline!.canRequestFuture) {
|
if (controller.timeline!.canRequestFuture) {
|
||||||
return Builder(
|
return Center(
|
||||||
builder: (context) {
|
child: IconButton(
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
onPressed: controller.requestFuture,
|
||||||
(_) => controller.requestFuture(),
|
icon: const Icon(Icons.refresh_outlined),
|
||||||
);
|
),
|
||||||
return Center(
|
|
||||||
child: IconButton(
|
|
||||||
onPressed: controller.requestFuture,
|
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Column(
|
return Column(
|
||||||
|
@ -84,18 +77,11 @@ class ChatEventList extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (controller.timeline!.canRequestHistory) {
|
if (controller.timeline!.canRequestHistory) {
|
||||||
return Builder(
|
return Center(
|
||||||
builder: (context) {
|
child: IconButton(
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
onPressed: controller.requestHistory,
|
||||||
(_) => controller.requestHistory(),
|
icon: const Icon(Icons.refresh_outlined),
|
||||||
);
|
),
|
||||||
return Center(
|
|
||||||
child: IconButton(
|
|
||||||
onPressed: controller.requestHistory,
|
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
|
|
Loading…
Reference in a new issue