2021-12-22 18:28:57 -05:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:frosty/models/emotes.dart';
|
|
|
|
|
import 'package:frosty/screens/channel/chat/emote_menu/emote_menu_section.dart';
|
2022-08-31 14:11:45 -04:00
|
|
|
import 'package:frosty/screens/channel/chat/stores/chat_store.dart';
|
2023-01-18 05:34:54 -05:00
|
|
|
import 'package:frosty/widgets/page_view.dart';
|
2021-12-22 18:28:57 -05:00
|
|
|
|
|
|
|
|
class EmoteMenuPanel extends StatelessWidget {
|
2022-04-01 16:30:35 -04:00
|
|
|
final ChatStore chatStore;
|
2022-07-03 05:43:29 -04:00
|
|
|
final List<Emote>? emotes;
|
|
|
|
|
final Map<String, List<Emote>>? twitchEmotes;
|
2021-12-22 18:28:57 -05:00
|
|
|
|
2022-01-19 23:01:31 -05:00
|
|
|
const EmoteMenuPanel({
|
|
|
|
|
Key? key,
|
2022-04-01 16:30:35 -04:00
|
|
|
required this.chatStore,
|
2022-07-03 05:43:29 -04:00
|
|
|
this.emotes,
|
|
|
|
|
this.twitchEmotes,
|
2022-01-19 23:01:31 -05:00
|
|
|
}) : super(key: key);
|
2021-12-22 18:28:57 -05:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2022-07-03 05:43:29 -04:00
|
|
|
if (emotes != null) {
|
2023-01-18 05:34:54 -05:00
|
|
|
final globalEmotes = emotes!
|
2023-10-22 18:38:32 -04:00
|
|
|
.where(
|
|
|
|
|
(emote) =>
|
|
|
|
|
emote.type == EmoteType.bttvGlobal ||
|
|
|
|
|
emote.type == EmoteType.ffzGlobal ||
|
|
|
|
|
emote.type == EmoteType.sevenTVGlobal,
|
|
|
|
|
)
|
2023-01-18 05:34:54 -05:00
|
|
|
.toList();
|
2021-12-22 18:28:57 -05:00
|
|
|
|
2022-07-03 05:43:29 -04:00
|
|
|
final channelEmotes = emotes!
|
2023-10-22 18:38:32 -04:00
|
|
|
.where(
|
|
|
|
|
(emote) =>
|
|
|
|
|
emote.type == EmoteType.bttvChannel ||
|
|
|
|
|
emote.type == EmoteType.bttvShared ||
|
|
|
|
|
emote.type == EmoteType.ffzChannel ||
|
|
|
|
|
emote.type == EmoteType.sevenTVChannel,
|
|
|
|
|
)
|
2022-07-03 05:43:29 -04:00
|
|
|
.toList();
|
2021-12-22 18:28:57 -05:00
|
|
|
|
2023-01-18 05:34:54 -05:00
|
|
|
return FrostyPageView(
|
|
|
|
|
headers: ['Global', if (channelEmotes.isNotEmpty) 'Channel'],
|
|
|
|
|
children: [
|
|
|
|
|
EmoteMenuSection(
|
|
|
|
|
chatStore: chatStore,
|
|
|
|
|
emotes: globalEmotes,
|
|
|
|
|
),
|
|
|
|
|
if (channelEmotes.isNotEmpty)
|
2022-07-03 05:43:29 -04:00
|
|
|
EmoteMenuSection(
|
|
|
|
|
chatStore: chatStore,
|
|
|
|
|
emotes: channelEmotes,
|
|
|
|
|
),
|
2021-12-22 18:28:57 -05:00
|
|
|
],
|
2022-07-03 05:43:29 -04:00
|
|
|
);
|
|
|
|
|
} else {
|
2023-01-18 05:34:54 -05:00
|
|
|
return FrostyPageView(
|
2023-04-29 11:34:28 -04:00
|
|
|
headers:
|
|
|
|
|
twitchEmotes!.keys.map((header) => header.split(' ')[0]).toList(),
|
|
|
|
|
children: twitchEmotes!.entries
|
|
|
|
|
.map((e) => EmoteMenuSection(chatStore: chatStore, emotes: e.value))
|
|
|
|
|
.toList(),
|
2022-07-03 05:43:29 -04:00
|
|
|
);
|
|
|
|
|
}
|
2021-12-22 18:28:57 -05:00
|
|
|
}
|
|
|
|
|
}
|