Skip to content

Commit

Permalink
Show toast when composer scroll to bottom while email content is loading
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed May 9, 2024
1 parent b77c53e commit 9b89c8b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/lib/presentation/views/toast/tmail_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ToastView {
static OverlayState? overlayState;
static OverlayEntry? _overlayEntry;
static bool _isVisible = false;
static bool get isVisible => _isVisible;

static void createView(
String text,
Expand Down
20 changes: 20 additions & 0 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
scrollControllerEmailAddress.addListener(_scrollControllerEmailAddressListener);
_listenStreamEvent();
_getAlwaysReadReceiptSetting();
_addScrollControllerListener();
}

@override
Expand Down Expand Up @@ -268,6 +269,7 @@ class ComposerController extends BaseController with DragDropFileMixin {
bccEmailAddressController.dispose();
uploadInlineImageWorker.dispose();
dashboardViewStateWorker.dispose();
scrollController.removeListener(_onScrollToBottomListener);
scrollController.dispose();
scrollControllerEmailAddress.removeListener(_scrollControllerEmailAddressListener);
scrollControllerEmailAddress.dispose();
Expand Down Expand Up @@ -413,6 +415,10 @@ class ComposerController extends BaseController with DragDropFileMixin {
}
}

void _addScrollControllerListener() {
scrollController.addListener(_onScrollToBottomListener);
}

void createFocusNodeInput() {
toAddressFocusNode = FocusNode();
ccAddressFocusNode = FocusNode();
Expand Down Expand Up @@ -1700,6 +1706,20 @@ class ComposerController extends BaseController with DragDropFileMixin {
}
}

void _onScrollToBottomListener() {
if (scrollController.position.atEdge // screen at top or bottom edge
&& scrollController.position.pixels > 0 // screen not at top
&& !_isEmailBodyLoaded // email not loaded
&& !ToastView.isVisible // no toast showing
&& currentOverlayContext != null
&& currentContext != null
) {
appToast.showToastMessage(
currentOverlayContext!,
AppLocalizations.of(currentContext!).emailContentIsBeingLoaded);
}
}

void toggleRequestReadReceipt() {
hasRequestReadReceipt.toggle();
}
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/intl_messages.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3813,5 +3813,11 @@
"type": "text",
"placeholders_order": [],
"placeholders": {}
},
"emailContentIsBeingLoaded": "Email content is being loaded",
"@emailContentIsBeingLoaded": {
"type": "text",
"placeholders_order": [],
"placeholders": {}
}
}
7 changes: 7 additions & 0 deletions lib/main/localizations/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3971,4 +3971,11 @@ class AppLocalizations {
'Show less',
name: 'showLess');
}

String get emailContentIsBeingLoaded {
return Intl.message(
'Email content is being loaded',
name: 'emailContentIsBeingLoaded'
);
}
}

0 comments on commit 9b89c8b

Please sign in to comment.