Merge pull request 'feat: add "other" records category' (#588) from def/add_other_category into master

Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/588
Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
Inex Code 2024-10-16 18:07:11 +03:00
commit cd52527b59
4 changed files with 55 additions and 9 deletions

View file

@ -215,6 +215,8 @@
"services_subtitle": "Type “A” records required for each service.", "services_subtitle": "Type “A” records required for each service.",
"email_title": "Email", "email_title": "Email",
"email_subtitle": "Records necessary for secure email exchange.", "email_subtitle": "Records necessary for secure email exchange.",
"other_title": "Other",
"other_subtitle": "Other records needed for the work of the SelfPrivacy",
"update_list": "Update list" "update_list": "Update list"
}, },
"backup": { "backup": {

View file

@ -10,7 +10,6 @@ class DesiredDnsRecord {
required this.content, required this.content,
this.type = 'A', this.type = 'A',
this.description = '', this.description = '',
this.category = DnsRecordsCategory.services,
this.isSatisfied = false, this.isSatisfied = false,
this.displayName, this.displayName,
}); });
@ -20,16 +19,25 @@ class DesiredDnsRecord {
final String content; final String content;
final String description; final String description;
final String? displayName; final String? displayName;
final DnsRecordsCategory category;
final bool isSatisfied; final bool isSatisfied;
DnsRecordsCategory get category {
switch (type) {
case 'A':
return DnsRecordsCategory.services;
case 'CAA':
return DnsRecordsCategory.other;
default:
return DnsRecordsCategory.email;
}
}
DesiredDnsRecord copyWith({ DesiredDnsRecord copyWith({
final String? name, final String? name,
final String? type, final String? type,
final String? content, final String? content,
final String? description, final String? description,
final String? displayName, final String? displayName,
final DnsRecordsCategory? category,
final bool? isSatisfied, final bool? isSatisfied,
}) => }) =>
DesiredDnsRecord( DesiredDnsRecord(
@ -37,7 +45,6 @@ class DesiredDnsRecord {
type: type ?? this.type, type: type ?? this.type,
content: content ?? this.content, content: content ?? this.content,
description: description ?? this.description, description: description ?? this.description,
category: category ?? this.category,
isSatisfied: isSatisfied ?? this.isSatisfied, isSatisfied: isSatisfied ?? this.isSatisfied,
displayName: displayName ?? this.displayName, displayName: displayName ?? this.displayName,
); );

View file

@ -122,7 +122,6 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
content: pendingDnsRecord.content!, content: pendingDnsRecord.content!,
isSatisfied: isSatisfied, isSatisfied: isSatisfied,
type: pendingDnsRecord.type, type: pendingDnsRecord.type,
category: DnsRecordsCategory.email,
), ),
); );
} else { } else {
@ -138,9 +137,7 @@ class DnsRecordsCubit extends ServerConnectionDependentCubit<DnsRecordsState> {
displayName: pendingDnsRecord.displayName, displayName: pendingDnsRecord.displayName,
content: pendingDnsRecord.content!, content: pendingDnsRecord.content!,
isSatisfied: foundMatch, isSatisfied: foundMatch,
category: pendingDnsRecord.type == 'A' type: pendingDnsRecord.type,
? DnsRecordsCategory.services
: DnsRecordsCategory.email,
), ),
); );
} }

View file

@ -198,6 +198,46 @@ class _DnsDetailsPageState extends State<DnsDetailsPage> {
], ],
), ),
), ),
const SizedBox(height: 16.0),
ListTile(
title: Text(
'domain.other_title'.tr(),
style: Theme.of(context).textTheme.headlineSmall!.copyWith(
color: Theme.of(context).colorScheme.secondary,
),
),
subtitle: Text(
'domain.other_subtitle'.tr(),
style: Theme.of(context).textTheme.labelMedium,
),
),
...dnsCubit.dnsRecords
.where(
(final dnsRecord) =>
dnsRecord.category == DnsRecordsCategory.other,
)
.map(
(final dnsRecord) => Column(
children: [
ListTile(
leading: Icon(
dnsRecord.isSatisfied
? Icons.check_circle_outline
: dnsCubit.dnsState == DnsRecordsStatus.refreshing
? Icons.refresh
: Icons.error_outline,
color: dnsRecord.isSatisfied
? goodColor
: dnsCubit.dnsState == DnsRecordsStatus.refreshing
? neutralColor
: errorColor,
),
title: Text(dnsRecord.displayName ?? dnsRecord.name),
subtitle: Text(dnsRecord.content),
),
],
),
),
], ],
); );
} }