-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3002 [MOBILE] Fix
no result
screen still show during search is i…
…n progress
- Loading branch information
Showing
4 changed files
with
103 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
lib/features/search/email/presentation/widgets/empty_search_email_widget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
); | ||
} | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters