Solian/lib/models/stickers.dart

83 lines
1.9 KiB
Dart
Raw Normal View History

2024-09-16 18:14:23 +00:00
import 'package:json_annotation/json_annotation.dart';
2024-08-03 17:03:09 +00:00
import 'package:solian/models/account.dart';
import 'package:solian/models/attachment.dart';
2024-08-06 10:18:40 +00:00
import 'package:solian/services.dart';
2024-08-03 17:03:09 +00:00
part 'stickers.g.dart';
@JsonSerializable()
2024-08-03 17:03:09 +00:00
class Sticker {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String alias;
String name;
int attachmentId;
Attachment attachment;
int packId;
StickerPack? pack;
int accountId;
Account account;
Sticker({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.alias,
required this.name,
required this.attachmentId,
required this.attachment,
required this.packId,
required this.pack,
required this.accountId,
required this.account,
});
2024-08-06 17:47:53 +00:00
String get textPlaceholder => '${pack?.prefix}$alias';
2024-08-06 10:18:40 +00:00
String get textWarpedPlaceholder => ':$textPlaceholder:';
String get imageUrl => ServiceFinder.buildUrl(
'files',
'/attachments/${attachment.rid}',
2024-08-06 10:18:40 +00:00
);
factory Sticker.fromJson(Map<String, dynamic> json) =>
_$StickerFromJson(json);
2024-08-03 17:03:09 +00:00
Map<String, dynamic> toJson() => _$StickerToJson(this);
2024-08-03 17:03:09 +00:00
}
@JsonSerializable()
2024-08-03 17:03:09 +00:00
class StickerPack {
int id;
DateTime createdAt;
DateTime updatedAt;
DateTime? deletedAt;
String prefix;
String name;
String description;
List<Sticker>? stickers;
int accountId;
Account account;
StickerPack({
required this.id,
required this.createdAt,
required this.updatedAt,
required this.deletedAt,
required this.prefix,
required this.name,
required this.description,
required this.stickers,
required this.accountId,
required this.account,
});
factory StickerPack.fromJson(Map<String, dynamic> json) =>
_$StickerPackFromJson(json);
2024-08-03 17:03:09 +00:00
Map<String, dynamic> toJson() => _$StickerPackToJson(this);
2024-08-03 17:03:09 +00:00
}