97 lines
2.7 KiB
Dart
97 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../speech/app_speech.dart';
|
|
import 'chat_session_state.dart';
|
|
import 'session_activity_badge.dart';
|
|
|
|
/// Compact mode keeps task attention and pane state alongside identity.
|
|
class ChatCompactAvatar extends StatelessWidget {
|
|
const ChatCompactAvatar({
|
|
super.key,
|
|
required this.title,
|
|
required this.color,
|
|
required this.active,
|
|
required this.visible,
|
|
required this.running,
|
|
required this.backgroundTasks,
|
|
this.awaitingOperator = 0,
|
|
required this.unread,
|
|
this.sessionId = '',
|
|
});
|
|
|
|
/// The chat's id; its reply being read aloud shows the speaking badge.
|
|
final String sessionId;
|
|
final String title;
|
|
final Color color;
|
|
final bool active, visible, running, unread;
|
|
final int backgroundTasks;
|
|
final int awaitingOperator;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
CircleAvatar(
|
|
foregroundColor: color,
|
|
backgroundColor: color.withValues(alpha: active ? .26 : .12),
|
|
child: Text(
|
|
title.characters.take(2).toString(),
|
|
style: TextStyle(fontWeight: active ? FontWeight.bold : null),
|
|
),
|
|
),
|
|
if (active || visible)
|
|
PositionedDirectional(
|
|
top: -2,
|
|
start: -5,
|
|
child: _Disc(
|
|
child: Icon(
|
|
active ? Icons.radio_button_checked : Icons.visibility_outlined,
|
|
size: 14,
|
|
color: chatStateForeground(context),
|
|
),
|
|
),
|
|
),
|
|
PositionedDirectional(
|
|
bottom: -2,
|
|
end: -3,
|
|
child: ValueListenableBuilder(
|
|
valueListenable: speechReading,
|
|
builder: (context, reading, _) =>
|
|
chatSessionActivityBadge(
|
|
running: running,
|
|
backgroundTasks: backgroundTasks,
|
|
awaitingOperator: awaitingOperator,
|
|
speaking: sessionId.isNotEmpty && reading?.scope == sessionId,
|
|
) ??
|
|
const SizedBox.shrink(),
|
|
),
|
|
),
|
|
if (unread)
|
|
PositionedDirectional(
|
|
top: -2,
|
|
end: -3,
|
|
child: _Disc(
|
|
child: Icon(
|
|
Icons.mark_chat_unread_outlined,
|
|
key: const Key('chat-compact-unread'),
|
|
size: 14,
|
|
color: chatStateForeground(context),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
class _Disc extends StatelessWidget {
|
|
const _Disc({required this.child});
|
|
final Widget child;
|
|
@override
|
|
Widget build(BuildContext context) => DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: Theme.of(context).colorScheme.surface,
|
|
),
|
|
child: Padding(padding: const EdgeInsets.all(1), child: child),
|
|
);
|
|
}
|