TF-2362 Add LoadMoreProgressBar as item email list
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit 1e3ffabfad18df3a1dc72de629413049b96fe595)
This commit is contained in:
@@ -37,7 +37,6 @@ import 'package:tmail_ui_user/features/thread/presentation/widgets/empty_emails_
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/filter_message_cupertino_action_sheet_action_builder.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/scroll_to_top_button_widget.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/spam_banner/spam_report_banner_widget.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/thread_view_bottom_loading_bar_widget.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/thread_view_loading_bar_widget.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
@@ -190,7 +189,6 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
})
|
||||
)
|
||||
),
|
||||
Obx(() => ThreadViewBottomLoadingBarWidget(viewState: controller.viewState.value)),
|
||||
_buildListButtonSelectionForMobile(context),
|
||||
]
|
||||
)
|
||||
@@ -355,13 +353,16 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
key: const PageStorageKey('list_presentation_email_in_threads'),
|
||||
controller: controller.listEmailController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: listPresentationEmail.length + 1,
|
||||
itemCount: listPresentationEmail.length + 2,
|
||||
itemBuilder: (context, index) => Obx(() {
|
||||
if (index == listPresentationEmail.length) {
|
||||
return _buildLoadMoreButton(
|
||||
context,
|
||||
controller.loadingMoreStatus.value);
|
||||
}
|
||||
if (index == listPresentationEmail.length + 1) {
|
||||
return _buildLoadMoreProgressBar(controller.loadingMoreStatus.value);
|
||||
}
|
||||
return _buildEmailItemNotDraggable(
|
||||
context,
|
||||
listPresentationEmail[index]);
|
||||
@@ -386,13 +387,16 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
key: const PageStorageKey('list_presentation_email_in_threads'),
|
||||
controller: controller.listEmailController,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: listPresentationEmail.length + 1,
|
||||
itemCount: listPresentationEmail.length + 2,
|
||||
itemBuilder: (context, index) => Obx(() {
|
||||
if (index == listPresentationEmail.length) {
|
||||
return _buildLoadMoreButton(
|
||||
context,
|
||||
controller.loadingMoreStatus.value);
|
||||
}
|
||||
if (index == listPresentationEmail.length + 1) {
|
||||
return _buildLoadMoreProgressBar(controller.loadingMoreStatus.value);
|
||||
}
|
||||
return _buildEmailItem(
|
||||
context,
|
||||
listPresentationEmail[index]);
|
||||
@@ -454,6 +458,13 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
Widget _buildLoadMoreProgressBar(LoadingMoreStatus loadingMoreStatus) {
|
||||
if (loadingMoreStatus.isRunning) {
|
||||
return const CupertinoLoadingWidget();
|
||||
}
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
Widget _buildEmailItem(BuildContext context, PresentationEmail presentationEmail) {
|
||||
if (controller.responsiveUtils.isWebDesktop(context)) {
|
||||
return _buildEmailItemDraggable(context, presentationEmail);
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/presentation/views/loading/cupertino_loading_widget.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/load_more_emails_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_more_email_state.dart';
|
||||
|
||||
class ThreadViewBottomLoadingBarWidget extends StatelessWidget {
|
||||
|
||||
final Either<Failure, Success> viewState;
|
||||
|
||||
const ThreadViewBottomLoadingBarWidget({
|
||||
super.key,
|
||||
required this.viewState,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return viewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) {
|
||||
if (success is SearchingMoreState || success is LoadingMoreEmails) {
|
||||
return const Padding(
|
||||
padding: EdgeInsetsDirectional.only(bottom: 16),
|
||||
child: CupertinoLoadingWidget());
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user