TF-4002 Apply new design for folder creation modal on web
This commit is contained in:
@@ -19,6 +19,7 @@ import 'package:tmail_ui_user/features/base/action/update_mailbox_properties_act
|
||||
import 'package:tmail_ui_user/features/base/action/update_mailbox_properties_action/update_mailbox_total_emails_count_action.dart';
|
||||
import 'package:tmail_ui_user/features/base/action/update_mailbox_properties_action/update_mailbox_unread_count_action.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/expand_folder_trigger_scrollable_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/base/mixin/message_dialog_action_manager.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/mailbox_subscribe_action_state.dart';
|
||||
@@ -55,7 +56,8 @@ typedef MovingMailboxActionCallback = void Function(PresentationMailbox mailboxS
|
||||
typedef DeleteMailboxActionCallback = void Function(PresentationMailbox mailbox);
|
||||
typedef AllowSubaddressingActionCallback = void Function(MailboxId, Map<String, List<String>?>?, MailboxActions);
|
||||
|
||||
abstract class BaseMailboxController extends BaseController {
|
||||
abstract class BaseMailboxController extends BaseController
|
||||
with ExpandFolderTriggerScrollableMixin {
|
||||
final TreeBuilder _treeBuilder;
|
||||
final VerifyNameInteractor verifyNameInteractor;
|
||||
final GetAllMailboxInteractor? getAllMailboxInteractor;
|
||||
@@ -159,44 +161,6 @@ abstract class BaseMailboxController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
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('BaseMailboxController::_scrollToSelfIfNeeded:position = $position |screenHeight = $screenHeight | bottomY = $bottomY');
|
||||
if (bottomY > screenHeight) {
|
||||
final scrollOffset = scrollController.offset + bottomY - screenHeight + 40;
|
||||
log('BaseMailboxController::_scrollToSelfIfNeeded:scrollOffset = $scrollOffset:');
|
||||
scrollController.animateTo(
|
||||
scrollOffset,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void selectMailboxNode(MailboxNode mailboxNodeSelected) {
|
||||
final newSelectMode = mailboxNodeSelected.selectMode == SelectMode.INACTIVE
|
||||
? SelectMode.ACTIVE
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,14 @@ class DefaultButtonArrowDownFieldWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final String iconArrowDown;
|
||||
final VoidCallback onTap;
|
||||
final Widget? icon;
|
||||
|
||||
const DefaultButtonArrowDownFieldWidget({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.iconArrowDown,
|
||||
required this.onTap,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -35,6 +37,7 @@ class DefaultButtonArrowDownFieldWidget extends StatelessWidget {
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
if (icon != null) icon!,
|
||||
Expanded(
|
||||
child: Text(
|
||||
text,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/views/dialog/confirm_dialog_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ModalListActionButtonWidget extends StatelessWidget {
|
||||
final String positiveLabel;
|
||||
final String negativeLabel;
|
||||
final VoidCallback onNegativeAction;
|
||||
final VoidCallback onPositiveAction;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
const ModalListActionButtonWidget({
|
||||
super.key,
|
||||
required this.positiveLabel,
|
||||
required this.negativeLabel,
|
||||
required this.onPositiveAction,
|
||||
required this.onNegativeAction,
|
||||
this.padding,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget negativeButton = Container(
|
||||
constraints: const BoxConstraints(minWidth: 67),
|
||||
height: 48,
|
||||
child: ConfirmDialogButton(
|
||||
label: negativeLabel,
|
||||
onTapAction: onNegativeAction,
|
||||
),
|
||||
);
|
||||
|
||||
Widget positiveButton = Container(
|
||||
constraints: const BoxConstraints(minWidth: 153),
|
||||
height: 48,
|
||||
child: ConfirmDialogButton(
|
||||
label: positiveLabel,
|
||||
backgroundColor: AppColor.primaryMain,
|
||||
textColor: Colors.white,
|
||||
onTapAction: onPositiveAction,
|
||||
),
|
||||
);
|
||||
|
||||
Widget bodyWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(child: negativeButton),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(child: positiveButton),
|
||||
],
|
||||
);
|
||||
|
||||
if (padding != null) {
|
||||
return Padding(padding: padding!, child: bodyWidget);
|
||||
} else {
|
||||
return bodyWidget;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user