mirror of
https://github.com/linagora/tmail-flutter.git
synced 2026-12-05 16:08:46 +00:00
42 lines
1.5 KiB
Dart
42 lines
1.5 KiB
Dart
import 'package:tmail_ui_user/features/thread/presentation/model/email_selection_action_type.dart';
|
|
import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_builder.dart';
|
|
|
|
import '../base/core_robot.dart';
|
|
import '../utils/wait_for_condition.dart';
|
|
import 'abstract/abstract_thread_selection_robot.dart';
|
|
|
|
class ThreadSelectionRobot extends CoreRobot implements AbstractThreadSelectionRobot {
|
|
ThreadSelectionRobot(super.$);
|
|
|
|
@override
|
|
Future<void> selectEmailWithSubject(String subject) => waitForCondition(
|
|
() async {
|
|
// Checked before pressing: a second press on a selected tile unselects it.
|
|
if (_isEmailSelected(subject)) return true;
|
|
await $(subject).longPress();
|
|
return _isEmailSelected(subject);
|
|
},
|
|
reason: 'Email "$subject" was not selected',
|
|
);
|
|
|
|
bool _isEmailSelected(String subject) => $(EmailTileBuilder)
|
|
.which<EmailTileBuilder>((tile) =>
|
|
tile.presentationEmail.subject == subject && tile.presentationEmail.isSelected)
|
|
.exists;
|
|
|
|
@override
|
|
Future<void> tapStarSelectedEmails() =>
|
|
_tapMoreAction(EmailSelectionActionType.markAsStarred);
|
|
|
|
@override
|
|
Future<void> tapUnstarSelectedEmails() =>
|
|
_tapMoreAction(EmailSelectionActionType.unMarkAsStarred);
|
|
|
|
Future<void> _tapMoreAction(EmailSelectionActionType action) async {
|
|
await $(#moreAction_selected_email_button).tap();
|
|
await $.pumpAndTrySettle();
|
|
await $(Symbol('${action.name}_action')).tap();
|
|
await $.pumpAndTrySettle();
|
|
}
|
|
}
|