Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: ice License 1.0

import 'dart:async';

import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
Expand Down Expand Up @@ -114,19 +116,42 @@ class TokenizedCommunityPage extends HookConsumerWidget {
final targetCtx = sectionKeys[index].currentContext;
if (targetCtx == null) return;

double outerOffsetDy = 0;

final nestedState = targetCtx.findAncestorStateOfType<NestedScrollViewState>();
final inner = nestedState?.innerController ?? innerScrollController.value;
if (inner == null || !inner.hasClients) return;

final ro = targetCtx.findRenderObject();
final outer = nestedState?.outerController;
if (outer != null && outer.hasClients) {
outerOffsetDy = outer.position.pixels;
final outerTarget = outer.position.maxScrollExtent - (index == 0 ? 40 : 0);

unawaited(
outer.animateTo(
outerTarget,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
),
);
if (index == 0) {
return;
}
}

final updatedCtx = sectionKeys[index].currentContext;
if (updatedCtx == null) return;

final ro = updatedCtx.findRenderObject();
if (ro == null) return;

final viewport = RenderAbstractViewport.of(ro);

// Align the section to the TOP of the inner viewport.
final desired = viewport.getOffsetToReveal(ro, 0).offset;
final pos = inner.position;
final target = (desired - 110.0).clamp(pos.minScrollExtent, pos.maxScrollExtent);
final target = (desired - (outerOffsetDy == 0 ? 40 : 160))
.clamp(pos.minScrollExtent, pos.maxScrollExtent);

await inner.animateTo(
target,
Expand Down