TF-4002 Apply new design for folder creation modal on web

This commit is contained in:
dab246
2025-09-04 15:06:28 +07:00
committed by Dat H. Pham
parent c09a2c92b2
commit 36e58fc990
23 changed files with 689 additions and 498 deletions
@@ -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,
);
}
}
}