TF-3002 [MOBILE] Fix no result screen still show during search is in progress
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/state/search_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/widgets/empty_emails_widget.dart';
|
||||
|
||||
class EmptySearchEmailWidget extends StatelessWidget {
|
||||
|
||||
final Either<Failure, Success> resultSearchViewState;
|
||||
final Either<Failure, Success> suggestionViewState;
|
||||
final bool isNetworkConnectionAvailable;
|
||||
|
||||
const EmptySearchEmailWidget({
|
||||
super.key,
|
||||
required this.resultSearchViewState,
|
||||
required this.suggestionViewState,
|
||||
required this.isNetworkConnectionAvailable,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return resultSearchViewState.fold(
|
||||
(failure) => _suggestionViewStateToUI(suggestionViewState),
|
||||
(success) {
|
||||
if (success is SearchingState) {
|
||||
return const SizedBox.shrink();
|
||||
} else {
|
||||
return _suggestionViewStateToUI(suggestionViewState);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Widget _suggestionViewStateToUI(Either<Failure, Success> viewState) {
|
||||
return viewState.fold(
|
||||
(failure) => EmptyEmailsWidget(
|
||||
key: const Key('empty_search_email_view'),
|
||||
isNetworkConnectionAvailable: isNetworkConnectionAvailable,
|
||||
isSearchActive: true
|
||||
),
|
||||
(success) {
|
||||
if (success is LoadingState) {
|
||||
return const SizedBox.shrink();
|
||||
} else {
|
||||
return EmptyEmailsWidget(
|
||||
key: const Key('empty_search_email_view'),
|
||||
isNetworkConnectionAvailable: isNetworkConnectionAvailable,
|
||||
isSearchActive: true
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+17
-19
@@ -20,17 +20,7 @@ class SearchEmailLoadingBarWidget extends StatelessWidget with AppLoaderMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return resultSearchViewState.fold(
|
||||
(failure) {
|
||||
return suggestionViewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) => success is LoadingState
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: loadingWidget
|
||||
)
|
||||
: const SizedBox.shrink()
|
||||
);
|
||||
},
|
||||
(failure) => _suggestionViewStateToUI(suggestionViewState),
|
||||
(success) {
|
||||
if (success is SearchingState) {
|
||||
return Padding(
|
||||
@@ -38,15 +28,23 @@ class SearchEmailLoadingBarWidget extends StatelessWidget with AppLoaderMixin {
|
||||
child: loadingWidget
|
||||
);
|
||||
} else {
|
||||
return suggestionViewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) => success is LoadingState
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: loadingWidget
|
||||
)
|
||||
: const SizedBox.shrink()
|
||||
return _suggestionViewStateToUI(suggestionViewState);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Widget _suggestionViewStateToUI(Either<Failure, Success> viewState) {
|
||||
return viewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) {
|
||||
if (success is LoadingState) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: loadingWidget
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user