Upgrade to Flutter 3.7.0 (#233)

* Rename `Badge` to `ChatBadge`
Flutter 3.7.0 adds a new `Badge` component that conflicts with the
existing badge widget.

* Fix new linting errors

* Upgrade packages
This commit is contained in:
Tommy Chow 2023-01-26 23:56:16 -05:00 • committed by GitHub
parent 8f8bb1ae28
commit 5d95843de8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 377 additions and 235 deletions

View file

@ -45,7 +45,7 @@ class BTTVApi {
}
/// Returns a map of username to their BTTV badge.
Future<Map<String, Badge>> getBadges() async {
Future<Map<String, ChatBadge>> getBadges() async {
final url = Uri.parse('https://api.betterttv.net/3/cached/badges');
final response = await _client.get(url);
@ -54,7 +54,7 @@ class BTTVApi {
final badgeObjects = badges.map((badge) => BadgeInfoBTTV.fromJson(badge)).toList();
return {for (final badge in badgeObjects) badge.providerId: Badge.fromBTTV(badge)};
return {for (final badge in badgeObjects) badge.providerId: ChatBadge.fromBTTV(badge)};
} else {
return Future.error('Failed to get BTTV badges');
}

View file

@ -51,7 +51,7 @@ class FFZApi {
}
/// Returns a map of badges user IDs to a list of their FFZ badges.
Future<Map<String, List<Badge>>> getBadges() async {
Future<Map<String, List<ChatBadge>>> getBadges() async {
final url = Uri.parse('https://api.frankerfacez.com/v1/badges/ids');
final response = await _client.get(url);
@ -60,11 +60,11 @@ class FFZApi {
final badges = decoded['badges'] as List;
final badgeObjects = badges.map((badge) => BadgeInfoFFZ.fromJson(badge)).toList();
final result = <String, List<Badge>>{};
final result = <String, List<ChatBadge>>{};
for (final badge in badgeObjects.reversed) {
for (final userId in decoded['users'][badge.id.toString()]) {
final entry = result[userId.toString()];
final normalBadge = Badge.fromFFZ(badge);
final normalBadge = ChatBadge.fromFFZ(badge);
if (entry == null) {
result[userId.toString()] = [normalBadge];
} else {

View file

@ -41,7 +41,7 @@ class SevenTVApi {
}
/// Returns a map of user IDS to a list of their 7TV badges.
Future<Map<String, List<Badge>>> getBadges() async {
Future<Map<String, List<ChatBadge>>> getBadges() async {
final url = Uri.parse('https://api.7tv.app/v2/badges?user_identifier=twitch_id');
final response = await _client.get(url);
@ -49,11 +49,11 @@ class SevenTVApi {
final decoded = jsonDecode(response.body)['badges'] as List;
final badges = decoded.map((emote) => BadgeInfo7TV.fromJson(emote));
final result = <String, List<Badge>>{};
final result = <String, List<ChatBadge>>{};
for (final badge in badges) {
for (final userId in badge.users) {
final entry = result[userId];
final normalBadge = Badge.from7TV(badge);
final normalBadge = ChatBadge.from7TV(badge);
if (entry == null) {
result[userId] = [normalBadge];
} else {

View file

@ -90,15 +90,15 @@ class TwitchApi {
}
/// Returns a map of global Twitch badges to their [Emote] object.
Future<Map<String, Badge>> getBadgesGlobal() async {
Future<Map<String, ChatBadge>> getBadgesGlobal() async {
final url = Uri.parse('https://badges.twitch.tv/v1/badges/global/display');
final response = await _client.get(url);
if (response.statusCode == 200) {
final result = <String, Badge>{};
final result = <String, ChatBadge>{};
final decoded = jsonDecode(response.body)['badge_sets'] as Map;
decoded.forEach((id, versions) => (versions['versions'] as Map).forEach(
(version, badgeInfo) => result['$id/$version'] = Badge.fromTwitch(BadgeInfoTwitch.fromJson(badgeInfo))));
(version, badgeInfo) => result['$id/$version'] = ChatBadge.fromTwitch(BadgeInfoTwitch.fromJson(badgeInfo))));
return result;
} else {
@ -107,15 +107,15 @@ class TwitchApi {
}
/// Returns a map of a channel's Twitch badges to their [Emote] object.
Future<Map<String, Badge>> getBadgesChannel({required String id}) async {
Future<Map<String, ChatBadge>> getBadgesChannel({required String id}) async {
final url = Uri.parse('https://badges.twitch.tv/v1/badges/channels/$id/display');
final response = await _client.get(url);
if (response.statusCode == 200) {
final result = <String, Badge>{};
final result = <String, ChatBadge>{};
final decoded = jsonDecode(response.body)['badge_sets'] as Map;
decoded.forEach((id, versions) => (versions['versions'] as Map).forEach(
(version, badgeInfo) => result['$id/$version'] = Badge.fromTwitch(BadgeInfoTwitch.fromJson(badgeInfo))));
(version, badgeInfo) => result['$id/$version'] = ChatBadge.fromTwitch(BadgeInfoTwitch.fromJson(badgeInfo))));
return result;
} else {

View file

@ -142,7 +142,6 @@ final lightTheme = ThemeData(
primarySwatch: Colors.deepPurple,
accentColor: purple,
),
toggleableActiveColor: purple,
tabBarTheme: const TabBarTheme(
labelColor: Colors.black,
unselectedLabelColor: Colors.grey,
@ -173,7 +172,6 @@ final darkTheme = ThemeData(
accentColor: purple,
),
dialogBackgroundColor: gray,
toggleableActiveColor: purple,
inputDecorationTheme: inputTheme,
tooltipTheme: tooltipTheme,
snackBarTheme: snackBarTheme,
@ -198,7 +196,6 @@ final oledTheme = ThemeData(
accentColor: purple,
),
dialogBackgroundColor: Colors.black,
toggleableActiveColor: purple,
inputDecorationTheme: inputTheme,
tooltipTheme: tooltipTheme,
snackBarTheme: snackBarTheme,

View file

@ -99,39 +99,39 @@ class BadgeDetailsBTTV {
factory BadgeDetailsBTTV.fromJson(Map<String, dynamic> json) => _$BadgeDetailsBTTVFromJson(json);
}
class Badge {
class ChatBadge {
final String name;
final String url;
final BadgeType type;
final String? color;
const Badge({
const ChatBadge({
required this.name,
required this.url,
this.color,
required this.type,
});
factory Badge.fromTwitch(BadgeInfoTwitch badge) => Badge(
factory ChatBadge.fromTwitch(BadgeInfoTwitch badge) => ChatBadge(
name: badge.title,
url: badge.imageUrl4x,
type: BadgeType.twitch,
);
factory Badge.fromBTTV(BadgeInfoBTTV badge) => Badge(
factory ChatBadge.fromBTTV(BadgeInfoBTTV badge) => ChatBadge(
name: badge.badge.description,
url: badge.badge.svg,
type: BadgeType.bttv,
);
factory Badge.fromFFZ(BadgeInfoFFZ badge) => Badge(
factory ChatBadge.fromFFZ(BadgeInfoFFZ badge) => ChatBadge(
name: badge.title,
url: 'https:${badge.urls.url4x}',
color: badge.color,
type: BadgeType.ffz,
);
factory Badge.from7TV(BadgeInfo7TV badge) => Badge(
factory ChatBadge.from7TV(BadgeInfo7TV badge) => ChatBadge(
name: badge.tooltip,
url: badge.urls[2][1],
type: BadgeType.sevenTV,

View file

@ -178,7 +178,7 @@ class IRCMessage {
'https:${ffzRoomInfo!.modUrls?.url4x ?? ffzRoomInfo.modUrls?.url2x ?? ffzRoomInfo.modUrls!.url1x}';
}
final newBadge = Badge(
final newBadge = ChatBadge(
name: skipBot ? 'Moderator (Bot)' : 'Moderator',
url: badgeUrl,
type: BadgeType.twitch,
@ -201,7 +201,7 @@ class IRCMessage {
'https:${ffzRoomInfo!.vipBadge?.url4x ?? ffzRoomInfo.vipBadge?.url2x ?? ffzRoomInfo.vipBadge!.url1x}';
}
final newBadge = Badge(
final newBadge = ChatBadge(
name: badgeInfo.name,
url: badgeUrl,
type: BadgeType.twitch,
@ -466,7 +466,7 @@ class IRCMessage {
}
static Widget _createBadgeWidget({
required Badge badge,
required ChatBadge badge,
required double size,
Color? backgroundColor,
bool? isSvg,
@ -498,7 +498,7 @@ class IRCMessage {
}
static WidgetSpan _createBadgeSpan({
required Badge badge,
required ChatBadge badge,
required double size,
Color? backgroundColor,
bool? isSvg,

View file

@ -169,6 +169,8 @@ class _ChattersListState extends State<ChattersList> {
headers: context.read<AuthStore>().headersTwitch,
userLogin: users[index]);
if (!mounted) return;
showModalBottomSheet(
backgroundColor: Colors.transparent,
isScrollControlled: true,

View file

@ -32,7 +32,7 @@ abstract class ChatAssetsStoreBase with Store {
List<Emote> get sevenTVEmotes => _emoteToObject.values.where((emote) => is7TV(emote)).toList();
/// The map of badges ids to their object representation.
final twitchBadgesToObject = ObservableMap<String, Badge>();
final twitchBadgesToObject = ObservableMap<String, ChatBadge>();
@readonly
var _recentEmotes = ObservableList<Emote>();
@ -53,15 +53,15 @@ abstract class ChatAssetsStoreBase with Store {
/// The map of user IDs to their FFZ badges.
@readonly
var _userToFFZBadges = <String, List<Badge>>{};
var _userToFFZBadges = <String, List<ChatBadge>>{};
/// The map of user IDs to their 7TV badges.
@readonly
var _userTo7TVBadges = <String, List<Badge>>{};
var _userTo7TVBadges = <String, List<ChatBadge>>{};
/// The map of user IDs to their BTTV badge.
@readonly
var _userToBTTVBadges = <String, Badge>{};
var _userToBTTVBadges = <String, ChatBadge>{};
/// Whether or not the emote menu is visible.
@observable

View file

@ -108,16 +108,16 @@ mixin _$ChatAssetsStore on ChatAssetsStoreBase, Store {
late final _$_userToFFZBadgesAtom =
Atom(name: 'ChatAssetsStoreBase._userToFFZBadges', context: context);
Map<String, List<Badge>> get userToFFZBadges {
Map<String, List<ChatBadge>> get userToFFZBadges {
_$_userToFFZBadgesAtom.reportRead();
return super._userToFFZBadges;
}
@override
Map<String, List<Badge>> get _userToFFZBadges => userToFFZBadges;
Map<String, List<ChatBadge>> get _userToFFZBadges => userToFFZBadges;
@override
set _userToFFZBadges(Map<String, List<Badge>> value) {
set _userToFFZBadges(Map<String, List<ChatBadge>> value) {
_$_userToFFZBadgesAtom.reportWrite(value, super._userToFFZBadges, () {
super._userToFFZBadges = value;
});
@ -126,16 +126,16 @@ mixin _$ChatAssetsStore on ChatAssetsStoreBase, Store {
late final _$_userTo7TVBadgesAtom =
Atom(name: 'ChatAssetsStoreBase._userTo7TVBadges', context: context);
Map<String, List<Badge>> get userTo7TVBadges {
Map<String, List<ChatBadge>> get userTo7TVBadges {
_$_userTo7TVBadgesAtom.reportRead();
return super._userTo7TVBadges;
}
@override
Map<String, List<Badge>> get _userTo7TVBadges => userTo7TVBadges;
Map<String, List<ChatBadge>> get _userTo7TVBadges => userTo7TVBadges;
@override
set _userTo7TVBadges(Map<String, List<Badge>> value) {
set _userTo7TVBadges(Map<String, List<ChatBadge>> value) {
_$_userTo7TVBadgesAtom.reportWrite(value, super._userTo7TVBadges, () {
super._userTo7TVBadges = value;
});
@ -144,16 +144,16 @@ mixin _$ChatAssetsStore on ChatAssetsStoreBase, Store {
late final _$_userToBTTVBadgesAtom =
Atom(name: 'ChatAssetsStoreBase._userToBTTVBadges', context: context);
Map<String, Badge> get userToBTTVBadges {
Map<String, ChatBadge> get userToBTTVBadges {
_$_userToBTTVBadgesAtom.reportRead();
return super._userToBTTVBadges;
}
@override
Map<String, Badge> get _userToBTTVBadges => userToBTTVBadges;
Map<String, ChatBadge> get _userToBTTVBadges => userToBTTVBadges;
@override
set _userToBTTVBadges(Map<String, Badge> value) {
set _userToBTTVBadges(Map<String, ChatBadge> value) {
_$_userToBTTVBadgesAtom.reportWrite(value, super._userToBTTVBadges, () {
super._userToBTTVBadges = value;
});

View file

@ -2,7 +2,6 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:frosty/constants.dart';
import 'package:frosty/models/badges.dart';
import 'package:frosty/models/emotes.dart';
import 'package:frosty/models/irc.dart';
import 'package:frosty/screens/channel/chat/details/chat_details_store.dart';

View file

@ -92,7 +92,7 @@ class _CategoryStreamsState extends State<CategoryStreams> {
centerTitle: true,
title: Text(
widget.categoryName,
style: Theme.of(context).textTheme.headline6?.copyWith(fontWeight: FontWeight.bold),
style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),

View file

@ -71,6 +71,8 @@ class _OtherSettingsState extends State<OtherSettings> {
onTap: () async {
final packageInfo = await PackageInfo.fromPlatform();
if (!mounted) return;
showAboutDialog(
context: context,
applicationIcon: SvgPicture.asset(

File diff suppressed because it is too large Load diff