TF-4193 Add Label to Preferences in Setting
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/preferences/preferences_config.dart';
|
||||
|
||||
part 'label_config.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class LabelConfig extends PreferencesConfig {
|
||||
final bool isEnabled;
|
||||
|
||||
LabelConfig({this.isEnabled = false});
|
||||
|
||||
factory LabelConfig.initial() => LabelConfig();
|
||||
|
||||
factory LabelConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$LabelConfigFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$LabelConfigToJson(this);
|
||||
|
||||
@override
|
||||
List<Object> get props => [isEnabled];
|
||||
}
|
||||
|
||||
extension LabelConfigExtension on LabelConfig {
|
||||
LabelConfig copyWith({bool? isEnabled}) {
|
||||
return LabelConfig(
|
||||
isEnabled: isEnabled ?? this.isEnabled,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/preferences/ai_scribe_config.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/preferences/label_config.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/preferences/preferences_config.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/preferences/spam_report_config.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/preferences/text_formatting_menu_config.dart';
|
||||
@@ -60,6 +61,16 @@ class PreferencesSetting with EquatableMixin {
|
||||
}
|
||||
}
|
||||
|
||||
LabelConfig get labelConfig {
|
||||
final labelConfig =
|
||||
configs.firstWhereOrNull((config) => config is LabelConfig);
|
||||
if (labelConfig != null) {
|
||||
return labelConfig as LabelConfig;
|
||||
} else {
|
||||
return LabelConfig.initial();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [configs];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user