diff --git a/lib/components/chat_history/twitch/subscription_event.dart b/lib/components/chat_history/twitch/subscription_event.dart index 94cabc0e..0efb5562 100644 --- a/lib/components/chat_history/twitch/subscription_event.dart +++ b/lib/components/chat_history/twitch/subscription_event.dart @@ -9,6 +9,16 @@ import 'package:rtchat/models/messages/twitch/subscription_message_event.dart'; import 'package:rtchat/models/style.dart'; import 'package:rtchat/models/user.dart'; +Color tierColor(BuildContext context, String tier) { + if (tier == '2000') { + return const Color(0xFF9A93A9); + } else if (tier == '3000') { + return const Color(0xFFC09C39); + } else { + return Theme.of(context).colorScheme.primary; + } +} + class TwitchSubscriptionEventWidget extends StatelessWidget { final TwitchSubscriptionEventModel model; @@ -16,6 +26,7 @@ class TwitchSubscriptionEventWidget extends StatelessWidget { @override Widget build(BuildContext context) { + final textTheme = Theme.of(context).textTheme.titleSmall; return DecoratedEventWidget.icon( icon: Icons.star, child: Text.rich( @@ -24,9 +35,11 @@ class TwitchSubscriptionEventWidget extends StatelessWidget { TextSpan( text: model.subscriberUserName, style: Theme.of(context).textTheme.titleSmall), + const TextSpan(text: " subscribed "), TextSpan( - text: - " subscribed at Tier ${model.tier.replaceAll("000", "")}."), + text: "Tier ${model.tier.replaceAll("000", "")}", + style: textTheme?.copyWith(color: tierColor(context, model.tier)), + ), ], ), ), @@ -41,22 +54,23 @@ class TwitchSubscriptionGiftEventWidget extends StatelessWidget { @override Widget build(BuildContext context) { + final textTheme = Theme.of(context).textTheme.titleSmall; return DecoratedEventWidget.icon( - icon: Icons.star, + icon: Icons.redeem, child: Text.rich( TextSpan( children: [ + TextSpan(text: model.gifterUserName, style: textTheme), + TextSpan(text: " gifted ${model.total} "), TextSpan( - text: model.gifterUserName, - style: Theme.of(context).textTheme.titleSmall), + text: "Tier ${model.tier.replaceAll("000", "")}", + style: + textTheme?.copyWith(color: tierColor(context, model.tier))), TextSpan( - text: - " gifted ${model.total} Tier ${model.tier.replaceAll("000", "")} "), - TextSpan( - text: model.total > 1 ? "subscriptions. " : "subscription. "), + text: model.total > 1 ? " subscriptions" : " subscription"), TextSpan( text: model.cumulativeTotal > 0 - ? "They've gifted ${model.cumulativeTotal} subs in the channel" + ? " (${model.cumulativeTotal} total)" : ""), ], ), @@ -70,16 +84,6 @@ class TwitchSubscriptionMessageEventWidget extends StatelessWidget { const TwitchSubscriptionMessageEventWidget(this.model, {super.key}); - Color chipBackgroundColor(BuildContext context, String tier) { - if (tier == '2000') { - return const Color(0xFF9A93A9); - } else if (tier == '3000') { - return const Color(0xFFC09C39); - } else { - return Theme.of(context).colorScheme.secondary; - } - } - Iterable _render( BuildContext context, StyleModel styleModel, MessageToken token) sync* { final tagStyleStreamer = TextStyle( @@ -128,53 +132,45 @@ class TwitchSubscriptionMessageEventWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return DecoratedEventWidget( - padding: const EdgeInsets.symmetric(horizontal: 12), + final textTheme = Theme.of(context).textTheme.titleSmall; + return DecoratedEventWidget.icon( + icon: Icons.star, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text.rich( TextSpan( children: [ - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: Padding( - padding: const EdgeInsets.only(right: 8), - child: Chip( - label: Text("Tier ${model.tier.replaceAll("000", "")}"), - backgroundColor: chipBackgroundColor(context, model.tier), - ), - ), - ), TextSpan( text: model.subscriberUserName, style: Theme.of(context).textTheme.titleSmall), - const TextSpan(text: " subscribed for "), + const TextSpan(text: " subscribed "), + TextSpan( + text: "Tier ${model.tier.replaceAll("000", "")}", + style: + textTheme?.copyWith(color: tierColor(context, model.tier)), + ), + const TextSpan(text: " for "), TextSpan( text: model.cumulativeMonths == 1 - ? "1 month!" - : "${model.cumulativeMonths} months!", - style: Theme.of(context).textTheme.titleSmall), + ? "1 month" + : "${model.cumulativeMonths} months", + style: textTheme), ], ), ), if (model.text.isNotEmpty) - Padding( - padding: const EdgeInsets.only(bottom: 8), - child: - Consumer(builder: (context, styleModel, child) { - return Text.rich( - TextSpan( - children: [ - TextSpan( - text: model.subscriberUserName, - style: Theme.of(context).textTheme.titleSmall), - const TextSpan(text: ": "), - ...model.tokenize().expand((token) { - return _render(context, styleModel, token); - }), - ], - ), - ); - })), + Consumer(builder: (context, styleModel, child) { + return Text.rich( + TextSpan( + children: [ + TextSpan(text: model.subscriberUserName, style: textTheme), + const TextSpan(text: ": "), + ...model.tokenize().expand((token) { + return _render(context, styleModel, token); + }), + ], + ), + ); + }), ]), ); } diff --git a/lib/screens/settings/events.dart b/lib/screens/settings/events.dart index 91f7f687..fa22d4ee 100644 --- a/lib/screens/settings/events.dart +++ b/lib/screens/settings/events.dart @@ -20,6 +20,8 @@ import 'package:rtchat/models/messages/twitch/hype_train_event.dart'; import 'package:rtchat/models/messages/twitch/prediction_event.dart'; import 'package:rtchat/models/messages/twitch/raiding_event.dart'; import 'package:rtchat/models/messages/twitch/subscription_event.dart'; +import 'package:rtchat/models/messages/twitch/subscription_gift_event.dart'; +import 'package:rtchat/models/messages/twitch/subscription_message_event.dart'; import 'package:rtchat/models/messages/twitch/user.dart'; class EventsScreen extends StatelessWidget { @@ -70,6 +72,33 @@ class EventsScreen extends StatelessWidget { subscriberUserName: 'muxfd', tier: '1000', )))), + Padding( + padding: const EdgeInsets.fromLTRB(16, 20, 16, 0), + child: StyleModelTheme( + child: TwitchSubscriptionGiftEventWidget( + TwitchSubscriptionGiftEventModel( + messageId: '', + timestamp: DateTime.now(), + tier: '2000', + gifterUserName: 'muxfd', + total: 10, + cumulativeTotal: 20, + )))), + Padding( + padding: const EdgeInsets.fromLTRB(16, 20, 16, 0), + child: StyleModelTheme( + child: TwitchSubscriptionMessageEventWidget( + TwitchSubscriptionMessageEventModel( + messageId: '', + timestamp: DateTime.now(), + subscriberUserName: 'muxfd', + tier: '3000', + cumulativeMonths: 10, + durationMonths: 10, + streakMonths: 10, + emotes: [], + text: 'Thanks for the stream!', + )))), EventConfigListTile( title: const Text('Subscribe event config'), subtitle: const Text('Customize your subscription event'),