TF-4193 Show/Hide Label list when toggle label state in Setting

This commit is contained in:
dab246
2025-12-09 16:05:19 +07:00
committed by Dat H. Pham
parent 10038a3836
commit ef2ab39a3a
18 changed files with 209 additions and 24 deletions
@@ -16,4 +16,6 @@ abstract class ManageAccountRepository {
Future<bool> getLabelVisibility();
Future<void> saveLabelVisibility(bool visible);
Future<bool> getLabelSettingState();
}
@@ -0,0 +1,19 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
class GettingLabelSettingState extends LoadingState {}
class GetLabelSettingStateSuccess extends UIState {
final bool isEnabled;
final AccountId accountId;
GetLabelSettingStateSuccess(this.isEnabled, this.accountId);
@override
List<Object> get props => [isEnabled, accountId];
}
class GetLabelSettingStateFailure extends FeatureFailure {
GetLabelSettingStateFailure(dynamic exception) : super(exception: exception);
}
@@ -0,0 +1,22 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
import 'package:tmail_ui_user/features/manage_account/domain/state/get_label_setting_state.dart';
class GetLabelSettingStateInteractor {
final ManageAccountRepository _manageAccountRepository;
GetLabelSettingStateInteractor(this._manageAccountRepository);
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
try {
yield Right(GettingLabelSettingState());
final isEnable = await _manageAccountRepository.getLabelSettingState();
yield Right(GetLabelSettingStateSuccess(isEnable, accountId));
} catch (e) {
yield Left(GetLabelSettingStateFailure(e));
}
}
}