Merge commit '8b1ca066aca07861622b4b1350b7988531ccd5e0' into pipelines/run-20261111-0456-cupertino-out-runs-ui-part-1-2ad5
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/chat_account_usage.dart';
|
||||
@@ -47,19 +46,10 @@ class _ChatAccountUsageSectionState extends State<ChatAccountUsageSection> {
|
||||
Widget build(BuildContext context) {
|
||||
final usage = widget.usage;
|
||||
if (usage == null) return const SizedBox.shrink();
|
||||
final cupertino = widget.cupertino;
|
||||
final now = widget.now();
|
||||
final secondary = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final body = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final title = cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final body = Theme.of(context).textTheme.bodyMedium;
|
||||
final title = Theme.of(context).textTheme.titleSmall;
|
||||
final muted = body?.copyWith(color: secondary);
|
||||
final asOf = chatQuotaAsOf(usage.asOf, now);
|
||||
final plan = chatPlanLabel(usage.plan);
|
||||
@@ -95,7 +85,6 @@ class _ChatAccountUsageSectionState extends State<ChatAccountUsageSection> {
|
||||
_QuotaWindowRow(
|
||||
window: window,
|
||||
now: now,
|
||||
cupertino: cupertino,
|
||||
body: body,
|
||||
muted: muted,
|
||||
),
|
||||
@@ -119,14 +108,12 @@ class _QuotaWindowRow extends StatelessWidget {
|
||||
const _QuotaWindowRow({
|
||||
required this.window,
|
||||
required this.now,
|
||||
required this.cupertino,
|
||||
required this.body,
|
||||
required this.muted,
|
||||
});
|
||||
|
||||
final ChatQuotaWindow window;
|
||||
final DateTime now;
|
||||
final bool cupertino;
|
||||
final TextStyle? body;
|
||||
final TextStyle? muted;
|
||||
|
||||
@@ -135,24 +122,12 @@ class _QuotaWindowRow extends StatelessWidget {
|
||||
final summary = chatQuotaSummary(window, now);
|
||||
final fraction = (window.usedPercent / 100).clamp(0.0, 1.0);
|
||||
final high = window.usedPercent >= 90;
|
||||
// Cupertino has no linear progress control; the standard indicator is
|
||||
// drawn with the system fill and tint colors, like UIProgressView.
|
||||
final bar = cupertino
|
||||
? LinearProgressIndicator(
|
||||
value: fraction,
|
||||
backgroundColor: CupertinoColors.systemFill.resolveFrom(context),
|
||||
color:
|
||||
(high ? CupertinoColors.systemRed : CupertinoColors.activeBlue)
|
||||
.resolveFrom(context),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
semanticsLabel: '${window.label} quota',
|
||||
)
|
||||
: LinearProgressIndicator(
|
||||
value: fraction,
|
||||
color: high ? Theme.of(context).colorScheme.error : null,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
semanticsLabel: '${window.label} quota',
|
||||
);
|
||||
final bar = LinearProgressIndicator(
|
||||
value: fraction,
|
||||
color: high ? Theme.of(context).colorScheme.error : null,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
semanticsLabel: '${window.label} quota',
|
||||
);
|
||||
return Padding(
|
||||
key: Key('chat-account-window-${window.id}'),
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -25,19 +24,14 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = taskCupertino(context);
|
||||
final kind = taskKindLabel(shell);
|
||||
final agent = '${shell['task_type'] ?? ''}'.contains('agent');
|
||||
final progress = distinctTaskProgress(shell);
|
||||
final elapsed = taskElapsed(shell, now);
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
final status = DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: cupertino
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.secondaryContainer,
|
||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -45,26 +39,14 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.play_fill : Icons.play_arrow_rounded,
|
||||
size: 14,
|
||||
color: accent,
|
||||
),
|
||||
Icon(Icons.play_arrow_rounded, size: 14, color: accent),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
'Running',
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: CupertinoColors.label.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -76,14 +58,7 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
children: [
|
||||
Flexible(child: Text(selected ? 'Hide details' : 'Details')),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
cupertino
|
||||
? (selected
|
||||
? CupertinoIcons.chevron_up
|
||||
: CupertinoIcons.chevron_down)
|
||||
: (selected ? Icons.expand_less : Icons.expand_more),
|
||||
size: 18,
|
||||
),
|
||||
Icon(selected ? Icons.expand_less : Icons.expand_more, size: 18),
|
||||
],
|
||||
);
|
||||
return ChatTaskSurface(
|
||||
@@ -96,17 +71,9 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: cupertino
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.primaryContainer,
|
||||
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||
child: Icon(
|
||||
agent
|
||||
? (cupertino
|
||||
? CupertinoIcons.person_2
|
||||
: Icons.smart_toy_outlined)
|
||||
: (cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal),
|
||||
agent ? Icons.smart_toy_outlined : Icons.terminal,
|
||||
color: accent,
|
||||
),
|
||||
),
|
||||
@@ -149,12 +116,7 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
label: 'Elapsed ${taskDuration(elapsed)}',
|
||||
child: Text(
|
||||
taskDuration(elapsed),
|
||||
style: (cupertino
|
||||
? CupertinoTheme.of(context)
|
||||
.textTheme
|
||||
.navLargeTitleTextStyle
|
||||
.copyWith(fontSize: 24)
|
||||
: Theme.of(context).textTheme.headlineSmall),
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -165,10 +127,7 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
const SizedBox(height: 16),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: cupertino
|
||||
? CupertinoColors.tertiarySystemGroupedBackground
|
||||
.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
@@ -177,9 +136,7 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.text_bubble
|
||||
: Icons.notes_rounded,
|
||||
Icons.notes_rounded,
|
||||
size: 18,
|
||||
color: taskSecondary(context),
|
||||
),
|
||||
@@ -202,28 +159,15 @@ class ChatBackgroundTaskCard extends StatelessWidget {
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: Semantics(
|
||||
expanded: selected,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
key: ValueKey('chat-bg-task-${shellIdOf(shell)}'),
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: onDetails,
|
||||
child: details,
|
||||
)
|
||||
: TextButton(
|
||||
key: ValueKey('chat-bg-task-${shellIdOf(shell)}'),
|
||||
onPressed: onDetails,
|
||||
child: details,
|
||||
),
|
||||
child: TextButton(
|
||||
key: ValueKey('chat-bg-task-${shellIdOf(shell)}'),
|
||||
onPressed: onDetails,
|
||||
child: details,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (detail != null) ...[
|
||||
if (cupertino)
|
||||
Container(
|
||||
height: 0.5,
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
)
|
||||
else
|
||||
const Divider(),
|
||||
const Divider(),
|
||||
const SizedBox(height: 12),
|
||||
detail!,
|
||||
],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -27,7 +26,6 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = taskCupertino(context);
|
||||
final command = taskText(shell, 'command');
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -38,7 +36,7 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
|
||||
runSpacing: 16,
|
||||
children: [
|
||||
ChatTaskFact(
|
||||
icon: cupertino ? CupertinoIcons.number : Icons.tag,
|
||||
icon: Icons.tag,
|
||||
label: shellOutputTaskIdentityLabel,
|
||||
value: shellIdOf(shell),
|
||||
monospace: true,
|
||||
@@ -46,9 +44,7 @@ class ChatBackgroundTaskDetail extends StatelessWidget {
|
||||
if (command != null &&
|
||||
!sameTaskText(command, taskDisplayTitle(shell)))
|
||||
ChatTaskFact(
|
||||
icon: cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal,
|
||||
icon: Icons.terminal,
|
||||
label: shellOutputCommandLabel,
|
||||
value: command,
|
||||
monospace: true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:math' as math;
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../domain/chat_shells.dart';
|
||||
@@ -23,7 +22,6 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = taskCupertino(context);
|
||||
final state = output?.state ?? ChatShellOutputState.none;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -37,13 +35,7 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal,
|
||||
size: 18,
|
||||
color: taskSecondary(context),
|
||||
),
|
||||
Icon(Icons.terminal, size: 18, color: taskSecondary(context)),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(shellOutputLabel, style: taskHeading(context)),
|
||||
@@ -61,16 +53,12 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
const SizedBox(height: 8),
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: cupertino
|
||||
? CupertinoColors.tertiarySystemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
)
|
||||
: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: _outputArea(context, cupertino),
|
||||
child: _outputArea(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -79,17 +67,12 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
|
||||
/// The host's own monospace body for one output page. `height` is set so the
|
||||
/// visible-line bound below is measured on the same line box that is drawn.
|
||||
TextStyle _outputStyle(BuildContext context, bool cupertino) =>
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall ?? const TextStyle())
|
||||
.copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
height: _outputLineHeight,
|
||||
// Cupertino's style is not inheriting; a selectable body needs a
|
||||
// baseline from its own style.
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
);
|
||||
TextStyle _outputStyle(BuildContext context) =>
|
||||
(Theme.of(context).textTheme.bodySmall ?? const TextStyle()).copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
height: _outputLineHeight,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
);
|
||||
|
||||
/// The number of output lines the pane shows before it scrolls: up to twelve,
|
||||
/// fewer when the user's text scale or the bar's remaining height would let
|
||||
@@ -103,58 +86,32 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
return math.max(2, math.min(lines, math.min(_outputVisibleLines, fit)));
|
||||
}
|
||||
|
||||
/// Selectable output in the host's own control. A Cupertino-only app has no
|
||||
/// `MaterialLocalizations`, which `SelectableText` asserts on, so one English
|
||||
/// default scope is supplied for its context menu (the chat markdown view's
|
||||
/// own pattern).
|
||||
Widget _selectableOutput(
|
||||
BuildContext context,
|
||||
bool cupertino,
|
||||
String output,
|
||||
TextStyle style,
|
||||
int maxLines,
|
||||
) {
|
||||
final text = SelectableText(
|
||||
output,
|
||||
semanticsLabel: output,
|
||||
key: const Key('chat-bg-task-output'),
|
||||
style: style,
|
||||
// A multiline selectable body scrolls itself: the host's text control
|
||||
// keeps the page selectable and gives it its own scrollbar/drag, so no
|
||||
// nested scroller can steal the conversation's gestures.
|
||||
maxLines: maxLines,
|
||||
);
|
||||
if (!cupertino) return text;
|
||||
return Localizations(
|
||||
locale: Localizations.maybeLocaleOf(context) ?? const Locale('en'),
|
||||
delegates: const [
|
||||
DefaultWidgetsLocalizations.delegate,
|
||||
DefaultMaterialLocalizations.delegate,
|
||||
DefaultCupertinoLocalizations.delegate,
|
||||
],
|
||||
child: text,
|
||||
);
|
||||
}
|
||||
/// Selectable output in the host's own control.
|
||||
Widget _selectableOutput(String output, TextStyle style, int maxLines) =>
|
||||
SelectableText(
|
||||
output,
|
||||
semanticsLabel: output,
|
||||
key: const Key('chat-bg-task-output'),
|
||||
style: style,
|
||||
// A multiline selectable body scrolls itself: the host's text control
|
||||
// keeps the page selectable and gives it its own scrollbar/drag, so no
|
||||
// nested scroller can steal the conversation's gestures.
|
||||
maxLines: maxLines,
|
||||
);
|
||||
|
||||
Widget _outputArea(BuildContext context, bool cupertino) {
|
||||
Widget _outputArea(BuildContext context) {
|
||||
final state = output?.state ?? ChatShellOutputState.none;
|
||||
final muted = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final noteStyle =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(color: muted);
|
||||
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final noteStyle = Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: muted);
|
||||
switch (state) {
|
||||
case ChatShellOutputState.none:
|
||||
return const SizedBox.shrink();
|
||||
case ChatShellOutputState.loading:
|
||||
return Align(
|
||||
return const Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
case ChatShellOutputState.error:
|
||||
return Row(
|
||||
@@ -166,9 +123,7 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
child: Text(
|
||||
output?.error ?? '',
|
||||
style: noteStyle?.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -184,14 +139,12 @@ class ChatBackgroundTaskOutput extends StatelessWidget {
|
||||
return Text(shellOutputEmptyNote, style: noteStyle);
|
||||
case ChatShellOutputState.ready:
|
||||
final page = output!.page!;
|
||||
final style = _outputStyle(context, cupertino);
|
||||
final style = _outputStyle(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 4,
|
||||
children: [
|
||||
_selectableOutput(
|
||||
context,
|
||||
cupertino,
|
||||
page.output,
|
||||
style,
|
||||
_outputVisibleLineCount(context, style),
|
||||
@@ -214,14 +167,6 @@ class ChatBackgroundTaskButton extends StatelessWidget {
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (taskCupertino(context)) {
|
||||
return CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
return TextButton(onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
Widget build(BuildContext context) =>
|
||||
TextButton(onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_background_tasks_controller.dart';
|
||||
import 'chat_background_tasks_dialog.dart';
|
||||
|
||||
@@ -58,20 +56,13 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
||||
if (_modal != null) return;
|
||||
unawaited(controller.refreshAutomations());
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
Widget dialog(BuildContext context) => ChatBackgroundTasksDialog(
|
||||
key: const Key('chat-background-tasks-modal'),
|
||||
controller: controller,
|
||||
onClose: () => Navigator.of(context, rootNavigator: true).pop(),
|
||||
);
|
||||
|
||||
final TransitionRoute<void> route = cupertino
|
||||
? CupertinoModalPopupRoute<void>(
|
||||
barrierDismissible: true,
|
||||
builder: dialog,
|
||||
)
|
||||
: DialogRoute<void>(context: context, builder: dialog);
|
||||
final route = DialogRoute<void>(context: context, builder: dialog);
|
||||
_modal = route;
|
||||
Navigator.of(context, rootNavigator: true).push(route);
|
||||
route.completed.then((_) {
|
||||
@@ -109,11 +100,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
||||
);
|
||||
}
|
||||
final label = failed && labels.isEmpty ? 'Tasks' : labels.join(', ');
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final labelStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||
: Theme.of(context).textTheme.labelSmall;
|
||||
final labelStyle = Theme.of(context).textTheme.labelSmall;
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: label, style: labelStyle),
|
||||
textDirection: Directionality.of(context),
|
||||
@@ -121,7 +108,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
||||
)..layout();
|
||||
final compact =
|
||||
constraints.maxWidth.isFinite &&
|
||||
painter.width + (cupertino ? 32 : 40) > constraints.maxWidth;
|
||||
painter.width + 40 > constraints.maxWidth;
|
||||
painter.dispose();
|
||||
Widget caption() => compact
|
||||
? Wrap(
|
||||
@@ -134,10 +121,7 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (count > 0) ...[
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.clock : Icons.schedule,
|
||||
size: 16,
|
||||
),
|
||||
Icon(Icons.schedule, size: 16),
|
||||
const SizedBox(width: 2),
|
||||
],
|
||||
Text('$automationCount', style: labelStyle),
|
||||
@@ -153,51 +137,21 @@ class _ChatBackgroundTasksState extends State<ChatBackgroundTasks> {
|
||||
style: labelStyle,
|
||||
);
|
||||
final automationOnly = count == 0 && (automationCount ?? 0) > 0;
|
||||
final Widget button;
|
||||
if (cupertino) {
|
||||
final color = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
button = CupertinoButton(
|
||||
key: const Key('chat-background-tasks-button'),
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
onPressed: _open,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
automationOnly
|
||||
? CupertinoIcons.clock
|
||||
: CupertinoIcons.square_stack_3d_up,
|
||||
size: 16,
|
||||
color: color,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: DefaultTextStyle.merge(
|
||||
style: TextStyle(color: color),
|
||||
child: caption(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final theme = Theme.of(context);
|
||||
button = TextButton.icon(
|
||||
key: const Key('chat-background-tasks-button'),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: theme.colorScheme.onSurfaceVariant,
|
||||
padding: EdgeInsets.symmetric(horizontal: compact ? 4 : 8),
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
onPressed: _open,
|
||||
icon: Icon(
|
||||
automationOnly ? Icons.schedule : Icons.layers_outlined,
|
||||
size: 16,
|
||||
),
|
||||
label: caption(),
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
final button = TextButton.icon(
|
||||
key: const Key('chat-background-tasks-button'),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: theme.colorScheme.onSurfaceVariant,
|
||||
padding: EdgeInsets.symmetric(horizontal: compact ? 4 : 8),
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
onPressed: _open,
|
||||
icon: Icon(
|
||||
automationOnly ? Icons.schedule : Icons.layers_outlined,
|
||||
size: 16,
|
||||
),
|
||||
label: caption(),
|
||||
);
|
||||
return Padding(
|
||||
// Level with the field's single line, beside Send.
|
||||
padding: const EdgeInsetsDirectional.only(end: 4, bottom: 4),
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/chat_shells.dart';
|
||||
import 'chat_background_tasks_controller.dart';
|
||||
import 'chat_background_tasks_panel.dart';
|
||||
import 'chat_task_presentation.dart';
|
||||
|
||||
/// A task inspector needs a reading surface, rather than alert-sized content.
|
||||
class ChatBackgroundTasksDialog extends StatelessWidget {
|
||||
@@ -23,7 +21,6 @@ class ChatBackgroundTasksDialog extends StatelessWidget {
|
||||
);
|
||||
|
||||
Widget _dialog(BuildContext context) {
|
||||
final cupertino = taskCupertino(context);
|
||||
final title = (controller.automationStatus.count ?? 0) > 0
|
||||
? (controller.running.isEmpty ? 'Automations' : 'Tasks and automations')
|
||||
: backgroundTasksTitle;
|
||||
@@ -31,32 +28,6 @@ class ChatBackgroundTasksDialog extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: ChatBackgroundTasksPanel(controller: controller),
|
||||
);
|
||||
if (cupertino) {
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: 0.88,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 840),
|
||||
child: CupertinoPageScaffold(
|
||||
backgroundColor: CupertinoColors.systemGroupedBackground
|
||||
.resolveFrom(context),
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
automaticallyImplyLeading: false,
|
||||
leading: const Icon(CupertinoIcons.square_stack_3d_up),
|
||||
middle: Text(title),
|
||||
trailing: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onClose,
|
||||
child: const Text('Done'),
|
||||
),
|
||||
),
|
||||
child: SafeArea(child: SingleChildScrollView(child: panel)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Dialog(
|
||||
constraints: const BoxConstraints(maxWidth: 840),
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/chat_shells.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_background_task_card.dart';
|
||||
import 'chat_background_task_detail.dart';
|
||||
import 'chat_background_tasks_controller.dart';
|
||||
@@ -49,8 +47,6 @@ class _ChatBackgroundTasksPanelState extends State<ChatBackgroundTasksPanel> {
|
||||
listenable: controller,
|
||||
builder: (context, _) {
|
||||
final at = now;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final running = controller.running;
|
||||
final shell = controller.selectedShell;
|
||||
final error = controller.error;
|
||||
@@ -60,10 +56,7 @@ class _ChatBackgroundTasksPanelState extends State<ChatBackgroundTasksPanel> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (controller.loading)
|
||||
cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const LinearProgressIndicator(),
|
||||
if (controller.loading) const LinearProgressIndicator(),
|
||||
if (automation.unavailable)
|
||||
Text(
|
||||
'Automation status is not available for this chat connection.',
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/glass_pill.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import '../ui/sessions/chat_color_palette.dart';
|
||||
|
||||
/// How strongly the chat's shade colours the bar's glass pieces over the
|
||||
@@ -70,12 +68,9 @@ class ChatBarTint {
|
||||
ChatBarTint? chatBarTintOf(BuildContext context, String? name) {
|
||||
final shade = chatColorShade(context, name);
|
||||
if (shade == null) return null;
|
||||
final cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return ChatBarTint.from(
|
||||
shade: shade,
|
||||
raised: cupertino
|
||||
? CupertinoColors.systemGrey5.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
raised: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
dark: chatColorDarkSurface(context),
|
||||
inactive: ChatPaneActivity.inactiveOf(context),
|
||||
solid: MediaQuery.maybeHighContrastOf(context) ?? false,
|
||||
@@ -97,9 +92,7 @@ Color chatFocusRingColor(BuildContext context, String? name) {
|
||||
if (shade != null) {
|
||||
return chatSeededScheme(shade, dark: chatColorDarkSurface(context)).primary;
|
||||
}
|
||||
return chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
}
|
||||
|
||||
/// Marks a split pane that is not the active one, so its bar fades its tint.
|
||||
@@ -123,10 +116,9 @@ class ChatPaneActivity extends InheritedWidget {
|
||||
inactive != oldWidget.inactive;
|
||||
}
|
||||
|
||||
/// Gives the bar's controls the tint's foreground: Material icon buttons
|
||||
/// through the ambient icon colour, Cupertino buttons (Back, Files, More)
|
||||
/// through the theme's primary colour, their native tint, and the chat's own
|
||||
/// bar controls through [foregroundOf].
|
||||
/// Gives the bar's controls the tint's foreground: the Material icon buttons
|
||||
/// through the ambient icon colour, and the chat's own bar controls through
|
||||
/// [foregroundOf].
|
||||
class ChatBarTintScope extends InheritedWidget {
|
||||
ChatBarTintScope({
|
||||
super.key,
|
||||
@@ -134,18 +126,9 @@ class ChatBarTintScope extends InheritedWidget {
|
||||
required bool cupertino,
|
||||
required Widget child,
|
||||
}) : super(
|
||||
child: Builder(
|
||||
builder: (context) => cupertino
|
||||
? CupertinoTheme(
|
||||
data: CupertinoTheme.of(
|
||||
context,
|
||||
).copyWith(primaryColor: tint.foreground),
|
||||
child: child,
|
||||
)
|
||||
: IconTheme.merge(
|
||||
data: IconThemeData(color: tint.foreground),
|
||||
child: child,
|
||||
),
|
||||
child: IconTheme.merge(
|
||||
data: IconThemeData(color: tint.foreground),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/theme/app_theme.dart';
|
||||
import 'settings_layout.dart';
|
||||
import 'settings_theme.dart';
|
||||
|
||||
/// The Settings page's scrolling column of groups.
|
||||
///
|
||||
@@ -11,8 +9,7 @@ import 'settings_theme.dart';
|
||||
/// floating tab bar's (the bottom media padding), so at rest nothing is hidden
|
||||
/// and scrolled groups pass behind the glass pills. The column starts at the
|
||||
/// bar's own side inset, so the groups line up under the title pill, and stops
|
||||
/// at [settingsContentMaxWidth] on a wide window. Cupertino paints the page in
|
||||
/// the grouped background its inset-grouped sections are designed for.
|
||||
/// at [settingsContentMaxWidth] on a wide window.
|
||||
class SettingsPageBody extends StatelessWidget {
|
||||
const SettingsPageBody({super.key, required this.children});
|
||||
|
||||
@@ -21,11 +18,7 @@ class SettingsPageBody extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final insets = MediaQuery.paddingOf(context);
|
||||
// The inset-grouped section already pads above its own header.
|
||||
final gap = usesCupertinoControls(context)
|
||||
? settingsTitleGap
|
||||
: settingsSectionGap;
|
||||
final Widget list = SingleChildScrollView(
|
||||
return SingleChildScrollView(
|
||||
key: const ValueKey<String>('settings.scroll'),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
insets.left + settingsPageSidePadding,
|
||||
@@ -41,7 +34,7 @@ class SettingsPageBody extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
for (final (index, child) in children.indexed) ...<Widget>[
|
||||
if (index > 0) SizedBox(height: gap),
|
||||
if (index > 0) const SizedBox(height: settingsSectionGap),
|
||||
child,
|
||||
],
|
||||
],
|
||||
@@ -49,15 +42,5 @@ class SettingsPageBody extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
if (!usesCupertinoControls(context)) return list;
|
||||
return ColoredBox(
|
||||
color: settingsCupertinoBackground.resolveFrom(context),
|
||||
child: list,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The Cupertino Settings page background: the system grouped background, so
|
||||
/// the inset sections' rows read as raised cards in light and dark.
|
||||
const CupertinoDynamicColor settingsCupertinoBackground =
|
||||
AppColors.groupedBackground;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../ui/motion/quick_switch_animation.dart';
|
||||
import 'settings_theme.dart';
|
||||
@@ -9,28 +8,6 @@ class SettingsQuickSwitchControl extends StatelessWidget {
|
||||
const SettingsQuickSwitchControl({super.key, required this.controller});
|
||||
final QuickSwitchAnimationController controller;
|
||||
|
||||
Future<void> _choose(BuildContext context) async {
|
||||
final choice = await showCupertinoModalPopup<QuickSwitchAnimation>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: const Text('Quick switch animation'),
|
||||
actions: [
|
||||
for (final animation in QuickSwitchAnimation.values)
|
||||
CupertinoActionSheetAction(
|
||||
isDefaultAction: animation == controller.value,
|
||||
onPressed: () => Navigator.pop(context, animation),
|
||||
child: Text(animation.label),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (choice != null) await controller.setAnimation(choice);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: controller,
|
||||
@@ -41,33 +18,17 @@ class SettingsQuickSwitchControl extends StatelessWidget {
|
||||
'Quick switch animation',
|
||||
style: settingsTextStyle(context, title: true),
|
||||
),
|
||||
if (usesCupertinoControls(context))
|
||||
CupertinoButton(
|
||||
onPressed: () => unawaited(_choose(context)),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(controller.value.label),
|
||||
const SizedBox(width: 8),
|
||||
const Icon(CupertinoIcons.chevron_down),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
DropdownButton<QuickSwitchAnimation>(
|
||||
value: controller.value,
|
||||
isExpanded: true,
|
||||
items: [
|
||||
for (final animation in QuickSwitchAnimation.values)
|
||||
DropdownMenuItem(
|
||||
value: animation,
|
||||
child: Text(animation.label),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value != null) unawaited(controller.setAnimation(value));
|
||||
},
|
||||
),
|
||||
DropdownButton<QuickSwitchAnimation>(
|
||||
value: controller.value,
|
||||
isExpanded: true,
|
||||
items: [
|
||||
for (final animation in QuickSwitchAnimation.values)
|
||||
DropdownMenuItem(value: animation, child: Text(animation.label)),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value != null) unawaited(controller.setAnimation(value));
|
||||
},
|
||||
),
|
||||
Text(controller.value.description),
|
||||
const SizedBox(height: 8),
|
||||
QuickSwitchPreview(animation: controller.value),
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'settings_theme.dart';
|
||||
|
||||
/// One row of a [SettingsGroup]: Material [ListTile], Cupertino
|
||||
/// [CupertinoListTile]. The subtitle wraps (the Cupertino tile otherwise caps
|
||||
/// it at one line), so addresses and status details stay readable at large
|
||||
/// text.
|
||||
/// One row of a [SettingsGroup]: a Material [ListTile]. The subtitle wraps, so
|
||||
/// addresses and status details stay readable at large text.
|
||||
class SettingsRow extends StatelessWidget {
|
||||
const SettingsRow({
|
||||
super.key,
|
||||
@@ -26,7 +21,7 @@ class SettingsRow extends StatelessWidget {
|
||||
final Widget? trailing;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
/// A navigation row: shows the platform's disclosure chevron.
|
||||
/// A navigation row: shows the disclosure chevron.
|
||||
final bool chevron;
|
||||
|
||||
/// A command row (Reconnect, Add server): the title takes the accent
|
||||
@@ -34,43 +29,9 @@ class SettingsRow extends StatelessWidget {
|
||||
final bool action;
|
||||
final bool enabled;
|
||||
|
||||
Widget _wrapping(Widget child) => Builder(
|
||||
builder: (context) => DefaultTextStyle(
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tap = enabled ? onTap : null;
|
||||
final subtitle = this.subtitle;
|
||||
if (usesCupertinoControls(context)) {
|
||||
final accent = CupertinoTheme.of(context).primaryColor;
|
||||
final disabled = CupertinoColors.tertiaryLabel.resolveFrom(context);
|
||||
return CupertinoListTile(
|
||||
leading: leading == null
|
||||
? null
|
||||
: IconTheme.merge(
|
||||
data: IconThemeData(color: enabled ? accent : disabled),
|
||||
child: leading!,
|
||||
),
|
||||
title: DefaultTextStyle.merge(
|
||||
style: TextStyle(
|
||||
color: !enabled
|
||||
? disabled
|
||||
: action
|
||||
? accent
|
||||
: null,
|
||||
),
|
||||
child: title,
|
||||
),
|
||||
subtitle: subtitle == null ? null : _wrapping(subtitle),
|
||||
trailing:
|
||||
trailing ?? (chevron ? const CupertinoListTileChevron() : null),
|
||||
onTap: tap,
|
||||
);
|
||||
}
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return ListTile(
|
||||
enabled: enabled,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/scale/ui_scale.dart';
|
||||
@@ -34,7 +33,6 @@ class _SettingsScaleSectionState extends State<SettingsScaleSection> {
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: _controller,
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final value = _draft ?? _controller.scale;
|
||||
final label = '${value.toStringAsFixed(1)}×';
|
||||
final reset = _controller.scale == 1 && _draft == null
|
||||
@@ -70,41 +68,23 @@ class _SettingsScaleSectionState extends State<SettingsScaleSection> {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Text(label, style: settingsTextStyle(context, title: true)),
|
||||
cupertino
|
||||
? CupertinoButton(
|
||||
onPressed: reset,
|
||||
child: const Text('Reset'),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: reset,
|
||||
child: const Text('Reset'),
|
||||
),
|
||||
TextButton(onPressed: reset, child: const Text('Reset')),
|
||||
],
|
||||
),
|
||||
Semantics(
|
||||
label: 'Interface size',
|
||||
child: cupertino
|
||||
? CupertinoSlider(
|
||||
key: const Key('settings-ui-scale'),
|
||||
value: value,
|
||||
min: minUiScale,
|
||||
max: maxUiScale,
|
||||
divisions: 15,
|
||||
onChanged: drag,
|
||||
onChangeEnd: _apply,
|
||||
)
|
||||
: Slider(
|
||||
key: const Key('settings-ui-scale'),
|
||||
value: value,
|
||||
min: minUiScale,
|
||||
max: maxUiScale,
|
||||
divisions: 15,
|
||||
label: label,
|
||||
semanticFormatterCallback: (v) =>
|
||||
'${v.toStringAsFixed(1)} times',
|
||||
onChanged: drag,
|
||||
onChangeEnd: _apply,
|
||||
),
|
||||
child: Slider(
|
||||
key: const Key('settings-ui-scale'),
|
||||
value: value,
|
||||
min: minUiScale,
|
||||
max: maxUiScale,
|
||||
divisions: 15,
|
||||
label: label,
|
||||
semanticFormatterCallback: (v) =>
|
||||
'${v.toStringAsFixed(1)} times',
|
||||
onChanged: drag,
|
||||
onChangeEnd: _apply,
|
||||
),
|
||||
),
|
||||
const Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'settings_keys.dart';
|
||||
import 'settings_row.dart';
|
||||
import 'settings_theme.dart';
|
||||
|
||||
/// The Settings entry to the saved-schedule list.
|
||||
///
|
||||
@@ -22,11 +20,7 @@ class SettingsSchedulesSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsRow(
|
||||
key: SettingsKeys.schedules,
|
||||
leading: Icon(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoIcons.calendar
|
||||
: Icons.event_repeat_outlined,
|
||||
),
|
||||
leading: const Icon(Icons.event_repeat_outlined),
|
||||
title: const Text(settingsSchedulesLabel),
|
||||
subtitle: const Text(settingsSchedulesSecondary),
|
||||
chevron: true,
|
||||
|
||||
@@ -4,15 +4,12 @@ import '../../ui/adaptive/segmented_bar.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/transport/pipelines_client.dart' as transport;
|
||||
import '../../shell/shell_bar.dart';
|
||||
import '../attention/notify/notification_controller.dart';
|
||||
import 'default_endpoint.dart';
|
||||
import 'settings_controller.dart';
|
||||
import 'settings_controls.dart';
|
||||
import 'settings_font_section.dart';
|
||||
import 'settings_animation_section.dart';
|
||||
import 'settings_scale_section.dart';
|
||||
@@ -44,7 +41,7 @@ import 'managed_connection_section.dart';
|
||||
part 'settings_topic_pages.dart';
|
||||
|
||||
/// The Settings destination: the server connection and the server-side
|
||||
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
|
||||
/// workspace in native Material controls.
|
||||
///
|
||||
/// The shared [transport.PipelinesClient] is supplied by the shell. This screen
|
||||
/// subscribes to it, connects/disconnects it and pings it on connected, but it
|
||||
@@ -190,25 +187,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
pages: _topicPages(),
|
||||
navigationScope: widget.navigationScope,
|
||||
);
|
||||
if (widget.embedded) {
|
||||
// Under the shell's bar the Cupertino page is the grouped background
|
||||
// right up to the top edge: the bar's scrim takes the same colour, so
|
||||
// no white band or seam shows above the groups.
|
||||
if (usesCupertinoControls(context) && ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
backgroundColor: settingsCupertinoBackground,
|
||||
child: content,
|
||||
);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
if (usesCupertinoControls(context)) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: settingsCupertinoBackground,
|
||||
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
|
||||
child: content,
|
||||
);
|
||||
}
|
||||
if (widget.embedded) return content;
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: const SegmentedBar(cupertino: false, title: 'Settings'),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'settings_controller.dart';
|
||||
@@ -111,8 +110,8 @@ Widget settingsConnectionFooter(SettingsController controller) => Column(
|
||||
);
|
||||
|
||||
/// Workspace controls. The path is resolved by the execution server, and the
|
||||
/// helper says so explicitly; an empty saved value is named "(none)". Save
|
||||
/// stays a legible tonal (Cupertino: plain) button while it is unavailable.
|
||||
/// helper says so explicitly; an empty saved value is named "(none)". Save is
|
||||
/// a tonal button while it is unavailable.
|
||||
class SettingsWorkspaceSection extends StatelessWidget {
|
||||
const SettingsWorkspaceSection({
|
||||
super.key,
|
||||
@@ -150,22 +149,11 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
||||
runSpacing: settingsFieldGap,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: <Widget>[
|
||||
if (usesCupertinoControls(context))
|
||||
// A tinted button keeps its shape when disabled, so an
|
||||
// unsaved-nothing state reads as a disabled button,
|
||||
// not as stray grey text.
|
||||
CupertinoButton.tinted(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
)
|
||||
else
|
||||
FilledButton.tonal(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
),
|
||||
FilledButton.tonal(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
),
|
||||
Text(
|
||||
savedWorkspaceLine(controller.savedWorkspace),
|
||||
style: settingsTextStyle(context, secondary: true),
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/session/server_session.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
|
||||
/// Signs the phone in at the server's web login with the same password the
|
||||
/// browser uses, so the app can reach a server behind it (over Tailscale, for
|
||||
@@ -64,45 +62,7 @@ class _SettingsSignInSectionState extends State<SettingsSignInSection> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final signedIn = ServerSession.cookie != null;
|
||||
final field = cupertino
|
||||
? CupertinoTextField(
|
||||
key: const Key('settings-sign-in-password'),
|
||||
controller: _password,
|
||||
obscureText: true,
|
||||
placeholder: 'Web password',
|
||||
onSubmitted: (_) => _signIn(),
|
||||
)
|
||||
: TextField(
|
||||
key: const Key('settings-sign-in-password'),
|
||||
controller: _password,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Web password'),
|
||||
onSubmitted: (_) => _signIn(),
|
||||
);
|
||||
final signIn = cupertino
|
||||
? CupertinoButton.filled(
|
||||
key: const Key('settings-sign-in'),
|
||||
onPressed: _busy ? null : _signIn,
|
||||
child: const Text('Sign in'),
|
||||
)
|
||||
: FilledButton(
|
||||
key: const Key('settings-sign-in'),
|
||||
onPressed: _busy ? null : _signIn,
|
||||
child: const Text('Sign in'),
|
||||
);
|
||||
final signOut = cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('settings-sign-out'),
|
||||
onPressed: _signOut,
|
||||
child: const Text('Sign out'),
|
||||
)
|
||||
: TextButton(
|
||||
key: const Key('settings-sign-out'),
|
||||
onPressed: _signOut,
|
||||
child: const Text('Sign out'),
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -112,9 +72,30 @@ class _SettingsSignInSectionState extends State<SettingsSignInSection> {
|
||||
: 'Only needed when the server sits behind the web login.',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
field,
|
||||
TextField(
|
||||
key: const Key('settings-sign-in-password'),
|
||||
controller: _password,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(labelText: 'Web password'),
|
||||
onSubmitted: (_) => _signIn(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(spacing: 8, children: [signIn, if (signedIn) signOut]),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
children: [
|
||||
FilledButton(
|
||||
key: const Key('settings-sign-in'),
|
||||
onPressed: _busy ? null : _signIn,
|
||||
child: const Text('Sign in'),
|
||||
),
|
||||
if (signedIn)
|
||||
TextButton(
|
||||
key: const Key('settings-sign-out'),
|
||||
onPressed: _signOut,
|
||||
child: const Text('Sign out'),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_message != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/transport/pipelines_client.dart' as transport;
|
||||
@@ -16,38 +15,30 @@ class SettingsStatusRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final state = controller.connection;
|
||||
final lines = controller.connectionLines;
|
||||
final title = lines.isEmpty ? '' : lines.first;
|
||||
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
||||
final connectedColor = cupertino
|
||||
? CupertinoColors.systemGreen.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final connectedColor = Theme.of(context).colorScheme.primary;
|
||||
final Color? color = switch (state.kind) {
|
||||
transport.ConnectionKind.connected => connectedColor,
|
||||
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
||||
_ => null,
|
||||
};
|
||||
final Widget leading = switch (state.kind) {
|
||||
transport.ConnectionKind.connecting =>
|
||||
cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const SizedBox.square(
|
||||
dimension: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
transport.ConnectionKind.connecting => const SizedBox.square(
|
||||
dimension: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
transport.ConnectionKind.connected => Icon(
|
||||
cupertino ? CupertinoIcons.checkmark_circle_fill : Icons.check_circle,
|
||||
Icons.check_circle,
|
||||
color: color,
|
||||
),
|
||||
transport.ConnectionKind.disconnected => Icon(
|
||||
cupertino ? CupertinoIcons.xmark_circle_fill : Icons.error_outline,
|
||||
Icons.error_outline,
|
||||
color: color,
|
||||
),
|
||||
transport.ConnectionKind.idle => Icon(
|
||||
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
|
||||
),
|
||||
transport.ConnectionKind.idle => Icon(Icons.radio_button_unchecked),
|
||||
};
|
||||
return SettingsRow(
|
||||
leading: leading,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'settings_layout.dart';
|
||||
import 'settings_theme.dart';
|
||||
import 'settings_page_body.dart';
|
||||
import 'settings_topic_store.dart';
|
||||
import '../../core/storage/ordered_local_storage.dart';
|
||||
import '../../ui/motion/surface_visibility.dart';
|
||||
@@ -133,37 +129,13 @@ class _SettingsTopicTabsState extends State<SettingsTopicTabs>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabs = usesCupertinoControls(context)
|
||||
? SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: settingsPageSidePadding,
|
||||
),
|
||||
child: CupertinoSlidingSegmentedControl<SettingsTopic>(
|
||||
groupValue: _selected,
|
||||
children: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: settingsControlGap,
|
||||
),
|
||||
child: Text(topic.label),
|
||||
),
|
||||
},
|
||||
onValueChanged: (topic) {
|
||||
if (topic != null) _tabs.index = topic.index;
|
||||
},
|
||||
),
|
||||
)
|
||||
: TabBar(
|
||||
controller: _tabs,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
tabs: [
|
||||
for (final topic in SettingsTopic.values) Tab(text: topic.label),
|
||||
],
|
||||
);
|
||||
final body = SafeArea(
|
||||
final tabs = TabBar(
|
||||
controller: _tabs,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
tabs: [for (final topic in SettingsTopic.values) Tab(text: topic.label)],
|
||||
);
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -194,11 +166,5 @@ class _SettingsTopicTabsState extends State<SettingsTopicTabs>
|
||||
],
|
||||
),
|
||||
);
|
||||
return usesCupertinoControls(context)
|
||||
? ColoredBox(
|
||||
color: settingsCupertinoBackground.resolveFrom(context),
|
||||
child: body,
|
||||
)
|
||||
: body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'settings_keys.dart';
|
||||
import 'settings_row.dart';
|
||||
import 'settings_theme.dart';
|
||||
|
||||
/// The Settings entry to the Templates gallery.
|
||||
///
|
||||
@@ -23,11 +21,7 @@ class SettingsTemplatesSection extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsRow(
|
||||
key: SettingsKeys.templates,
|
||||
leading: Icon(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoIcons.square_grid_2x2
|
||||
: Icons.widgets_outlined,
|
||||
),
|
||||
leading: const Icon(Icons.widgets_outlined),
|
||||
title: const Text(settingsTemplatesLabel),
|
||||
subtitle: const Text(settingsTemplatesSecondary),
|
||||
chevron: true,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../terminal/terminal_layout.dart';
|
||||
@@ -16,41 +15,25 @@ class SettingsTerminalSection extends StatelessWidget {
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: layout,
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final Widget choice = cupertino
|
||||
? CupertinoSlidingSegmentedControl<TerminalMode>(
|
||||
groupValue: layout.mode,
|
||||
children: {
|
||||
for (final mode in TerminalMode.values)
|
||||
mode: Padding(
|
||||
key: ValueKey('settings-terminal-${mode.name}'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(mode.label),
|
||||
),
|
||||
},
|
||||
onValueChanged: (mode) {
|
||||
if (mode != null) layout.setMode(mode);
|
||||
},
|
||||
)
|
||||
: SegmentedButton<TerminalMode>(
|
||||
segments: [
|
||||
for (final mode in TerminalMode.values)
|
||||
ButtonSegment(
|
||||
value: mode,
|
||||
label: Text(
|
||||
mode.label,
|
||||
key: ValueKey('settings-terminal-${mode.name}'),
|
||||
),
|
||||
icon: Icon(
|
||||
mode == TerminalMode.panel
|
||||
? Icons.call_to_action_outlined
|
||||
: Icons.picture_in_picture_alt_outlined,
|
||||
),
|
||||
),
|
||||
],
|
||||
selected: {layout.mode},
|
||||
onSelectionChanged: (modes) => layout.setMode(modes.first),
|
||||
);
|
||||
final Widget choice = SegmentedButton<TerminalMode>(
|
||||
segments: [
|
||||
for (final mode in TerminalMode.values)
|
||||
ButtonSegment(
|
||||
value: mode,
|
||||
label: Text(
|
||||
mode.label,
|
||||
key: ValueKey('settings-terminal-${mode.name}'),
|
||||
),
|
||||
icon: Icon(
|
||||
mode == TerminalMode.panel
|
||||
? Icons.call_to_action_outlined
|
||||
: Icons.picture_in_picture_alt_outlined,
|
||||
),
|
||||
),
|
||||
],
|
||||
selected: {layout.mode},
|
||||
onSelectionChanged: (modes) => layout.setMode(modes.first),
|
||||
);
|
||||
return SettingsGroup(
|
||||
title: 'Terminal',
|
||||
footer: Column(
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/adaptive/host.dart';
|
||||
Color settingsErrorColor(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.error;
|
||||
|
||||
/// Cupertino only under an explicit Cupertino host; Material on every
|
||||
/// platform otherwise.
|
||||
bool usesCupertinoControls(BuildContext context) => usesCupertinoHost(context);
|
||||
|
||||
Color settingsErrorColor(BuildContext context) => usesCupertinoControls(context)
|
||||
? CupertinoColors.destructiveRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error;
|
||||
|
||||
/// Resolve native text roles from the actual host, not Material's fallback
|
||||
/// light theme when mounted under a dark CupertinoApp.
|
||||
/// Resolve the app's text roles from the Material theme.
|
||||
TextStyle settingsTextStyle(
|
||||
BuildContext context, {
|
||||
bool title = false,
|
||||
bool secondary = false,
|
||||
bool error = false,
|
||||
}) {
|
||||
if (usesCupertinoControls(context)) {
|
||||
final text = CupertinoTheme.of(context).textTheme;
|
||||
return (title ? text.navTitleTextStyle : text.textStyle).copyWith(
|
||||
color: error
|
||||
? settingsErrorColor(context)
|
||||
: (secondary ? CupertinoColors.secondaryLabel : CupertinoColors.label)
|
||||
.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
final base = (title
|
||||
? theme.textTheme.titleMedium
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'settings_copy.dart';
|
||||
@@ -13,14 +12,15 @@ class SettingsTrustWarning extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final icon = usesCupertinoControls(context)
|
||||
? CupertinoIcons.exclamationmark_triangle
|
||||
: Icons.warning_amber_rounded;
|
||||
final error = settingsErrorColor(context);
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Icon(icon, color: error, semanticLabel: 'Warning'),
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
color: error,
|
||||
semanticLabel: 'Warning',
|
||||
),
|
||||
const SizedBox(width: settingsControlGap),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import '../updates/app_updates.dart';
|
||||
import 'server_connections.dart';
|
||||
|
||||
@@ -108,31 +106,14 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
Widget button(
|
||||
Key key,
|
||||
String label,
|
||||
VoidCallback? onPressed,
|
||||
bool primary,
|
||||
) => cupertino
|
||||
? (primary
|
||||
? CupertinoButton.filled(
|
||||
key: key,
|
||||
onPressed: onPressed,
|
||||
child: Text(label),
|
||||
)
|
||||
: CupertinoButton(
|
||||
key: key,
|
||||
onPressed: onPressed,
|
||||
child: Text(label),
|
||||
))
|
||||
: (primary
|
||||
? FilledButton(key: key, onPressed: onPressed, child: Text(label))
|
||||
: OutlinedButton(
|
||||
key: key,
|
||||
onPressed: onPressed,
|
||||
child: Text(label),
|
||||
));
|
||||
) => primary
|
||||
? FilledButton(key: key, onPressed: onPressed, child: Text(label))
|
||||
: OutlinedButton(key: key, onPressed: onPressed, child: Text(label));
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -166,11 +147,7 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
|
||||
if (_progress != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: cupertino
|
||||
? CupertinoActivityIndicator.partiallyRevealed(
|
||||
progress: _progress!,
|
||||
)
|
||||
: LinearProgressIndicator(value: _progress),
|
||||
child: LinearProgressIndicator(value: _progress),
|
||||
),
|
||||
if (_message != null)
|
||||
Padding(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -12,11 +11,6 @@ Widget _host(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
Widget _cupertinoHost(Widget child) => CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: child),
|
||||
);
|
||||
|
||||
JsonMap _usageFrame(JsonMap usage) => {
|
||||
'session_id': 's',
|
||||
'kind': 'usage',
|
||||
@@ -49,10 +43,7 @@ JsonMap _claudeAccount(DateTime now) => {
|
||||
],
|
||||
};
|
||||
|
||||
Future<FakeChatGateway> _thread(
|
||||
WidgetTester tester, {
|
||||
bool cupertino = false,
|
||||
}) async {
|
||||
Future<FakeChatGateway> _thread(WidgetTester tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => chatPage([]);
|
||||
@@ -61,7 +52,7 @@ Future<FakeChatGateway> _thread(
|
||||
sessionId: 's',
|
||||
onBack: () {},
|
||||
);
|
||||
await tester.pumpWidget(cupertino ? _cupertinoHost(thread) : _host(thread));
|
||||
await tester.pumpWidget(_host(thread));
|
||||
await tester.pumpAndSettle();
|
||||
return gateway;
|
||||
}
|
||||
@@ -141,69 +132,62 @@ void main() {
|
||||
});
|
||||
|
||||
// Chat details is Material only (a dialog, or a sheet on a phone).
|
||||
for (final cupertino in [false]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: account usage shows windows, plan and age', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = await _thread(tester, cupertino: cupertino);
|
||||
gateway.emitEvent(
|
||||
_usageFrame({
|
||||
'scope': 'session',
|
||||
'total_tokens': 1200,
|
||||
'account': _claudeAccount(DateTime.now()),
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await _openInfo(tester);
|
||||
|
||||
expect(find.text('Account usage'), findsOneWidget);
|
||||
expect(find.text('Claude Code · Max plan'), findsOneWidget);
|
||||
expect(find.text('5-hour'), findsOneWidget);
|
||||
expect(find.text('42% used · resets in 2h 14m'), findsOneWidget);
|
||||
expect(find.text('Weekly'), findsOneWidget);
|
||||
expect(find.text('93% used · resets in 3d 5h'), findsOneWidget);
|
||||
expect(find.text('as of just now'), findsOneWidget);
|
||||
final bars = tester
|
||||
.widgetList<LinearProgressIndicator>(
|
||||
find.byType(LinearProgressIndicator),
|
||||
)
|
||||
.toList();
|
||||
expect(bars.map((bar) => bar.value), [
|
||||
closeTo(.42, 1e-9),
|
||||
closeTo(.934, 1e-9),
|
||||
]);
|
||||
expect(bars.first.semanticsLabel, '5-hour quota');
|
||||
// Token metrics are still shown beside the quota.
|
||||
expect(find.text('1,200'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'$host: unknown quota hides the section; no-API harness says so',
|
||||
(tester) async {
|
||||
final gateway = await _thread(tester, cupertino: cupertino);
|
||||
gateway.emitEvent(_usageFrame({'scope': 'session', 'total_tokens': 5}));
|
||||
await tester.pump();
|
||||
await _openInfo(tester);
|
||||
expect(find.byKey(const Key('chat-account-usage')), findsNothing);
|
||||
expect(find.text('Account usage'), findsNothing);
|
||||
expect(find.byType(LinearProgressIndicator), findsNothing);
|
||||
|
||||
gateway.emitEvent(
|
||||
_usageFrame({
|
||||
'scope': 'session',
|
||||
'total_tokens': 6,
|
||||
'account': {'harness': 'OpenCode', 'unsupported': true},
|
||||
}),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Account usage'), findsOneWidget);
|
||||
expect(find.text('Not reported by OpenCode'), findsOneWidget);
|
||||
expect(find.byType(LinearProgressIndicator), findsNothing);
|
||||
},
|
||||
testWidgets('account usage shows windows, plan and age', (tester) async {
|
||||
final gateway = await _thread(tester);
|
||||
gateway.emitEvent(
|
||||
_usageFrame({
|
||||
'scope': 'session',
|
||||
'total_tokens': 1200,
|
||||
'account': _claudeAccount(DateTime.now()),
|
||||
}),
|
||||
);
|
||||
}
|
||||
await tester.pump();
|
||||
await _openInfo(tester);
|
||||
|
||||
expect(find.text('Account usage'), findsOneWidget);
|
||||
expect(find.text('Claude Code · Max plan'), findsOneWidget);
|
||||
expect(find.text('5-hour'), findsOneWidget);
|
||||
expect(find.text('42% used · resets in 2h 14m'), findsOneWidget);
|
||||
expect(find.text('Weekly'), findsOneWidget);
|
||||
expect(find.text('93% used · resets in 3d 5h'), findsOneWidget);
|
||||
expect(find.text('as of just now'), findsOneWidget);
|
||||
final bars = tester
|
||||
.widgetList<LinearProgressIndicator>(
|
||||
find.byType(LinearProgressIndicator),
|
||||
)
|
||||
.toList();
|
||||
expect(bars.map((bar) => bar.value), [
|
||||
closeTo(.42, 1e-9),
|
||||
closeTo(.934, 1e-9),
|
||||
]);
|
||||
expect(bars.first.semanticsLabel, '5-hour quota');
|
||||
// Token metrics are still shown beside the quota.
|
||||
expect(find.text('1,200'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('unknown quota hides the section; no-API harness says so', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = await _thread(tester);
|
||||
gateway.emitEvent(_usageFrame({'scope': 'session', 'total_tokens': 5}));
|
||||
await tester.pump();
|
||||
await _openInfo(tester);
|
||||
expect(find.byKey(const Key('chat-account-usage')), findsNothing);
|
||||
expect(find.text('Account usage'), findsNothing);
|
||||
expect(find.byType(LinearProgressIndicator), findsNothing);
|
||||
|
||||
gateway.emitEvent(
|
||||
_usageFrame({
|
||||
'scope': 'session',
|
||||
'total_tokens': 6,
|
||||
'account': {'harness': 'OpenCode', 'unsupported': true},
|
||||
}),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Account usage'), findsOneWidget);
|
||||
expect(find.text('Not reported by OpenCode'), findsOneWidget);
|
||||
expect(find.byType(LinearProgressIndicator), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('an account-only frame keeps the recorded token metrics', (
|
||||
tester,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_background_tasks_controller.dart';
|
||||
@@ -8,85 +7,75 @@ import 'package:pipelines_app/features/chat/conversation/chat_task_metadata_view
|
||||
import 'chat_background_tasks_fixtures.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'recorded facts wrap at 2x, tick without requests, dispose clock ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
var now = DateTime.utc(2026, 11, 6, 10);
|
||||
var clockReads = 0;
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [
|
||||
{
|
||||
'id': 'a',
|
||||
'status': 'running',
|
||||
'command': 'Review integration changes',
|
||||
'started_at': now
|
||||
.subtract(const Duration(minutes: 2))
|
||||
.millisecondsSinceEpoch,
|
||||
'progress':
|
||||
'Checking the targeted tests and reviewing the remaining findings',
|
||||
'tool_count': 18,
|
||||
'token_count': 12450,
|
||||
},
|
||||
],
|
||||
};
|
||||
final controller = ChatBackgroundTasksController(gateway, 's');
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(gateway.close);
|
||||
final panel = ChatBackgroundTasksPanel(
|
||||
controller: controller,
|
||||
clock: () {
|
||||
clockReads++;
|
||||
return now;
|
||||
testWidgets('recorded facts wrap at 2x, tick without requests, dispose clock', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
var now = DateTime.utc(2026, 11, 6, 10);
|
||||
var clockReads = 0;
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [
|
||||
{
|
||||
'id': 'a',
|
||||
'status': 'running',
|
||||
'command': 'Review integration changes',
|
||||
'started_at': now
|
||||
.subtract(const Duration(minutes: 2))
|
||||
.millisecondsSinceEpoch,
|
||||
'progress':
|
||||
'Checking the targeted tests and reviewing the remaining findings',
|
||||
'tool_count': 18,
|
||||
'token_count': 12450,
|
||||
},
|
||||
);
|
||||
Widget builder(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: builder,
|
||||
home: CupertinoPageScaffold(
|
||||
child: SingleChildScrollView(child: panel),
|
||||
),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: builder,
|
||||
home: Scaffold(body: SingleChildScrollView(child: panel)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2m 0s'), findsOneWidget);
|
||||
expect(find.text('18'), findsOneWidget);
|
||||
expect(find.text('12,450'), findsOneWidget);
|
||||
expect(find.textContaining('6 November 2026'), findsOneWidget);
|
||||
final requests = gateway.calls.length;
|
||||
now = now.add(const Duration(seconds: 11));
|
||||
await tester.pump(const Duration(seconds: 11));
|
||||
expect(find.text('2m 11s'), findsOneWidget);
|
||||
expect(gateway.calls.length, requests);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
isEmpty,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
final stoppedAt = clockReads;
|
||||
await tester.pump(const Duration(seconds: 11));
|
||||
expect(clockReads, stoppedAt);
|
||||
expect(tester.takeException(), isNull);
|
||||
],
|
||||
};
|
||||
final controller = ChatBackgroundTasksController(gateway, 's');
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(gateway.close);
|
||||
final panel = ChatBackgroundTasksPanel(
|
||||
controller: controller,
|
||||
clock: () {
|
||||
clockReads++;
|
||||
return now;
|
||||
},
|
||||
);
|
||||
}
|
||||
Widget builder(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: builder,
|
||||
home: Scaffold(body: SingleChildScrollView(child: panel)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2m 0s'), findsOneWidget);
|
||||
expect(find.text('18'), findsOneWidget);
|
||||
expect(find.text('12,450'), findsOneWidget);
|
||||
expect(find.textContaining('6 November 2026'), findsOneWidget);
|
||||
final requests = gateway.calls.length;
|
||||
now = now.add(const Duration(seconds: 11));
|
||||
await tester.pump(const Duration(seconds: 11));
|
||||
expect(find.text('2m 11s'), findsOneWidget);
|
||||
expect(gateway.calls.length, requests);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
isEmpty,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
final stoppedAt = clockReads;
|
||||
await tester.pump(const Duration(seconds: 11));
|
||||
expect(clockReads, stoppedAt);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'selected detail keeps full metadata and requests only its output',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_background_task_card.dart';
|
||||
@@ -36,74 +35,68 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'one task has GUI hierarchy, no duplicate path, explicit lazy details ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(560, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final now = DateTime.utc(2026, 11, 6, 23, 44, 40);
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [
|
||||
{
|
||||
'id': 'example',
|
||||
'status': 'running',
|
||||
'task_type': 'local_agent',
|
||||
'command': example,
|
||||
'description': example,
|
||||
'progress': example,
|
||||
'started_at': now
|
||||
.subtract(const Duration(minutes: 4, seconds: 40))
|
||||
.millisecondsSinceEpoch,
|
||||
'tool_count': 37,
|
||||
'token_count': 120905,
|
||||
},
|
||||
],
|
||||
};
|
||||
final controller = ChatBackgroundTasksController(gateway, 's');
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(gateway.close);
|
||||
final panel = SingleChildScrollView(
|
||||
child: ChatBackgroundTasksPanel(
|
||||
controller: controller,
|
||||
clock: () => now,
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: panel))
|
||||
: MaterialApp(home: Scaffold(body: panel)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(ChatBackgroundTaskCard), findsOneWidget);
|
||||
expect(find.byType(ChatTaskSurface), findsOneWidget);
|
||||
expect(find.text(example), findsOneWidget);
|
||||
expect(find.text('4m 40s'), findsOneWidget);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(find.text('120,905'), findsOneWidget);
|
||||
expect(find.text('Tokens'), findsOneWidget);
|
||||
expect(find.text('37'), findsOneWidget);
|
||||
expect(find.text('Tool calls'), findsOneWidget);
|
||||
expect(find.text('Details'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
isEmpty,
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('chat-bg-task-example')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(example), findsOneWidget);
|
||||
expect(find.text('Hide details'), findsOneWidget);
|
||||
expect(find.text('Output'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
hasLength(1),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
testWidgets(
|
||||
'one task has GUI hierarchy, no duplicate path, explicit lazy details',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(560, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final now = DateTime.utc(2026, 11, 6, 23, 44, 40);
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [
|
||||
{
|
||||
'id': 'example',
|
||||
'status': 'running',
|
||||
'task_type': 'local_agent',
|
||||
'command': example,
|
||||
'description': example,
|
||||
'progress': example,
|
||||
'started_at': now
|
||||
.subtract(const Duration(minutes: 4, seconds: 40))
|
||||
.millisecondsSinceEpoch,
|
||||
'tool_count': 37,
|
||||
'token_count': 120905,
|
||||
},
|
||||
],
|
||||
};
|
||||
final controller = ChatBackgroundTasksController(gateway, 's');
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(gateway.close);
|
||||
final panel = SingleChildScrollView(
|
||||
child: ChatBackgroundTasksPanel(
|
||||
controller: controller,
|
||||
clock: () => now,
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: panel)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(ChatBackgroundTaskCard), findsOneWidget);
|
||||
expect(find.byType(ChatTaskSurface), findsOneWidget);
|
||||
expect(find.text(example), findsOneWidget);
|
||||
expect(find.text('4m 40s'), findsOneWidget);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(find.text('120,905'), findsOneWidget);
|
||||
expect(find.text('Tokens'), findsOneWidget);
|
||||
expect(find.text('37'), findsOneWidget);
|
||||
expect(find.text('Tool calls'), findsOneWidget);
|
||||
expect(find.text('Details'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
isEmpty,
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('chat-bg-task-example')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(example), findsOneWidget);
|
||||
expect(find.text('Hide details'), findsOneWidget);
|
||||
expect(find.text('Output'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
hasLength(1),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -8,15 +7,9 @@ import 'package:pipelines_app/features/chat/conversation/chat_background_tasks.d
|
||||
|
||||
import 'chat_background_tasks_fixtures.dart';
|
||||
|
||||
Widget host(
|
||||
TasksGateway gateway, {
|
||||
bool cupertino = false,
|
||||
String session = 's',
|
||||
}) {
|
||||
Widget host(TasksGateway gateway, {String session = 's'}) {
|
||||
final button = ChatBackgroundTasks(gateway: gateway, sessionId: session);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: button))
|
||||
: MaterialApp(home: Scaffold(body: button));
|
||||
return MaterialApp(home: Scaffold(body: button));
|
||||
}
|
||||
|
||||
Future<void> open(WidgetTester tester) async {
|
||||
@@ -25,86 +18,75 @@ Future<void> open(WidgetTester tester) async {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'count updates live, no eager output, Back/Done only close modal ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [task('a')],
|
||||
};
|
||||
addTearDown(gateway.close);
|
||||
await tester.pumpWidget(host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('1 task'), findsOneWidget);
|
||||
expect(find.text('command a'), findsNothing);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
isEmpty,
|
||||
);
|
||||
await open(tester);
|
||||
expect(find.text('command a'), findsOneWidget);
|
||||
gateway.shell('b', 'running');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2 running'), findsOneWidget);
|
||||
expect(find.text('command b'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byKey(const Key('chat-background-tasks-modal')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('2 tasks'), findsOneWidget);
|
||||
await open(tester);
|
||||
await tester.tap(find.text('Done'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2 tasks'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shells'),
|
||||
hasLength(1),
|
||||
);
|
||||
},
|
||||
);
|
||||
testWidgets(
|
||||
'count updates live, no eager output, Back/Done only close modal',
|
||||
(tester) async {
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [task('a')],
|
||||
};
|
||||
addTearDown(gateway.close);
|
||||
await tester.pumpWidget(host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('1 task'), findsOneWidget);
|
||||
expect(find.text('command a'), findsNothing);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shell_output'),
|
||||
isEmpty,
|
||||
);
|
||||
await open(tester);
|
||||
expect(find.text('command a'), findsOneWidget);
|
||||
gateway.shell('b', 'running');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2 running'), findsOneWidget);
|
||||
expect(find.text('command b'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byKey(const Key('chat-background-tasks-modal')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('2 tasks'), findsOneWidget);
|
||||
await open(tester);
|
||||
await tester.tap(find.text('Done'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2 tasks'), findsOneWidget);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type == 'chat_shells'),
|
||||
hasLength(1),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'session switch closes its own modal and drops late output ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [task('a')],
|
||||
};
|
||||
final page = Completer<JsonMap>();
|
||||
gateway.output = (_) => page.future;
|
||||
addTearDown(gateway.close);
|
||||
await tester.pumpWidget(host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
await open(tester);
|
||||
await tester.tap(find.byKey(const ValueKey('chat-bg-task-a')));
|
||||
await tester.pump();
|
||||
gateway.shells = (_) async => {'chat_shells': []};
|
||||
await tester.pumpWidget(
|
||||
host(gateway, cupertino: cupertino, session: 'other'),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
page.complete({
|
||||
'chat_shell_output': {'output': 'old session output'},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byKey(const Key('chat-background-tasks-modal')),
|
||||
findsNothing,
|
||||
);
|
||||
// The other session runs nothing: no control, never a "0 tasks".
|
||||
expect(find.text('0 tasks'), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('chat-background-tasks-button')),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('old session output'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
testWidgets('session switch closes its own modal and drops late output', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = TasksGateway()
|
||||
..shells = (_) async => {
|
||||
'chat_shells': [task('a')],
|
||||
};
|
||||
final page = Completer<JsonMap>();
|
||||
gateway.output = (_) => page.future;
|
||||
addTearDown(gateway.close);
|
||||
await tester.pumpWidget(host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
await open(tester);
|
||||
await tester.tap(find.byKey(const ValueKey('chat-bg-task-a')));
|
||||
await tester.pump();
|
||||
gateway.shells = (_) async => {'chat_shells': []};
|
||||
await tester.pumpWidget(host(gateway, session: 'other'));
|
||||
await tester.pumpAndSettle();
|
||||
page.complete({
|
||||
'chat_shell_output': {'output': 'old session output'},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('chat-background-tasks-modal')), findsNothing);
|
||||
// The other session runs nothing: no control, never a "0 tasks".
|
||||
expect(find.text('0 tasks'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-background-tasks-button')), findsNothing);
|
||||
expect(find.text('old session output'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'owner disposal removes only its modal, not an unrelated top route',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -88,21 +87,12 @@ List<String> _pageLines() => [
|
||||
for (var index = 0; index < 200; index++) 'line $index',
|
||||
];
|
||||
|
||||
Widget _host(
|
||||
_TasksGateway gateway, {
|
||||
bool cupertino = false,
|
||||
int syncToken = 0,
|
||||
}) {
|
||||
Widget _host(_TasksGateway gateway, {int syncToken = 0}) {
|
||||
final child = ChatBackgroundTasks(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
syncToken: syncToken,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SingleChildScrollView(child: child)),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: Scaffold(body: SingleChildScrollView(child: child)),
|
||||
@@ -431,37 +421,6 @@ void main() {
|
||||
expect(gateway.fieldsFor('chat_shells'), hasLength(2));
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino host keeps native buttons and the same facts', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _TasksGateway();
|
||||
gateway.shells = () async => _snapshot([_running('sh1')]);
|
||||
gateway.output = (_) async => {
|
||||
'chat_shell_output': {
|
||||
'shell': _running('sh1'),
|
||||
'output': 'native output',
|
||||
},
|
||||
};
|
||||
addTearDown(gateway.close);
|
||||
|
||||
await tester.pumpWidget(_host(gateway, cupertino: true));
|
||||
await tester.pumpAndSettle();
|
||||
await _openTasks(tester);
|
||||
|
||||
expect(find.byType(CupertinoButton), findsWidgets);
|
||||
expect(find.text('1 running'), findsOneWidget);
|
||||
await _tapTask(tester, 'sh1');
|
||||
|
||||
expect(find.text('Command'), findsNothing);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<SelectableText>(find.byKey(const Key('chat-bg-task-output')))
|
||||
.data,
|
||||
'native output',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('a long output page scrolls inside a bounded pane', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -598,37 +557,6 @@ void main() {
|
||||
expect(composer.bottom, lessThanOrEqualTo(568));
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino row elides its labels instead of overflowing', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 568);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
|
||||
final gateway = _TasksGateway();
|
||||
gateway.shells = () async => _snapshot([
|
||||
_running('sh1', command: 'go test ./... -run TestSomethingLongEnough'),
|
||||
]);
|
||||
gateway.output = (_) async => {
|
||||
'chat_shell_output': {
|
||||
'shell': _running('sh1'),
|
||||
'output': 'native output',
|
||||
},
|
||||
};
|
||||
addTearDown(gateway.close);
|
||||
|
||||
await tester.pumpWidget(_host(gateway, cupertino: true));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await _tapTask(tester, 'sh1');
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('Task identity'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the conversation mounts only the live task badge', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_bar_tint.dart';
|
||||
@@ -25,25 +24,19 @@ double _ratio(Color a, Color b) {
|
||||
/// The colours one host draws a chat's bar and composer with.
|
||||
typedef _Host = ({Color page, Color raised, Color shade});
|
||||
|
||||
/// Every palette colour's shade on one host and brightness, read through
|
||||
/// Every palette colour's shade on one brightness, read through
|
||||
/// the app's own [chatColorShade] under the app's theme.
|
||||
Future<Map<String, _Host>> _hostColours(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
required bool dark,
|
||||
}) async {
|
||||
final result = <String, _Host>{};
|
||||
final brightness = dark ? Brightness.dark : Brightness.light;
|
||||
Widget probe() => Builder(
|
||||
builder: (context) {
|
||||
for (final name in chatColorNames) {
|
||||
result[name] = (
|
||||
page: cupertino
|
||||
? AppColors.background.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
raised: cupertino
|
||||
? CupertinoColors.systemGrey5.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
page: Theme.of(context).colorScheme.surface,
|
||||
raised: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
shade: chatColorShade(context, name)!,
|
||||
);
|
||||
}
|
||||
@@ -51,91 +44,76 @@ Future<Map<String, _Host>> _hostColours(
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
theme: appCupertinoTheme.copyWith(brightness: brightness),
|
||||
home: probe(),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: dark ? appDarkTheme() : appLightTheme(),
|
||||
home: probe(),
|
||||
),
|
||||
MaterialApp(theme: dark ? appDarkTheme() : appLightTheme(), home: probe()),
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
void main() {
|
||||
final rows = <String>['host\ttheme\tcolour\tmeasure\tratio\tminimum'];
|
||||
final rows = <String>['theme\tcolour\tmeasure\tratio\tminimum'];
|
||||
|
||||
tearDownAll(() {
|
||||
final out = Platform.environment['CHAT_BAR_CONTRAST_OUT'];
|
||||
if (out != null) File(out).writeAsStringSync('${rows.join('\n')}\n');
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final dark in [false, true]) {
|
||||
final host = cupertino ? 'cupertino' : 'material';
|
||||
final theme = dark ? 'dark' : 'light';
|
||||
testWidgets('$host $theme: every chat colour meets AA in the bar and '
|
||||
'the focus ring', (tester) async {
|
||||
final colours = await _hostColours(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
dark: dark,
|
||||
for (final dark in [false, true]) {
|
||||
final theme = dark ? 'dark' : 'light';
|
||||
testWidgets('$theme: every chat colour meets AA in the bar and '
|
||||
'the focus ring', (tester) async {
|
||||
final colours = await _hostColours(tester, dark: dark);
|
||||
expect(colours.keys, chatColorNames);
|
||||
void check(String name, String what, double ratio, double minimum) {
|
||||
rows.add(
|
||||
'$theme\t$name\t$what\t'
|
||||
'${ratio.toStringAsFixed(2)}\t$minimum',
|
||||
);
|
||||
expect(colours.keys, chatColorNames);
|
||||
void check(String name, String what, double ratio, double minimum) {
|
||||
rows.add(
|
||||
'$host\t$theme\t$name\t$what\t'
|
||||
'${ratio.toStringAsFixed(2)}\t$minimum',
|
||||
);
|
||||
expect(
|
||||
ratio,
|
||||
greaterThanOrEqualTo(minimum),
|
||||
reason: '$host $theme $name: $what',
|
||||
);
|
||||
}
|
||||
expect(
|
||||
ratio,
|
||||
greaterThanOrEqualTo(minimum),
|
||||
reason: '$theme $name: $what',
|
||||
);
|
||||
}
|
||||
|
||||
for (final MapEntry(key: name, value: c) in colours.entries) {
|
||||
for (final inactive in [false, true]) {
|
||||
final tint = ChatBarTint.from(
|
||||
shade: c.shade,
|
||||
raised: c.raised,
|
||||
dark: dark,
|
||||
inactive: inactive,
|
||||
);
|
||||
// The glass lies over the bar's scrim, the page's colour.
|
||||
final pill = Color.alphaBlend(tint.fill, c.page);
|
||||
check(
|
||||
name,
|
||||
inactive ? 'inactive bar label' : 'bar label',
|
||||
_ratio(tint.foreground, pill),
|
||||
4.5,
|
||||
);
|
||||
// Solid under the system's high-contrast setting.
|
||||
final solid = ChatBarTint.from(
|
||||
shade: c.shade,
|
||||
raised: c.raised,
|
||||
dark: dark,
|
||||
inactive: inactive,
|
||||
solid: true,
|
||||
);
|
||||
check(
|
||||
name,
|
||||
inactive ? 'inactive solid bar label' : 'solid bar label',
|
||||
_ratio(solid.foreground, solid.fill),
|
||||
4.5,
|
||||
);
|
||||
}
|
||||
final ring = chatSeededScheme(c.shade, dark: dark).primary;
|
||||
check(name, 'focus ring vs page', _ratio(ring, c.page), 3);
|
||||
final composer = Color.alphaBlend(
|
||||
c.raised.withValues(alpha: GlassPill.fillOpacity),
|
||||
c.page,
|
||||
for (final MapEntry(key: name, value: c) in colours.entries) {
|
||||
for (final inactive in [false, true]) {
|
||||
final tint = ChatBarTint.from(
|
||||
shade: c.shade,
|
||||
raised: c.raised,
|
||||
dark: dark,
|
||||
inactive: inactive,
|
||||
);
|
||||
// The glass lies over the bar's scrim, the page's colour.
|
||||
final pill = Color.alphaBlend(tint.fill, c.page);
|
||||
check(
|
||||
name,
|
||||
inactive ? 'inactive bar label' : 'bar label',
|
||||
_ratio(tint.foreground, pill),
|
||||
4.5,
|
||||
);
|
||||
// Solid under the system's high-contrast setting.
|
||||
final solid = ChatBarTint.from(
|
||||
shade: c.shade,
|
||||
raised: c.raised,
|
||||
dark: dark,
|
||||
inactive: inactive,
|
||||
solid: true,
|
||||
);
|
||||
check(
|
||||
name,
|
||||
inactive ? 'inactive solid bar label' : 'solid bar label',
|
||||
_ratio(solid.foreground, solid.fill),
|
||||
4.5,
|
||||
);
|
||||
check(name, 'focus ring vs composer', _ratio(ring, composer), 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
final ring = chatSeededScheme(c.shade, dark: dark).primary;
|
||||
check(name, 'focus ring vs page', _ratio(ring, c.page), 3);
|
||||
final composer = Color.alphaBlend(
|
||||
c.raised.withValues(alpha: GlassPill.fillOpacity),
|
||||
c.page,
|
||||
);
|
||||
check(name, 'focus ring vs composer', _ratio(ring, composer), 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
/// A header in the app's theme, with one model-style control, Files, and an
|
||||
/// optional split-pane activity around it.
|
||||
Widget _header({
|
||||
required bool cupertino,
|
||||
String? color,
|
||||
Brightness brightness = Brightness.light,
|
||||
bool? inactive,
|
||||
@@ -27,16 +26,11 @@ Widget _header({
|
||||
chatColor: color,
|
||||
controls: [
|
||||
Builder(
|
||||
builder: (context) => cupertino
|
||||
? CupertinoButton(
|
||||
onPressed: () {},
|
||||
child: chatBarCupertinoContent(context, const Text('Model')),
|
||||
)
|
||||
: TextButton(
|
||||
style: chatBarTextButtonStyle(context),
|
||||
onPressed: () {},
|
||||
child: const Text('Model'),
|
||||
),
|
||||
builder: (context) => TextButton(
|
||||
style: chatBarTextButtonStyle(context),
|
||||
onPressed: () {},
|
||||
child: const Text('Model'),
|
||||
),
|
||||
),
|
||||
],
|
||||
actions: [
|
||||
@@ -55,22 +49,14 @@ Widget _header({
|
||||
alignment: Alignment.topCenter,
|
||||
child: SizedBox(width: 900, height: 120, child: header),
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoApp(
|
||||
theme: appCupertinoTheme.copyWith(brightness: brightness),
|
||||
home: CupertinoPageScaffold(child: body),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: brightness == Brightness.dark
|
||||
? appDarkTheme()
|
||||
: appLightTheme(),
|
||||
home: Scaffold(body: body),
|
||||
);
|
||||
return MaterialApp(
|
||||
theme: brightness == Brightness.dark ? appDarkTheme() : appLightTheme(),
|
||||
home: Scaffold(body: body),
|
||||
);
|
||||
}
|
||||
|
||||
Future<BuildContext> _pump(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
String? color,
|
||||
Brightness brightness = Brightness.light,
|
||||
bool? inactive,
|
||||
@@ -80,12 +66,7 @@ Future<BuildContext> _pump(
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
_header(
|
||||
cupertino: cupertino,
|
||||
color: color,
|
||||
brightness: brightness,
|
||||
inactive: inactive,
|
||||
),
|
||||
_header(color: color, brightness: brightness, inactive: inactive),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
return tester.element(find.byType(ChatThreadHeader));
|
||||
@@ -113,113 +94,91 @@ final _files = find.byType(ChatBarAction);
|
||||
final _back = find.byKey(const Key('chat-back'));
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: a chat with no colour keeps the neutral bar', (
|
||||
tester,
|
||||
) async {
|
||||
final context = await _pump(tester, cupertino: cupertino);
|
||||
expect(find.byKey(const Key('chat-bar-tint')), findsNothing);
|
||||
expect(find.byType(ChatBarTintScope), findsNothing);
|
||||
expect(_titleFill(tester), isNull);
|
||||
for (final pill in tester.widgetList<GlassPill>(find.byType(GlassPill))) {
|
||||
expect(pill.fill, isNull);
|
||||
}
|
||||
final neutral = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
expect(_textColor(tester, 'Model'), isSameColorAs(neutral));
|
||||
});
|
||||
|
||||
for (final brightness in Brightness.values) {
|
||||
testWidgets('$host ${brightness.name}: a coloured chat tints every '
|
||||
'glass piece and takes its foreground', (tester) async {
|
||||
final context = await _pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
color: 'teal',
|
||||
brightness: brightness,
|
||||
);
|
||||
final dark = brightness == Brightness.dark;
|
||||
final shade = chatColorShade(context, 'teal')!;
|
||||
final raised = cupertino
|
||||
? CupertinoColors.systemGrey5.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||
final expected = ChatBarTint.from(
|
||||
shade: shade,
|
||||
raised: raised,
|
||||
dark: dark,
|
||||
);
|
||||
expect(expected.fill.a, closeTo(GlassPill.fillOpacity, 1e-6));
|
||||
expect(
|
||||
expected.fill.withValues(alpha: 1),
|
||||
Color.alphaBlend(
|
||||
shade.withValues(alpha: dark ? chatBarTintDark : chatBarTintLight),
|
||||
raised,
|
||||
),
|
||||
);
|
||||
expect(
|
||||
expected.foreground,
|
||||
chatSeededScheme(shade, dark: dark).onPrimaryContainer,
|
||||
);
|
||||
expect(find.byKey(const Key('chat-bar-tint')), findsOneWidget);
|
||||
// Back, title, the control island and the Files island.
|
||||
final pills = tester.widgetList<GlassPill>(find.byType(GlassPill));
|
||||
expect(pills.length, greaterThanOrEqualTo(4));
|
||||
for (final pill in pills) {
|
||||
expect(pill.fill, expected.fill);
|
||||
}
|
||||
expect(_titleFill(tester), expected.fill);
|
||||
expect(_textColor(tester, 'Colour chat'), expected.foreground);
|
||||
expect(_textColor(tester, 'Model'), expected.foreground);
|
||||
expect(_iconIn(tester, _files), expected.foreground);
|
||||
});
|
||||
testWidgets('a chat with no colour keeps the neutral bar', (tester) async {
|
||||
final context = await _pump(tester);
|
||||
expect(find.byKey(const Key('chat-bar-tint')), findsNothing);
|
||||
expect(find.byType(ChatBarTintScope), findsNothing);
|
||||
expect(_titleFill(tester), isNull);
|
||||
for (final pill in tester.widgetList<GlassPill>(find.byType(GlassPill))) {
|
||||
expect(pill.fill, isNull);
|
||||
}
|
||||
final neutral = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
expect(_textColor(tester, 'Model'), isSameColorAs(neutral));
|
||||
});
|
||||
|
||||
testWidgets('$host: an inactive split pane fades its bar tint to half', (
|
||||
tester,
|
||||
) async {
|
||||
for (final brightness in Brightness.values) {
|
||||
testWidgets('${brightness.name}: a coloured chat tints every '
|
||||
'glass piece and takes its foreground', (tester) async {
|
||||
final context = await _pump(
|
||||
tester,
|
||||
cupertino: cupertino,
|
||||
color: 'orange',
|
||||
inactive: true,
|
||||
color: 'teal',
|
||||
brightness: brightness,
|
||||
);
|
||||
final shade = chatColorShade(context, 'orange')!;
|
||||
final raised = cupertino
|
||||
? CupertinoColors.systemGrey5.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||
final faded = ChatBarTint.from(
|
||||
final dark = brightness == Brightness.dark;
|
||||
final shade = chatColorShade(context, 'teal')!;
|
||||
final raised = Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||
final expected = ChatBarTint.from(
|
||||
shade: shade,
|
||||
raised: raised,
|
||||
dark: false,
|
||||
inactive: true,
|
||||
dark: dark,
|
||||
);
|
||||
expect(expected.fill.a, closeTo(GlassPill.fillOpacity, 1e-6));
|
||||
expect(
|
||||
faded.fill.withValues(alpha: 1),
|
||||
expected.fill.withValues(alpha: 1),
|
||||
Color.alphaBlend(
|
||||
shade.withValues(alpha: chatBarTintLight * chatBarInactiveFade),
|
||||
shade.withValues(alpha: dark ? chatBarTintDark : chatBarTintLight),
|
||||
raised,
|
||||
),
|
||||
);
|
||||
expect(_titleFill(tester), faded.fill);
|
||||
|
||||
// The same pane turning active takes the full tint.
|
||||
await tester.pumpWidget(
|
||||
_header(cupertino: cupertino, color: 'orange', inactive: false),
|
||||
expect(
|
||||
expected.foreground,
|
||||
chatSeededScheme(shade, dark: dark).onPrimaryContainer,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final full = ChatBarTint.from(shade: shade, raised: raised, dark: false);
|
||||
expect(_titleFill(tester), full.fill);
|
||||
expect(full.fill, isNot(faded.fill));
|
||||
expect(find.byKey(const Key('chat-bar-tint')), findsOneWidget);
|
||||
// Back, title, the control island and the Files island.
|
||||
final pills = tester.widgetList<GlassPill>(find.byType(GlassPill));
|
||||
expect(pills.length, greaterThanOrEqualTo(4));
|
||||
for (final pill in pills) {
|
||||
expect(pill.fill, expected.fill);
|
||||
}
|
||||
expect(_titleFill(tester), expected.fill);
|
||||
expect(_textColor(tester, 'Colour chat'), expected.foreground);
|
||||
expect(_textColor(tester, 'Model'), expected.foreground);
|
||||
expect(_iconIn(tester, _files), expected.foreground);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('Material: bar icons take the seeded onPrimaryContainer', (
|
||||
testWidgets('an inactive split pane fades its bar tint to half', (
|
||||
tester,
|
||||
) async {
|
||||
final context = await _pump(tester, cupertino: false, color: 'purple');
|
||||
final context = await _pump(tester, color: 'orange', inactive: true);
|
||||
final shade = chatColorShade(context, 'orange')!;
|
||||
final raised = Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||
final faded = ChatBarTint.from(
|
||||
shade: shade,
|
||||
raised: raised,
|
||||
dark: false,
|
||||
inactive: true,
|
||||
);
|
||||
expect(
|
||||
faded.fill.withValues(alpha: 1),
|
||||
Color.alphaBlend(
|
||||
shade.withValues(alpha: chatBarTintLight * chatBarInactiveFade),
|
||||
raised,
|
||||
),
|
||||
);
|
||||
expect(_titleFill(tester), faded.fill);
|
||||
|
||||
// The same pane turning active takes the full tint.
|
||||
await tester.pumpWidget(_header(color: 'orange', inactive: false));
|
||||
await tester.pumpAndSettle();
|
||||
final full = ChatBarTint.from(shade: shade, raised: raised, dark: false);
|
||||
expect(_titleFill(tester), full.fill);
|
||||
expect(full.fill, isNot(faded.fill));
|
||||
});
|
||||
|
||||
testWidgets('bar icons take the seeded onPrimaryContainer', (tester) async {
|
||||
final context = await _pump(tester, color: 'purple');
|
||||
final shade = chatColorShade(context, 'purple')!;
|
||||
final foreground = ColorScheme.fromSeed(
|
||||
seedColor: shade,
|
||||
@@ -227,23 +186,4 @@ void main() {
|
||||
expect(_iconIn(tester, _back), foreground);
|
||||
expect(_iconIn(tester, _files), foreground);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino: the colour is the bar tint, so Back and Files take '
|
||||
'it natively', (tester) async {
|
||||
final context = await _pump(tester, cupertino: true, color: 'purple');
|
||||
final tint = chatBarTintOf(context, 'purple')!;
|
||||
final inBar = tester.element(_files);
|
||||
expect(CupertinoTheme.of(inBar).primaryColor, tint.foreground);
|
||||
expect(_iconIn(tester, _files), tint.foreground);
|
||||
// The stock Back draws its chevron in its text style's colour.
|
||||
final chevron = tester.element(
|
||||
find.descendant(of: _back, matching: find.byType(RichText)).first,
|
||||
);
|
||||
expect(
|
||||
DefaultTextStyle.of(chevron).style.color,
|
||||
isSameColorAs(tint.foreground),
|
||||
);
|
||||
// Outside the bar the theme's tint is untouched.
|
||||
expect(CupertinoTheme.of(context).primaryColor, isNot(tint.foreground));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_bar_tint.dart';
|
||||
@@ -123,17 +122,4 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(_ring(tester).side.color.a, 0);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino composer rings in the theme primary colour', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(composerThread(gateway, cupertino: true));
|
||||
await tester.pumpAndSettle();
|
||||
await _focusField(tester);
|
||||
|
||||
final primary = CupertinoTheme.of(
|
||||
tester.element(find.byKey(const Key('chat-composer-field'))),
|
||||
).primaryColor;
|
||||
expect(_ring(tester).side.color, isSameColorAs(primary));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
@@ -8,57 +7,48 @@ import 'chat_thread_fixtures.dart';
|
||||
|
||||
void main() {
|
||||
// Chat details is Material only (a dialog, or a sheet on a phone).
|
||||
for (final cupertino in [false]) {
|
||||
testWidgets(
|
||||
'usage updates leave transcript widgets alone but refresh Info ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => chatPage([
|
||||
chatMessage(
|
||||
'a1',
|
||||
'assistant',
|
||||
parts: [
|
||||
{'type': 'text', 'text': '**Existing answer**'},
|
||||
],
|
||||
),
|
||||
]);
|
||||
final thread = ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
onBack: () {},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: thread))
|
||||
: MaterialApp(home: Scaffold(body: thread)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final answer = tester.widget<ChatMessageView>(
|
||||
find.byType(ChatMessageView),
|
||||
);
|
||||
gateway.emitEvent({
|
||||
'session_id': 's',
|
||||
'kind': 'usage',
|
||||
'usage': {'scope': 'session', 'total_tokens': 123},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<ChatMessageView>(find.byType(ChatMessageView)),
|
||||
same(answer),
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('chat-info')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('123'), findsOneWidget);
|
||||
gateway.emitEvent({
|
||||
'session_id': 's',
|
||||
'kind': 'usage',
|
||||
'usage': {'scope': 'session', 'total_tokens': 456},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('456'), findsOneWidget);
|
||||
expect(find.text('123'), findsNothing);
|
||||
},
|
||||
testWidgets('usage updates leave transcript widgets alone but refresh Info', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => chatPage([
|
||||
chatMessage(
|
||||
'a1',
|
||||
'assistant',
|
||||
parts: [
|
||||
{'type': 'text', 'text': '**Existing answer**'},
|
||||
],
|
||||
),
|
||||
]);
|
||||
final thread = ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
onBack: () {},
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: thread)));
|
||||
await tester.pumpAndSettle();
|
||||
final answer = tester.widget<ChatMessageView>(find.byType(ChatMessageView));
|
||||
gateway.emitEvent({
|
||||
'session_id': 's',
|
||||
'kind': 'usage',
|
||||
'usage': {'scope': 'session', 'total_tokens': 123},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<ChatMessageView>(find.byType(ChatMessageView)),
|
||||
same(answer),
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('chat-info')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('123'), findsOneWidget);
|
||||
gateway.emitEvent({
|
||||
'session_id': 's',
|
||||
'kind': 'usage',
|
||||
'usage': {'scope': 'session', 'total_tokens': 456},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('456'), findsOneWidget);
|
||||
expect(find.text('123'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -252,7 +251,6 @@ void main() {
|
||||
|
||||
await _pump(tester, client, platform: TargetPlatform.iOS);
|
||||
|
||||
expect(find.byType(CupertinoTextField), findsNothing);
|
||||
expect(find.byType(TextField), findsWidgets);
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_tabs.dart';
|
||||
@@ -33,7 +32,7 @@ class _PageState extends State<_Page> {
|
||||
controller: scroll,
|
||||
child: Column(
|
||||
children: [
|
||||
CupertinoTextField(controller: text),
|
||||
TextField(controller: text),
|
||||
for (var i = 0; i < 80; i++) Text('${widget.name} item $i'),
|
||||
],
|
||||
),
|
||||
@@ -41,84 +40,66 @@ class _PageState extends State<_Page> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('lazy topic pages retain draft and scroll ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final mounts = <SettingsTopic, int>{};
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => _Page(
|
||||
name: topic.name,
|
||||
onMount: () =>
|
||||
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: tabs))
|
||||
: MaterialApp(home: Scaffold(body: tabs)),
|
||||
);
|
||||
expect(mounts, {SettingsTopic.appearance: 1});
|
||||
final appearance = tester.state<_PageState>(find.byType(_Page));
|
||||
appearance.text.text = 'Keep this draft';
|
||||
appearance.scroll.jumpTo(150);
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(mounts, {
|
||||
SettingsTopic.appearance: 1,
|
||||
SettingsTopic.connection: 1,
|
||||
});
|
||||
final connection = tester.state<_PageState>(find.byType(_Page));
|
||||
connection.text.text = 'Unsubmitted server';
|
||||
connection.scroll.jumpTo(280);
|
||||
await selectSettingsTopic(tester, 'Appearance');
|
||||
expect(tester.state(find.byType(_Page)), same(appearance));
|
||||
expect(appearance.text.text, 'Keep this draft');
|
||||
expect(appearance.scroll.offset, 150);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(tester.state(find.byType(_Page)), same(connection));
|
||||
expect(connection.text.text, 'Unsubmitted server');
|
||||
expect(connection.scroll.offset, 280);
|
||||
expect(mounts.values, everyElement(1));
|
||||
});
|
||||
testWidgets('lazy topic pages retain draft and scroll', (tester) async {
|
||||
final mounts = <SettingsTopic, int>{};
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => _Page(
|
||||
name: topic.name,
|
||||
onMount: () =>
|
||||
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: tabs)));
|
||||
expect(mounts, {SettingsTopic.appearance: 1});
|
||||
final appearance = tester.state<_PageState>(find.byType(_Page));
|
||||
appearance.text.text = 'Keep this draft';
|
||||
appearance.scroll.jumpTo(150);
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(mounts, {SettingsTopic.appearance: 1, SettingsTopic.connection: 1});
|
||||
final connection = tester.state<_PageState>(find.byType(_Page));
|
||||
connection.text.text = 'Unsubmitted server';
|
||||
connection.scroll.jumpTo(280);
|
||||
await selectSettingsTopic(tester, 'Appearance');
|
||||
expect(tester.state(find.byType(_Page)), same(appearance));
|
||||
expect(appearance.text.text, 'Keep this draft');
|
||||
expect(appearance.scroll.offset, 150);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(tester.state(find.byType(_Page)), same(connection));
|
||||
expect(connection.text.text, 'Unsubmitted server');
|
||||
expect(connection.scroll.offset, 280);
|
||||
expect(mounts.values, everyElement(1));
|
||||
});
|
||||
|
||||
testWidgets('all topics reachable at narrow large text ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => Text('${topic.label} content'),
|
||||
},
|
||||
);
|
||||
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: scale,
|
||||
home: CupertinoPageScaffold(child: tabs),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: tabs),
|
||||
),
|
||||
);
|
||||
for (final topic in SettingsTopic.values) {
|
||||
await selectSettingsTopic(tester, topic.label);
|
||||
expect(find.text('${topic.label} content'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
testWidgets('all topics reachable at narrow large text', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => Text('${topic.label} content'),
|
||||
},
|
||||
);
|
||||
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: tabs),
|
||||
),
|
||||
);
|
||||
for (final topic in SettingsTopic.values) {
|
||||
await selectSettingsTopic(tester, topic.label);
|
||||
expect(find.text('${topic.label} content'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/servers/server_scope.dart';
|
||||
@@ -11,11 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'settings_topic_test_helper.dart';
|
||||
|
||||
Widget host({
|
||||
bool cupertino = false,
|
||||
String? scope,
|
||||
SettingsTopicStore? store,
|
||||
}) {
|
||||
Widget host({String? scope, SettingsTopicStore? store}) {
|
||||
final tabs = SettingsTopicTabs(
|
||||
navigationScope: scope,
|
||||
selectionStore: store,
|
||||
@@ -24,9 +19,7 @@ Widget host({
|
||||
topic: (_) => Text('${topic.name} page'),
|
||||
},
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: tabs))
|
||||
: MaterialApp(home: Scaffold(body: tabs));
|
||||
return MaterialApp(home: Scaffold(body: tabs));
|
||||
}
|
||||
|
||||
class DelayedStore implements SettingsTopicStore {
|
||||
@@ -67,26 +60,22 @@ class SharedQueuedTopicStore implements SettingsTopicStore {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('restores selected category after recreation ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await tester.pumpWidget(host(cupertino: cupertino, scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(host(cupertino: cupertino, scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
expect(
|
||||
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
||||
'connection',
|
||||
);
|
||||
});
|
||||
}
|
||||
testWidgets('restores selected category after recreation', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
expect(
|
||||
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
||||
'connection',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('server scopes and malformed selections are independent', (
|
||||
tester,
|
||||
|
||||
Reference in New Issue
Block a user