Files
umbrix/lib/features/proxy/model/proxy_entity.dart

39 lines
1.0 KiB
Dart
Raw Normal View History

2023-12-01 12:56:24 +03:30
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hiddify/singbox/model/singbox_proxy_type.dart';
part 'proxy_entity.freezed.dart';
@freezed
class ProxyGroupEntity with _$ProxyGroupEntity {
const ProxyGroupEntity._();
const factory ProxyGroupEntity({
required String tag,
required ProxyType type,
required String selected,
@Default([]) List<ProxyItemEntity> items,
}) = _ProxyGroupEntity;
String get name => _sanitizedTag(tag);
}
@freezed
class ProxyItemEntity with _$ProxyItemEntity {
const ProxyItemEntity._();
const factory ProxyItemEntity({
required String tag,
required ProxyType type,
required int urlTestDelay,
String? selectedTag,
}) = _ProxyItemEntity;
String get name => _sanitizedTag(tag);
String? get selectedName =>
selectedTag == null ? null : _sanitizedTag(selectedTag!);
2024-02-07 11:24:33 +01:00
bool get isVisible => !tag.contains("§hide§");
2023-12-01 12:56:24 +03:30
}
String _sanitizedTag(String tag) =>
tag.replaceFirst(RegExp(r"\§[^]*"), "").trimRight();