TF-4075 Jump to attachments list position on web responsive mobile

This commit is contained in:
dab246
2025-10-06 19:43:32 +07:00
committed by Dat H. Pham
parent 5f3098484b
commit 3478e2aabc
10 changed files with 91 additions and 3 deletions
+1
View File
@@ -17,6 +17,7 @@ export 'presentation/extensions/tap_down_details_extension.dart';
export 'presentation/extensions/map_extensions.dart';
export 'presentation/extensions/either_view_state_extension.dart';
export 'presentation/extensions/media_type_extension.dart';
export 'presentation/extensions/scroll_controller_extension.dart';
// Exceptions
export 'domain/exceptions/download_file_exception.dart';
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
extension ScrollControllerExtension on ScrollController {
void scrollToWidgetTop({
required GlobalKey key,
double padding = 70,
}) {
final context = key.currentContext;
if (context == null) return;
final renderBox = context.findRenderObject();
if (renderBox is! RenderBox) return;
final offsetY = renderBox.localToGlobal(Offset.zero).dy;
final currentScroll = offset;
final targetOffset = (currentScroll + offsetY - padding).clamp(
position.minScrollExtent,
position.maxScrollExtent,
);
animateTo(
targetOffset,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
}
}