mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Fix weird scrollcontroller state causing detail pane to open wrongly
This commit is contained in:
parent
497b75ce53
commit
5ac326b5c8
1 changed files with 13 additions and 3 deletions
|
@ -483,13 +483,19 @@ class _ViewerState extends State<Viewer>
|
|||
/// Called when the page is being built for the first time
|
||||
void _onCreateNewPage(BuildContext context, int index) {
|
||||
_pageStates[index] = _PageState(ScrollController(
|
||||
initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane
|
||||
? _calcDetailPaneOpenedScrollPosition(index)
|
||||
: 0));
|
||||
initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane
|
||||
? _calcDetailPaneOpenedScrollPosition(index)
|
||||
: 0,
|
||||
));
|
||||
}
|
||||
|
||||
/// Called when the page is being built after previously moved out of view
|
||||
void _onRecreatePageAfterMovedOut(BuildContext context, int index) {
|
||||
_pageStates[index]!.setScrollController(ScrollController(
|
||||
initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane
|
||||
? _calcDetailPaneOpenedScrollPosition(index)
|
||||
: 0,
|
||||
));
|
||||
if (_isShowDetailPane && !_isClosingDetailPane) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_pageStates[index]!.itemHeight != null) {
|
||||
|
@ -762,6 +768,10 @@ class _ViewerState extends State<Viewer>
|
|||
class _PageState {
|
||||
_PageState(this.scrollController);
|
||||
|
||||
void setScrollController(ScrollController c) {
|
||||
scrollController = c;
|
||||
}
|
||||
|
||||
ScrollController scrollController;
|
||||
double? itemHeight;
|
||||
bool hasLoaded = false;
|
||||
|
|
Loading…
Reference in a new issue