Skip to content

Commit aa54759

Browse files
committed
fix(tc): tapping on a tab should navigate straight to the section
1 parent ffe47a1 commit aa54759

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

lib/app/features/tokenized_communities/views/pages/tokenized_community_page.dart

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: ice License 1.0
22

3+
import 'dart:async';
4+
35
import 'package:decimal/decimal.dart';
46
import 'package:flutter/material.dart';
57
import 'package:flutter/rendering.dart';
@@ -107,19 +109,42 @@ class TokenizedCommunityPage extends HookConsumerWidget {
107109
final targetCtx = sectionKeys[index].currentContext;
108110
if (targetCtx == null) return;
109111

112+
double outerOffsetDy = 0;
113+
110114
final nestedState = targetCtx.findAncestorStateOfType<NestedScrollViewState>();
111115
final inner = nestedState?.innerController ?? innerScrollController.value;
112116
if (inner == null || !inner.hasClients) return;
113117

114-
final ro = targetCtx.findRenderObject();
118+
final outer = nestedState?.outerController;
119+
if (outer != null && outer.hasClients) {
120+
outerOffsetDy = outer.position.pixels;
121+
final outerTarget = outer.position.maxScrollExtent - (index == 0 ? 40 : 0);
122+
123+
unawaited(
124+
outer.animateTo(
125+
outerTarget,
126+
duration: const Duration(milliseconds: 300),
127+
curve: Curves.easeInOut,
128+
),
129+
);
130+
if (index == 0) {
131+
return;
132+
}
133+
}
134+
135+
final updatedCtx = sectionKeys[index].currentContext;
136+
if (updatedCtx == null) return;
137+
138+
final ro = updatedCtx.findRenderObject();
115139
if (ro == null) return;
116140

117141
final viewport = RenderAbstractViewport.of(ro);
118142

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

124149
await inner.animateTo(
125150
target,

0 commit comments

Comments
 (0)