revanced-manager/lib/models/patch.dart

49 lines
1.1 KiB
Dart
Raw Normal View History

import 'package:json_annotation/json_annotation.dart';
import 'package:revanced_manager/utils/string.dart';
part 'patch.g.dart';
@JsonSerializable()
2022-08-06 15:04:18 +02:00
class Patch {
Patch({
required this.name,
required this.description,
required this.excluded,
required this.dependencies,
required this.compatiblePackages,
2022-08-06 15:04:18 +02:00
});
factory Patch.fromJson(Map<String, dynamic> json) => _$PatchFromJson(json);
final String name;
final String description;
final bool excluded;
final List<String> dependencies;
final List<Package> compatiblePackages;
Map<String, dynamic> toJson() => _$PatchToJson(this);
String getSimpleName() {
return name
.replaceAll('-', ' ')
.split('-')
.join(' ')
.toTitleCase()
.replaceFirst('Microg', 'MicroG');
}
}
@JsonSerializable()
class Package {
Package({
required this.name,
required this.versions,
});
factory Package.fromJson(Map<String, dynamic> json) =>
_$PackageFromJson(json);
final String name;
final List<String> versions;
Map toJson() => _$PackageToJson(this);
2022-08-06 15:04:18 +02:00
}