Files
frosty/lib/models/badges.dart
Tommy Chow 9a6892746d 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

171 lines
3.5 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
part 'badges.g.dart';
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class BadgeInfoTwitch {
@JsonKey(name: 'image_url_1x')
final String imageUrl1x;
@JsonKey(name: 'image_url_2x')
final String imageUrl2x;
@JsonKey(name: 'image_url_4x')
final String imageUrl4x;
final String id;
final String title;
final String description;
const BadgeInfoTwitch(
this.imageUrl1x,
this.imageUrl2x,
this.imageUrl4x,
this.id,
this.title,
this.description,
);
factory BadgeInfoTwitch.fromJson(Map<String, dynamic> json) =>
_$BadgeInfoTwitchFromJson(json);
}
@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class BadgeInfoFFZ {
final int id;
final String title;
final String color;
final BadgeUrlsFFZ urls;
const BadgeInfoFFZ(
this.id,
this.title,
this.color,
this.urls,
);
factory BadgeInfoFFZ.fromJson(Map<String, dynamic> json) =>
_$BadgeInfoFFZFromJson(json);
}
@JsonSerializable(createToJson: false)
class BadgeUrlsFFZ {
@JsonKey(name: '1')
final String url1x;
@JsonKey(name: '2')
final String url2x;
@JsonKey(name: '4')
final String url4x;
const BadgeUrlsFFZ(
this.url1x,
this.url2x,
this.url4x,
);
factory BadgeUrlsFFZ.fromJson(Map<String, dynamic> json) =>
_$BadgeUrlsFFZFromJson(json);
}
@JsonSerializable(createToJson: false)
class BadgeInfo7TV {
final String tooltip;
final List<List<String>> urls;
final List<String> users;
BadgeInfo7TV(
this.tooltip,
this.urls,
this.users,
);
factory BadgeInfo7TV.fromJson(Map<String, dynamic> json) =>
_$BadgeInfo7TVFromJson(json);
}
@JsonSerializable(createToJson: false)
class BadgeInfoBTTV {
final String providerId;
final BadgeDetailsBTTV badge;
BadgeInfoBTTV(
this.providerId,
this.badge,
);
factory BadgeInfoBTTV.fromJson(Map<String, dynamic> json) =>
_$BadgeInfoBTTVFromJson(json);
}
@JsonSerializable(createToJson: false)
class BadgeDetailsBTTV {
final String description;
final String svg;
BadgeDetailsBTTV(
this.description,
this.svg,
);
factory BadgeDetailsBTTV.fromJson(Map<String, dynamic> json) =>
_$BadgeDetailsBTTVFromJson(json);
}
class ChatBadge {
final String name;
final String url;
final BadgeType type;
final String? color;
const ChatBadge({
required this.name,
required this.url,
this.color,
required this.type,
});
factory ChatBadge.fromTwitch(BadgeInfoTwitch badge) => ChatBadge(
name: badge.title,
url: badge.imageUrl4x,
type: BadgeType.twitch,
);
factory ChatBadge.fromBTTV(BadgeInfoBTTV badge) => ChatBadge(
name: badge.badge.description,
url: badge.badge.svg,
type: BadgeType.bttv,
);
factory ChatBadge.fromFFZ(BadgeInfoFFZ badge) => ChatBadge(
name: badge.title,
url: badge.urls.url4x,
color: badge.color,
type: BadgeType.ffz,
);
factory ChatBadge.from7TV(BadgeInfo7TV badge) => ChatBadge(
name: badge.tooltip,
url: badge.urls[2][1],
type: BadgeType.sevenTV,
);
}
enum BadgeType {
twitch,
bttv,
ffz,
sevenTV;
@override
String toString() {
switch (this) {
case BadgeType.twitch:
return 'Twitch badge';
case BadgeType.bttv:
return 'BetterTTV badge';
case BadgeType.ffz:
return 'FrankerFaceZ badge';
case BadgeType.sevenTV:
return '7TV badge';
}
}
}