mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +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
|
/// Called when the page is being built for the first time
|
||||||
void _onCreateNewPage(BuildContext context, int index) {
|
void _onCreateNewPage(BuildContext context, int index) {
|
||||||
_pageStates[index] = _PageState(ScrollController(
|
_pageStates[index] = _PageState(ScrollController(
|
||||||
initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane
|
initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane
|
||||||
? _calcDetailPaneOpenedScrollPosition(index)
|
? _calcDetailPaneOpenedScrollPosition(index)
|
||||||
: 0));
|
: 0,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the page is being built after previously moved out of view
|
/// Called when the page is being built after previously moved out of view
|
||||||
void _onRecreatePageAfterMovedOut(BuildContext context, int index) {
|
void _onRecreatePageAfterMovedOut(BuildContext context, int index) {
|
||||||
|
_pageStates[index]!.setScrollController(ScrollController(
|
||||||
|
initialScrollOffset: _isShowDetailPane && !_isClosingDetailPane
|
||||||
|
? _calcDetailPaneOpenedScrollPosition(index)
|
||||||
|
: 0,
|
||||||
|
));
|
||||||
if (_isShowDetailPane && !_isClosingDetailPane) {
|
if (_isShowDetailPane && !_isClosingDetailPane) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (_pageStates[index]!.itemHeight != null) {
|
if (_pageStates[index]!.itemHeight != null) {
|
||||||
|
@ -762,6 +768,10 @@ class _ViewerState extends State<Viewer>
|
||||||
class _PageState {
|
class _PageState {
|
||||||
_PageState(this.scrollController);
|
_PageState(this.scrollController);
|
||||||
|
|
||||||
|
void setScrollController(ScrollController c) {
|
||||||
|
scrollController = c;
|
||||||
|
}
|
||||||
|
|
||||||
ScrollController scrollController;
|
ScrollController scrollController;
|
||||||
double? itemHeight;
|
double? itemHeight;
|
||||||
bool hasLoaded = false;
|
bool hasLoaded = false;
|
||||||
|
|
Loading…
Reference in a new issue