import '../../../../core/servers/server_context.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'chat_adaptive.dart'; /// State uses neutral text and shapes; the chat's chosen color stays identity. Color chatStateForeground(BuildContext context) => chatControlsStyleOf(context) == ChatControlsStyle.cupertino ? CupertinoColors.label.resolveFrom(context) : Theme.of(context).colorScheme.onSurface; Color chatMetadataForeground(BuildContext context) => chatControlsStyleOf(context) == ChatControlsStyle.cupertino ? CupertinoColors.label.resolveFrom(context).withValues(alpha: .82) : Theme.of(context).colorScheme.onSurfaceVariant; class ChatSessionStateLine extends StatelessWidget { const ChatSessionStateLine({ super.key, required this.active, required this.visible, required this.running, required this.backgroundTasks, required this.unread, }); final bool active, visible, running, unread; final int backgroundTasks; @override Widget build(BuildContext context) { final entries = <(IconData, String)>[ if (active) (Icons.radio_button_checked, 'Active') else if (visible) (Icons.visibility_outlined, 'Visible'), if (running) (Icons.play_circle_outline, 'Working'), if (backgroundTasks > 0) (Icons.pending_actions, '$backgroundTasks background'), if (unread) (Icons.mark_chat_unread_outlined, 'New'), ]; return Wrap( spacing: 10, runSpacing: 4, children: [ for (final (icon, label) in entries) Row( mainAxisSize: MainAxisSize.min, children: [ Icon(icon, size: 14, color: chatStateForeground(context)), const SizedBox(width: 4), Flexible( child: Text( label, style: TextStyle(color: chatStateForeground(context)), ), ), ], ), ], ); } } class ChatSessionSubtitle extends StatelessWidget { const ChatSessionSubtitle({ super.key, required this.metadata, this.machineName, required this.closed, required this.active, required this.visible, required this.running, required this.backgroundTasks, required this.unread, }); final String metadata; final String? machineName; final bool closed, active, visible, running, unread; final int backgroundTasks; @override Widget build(BuildContext context) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text.rich( TextSpan( children: [ if (closed) const TextSpan( text: 'Closed', style: TextStyle(fontWeight: FontWeight.w600), ), if (closed && metadata.isNotEmpty) const TextSpan(text: ' · '), TextSpan( text: machineName == null ? ServerContext.metadata(context, metadata) : '$machineName${metadata.isEmpty ? '' : ' · $metadata'}', ), ], ), style: TextStyle(color: chatMetadataForeground(context)), ), if (active || visible || running || backgroundTasks > 0 || unread) Padding( padding: const EdgeInsets.only(top: 4), child: ChatSessionStateLine( active: active, visible: visible, running: running, backgroundTasks: backgroundTasks, unread: unread, ), ), ], ); }