TF-4002 Apply new design for folder creation modal on web
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:model/mailbox/expand_mode.dart';
|
||||
|
||||
mixin ExpandFolderTriggerScrollableMixin {
|
||||
void triggerScrollWhenExpandFolder(
|
||||
ExpandMode expandMode,
|
||||
GlobalKey itemKey,
|
||||
ScrollController scrollController,
|
||||
) {
|
||||
if (expandMode == ExpandMode.COLLAPSE) return;
|
||||
|
||||
final context = itemKey.currentContext;
|
||||
if (context == null) return;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollToSelfIfNeeded(context, scrollController);
|
||||
});
|
||||
}
|
||||
|
||||
void _scrollToSelfIfNeeded(
|
||||
BuildContext context,
|
||||
ScrollController scrollController,
|
||||
) {
|
||||
final renderBox = context.findRenderObject() as RenderBox?;
|
||||
if (renderBox == null) return;
|
||||
|
||||
final position = renderBox.localToGlobal(Offset.zero);
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
const offsetY = 200;
|
||||
final bottomY = position.dy + renderBox.size.height + offsetY;
|
||||
log('$runtimeType::_scrollToSelfIfNeeded:position = $position |screenHeight = $screenHeight | bottomY = $bottomY');
|
||||
if (bottomY > screenHeight) {
|
||||
final scrollOffset =
|
||||
scrollController.offset + bottomY - screenHeight + 40;
|
||||
log('$runtimeType::_scrollToSelfIfNeeded:scrollOffset = $scrollOffset:');
|
||||
scrollController.animateTo(
|
||||
scrollOffset,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user