mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +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,19 +53,12 @@ class ChatEventList extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (controller.timeline!.canRequestFuture) {
|
if (controller.timeline!.canRequestFuture) {
|
||||||
return Builder(
|
|
||||||
builder: (context) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
|
||||||
(_) => controller.requestFuture(),
|
|
||||||
);
|
|
||||||
return Center(
|
return Center(
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: controller.requestFuture,
|
onPressed: controller.requestFuture,
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
icon: const Icon(Icons.refresh_outlined),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
@ -84,19 +77,12 @@ class ChatEventList extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (controller.timeline!.canRequestHistory) {
|
if (controller.timeline!.canRequestHistory) {
|
||||||
return Builder(
|
|
||||||
builder: (context) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback(
|
|
||||||
(_) => controller.requestHistory(),
|
|
||||||
);
|
|
||||||
return Center(
|
return Center(
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: controller.requestHistory,
|
onPressed: controller.requestHistory,
|
||||||
icon: const Icon(Icons.refresh_outlined),
|
icon: const Icon(Icons.refresh_outlined),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue