2022-08-31 14:11:45 -04:00
|
|
|
import 'package:frosty/constants.dart';
|
2021-08-18 13:23:13 -04:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
|
|
|
|
|
|
part 'emotes.g.dart';
|
|
|
|
|
|
2021-09-01 22:58:42 -04:00
|
|
|
// * Twitch Emotes *
|
2021-08-19 18:18:48 -04:00
|
|
|
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
|
2021-08-18 13:23:13 -04:00
|
|
|
class EmoteTwitch {
|
|
|
|
|
final String id;
|
|
|
|
|
final String name;
|
|
|
|
|
final String? emoteType;
|
2021-12-22 17:50:42 -05:00
|
|
|
final String? ownerId;
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2021-11-18 22:13:01 -05:00
|
|
|
const EmoteTwitch(
|
|
|
|
|
this.id,
|
|
|
|
|
this.name,
|
|
|
|
|
this.emoteType,
|
2021-12-22 17:50:42 -05:00
|
|
|
this.ownerId,
|
2021-11-18 22:13:01 -05:00
|
|
|
);
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory EmoteTwitch.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$EmoteTwitchFromJson(json);
|
2021-08-18 13:23:13 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-01 22:58:42 -04:00
|
|
|
// * BTTV Emotes *
|
2021-08-18 13:23:13 -04:00
|
|
|
@JsonSerializable(createToJson: false)
|
2021-12-12 16:02:46 -05:00
|
|
|
class EmoteBTTV {
|
2021-08-18 13:23:13 -04:00
|
|
|
final String id;
|
|
|
|
|
final String code;
|
|
|
|
|
|
2021-12-12 16:02:46 -05:00
|
|
|
const EmoteBTTV(
|
2021-11-18 22:13:01 -05:00
|
|
|
this.id,
|
|
|
|
|
this.code,
|
|
|
|
|
);
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory EmoteBTTV.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$EmoteBTTVFromJson(json);
|
2021-08-18 13:23:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
|
|
|
class EmoteBTTVChannel {
|
2021-12-12 16:02:46 -05:00
|
|
|
final List<EmoteBTTV> channelEmotes;
|
|
|
|
|
final List<EmoteBTTV> sharedEmotes;
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2021-11-18 22:13:01 -05:00
|
|
|
const EmoteBTTVChannel(
|
|
|
|
|
this.channelEmotes,
|
|
|
|
|
this.sharedEmotes,
|
|
|
|
|
);
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory EmoteBTTVChannel.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$EmoteBTTVChannelFromJson(json);
|
2021-08-18 13:23:13 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-01 22:58:42 -04:00
|
|
|
// * FFZ Emotes *
|
2021-12-31 20:34:12 -05:00
|
|
|
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
|
|
|
|
|
class RoomFFZ {
|
|
|
|
|
final int set;
|
|
|
|
|
final ImagesFFZ? vipBadge;
|
|
|
|
|
final ImagesFFZ? modUrls;
|
|
|
|
|
|
|
|
|
|
const RoomFFZ(
|
|
|
|
|
this.set,
|
|
|
|
|
this.vipBadge,
|
|
|
|
|
this.modUrls,
|
2021-11-18 22:13:01 -05:00
|
|
|
);
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory RoomFFZ.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$RoomFFZFromJson(json);
|
2021-08-18 13:23:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
|
|
|
class ImagesFFZ {
|
2021-12-31 20:34:12 -05:00
|
|
|
@JsonKey(name: '1')
|
2021-08-18 13:23:13 -04:00
|
|
|
final String url1x;
|
2021-12-31 20:34:12 -05:00
|
|
|
@JsonKey(name: '2')
|
2021-08-18 13:23:13 -04:00
|
|
|
final String? url2x;
|
2021-12-31 20:34:12 -05:00
|
|
|
@JsonKey(name: '4')
|
2021-08-18 13:23:13 -04:00
|
|
|
final String? url4x;
|
|
|
|
|
|
2021-11-18 22:13:01 -05:00
|
|
|
const ImagesFFZ(
|
|
|
|
|
this.url1x,
|
|
|
|
|
this.url2x,
|
|
|
|
|
this.url4x,
|
|
|
|
|
);
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory ImagesFFZ.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$ImagesFFZFromJson(json);
|
2021-08-18 13:23:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false)
|
|
|
|
|
class EmoteFFZ {
|
2021-12-31 20:34:12 -05:00
|
|
|
final String name;
|
|
|
|
|
final int height;
|
|
|
|
|
final int width;
|
|
|
|
|
final ImagesFFZ urls;
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2021-11-18 22:13:01 -05:00
|
|
|
const EmoteFFZ(
|
2021-12-31 20:34:12 -05:00
|
|
|
this.name,
|
|
|
|
|
this.height,
|
|
|
|
|
this.width,
|
|
|
|
|
this.urls,
|
2021-11-18 22:13:01 -05:00
|
|
|
);
|
2021-08-18 13:23:13 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory EmoteFFZ.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$EmoteFFZFromJson(json);
|
2021-08-18 13:23:13 -04:00
|
|
|
}
|
2021-09-01 22:58:42 -04:00
|
|
|
|
|
|
|
|
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
|
|
|
|
|
class Emote7TV {
|
|
|
|
|
final String name;
|
|
|
|
|
final List<String> visibilitySimple;
|
|
|
|
|
final List<int> width;
|
|
|
|
|
final List<int> height;
|
|
|
|
|
final List<List<String>> urls;
|
|
|
|
|
|
2021-11-18 22:13:01 -05:00
|
|
|
const Emote7TV(
|
|
|
|
|
this.name,
|
|
|
|
|
this.visibilitySimple,
|
|
|
|
|
this.width,
|
|
|
|
|
this.height,
|
|
|
|
|
this.urls,
|
|
|
|
|
);
|
2021-09-01 22:58:42 -04:00
|
|
|
|
2023-04-29 11:34:28 -04:00
|
|
|
factory Emote7TV.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$Emote7TVFromJson(json);
|
2021-09-01 22:58:42 -04:00
|
|
|
}
|
2021-12-12 16:02:46 -05:00
|
|
|
|
|
|
|
|
/// The common emote class.
|
2022-01-19 23:01:31 -05:00
|
|
|
@JsonSerializable()
|
2021-12-12 16:02:46 -05:00
|
|
|
class Emote {
|
|
|
|
|
final String name;
|
|
|
|
|
final int? width;
|
|
|
|
|
final int? height;
|
2021-12-15 01:49:25 -05:00
|
|
|
final bool zeroWidth;
|
2021-12-12 16:02:46 -05:00
|
|
|
final String url;
|
|
|
|
|
final EmoteType type;
|
2022-07-03 05:43:29 -04:00
|
|
|
final String? ownerId;
|
2021-12-12 16:02:46 -05:00
|
|
|
|
2021-12-15 01:49:25 -05:00
|
|
|
const Emote({
|
|
|
|
|
required this.name,
|
2021-12-12 16:02:46 -05:00
|
|
|
this.width,
|
|
|
|
|
this.height,
|
2021-12-15 01:49:25 -05:00
|
|
|
required this.zeroWidth,
|
|
|
|
|
required this.url,
|
|
|
|
|
required this.type,
|
2022-07-03 05:43:29 -04:00
|
|
|
this.ownerId,
|
2021-12-15 01:49:25 -05:00
|
|
|
});
|
2021-12-12 16:02:46 -05:00
|
|
|
|
|
|
|
|
factory Emote.fromTwitch(EmoteTwitch emote, EmoteType type) => Emote(
|
2021-12-15 01:49:25 -05:00
|
|
|
name: emote.name,
|
|
|
|
|
zeroWidth: false,
|
2023-04-29 11:34:28 -04:00
|
|
|
url:
|
|
|
|
|
'https://static-cdn.jtvnw.net/emoticons/v2/${emote.id}/default/dark/3.0',
|
2021-12-15 01:49:25 -05:00
|
|
|
type: type,
|
2022-07-03 05:43:29 -04:00
|
|
|
ownerId: emote.ownerId,
|
2021-12-12 16:02:46 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
factory Emote.fromBTTV(EmoteBTTV emote, EmoteType type) => Emote(
|
2021-12-15 01:49:25 -05:00
|
|
|
name: emote.code,
|
|
|
|
|
zeroWidth: zeroWidthEmotes.contains(emote.code),
|
|
|
|
|
url: 'https://cdn.betterttv.net/emote/${emote.id}/3x',
|
|
|
|
|
type: type,
|
2021-12-12 16:02:46 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
factory Emote.fromFFZ(EmoteFFZ emote, EmoteType type) => Emote(
|
2021-12-31 20:34:12 -05:00
|
|
|
name: emote.name,
|
2021-12-15 01:49:25 -05:00
|
|
|
zeroWidth: false,
|
2022-03-28 02:48:32 -04:00
|
|
|
width: emote.width,
|
|
|
|
|
height: emote.height,
|
2023-03-05 05:23:06 -05:00
|
|
|
url: emote.urls.url4x ?? emote.urls.url2x ?? emote.urls.url1x,
|
2021-12-15 01:49:25 -05:00
|
|
|
type: type,
|
2021-12-12 16:02:46 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
factory Emote.from7TV(Emote7TV emote, EmoteType type) => Emote(
|
2021-12-15 01:49:25 -05:00
|
|
|
name: emote.name,
|
|
|
|
|
width: emote.width.first,
|
|
|
|
|
height: emote.height.first,
|
2022-05-11 23:10:02 -04:00
|
|
|
zeroWidth: emote.visibilitySimple.contains('ZERO_WIDTH'),
|
2021-12-15 01:49:25 -05:00
|
|
|
url: emote.urls[3][1],
|
|
|
|
|
type: type,
|
2021-12-12 16:02:46 -05:00
|
|
|
);
|
2022-01-19 23:01:31 -05:00
|
|
|
|
|
|
|
|
factory Emote.fromJson(Map<String, dynamic> json) => _$EmoteFromJson(json);
|
|
|
|
|
Map<String, dynamic> toJson() => _$EmoteToJson(this);
|
2021-12-12 16:02:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum EmoteType {
|
2022-02-03 21:43:59 -05:00
|
|
|
twitchBits,
|
|
|
|
|
twitchFollower,
|
2021-12-22 17:50:42 -05:00
|
|
|
twitchSub,
|
2021-12-12 16:02:46 -05:00
|
|
|
twitchGlobal,
|
2021-12-22 17:50:42 -05:00
|
|
|
twitchUnlocked,
|
2021-12-12 16:02:46 -05:00
|
|
|
twitchChannel,
|
|
|
|
|
ffzGlobal,
|
|
|
|
|
ffzChannel,
|
|
|
|
|
bttvGlobal,
|
|
|
|
|
bttvChannel,
|
|
|
|
|
bttvShared,
|
2022-01-16 20:14:24 -05:00
|
|
|
sevenTVGlobal,
|
2023-10-22 18:38:32 -04:00
|
|
|
sevenTVChannel;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
String toString() {
|
|
|
|
|
switch (this) {
|
|
|
|
|
case EmoteType.twitchBits:
|
|
|
|
|
return 'Twitch bits emote';
|
|
|
|
|
case EmoteType.twitchFollower:
|
|
|
|
|
return 'Twitch follower emote';
|
|
|
|
|
case EmoteType.twitchSub:
|
|
|
|
|
return 'Twitch sub emote';
|
|
|
|
|
case EmoteType.twitchGlobal:
|
|
|
|
|
return 'Twitch global emote';
|
|
|
|
|
case EmoteType.twitchUnlocked:
|
|
|
|
|
return 'Twitch unlocked emote';
|
|
|
|
|
case EmoteType.twitchChannel:
|
|
|
|
|
return 'Twitch channel emote';
|
|
|
|
|
case EmoteType.ffzGlobal:
|
|
|
|
|
return 'FrankerFaceZ global emote';
|
|
|
|
|
case EmoteType.ffzChannel:
|
|
|
|
|
return 'FrankerFaceZ channel emote';
|
|
|
|
|
case EmoteType.bttvGlobal:
|
|
|
|
|
return 'BetterTTV global emote';
|
|
|
|
|
case EmoteType.bttvChannel:
|
|
|
|
|
return 'BetterTTV channel emote';
|
|
|
|
|
case EmoteType.bttvShared:
|
|
|
|
|
return 'BetterTTV shared emote';
|
|
|
|
|
case EmoteType.sevenTVGlobal:
|
|
|
|
|
return '7TV global emote';
|
|
|
|
|
case EmoteType.sevenTVChannel:
|
|
|
|
|
return '7TV channel emote';
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-12 16:02:46 -05:00
|
|
|
}
|