frosty/lib/models/emotes.dart

234 lines
5.3 KiB
Dart
Raw Normal View History

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;
final String? ownerId;
2021-08-18 13:23:13 -04:00
const EmoteTwitch(
this.id,
this.name,
this.emoteType,
this.ownerId,
);
2021-08-18 13:23:13 -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)
class EmoteBTTV {
2021-08-18 13:23:13 -04:00
final String id;
final String code;
const EmoteBTTV(
this.id,
this.code,
);
2021-08-18 13:23:13 -04:00
factory EmoteBTTV.fromJson(Map<String, dynamic> json) =>
_$EmoteBTTVFromJson(json);
2021-08-18 13:23:13 -04:00
}
@JsonSerializable(createToJson: false)
class EmoteBTTVChannel {
final List<EmoteBTTV> channelEmotes;
final List<EmoteBTTV> sharedEmotes;
2021-08-18 13:23:13 -04:00
const EmoteBTTVChannel(
this.channelEmotes,
this.sharedEmotes,
);
2021-08-18 13:23:13 -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 *
@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-08-18 13:23:13 -04:00
factory RoomFFZ.fromJson(Map<String, dynamic> json) =>
_$RoomFFZFromJson(json);
2021-08-18 13:23:13 -04:00
}
@JsonSerializable(createToJson: false)
class ImagesFFZ {
@JsonKey(name: '1')
2021-08-18 13:23:13 -04:00
final String url1x;
@JsonKey(name: '2')
2021-08-18 13:23:13 -04:00
final String? url2x;
@JsonKey(name: '4')
2021-08-18 13:23:13 -04:00
final String? url4x;
const ImagesFFZ(
this.url1x,
this.url2x,
this.url4x,
);
2021-08-18 13:23:13 -04:00
factory ImagesFFZ.fromJson(Map<String, dynamic> json) =>
_$ImagesFFZFromJson(json);
2021-08-18 13:23:13 -04:00
}
@JsonSerializable(createToJson: false)
class EmoteFFZ {
final String name;
final int height;
final int width;
final ImagesFFZ urls;
2021-08-18 13:23:13 -04:00
const EmoteFFZ(
this.name,
this.height,
this.width,
this.urls,
);
2021-08-18 13:23:13 -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;
const Emote7TV(
this.name,
this.visibilitySimple,
this.width,
this.height,
this.urls,
);
2021-09-01 22:58:42 -04:00
factory Emote7TV.fromJson(Map<String, dynamic> json) =>
_$Emote7TVFromJson(json);
2021-09-01 22:58:42 -04:00
}
/// The common emote class.
@JsonSerializable()
class Emote {
final String name;
final int? width;
final int? height;
final bool zeroWidth;
final String url;
final EmoteType type;
final String? ownerId;
const Emote({
required this.name,
this.width,
this.height,
required this.zeroWidth,
required this.url,
required this.type,
this.ownerId,
});
factory Emote.fromTwitch(EmoteTwitch emote, EmoteType type) => Emote(
name: emote.name,
zeroWidth: false,
url:
'https://static-cdn.jtvnw.net/emoticons/v2/${emote.id}/default/dark/3.0',
type: type,
ownerId: emote.ownerId,
);
factory Emote.fromBTTV(EmoteBTTV emote, EmoteType type) => Emote(
name: emote.code,
zeroWidth: zeroWidthEmotes.contains(emote.code),
url: 'https://cdn.betterttv.net/emote/${emote.id}/3x',
type: type,
);
factory Emote.fromFFZ(EmoteFFZ emote, EmoteType type) => Emote(
name: emote.name,
zeroWidth: false,
width: emote.width,
height: emote.height,
url: emote.urls.url4x ?? emote.urls.url2x ?? emote.urls.url1x,
type: type,
);
factory Emote.from7TV(Emote7TV emote, EmoteType type) => Emote(
name: emote.name,
width: emote.width.first,
height: emote.height.first,
zeroWidth: emote.visibilitySimple.contains('ZERO_WIDTH'),
url: emote.urls[3][1],
type: type,
);
factory Emote.fromJson(Map<String, dynamic> json) => _$EmoteFromJson(json);
Map<String, dynamic> toJson() => _$EmoteToJson(this);
}
enum EmoteType {
2022-02-03 21:43:59 -05:00
twitchBits,
twitchFollower,
twitchSub,
twitchGlobal,
twitchUnlocked,
twitchChannel,
ffzGlobal,
ffzChannel,
bttvGlobal,
bttvChannel,
bttvShared,
sevenTVGlobal,
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
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';
}
}
}