* migrate to dio * ignore folders * simplify twitch api headers handling * clean up main * simplify logs * optimize profile picture fetching fixes refetches on tab switch * update claude md * refactor irc.dart * update copilot instructions with essential commands and project structure details * implement message sending state management and UI updates * refactor notification handling and add copy-paste functionality in chat * refactor AlertMessage to support vertical layout and optional padding * refactor error messages for consistency and clarity across various components * refactor chat layout to use draggable divider and improve chat width settings * refactor Uptime widget to use SharedTimerService for synchronized updates * refactor search results components to handle null future states gracefully * refactor loading indicators to use skeleton loaders for improved user experience * refactor UI components for improved layout and responsiveness, enhance skeleton loaders, and streamline padding adjustments * refactor: replace manual blur effects with BlurredContainer for consistency and reusability * refactor: enhance JavaScript execution and error handling in WebView components * refactor: replace app bar with blurred container for improved UI consistency across screens * refactor: streamline video chat layout and enhance PiP drag gesture functionality * revert some app bar changes * refactor: implement Picture-in-Picture drag functionality in VideoChat * refactor: pass currentChannelId to IRCMessage and ChatMessage for improved context * fix large thubmnail width * chore: update Gradle and Kotlin plugin versions for improved compatibility * changes from v4.10.0 branch * feat: integrate AnimatedScrollBorder for improved UI responsiveness across various screens * refactor: update SectionHeader styling and improve theme management * feat: add pinned section to StreamsList and enhance skeleton loader padding * feat: add repository guidelines for project structure, coding style, testing, and security * feat: enhance StreamCard UI with BlurredContainer and adjust border width in theme * feat: implement unfocusInput and safeRequestFocus methods to manage text field focus behavior * feat: enhance Picture-in-Picture drag interactions with haptic feedback and smooth animations * refactor: improve code formatting and readability across multiple files * feat: implement picture-in-picture mode toggle and state management for video playback * feat: reset PiP mode state when pausing video playback * feat: add custom app bar with profile picture and stream info for video chat * feat: convert multiple settings screens to use StatefulWidget and add animated scroll borders * feat: update blur configuration for adaptive alpha based on theme * fix: adjust default font size in SectionHeader widget * feat: enhance PiP mode with drag overlay instruction and UI improvements * fix: improve badge rendering with consistent margin and border for current channel * refactor: replace BackdropFilter with BlurredContainer for improved clarity and maintainability * fix: reduce background transparency in Uptime widget for better visibility * feat: enhance photo view dialog with full resolution toggle and blurred background * fix: reset chat delay to 0 when auto sync is enabled and update settings title for clarity * fix: adjust border width in theme to improve consistency * feat: add forceDarkMode option to BlurredContainer for improved theme adaptability * feat: implement offline followed channels feature with UI integration and settings option * fix: increase font size and weight for offline status text for better readability * feat: remove offline pinned channels feature and update related UI components * feat: optimize offline channels loading behavior based on expansion state * fix: improve clarity and consistency in repository guidelines formatting * feat: update full resolution URL handling and button visibility logic * feat: replace app bar with blurred version in chat-only mode and add animated scroll border * feat: refactor video chat layout for improved chat and video display in landscape mode * feat: remove bottom bar visibility setting and adjust chat layout accordingly * fix: simplify condition for displaying offline channels section in following tab * feat: enhance reply thread display with indentation and reply icon * feat: implement showModalBottomSheetWithProperFocus for improved focus handling * feat: add gradient direction support to BlurredContainer for enhanced visual effects * feat: enhance NavigationBar and Theme settings for improved visual consistency * feat: add gradient direction support to BlurredContainer in VideoChat for enhanced visual effects * chore: update .gitignore to include .cursor file for better environment management * fix: update PiP drag gesture conditions to include video paused state for better user experience * refactor: replace ScrollController with SettingsPageLayout in settings screens for improved layout management * refactor: centralize orientation handling by introducing OrientationUtils for improved readability and maintainability * refactor: replace OrientationUtils with ContextExtensions for streamlined context-based access to theme, layout, and API dependencies * refactor: improve video chat UI by adjusting title layout and adding stream info tooltips for better user experience * refactor: adjust titleSpacing in theme and navigation components for improved layout consistency * refactor: update stream info timer handling and overlay management for improved UI responsiveness * refactor: enhance stream info timer logic and overlay visibility management for chat-only mode * refactor: enhance input decoration theme in FrostyThemes for improved visual consistency and responsiveness * refactor: adjust inputDecorationTheme padding in FrostyThemes for improved visual consistency * refactor: enhance video overlay management by including video preview overlay in hideElements for improved UI consistency * refactor: improve chat bottom bar padding and video chat layout for enhanced UI consistency * refactor: adjust chat padding to account for device bottom insets for improved layout consistency * refactor: update text styles in FrostyThemes for improved visual consistency across UI components * refactor: update iOS minimum deployment target to 13.0 for improved compatibility * refactor: adjust chat bottom padding based on emote menu visibility for improved layout consistency * refactor: adjust padding values in StreamsList for improved layout consistency * refactor: replace Padding with AnimatedPadding in Chat for smoother layout transitions refactor: replace Container with AnimatedContainer in BlurredContainer for smoother animations * refactor: remove unnecessary radius property from ProfilePicture in OfflineChannelCard for cleaner code * refactor: enhance chat bottom bar suffix icon to display message delay with tooltip for improved user experience * refactor: update hint text and tooltips in chat bottom bar and search for improved clarity * refactor: simplify notification display logic and enhance chat input behavior for improved user experience * refactor: enhance layout consistency by adjusting spacing in various components across the channel and home screens * refactor: introduce LiveIndicator widget and adjust spacing in channel and video components for improved layout consistency * refactor: remove monospace font family from chat bottom bar for improved text rendering * refactor: reduce notification animation duration and change dismiss direction for improved user experience * refactor: replace VideoBar with StreamInfoBar in video components for improved layout and consistency * refactor: adjust font sizes and spacing in StreamInfoBar for improved layout consistency * refactor: standardize font sizes and update gradient stops in video components for improved visual consistency * refactor: update tooltip padding and background color in theme for improved visual consistency * refactor: enhance tooltip behavior and standardize font sizes in StreamInfoBar and related components for improved visual consistency * refactor: add showThumbnail option to LargeStreamCardSkeletonLoader for improved layout flexibility * refactor: add StreamInfoBarSkeletonLoader for improved layout consistency in stream components * refactor: add shadow effects to icons and text in StreamInfoBar and VideoOverlay for improved visual depth * refactor: update defaultOverlayOpacity to 0.0 for improved overlay behavior * fix: correct stream info text color on overlay * refactor: implement a new color picker dialog with random color generation for enhanced user experience * refactor: adjust gradient colors and stops in VideoOverlay for improved visual consistency * refactor: refine gradient colors and stops in VideoOverlay for enhanced visual clarity * refactor: add isCompact parameter to StreamInfoBar for responsive text sizing * fix: update tooltip background color to use surface color for better contrast * feat: add shared chat mode support in chat store and update StreamInfoBar for visual indication * refactor: disable debug print for IRC messages to reduce log clutter * feat: implement chat color selection feature with user color management in chat settings * refactor: replace color adjustment logic with new contrast-aware utility for chat names * refactor: simplify chat details UI by replacing list tiles with action cards and removing unused clear dialog * refactor: enhance chat details UI by improving time formatting and adding label styling to action cards * refactor: update chat color terminology to 'Username color' for clarity in UI * refactor: enhance chat details UI by introducing active chat modes display and improving layout structure * refactor: improve chat details layout by replacing ListTile with Padding and adding a Divider for better visual separation * refactor: remove chat notifications positioning setting and adjust notification alignment in video chat * refactor: streamline StreamInfoBar component by consolidating offline handling and improving layout for better readability * refactor: enhance StreamInfoBar by adding tooltip for streamer name and improving text overflow handling * refactor: adjust tooltip display duration in StreamInfoBar and update theme configuration * refactor: adjust margin and padding in StreamCard for improved layout consistency * chore: update dependencies in pubspec.yaml and pubspec.lock for Firebase and other packages * template * chore: update iOS platform version to 15.0 and Firebase dependencies to 12.2.0 * refactor: simplify StreamInfoBar layout by reducing nested widgets and improving text color handling * format * feat: enhance Channel model and StreamInfoBar to support offline channel details * feat: add offline indicator and improve StreamInfoBar layout for better offline channel display * fix: adjust icon color opacity in StreamInfoBar for improved visibility * feat: enhance dismissal animation in FrostyPhotoViewDialog to track swipe direction * docs: update copilot instructions for clarity and additional error handling details * refactor: optimize latency tooltip layout and improve offline indicator styling in VideoOverlay * feat: implement shared chat asset fetching and participant management in ChatAssetsStore * refactor: replace Observer with Builder for improved widget rebuilding in VideoOverlay * refactor: update StreamInfoBar border styling and adjust layout in VideoOverlay for improved visual consistency * feat: add showTextShadows property to StreamInfoBar for customizable text shadow display * refactor: adjust layout in VideoOverlay by adding padding to improve spacing and visual consistency * refactor: enhance VideoOverlay gradients and layout for improved visual hierarchy and user experience * refactor: reduce vertical padding in VideoOverlay for improved layout consistency * refactor: remove overlay opacity settings from VideoSettings and SettingsStore for simplification * refactor: improve text overlay transition in VideoChat for better user experience * Revert "refactor: improve text overlay transition in VideoChat for better user experience" This reverts commitfd16ff5ec3. * refactor: wrap videoOverlay in ColoredBox for improved layout handling * refactor: optimize animation duration and transition curves in VideoChat for smoother interactions * refactor: dispose searchScrollController in HomeStoreBase to prevent memory leaks * refactor: simplify gradient definitions in VideoOverlay for improved readability and maintainability * refactor: remove 'Offline' text overlay from VideoOverlay for cleaner UI * refactor: add refresh functionality for assets in ChatDetails with loading indicators * refactor: update visibility conditions for uptime, viewer count, and category display in StreamInfoBar * refactor: replace AlertDialog with FrostyDialog for consistent dialog styling across the application * refactor: enhance layout handling in FrostyPageView to prevent overflow during height transitions * refactor: replace ColorPickerDialog with AccentColorPickerDialog for improved color selection experience * refactor: replace theme and accent color settings with dedicated components for improved modularity and readability * refactor: replace ElevatedButton with TextButton for consistent button styling across dialogs * refactor: integrate MobX Observer for reactive state management in settings widgets * refactor: update theme and dialog components for improved styling and consistency * refactor: enhance dialog styling with rounded corners and border in theme configuration * refactor: improve dialog messages for unauthorized access handling * refactor: update bodyLarge text style in theme configuration to include font weight * refactor: standardize Divider usage and adjust theme styles for improved consistency * refactor: adjust Divider properties and theme styles for enhanced visual consistency * chore: remove GEMINI.md file as it is no longer needed for project documentation * refactor: enhance token validation and reconnect logic in AuthBase for improved error handling * format * refactor: integrate landscape cutout settings into VideoChat layout for improved responsiveness * refactor: implement app lifecycle handling in VideoChat and enhance stream info update logic in VideoStore * refactor: update landscape cutout conditionals in VideoChat layout for improved responsiveness * update AGENTS.md * add scrollbar to search * fix scrolling exception * update CLAUDE.md * 5 auth reconnect attemps then log out * increase reply max lines to 2 * simplify and improve reply formatting * add prime icon * better draggable divider * support draggable divider in fullscreen overlay chat * add text shadow in fullscreen chat overlay mode * format * add landscape checks * video store optimization attempts * Dispose WebViewController and remove JavaScript channels properly * Track and cleanup all MutationObservers to prevent accumulation * Throttle latency updates to once per 5 seconds (reduces CPU load) * Add timeout protection and null checks for robustness * Prevent duplicate event listeners on page reloads * double tap divider to reset * Revert "video store optimization attempts" This reverts commitb1df7b0de4. * optimize video store attempt 2 * Revert "double tap divider to reset" This reverts commitaeb26a4335. * optimize latency listener to open the menu and check every 20 secconds * more optimizations * hard refresh * abbreviate latency * fix lint * improve hide default overlay * fix chat no longer reconnecting with chat delay * refine chat alerts * fix historical message missing badges and emotes on initial connection * parallelize * revert * add reconnect button inline action * refactor: replace Scrollbar with FrostyScrollbar across chat and settings screens for consistent styling * tweak chat details menu * add scrollbar to release notes, renames for consistency * fix duplicate message case * fix chat delay alerts in auto sync mode * add regex for numeric strings and enhance display name formatting logic * exterminate borders * refactor: simplify active chat modes display in chat details screen * feat: enhance chat input button with delay notification and disable state * fix: wrap chat in SafeArea to prevent UI overflow issues * refactor: remove divider line from video chat and update draggable divider visibility logic * persist overlay in pip mode * fix: update chat delay handling and notifications in chat bottom bar * fix: update chat overlay visibility logic to respect fullscreen settings * tap to show deleted message * fix: prevent accidental chat scrolling when accessing system UI in landscape mode * show latency in portrait * fix: enhance chat delay notifications with dynamic delay time * docs: update CLAUDE.md for improved environment variable instructions and architecture overview * fix: improve chat delay countdown management and message handling * add preliminary release notes * remove agents.md * update lockfile * add initial multi chat feature * add option to persist multi chat tabs * add remove confirmation dialog * improve add chat design * lazy-load tabs * create global assets store to dedupe global asset fetching * improve tab design/styles * update notes * use frosty dialog * update claude md * tweak * add ability to reorder tabs * resolve conflict * merge cleanup * format * update release notes * add chat delay sync completion tracking to prevent countdown re-appearance * add tests * fix * update release notes * bump
620 lines
19 KiB
Dart
620 lines
19 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
import 'package:frosty/constants.dart';
|
|
import 'package:frosty/main.dart';
|
|
import 'package:frosty/models/irc.dart';
|
|
import 'package:frosty/screens/channel/chat/details/chat_details_store.dart';
|
|
import 'package:frosty/screens/channel/chat/details/chat_modes.dart';
|
|
import 'package:frosty/screens/channel/chat/details/chat_users_list.dart';
|
|
import 'package:frosty/screens/channel/chat/stores/chat_store.dart';
|
|
import 'package:frosty/screens/settings/settings.dart';
|
|
import 'package:frosty/utils.dart';
|
|
import 'package:frosty/utils/modal_bottom_sheet.dart';
|
|
import 'package:frosty/widgets/animated_scroll_border.dart';
|
|
import 'package:frosty/widgets/frosty_scrollbar.dart';
|
|
import 'package:frosty/widgets/section_header.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class ChatDetails extends StatefulWidget {
|
|
final ChatDetailsStore chatDetailsStore;
|
|
final ChatStore chatStore;
|
|
final String userLogin;
|
|
|
|
/// Callback to add a new chat tab.
|
|
/// Shows an "Add chat" option in the menu.
|
|
final VoidCallback onAddChat;
|
|
|
|
const ChatDetails({
|
|
super.key,
|
|
required this.chatDetailsStore,
|
|
required this.chatStore,
|
|
required this.userLogin,
|
|
required this.onAddChat,
|
|
});
|
|
|
|
@override
|
|
State<ChatDetails> createState() => _ChatDetailsState();
|
|
}
|
|
|
|
class _ChatDetailsState extends State<ChatDetails> {
|
|
late final _scrollController = ScrollController();
|
|
|
|
bool _isRefreshingAssets = false;
|
|
bool _showRefreshSuccess = false;
|
|
|
|
String formatDuration(Duration duration) {
|
|
if (duration.inMinutes < 60) {
|
|
return '${duration.inMinutes} ${Intl.plural(duration.inMinutes, one: 'minute', other: 'minutes')}';
|
|
}
|
|
|
|
return '${duration.inHours} ${Intl.plural(duration.inHours, one: 'hour', other: 'hours')}';
|
|
}
|
|
|
|
String formatTimeLeft(Duration duration) {
|
|
final hours = duration.inHours;
|
|
final minutes = duration.inMinutes.remainder(60);
|
|
final seconds = duration.inSeconds.remainder(60);
|
|
|
|
if (hours > 0) {
|
|
return '${hours}h ${minutes}m';
|
|
} else if (minutes > 0) {
|
|
return '${minutes}m ${seconds}s';
|
|
} else {
|
|
return '${seconds}s';
|
|
}
|
|
}
|
|
|
|
Future<void> _showSleepTimer(BuildContext context) {
|
|
const durations = [
|
|
Duration(minutes: 5),
|
|
Duration(minutes: 10),
|
|
Duration(minutes: 15),
|
|
Duration(minutes: 30),
|
|
Duration(hours: 1),
|
|
Duration(hours: 2),
|
|
Duration(hours: 3),
|
|
Duration(hours: 4),
|
|
Duration(hours: 5),
|
|
Duration(hours: 6),
|
|
Duration(hours: 7),
|
|
Duration(hours: 8),
|
|
Duration(hours: 9),
|
|
Duration(hours: 10),
|
|
Duration(hours: 11),
|
|
Duration(hours: 12),
|
|
];
|
|
|
|
return showModalBottomSheetWithProperFocus(
|
|
context: context,
|
|
builder: (context) => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const SectionHeader(
|
|
'Sleep timer',
|
|
padding: EdgeInsets.fromLTRB(16, 0, 16, 4),
|
|
isFirst: true,
|
|
),
|
|
AnimatedScrollBorder(scrollController: _scrollController),
|
|
Expanded(
|
|
child: ListView(
|
|
controller: _scrollController,
|
|
children: [
|
|
if (widget.chatStore.sleepTimer?.isActive == true)
|
|
Observer(
|
|
builder: (context) {
|
|
return ListTile(
|
|
leading: const Icon(Icons.close_rounded),
|
|
title: Text.rich(
|
|
TextSpan(
|
|
text: 'Cancel ',
|
|
children: [
|
|
TextSpan(
|
|
text: formatTimeLeft(
|
|
widget.chatStore.timeRemaining,
|
|
),
|
|
style: TextStyle(
|
|
color: Theme.of(context)
|
|
.textTheme
|
|
.bodyMedium
|
|
?.color
|
|
?.withValues(alpha: 0.6),
|
|
fontFeatures: [FontFeature.tabularFigures()],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
widget.chatStore.cancelSleepTimer();
|
|
|
|
Navigator.of(context).pop();
|
|
},
|
|
);
|
|
},
|
|
),
|
|
...durations.map(
|
|
(duration) => ListTile(
|
|
leading: const Icon(Icons.hourglass_top_rounded),
|
|
title: Text(formatDuration(duration)),
|
|
onTap: () {
|
|
widget.chatStore.updateSleepTimer(
|
|
duration: duration,
|
|
onTimerFinished: () => navigatorKey.currentState
|
|
?.popUntil((route) => route.isFirst),
|
|
);
|
|
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Converts a hex color string to a color name if it matches one of our predefined chat colors.
|
|
/// Returns null if no match is found.
|
|
String? _hexToColorName(String hexColor) {
|
|
// Remove # if present
|
|
final cleanHex = hexColor.startsWith('#')
|
|
? hexColor.substring(1)
|
|
: hexColor;
|
|
|
|
// Convert to uppercase for comparison
|
|
final upperHex = cleanHex.toUpperCase();
|
|
|
|
// Find matching color name
|
|
for (final entry in chatColorValues.entries) {
|
|
final colorValue = entry.value.toARGB32().toRadixString(16).toUpperCase();
|
|
// Remove alpha channel (first 2 characters) for comparison
|
|
if (colorValue.length >= 6) {
|
|
final colorHex = colorValue.substring(2);
|
|
if (colorHex == upperHex) {
|
|
return entry.key;
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
Future<void> _showChatColorPicker(BuildContext context) async {
|
|
final selectedColor = await _getCurrentUserColor();
|
|
if (!context.mounted) return;
|
|
|
|
showModalBottomSheetWithProperFocus(
|
|
context: context,
|
|
builder: (context) => SizedBox(
|
|
height: MediaQuery.of(context).size.height * 0.5,
|
|
child: _ChatColorPickerModal(
|
|
initialColor: selectedColor,
|
|
scrollController: _scrollController,
|
|
onColorSelected: _handleColorUpdate,
|
|
chatStore: widget.chatStore,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<String?> _getCurrentUserColor() async {
|
|
try {
|
|
final currentColorHex = await widget.chatStore.twitchApi.getUserChatColor(
|
|
userId: widget.chatStore.auth.user.details!.id,
|
|
);
|
|
|
|
if (currentColorHex.isNotEmpty) {
|
|
return _hexToColorName(currentColorHex);
|
|
}
|
|
} catch (e) {
|
|
// Ignore errors when fetching current color
|
|
}
|
|
return null;
|
|
}
|
|
|
|
Future<void> _handleColorUpdate(BuildContext context, String color) async {
|
|
final success = await widget.chatStore.twitchApi.updateUserChatColor(
|
|
userId: widget.chatStore.auth.user.details!.id,
|
|
color: color,
|
|
);
|
|
|
|
if (!context.mounted) return;
|
|
Navigator.of(context).pop();
|
|
|
|
final message = success
|
|
? 'Chat color updated successfully!'
|
|
: 'Failed to update chat color. Please try again.';
|
|
_showMessage(context, message);
|
|
}
|
|
|
|
void _showMessage(BuildContext context, String message) {
|
|
ScaffoldMessenger.of(
|
|
context,
|
|
).showSnackBar(SnackBar(content: Text(message)));
|
|
}
|
|
|
|
bool _hasActiveModes() {
|
|
final roomState = widget.chatDetailsStore.roomState;
|
|
return roomState.subMode != '0' ||
|
|
roomState.followersOnly != '-1' ||
|
|
roomState.emoteOnly != '0' ||
|
|
roomState.slowMode != '0' ||
|
|
roomState.r9k != '0';
|
|
}
|
|
|
|
Widget _buildRefreshTrailingWidget() {
|
|
return AnimatedSwitcher(
|
|
duration: const Duration(milliseconds: 200),
|
|
child: _isRefreshingAssets
|
|
? const SizedBox(
|
|
width: 20,
|
|
height: 20,
|
|
child: CircularProgressIndicator.adaptive(strokeWidth: 2),
|
|
)
|
|
: _showRefreshSuccess
|
|
? Icon(
|
|
Icons.check_rounded,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
key: const ValueKey('success'),
|
|
)
|
|
: const SizedBox.shrink(),
|
|
);
|
|
}
|
|
|
|
Future<void> _handleRefreshAssets() async {
|
|
setState(() => _isRefreshingAssets = true);
|
|
|
|
try {
|
|
await widget.chatStore.getAssets();
|
|
if (mounted) {
|
|
HapticFeedback.lightImpact();
|
|
setState(() {
|
|
_isRefreshingAssets = false;
|
|
_showRefreshSuccess = true;
|
|
});
|
|
|
|
// Hide success after 2 seconds
|
|
Timer(const Duration(seconds: 2), () {
|
|
if (mounted) {
|
|
setState(() => _showRefreshSuccess = false);
|
|
}
|
|
});
|
|
}
|
|
} catch (e) {
|
|
if (mounted) {
|
|
setState(() => _isRefreshingAssets = false);
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Observer(
|
|
builder: (context) {
|
|
final hasActiveModes = _hasActiveModes();
|
|
|
|
final children = [
|
|
if (hasActiveModes)
|
|
ListTile(
|
|
title: SizedBox(
|
|
height: 48,
|
|
child: ListView(
|
|
scrollDirection: Axis.horizontal,
|
|
children: [
|
|
Observer(
|
|
builder: (context) => ChatModes(
|
|
roomState: widget.chatDetailsStore.roomState,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Observer(
|
|
builder: (context) {
|
|
final showVideo = widget.chatStore.settings.showVideo;
|
|
final label = showVideo ? 'Chat only' : 'Show video';
|
|
return ListTile(
|
|
leading: Icon(
|
|
showVideo ? Icons.chat_rounded : Icons.tv_rounded,
|
|
),
|
|
title: Text(label),
|
|
onTap: () {
|
|
widget.chatStore.settings.showVideo = !showVideo;
|
|
Navigator.of(context).pop();
|
|
},
|
|
);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.sync_rounded),
|
|
title: const Text('Refresh emotes and badges'),
|
|
trailing: _buildRefreshTrailingWidget(),
|
|
enabled: !_isRefreshingAssets,
|
|
onTap: _isRefreshingAssets ? null : _handleRefreshAssets,
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.wifi_off_rounded),
|
|
title: const Text('Reconnect'),
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
widget.chatStore.updateNotification('Reconnecting to chat...');
|
|
widget.chatStore.connectToChat();
|
|
},
|
|
),
|
|
if (widget.chatStore.auth.isLoggedIn)
|
|
ListTile(
|
|
leading: const Icon(Icons.palette_rounded),
|
|
title: const Text('Username color'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => _showChatColorPicker(context),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.people_rounded),
|
|
title: const Text('Chatters'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => showModalBottomSheetWithProperFocus(
|
|
isScrollControlled: true,
|
|
context: context,
|
|
builder: (context) => GestureDetector(
|
|
onTap: FocusScope.of(context).unfocus,
|
|
child: ChattersList(
|
|
chatDetailsStore: widget.chatDetailsStore,
|
|
chatStore: widget.chatStore,
|
|
userLogin: widget.userLogin,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.add_comment_rounded),
|
|
title: const Text('Add chat'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: widget.onAddChat,
|
|
),
|
|
Observer(
|
|
builder: (context) {
|
|
final hasTimer = widget.chatStore.timeRemaining.inSeconds > 0;
|
|
final label = hasTimer
|
|
? formatTimeLeft(widget.chatStore.timeRemaining)
|
|
: 'Sleep timer';
|
|
return ListTile(
|
|
leading: Icon(
|
|
hasTimer ? Icons.timer_rounded : Icons.timer_rounded,
|
|
color: hasTimer
|
|
? Theme.of(context).colorScheme.primary
|
|
: null,
|
|
),
|
|
title: Text(
|
|
label,
|
|
style: hasTimer
|
|
? TextStyle(
|
|
fontFeatures: const [FontFeature.tabularFigures()],
|
|
color: Theme.of(context).colorScheme.primary,
|
|
)
|
|
: null,
|
|
),
|
|
trailing: hasTimer
|
|
? Icon(
|
|
Icons.chevron_right,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
)
|
|
: const Icon(Icons.chevron_right),
|
|
onTap: () => _showSleepTimer(context),
|
|
);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.settings_rounded),
|
|
title: const Text('Settings'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) =>
|
|
Settings(settingsStore: widget.chatStore.settings),
|
|
),
|
|
),
|
|
),
|
|
];
|
|
|
|
return ListView(shrinkWrap: true, primary: false, children: children);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_scrollController.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
class _ChatColorPickerModal extends StatefulWidget {
|
|
const _ChatColorPickerModal({
|
|
required this.initialColor,
|
|
required this.scrollController,
|
|
required this.onColorSelected,
|
|
required this.chatStore,
|
|
});
|
|
|
|
final String? initialColor;
|
|
final ScrollController scrollController;
|
|
final Future<void> Function(BuildContext context, String color)
|
|
onColorSelected;
|
|
final ChatStore chatStore;
|
|
|
|
@override
|
|
State<_ChatColorPickerModal> createState() => _ChatColorPickerModalState();
|
|
}
|
|
|
|
class _ChatColorPickerModalState extends State<_ChatColorPickerModal> {
|
|
String? selectedColor;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
selectedColor = widget.initialColor;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildHeader(),
|
|
_buildPreview(),
|
|
AnimatedScrollBorder(scrollController: widget.scrollController),
|
|
_buildColorList(),
|
|
_buildBottomBar(),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildHeader() {
|
|
return const SectionHeader('Username color', isFirst: true);
|
|
}
|
|
|
|
Widget _buildPreview() {
|
|
if (selectedColor == null) return const SizedBox.shrink();
|
|
|
|
// Create a realistic preview using the current user's chat state and badges
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
|
child: _buildRealisticChatPreview(),
|
|
);
|
|
}
|
|
|
|
Widget _buildRealisticChatPreview() {
|
|
final userDetails = widget.chatStore.auth.user.details!;
|
|
final userState = widget.chatStore.userState;
|
|
|
|
// Create a mock IRC message with the user's current state
|
|
final mockTags = <String, String>{
|
|
'display-name': userDetails.displayName,
|
|
'color':
|
|
'#${chatColorValues[selectedColor!]!.toARGB32().toRadixString(16).substring(2)}',
|
|
'user-id': userDetails.id,
|
|
'mod': userState.mod ? '1' : '0',
|
|
'subscriber': userState.subscriber ? '1' : '0',
|
|
'id': 'preview-message',
|
|
'tmi-sent-ts': DateTime.now().millisecondsSinceEpoch.toString(),
|
|
};
|
|
|
|
// Copy any badges from the current user state
|
|
if (userState.raw != null) {
|
|
final userStateMessage = IRCMessage.fromString(userState.raw!);
|
|
if (userStateMessage.tags['badges'] != null) {
|
|
mockTags['badges'] = userStateMessage.tags['badges']!;
|
|
}
|
|
if (userStateMessage.tags['badge-info'] != null) {
|
|
mockTags['badge-info'] = userStateMessage.tags['badge-info']!;
|
|
}
|
|
}
|
|
|
|
final mockMessage = IRCMessage(
|
|
raw: '',
|
|
command: Command.privateMessage,
|
|
tags: mockTags,
|
|
user: userDetails.login,
|
|
message: 'How it will look in chat',
|
|
split: ['How', 'it', 'will', 'look', 'in', 'chat'],
|
|
action: false,
|
|
mention: false,
|
|
);
|
|
|
|
return Text.rich(
|
|
TextSpan(
|
|
children: mockMessage.generateSpan(
|
|
context,
|
|
assetsStore: widget.chatStore.assetsStore,
|
|
emoteScale: widget.chatStore.settings.emoteScale,
|
|
badgeScale: widget.chatStore.settings.badgeScale,
|
|
launchExternal: false, // Disable launching for preview
|
|
style: DefaultTextStyle.of(context).style,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildColorList() {
|
|
return Expanded(
|
|
child: FrostyScrollbar(
|
|
controller: widget.scrollController,
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
controller: widget.scrollController,
|
|
children: chatColorNames
|
|
.map((colorName) => _buildColorTile(colorName))
|
|
.toList(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildColorTile(String colorName) {
|
|
final isSelected = selectedColor == colorName;
|
|
final displayName = colorName
|
|
.replaceAll('_', ' ')
|
|
.split(' ')
|
|
.map((word) => word[0].toUpperCase() + word.substring(1))
|
|
.join(' ');
|
|
|
|
// Apply the same color adjustment for consistent preview
|
|
final rawColor = chatColorValues[colorName]!;
|
|
final adjustedColor = adjustChatNameColor(context, rawColor);
|
|
|
|
return ListTile(
|
|
leading: Container(
|
|
width: 24,
|
|
height: 24,
|
|
decoration: BoxDecoration(color: adjustedColor, shape: BoxShape.circle),
|
|
),
|
|
title: Text(displayName),
|
|
trailing: isSelected
|
|
? Icon(Icons.check, color: Theme.of(context).colorScheme.primary)
|
|
: null,
|
|
onTap: () => setState(() => selectedColor = colorName),
|
|
);
|
|
}
|
|
|
|
Widget _buildBottomBar() {
|
|
return Column(
|
|
children: [
|
|
AnimatedScrollBorder(
|
|
scrollController: widget.scrollController,
|
|
position: ScrollBorderPosition.bottom,
|
|
),
|
|
SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: TextButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
child: const Text('Cancel'),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: FilledButton(
|
|
onPressed: selectedColor == null
|
|
? null
|
|
: () => widget.onColorSelected(context, selectedColor!),
|
|
child: const Text('Save'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|