Remove Cupertino chat session branches
Keep the Material-only session UI and narrow its tests to the supported host. Preserve public Cupertino parameters for callers while removing unreachable Cupertino widgets and variants.
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
import '../../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
import '../../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Which standard control family this screen renders.
|
||||
enum ChatControlsStyle { material, cupertino }
|
||||
|
||||
/// Cupertino under an explicit Cupertino app, Material everywhere else,
|
||||
/// whatever the target platform. The shell decides the app class, so a bare
|
||||
/// Cupertino app never has to grow a Material ancestor just for this screen.
|
||||
/// Always Material: the app is Material-only, so no screen ever asks for the
|
||||
/// Cupertino family. The parameter stays for callers.
|
||||
ChatControlsStyle chatControlsStyleOf(BuildContext context) =>
|
||||
context.findAncestorWidgetOfExactType<MaterialApp>() == null
|
||||
? ChatControlsStyle.cupertino
|
||||
: ChatControlsStyle.material;
|
||||
ChatControlsStyle.material;
|
||||
|
||||
class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
|
||||
const ChatBarAction({
|
||||
@@ -27,6 +22,8 @@ class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
|
||||
final String label;
|
||||
final VoidCallback onPressed;
|
||||
final IconData materialIcon;
|
||||
|
||||
/// Kept for callers; the Material toolbar always draws [materialIcon].
|
||||
final IconData cupertinoIcon;
|
||||
final String? identifier;
|
||||
|
||||
@@ -40,18 +37,6 @@ class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return Semantics(
|
||||
identifier: identifier,
|
||||
label: label,
|
||||
button: true,
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: Icon(cupertinoIcon),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Semantics(
|
||||
identifier: identifier,
|
||||
child: IconButton(
|
||||
@@ -72,20 +57,6 @@ class ChatNewChatButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: onPressed,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(CupertinoIcons.add, size: 16),
|
||||
SizedBox(width: 4),
|
||||
Text('New chat'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return FilledButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
@@ -113,21 +84,15 @@ class ChatSearchField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final field = chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoSearchTextField(
|
||||
controller: controller,
|
||||
placeholder: 'Search chats',
|
||||
onChanged: onChanged,
|
||||
)
|
||||
: TextField(
|
||||
controller: controller,
|
||||
onChanged: onChanged,
|
||||
autofocus: autofocus,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.search),
|
||||
labelText: 'Search chats',
|
||||
),
|
||||
);
|
||||
final field = TextField(
|
||||
controller: controller,
|
||||
onChanged: onChanged,
|
||||
autofocus: autofocus,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.search),
|
||||
labelText: 'Search chats',
|
||||
),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: trailing.isEmpty
|
||||
@@ -145,81 +110,9 @@ class ChatSearchField extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// A grouped Cupertino card for a message that may wrap onto several lines.
|
||||
///
|
||||
/// [CupertinoListTile] forces its title to one ellipsised line, which cut long
|
||||
/// no-match queries and server reasons. This layout keeps the native card but
|
||||
/// lets the message wrap, with its action on a separate button below.
|
||||
class ChatCupertinoMessage extends StatelessWidget {
|
||||
const ChatCupertinoMessage({
|
||||
super.key,
|
||||
required this.message,
|
||||
this.icon,
|
||||
this.actionLabel,
|
||||
this.onAction,
|
||||
});
|
||||
|
||||
final String message;
|
||||
final IconData? icon;
|
||||
final String? actionLabel;
|
||||
final VoidCallback? onAction;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
child: CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(
|
||||
icon,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
Expanded(
|
||||
// Cupertino widgets normally supply their own text style.
|
||||
// This card is also mounted under a bare MaterialApp (the
|
||||
// iOS/macOS theme path), where Text would otherwise inherit
|
||||
// MaterialApp's "missing Material" fallback style.
|
||||
child: DefaultTextStyle.merge(
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(message),
|
||||
if (actionLabel != null && onAction != null)
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: CupertinoButton(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
onPressed: onAction,
|
||||
child: Text(actionLabel!),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A row action's refusal, shown at full width beneath its tile.
|
||||
///
|
||||
/// It must not sit in a `CupertinoListTile.subtitle`: that slot forces every
|
||||
/// It must not sit in a list tile's subtitle slot: that slot forces every
|
||||
/// paragraph to one ellipsised line, which cut the server's reason down to its
|
||||
/// first few words. Full width also stops a long refusal from turning a single
|
||||
/// Material row into a column taller than the viewport.
|
||||
@@ -242,13 +135,7 @@ class ChatRowError extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
)
|
||||
: TextStyle(color: Theme.of(context).colorScheme.error);
|
||||
final style = TextStyle(color: Theme.of(context).colorScheme.error);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 12),
|
||||
child: Row(
|
||||
@@ -265,14 +152,7 @@ class ChatRowError extends StatelessWidget {
|
||||
button: true,
|
||||
label: 'Dismiss refusal',
|
||||
excludeSemantics: true,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsetsDirectional.only(start: 8),
|
||||
minimumSize: Size.zero,
|
||||
onPressed: onDismiss,
|
||||
child: const Text('OK'),
|
||||
)
|
||||
: TextButton(onPressed: onDismiss, child: const Text('OK')),
|
||||
child: TextButton(onPressed: onDismiss, child: const Text('OK')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -292,14 +172,6 @@ class ChatErrorNotice extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return ChatCupertinoMessage(
|
||||
message: message,
|
||||
icon: CupertinoIcons.exclamationmark_circle,
|
||||
actionLabel: 'Retry',
|
||||
onAction: onRetry,
|
||||
);
|
||||
}
|
||||
return MaterialBanner(
|
||||
content: Text(message),
|
||||
actions: [TextButton(onPressed: onRetry, child: const Text('Retry'))],
|
||||
@@ -312,11 +184,7 @@ class ChatLoadingIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
);
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,28 +206,14 @@ class ChatUndoBar extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: DefaultTextStyle.merge(
|
||||
style: chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: DefaultTextStyle.of(context).style,
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
child: Text(message),
|
||||
),
|
||||
),
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino)
|
||||
CupertinoButton(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12),
|
||||
onPressed: onUndo,
|
||||
child: const Text('Undo'),
|
||||
)
|
||||
else
|
||||
TextButton(onPressed: onUndo, child: const Text('Undo')),
|
||||
TextButton(onPressed: onUndo, child: const Text('Undo')),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
// A standard Cupertino popup surface: the bar floats over the list, so it
|
||||
// needs its own painted card and shadow to stay legible.
|
||||
return CupertinoPopupSurface(child: content);
|
||||
}
|
||||
return Material(
|
||||
elevation: 3,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
|
||||
@@ -1,28 +1,13 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../domain/chat_colors.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// The host's own shade for a chat colour name, tuned for the current
|
||||
/// brightness: Cupertino's dynamic system colours, and Material's standard
|
||||
/// swatches (a deeper tone on light surfaces, a lighter one on dark), so the
|
||||
/// mark keeps its contrast in both. Null for no (or an unknown) colour.
|
||||
/// brightness: Material's standard swatches (a deeper tone on light surfaces,
|
||||
/// a lighter one on dark), so the mark keeps its contrast in both. Null for no
|
||||
/// (or an unknown) colour.
|
||||
Color? chatColorShade(BuildContext context, String? name) {
|
||||
if (name == null || !chatColorNames.contains(name)) return null;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
final CupertinoDynamicColor color = switch (name) {
|
||||
'red' => CupertinoColors.systemRed,
|
||||
'orange' => CupertinoColors.systemOrange,
|
||||
'amber' => CupertinoColors.systemYellow,
|
||||
'green' => CupertinoColors.systemGreen,
|
||||
'teal' => CupertinoColors.systemTeal,
|
||||
'blue' => CupertinoColors.systemBlue,
|
||||
'purple' => CupertinoColors.systemPurple,
|
||||
_ => CupertinoColors.systemPink,
|
||||
};
|
||||
return color.resolveFrom(context);
|
||||
}
|
||||
final dark = Theme.of(context).brightness == Brightness.dark;
|
||||
final MaterialColor swatch = switch (name) {
|
||||
'red' => Colors.red,
|
||||
@@ -42,8 +27,6 @@ Color? chatColorShade(BuildContext context, String? name) {
|
||||
};
|
||||
}
|
||||
|
||||
/// Whether the surrounding theme is dark, on either host.
|
||||
/// Whether the surrounding theme is dark.
|
||||
bool chatColorDarkSurface(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.brightnessOf(context) == Brightness.dark
|
||||
: Theme.of(context).brightness == Brightness.dark;
|
||||
Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../domain/chat_colors.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_color_palette.dart';
|
||||
|
||||
/// The chat colour choices: None, then the palette, as the host's own icon
|
||||
/// buttons. The chosen one shows a check. It keeps its own selection, so a
|
||||
/// pick shows at once inside a sheet that the list's rebuild cannot reach.
|
||||
/// The chat colour choices: None, then the palette, as icon buttons. The
|
||||
/// chosen one shows a check. It keeps its own selection, so a pick shows at
|
||||
/// once inside a sheet that the list's rebuild cannot reach.
|
||||
class ChatColorSwatches extends StatefulWidget {
|
||||
const ChatColorSwatches({
|
||||
super.key,
|
||||
@@ -51,21 +49,15 @@ class _ChatColorSwatchesState extends State<ChatColorSwatches> {
|
||||
}
|
||||
|
||||
Widget _swatch(BuildContext context, String? name) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final selected = _selected == name;
|
||||
final label = name == null ? 'No colour' : chatColorLabel(name);
|
||||
final muted = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = chatColorShade(context, name) ?? muted;
|
||||
final IconData icon = name == null
|
||||
? (cupertino ? CupertinoIcons.nosign : Icons.block)
|
||||
? Icons.block
|
||||
: selected
|
||||
? (cupertino
|
||||
? CupertinoIcons.checkmark_circle_fill
|
||||
: Icons.check_circle)
|
||||
: (cupertino ? CupertinoIcons.circle_fill : Icons.circle);
|
||||
? Icons.check_circle
|
||||
: Icons.circle;
|
||||
final glyph = Icon(icon, color: color, size: 32);
|
||||
// The None choice has no fill to check, so its selection is a ring.
|
||||
final mark = name == null && selected
|
||||
@@ -77,19 +69,12 @@ class _ChatColorSwatchesState extends State<ChatColorSwatches> {
|
||||
child: Padding(padding: const EdgeInsets.all(2), child: glyph),
|
||||
)
|
||||
: glyph;
|
||||
final button = cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsets.all(4),
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: () => _pick(name),
|
||||
child: mark,
|
||||
)
|
||||
: IconButton(
|
||||
tooltip: label,
|
||||
isSelected: selected,
|
||||
onPressed: () => _pick(name),
|
||||
icon: mark,
|
||||
);
|
||||
final button = IconButton(
|
||||
tooltip: label,
|
||||
isSelected: selected,
|
||||
onPressed: () => _pick(name),
|
||||
icon: mark,
|
||||
);
|
||||
return Semantics(
|
||||
key: Key('chat-color-${name ?? 'none'}'),
|
||||
button: true,
|
||||
@@ -117,17 +102,9 @@ class ChatColorSection extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final labelStyle =
|
||||
(cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodySmall)
|
||||
?.copyWith(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
final labelStyle = Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
return Padding(
|
||||
key: const Key('chat-color-section'),
|
||||
padding: padding,
|
||||
@@ -151,7 +128,6 @@ Future<void> showChatColorPicker(
|
||||
required String? selected,
|
||||
required ValueChanged<String?> onSelected,
|
||||
}) async {
|
||||
final cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
Widget content(BuildContext sheet) => Column(
|
||||
key: const Key('chat-color-sheet'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -159,7 +135,7 @@ Future<void> showChatColorPicker(
|
||||
children: [
|
||||
AppSheetHeader(
|
||||
title: 'Colour for $title',
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
doneKey: const Key('chat-color-done'),
|
||||
),
|
||||
Padding(
|
||||
@@ -168,20 +144,6 @@ Future<void> showChatColorPicker(
|
||||
),
|
||||
],
|
||||
);
|
||||
if (cupertino) {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (sheet) => Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SafeArea(
|
||||
child: CupertinoPopupSurface(
|
||||
child: SingleChildScrollView(child: content(sheet)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
await showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat_session_state.dart';
|
||||
import 'session_activity_badge.dart';
|
||||
@@ -38,7 +37,6 @@ class ChatCompactAvatar extends StatelessWidget {
|
||||
top: -2,
|
||||
start: -5,
|
||||
child: _Disc(
|
||||
cupertino: cupertino,
|
||||
child: Icon(
|
||||
active ? Icons.radio_button_checked : Icons.visibility_outlined,
|
||||
size: 14,
|
||||
@@ -58,7 +56,6 @@ class ChatCompactAvatar extends StatelessWidget {
|
||||
top: -2,
|
||||
end: -3,
|
||||
child: _Disc(
|
||||
cupertino: cupertino,
|
||||
child: Icon(
|
||||
Icons.mark_chat_unread_outlined,
|
||||
key: const Key('chat-compact-unread'),
|
||||
@@ -72,16 +69,13 @@ class ChatCompactAvatar extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _Disc extends StatelessWidget {
|
||||
const _Disc({required this.cupertino, required this.child});
|
||||
final bool cupertino;
|
||||
const _Disc({required this.child});
|
||||
final Widget child;
|
||||
@override
|
||||
Widget build(BuildContext context) => DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: cupertino
|
||||
? CupertinoColors.systemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
child: Padding(padding: const EdgeInsets.all(1), child: child),
|
||||
);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import '../../../../core/servers/chat/federated_chat_gateway.dart';
|
||||
import '../../../../core/servers/server_context.dart';
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_cycle.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import '../../domain/chat_colors.dart';
|
||||
import 'chat_color_palette.dart';
|
||||
import 'chat_visibility_marker.dart';
|
||||
@@ -44,29 +42,18 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
VoidCallback onPressed, {
|
||||
bool selected = false,
|
||||
}) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
return Semantics(
|
||||
label: title,
|
||||
button: true,
|
||||
selected: selected,
|
||||
onTap: onPressed,
|
||||
excludeSemantics: true,
|
||||
child: cupertino
|
||||
? Tooltip(
|
||||
message: title,
|
||||
child: CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
onPressed: onPressed,
|
||||
child: icon,
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
tooltip: title,
|
||||
onPressed: onPressed,
|
||||
icon: icon,
|
||||
color: selected ? Theme.of(context).colorScheme.primary : null,
|
||||
),
|
||||
child: IconButton(
|
||||
tooltip: title,
|
||||
onPressed: onPressed,
|
||||
icon: icon,
|
||||
color: selected ? Theme.of(context).colorScheme.primary : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,9 +81,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
].join('\n');
|
||||
final color =
|
||||
chatColorShade(context, chatSessionColor(row)) ??
|
||||
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary);
|
||||
Theme.of(context).colorScheme.primary;
|
||||
return ChatVisibilityMarker(
|
||||
sessionId: id,
|
||||
color: color,
|
||||
@@ -122,9 +107,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
running: running,
|
||||
backgroundTasks: backgroundTasks,
|
||||
unread: unread,
|
||||
cupertino:
|
||||
chatControlsStyleOf(context) ==
|
||||
ChatControlsStyle.cupertino,
|
||||
cupertino: false,
|
||||
),
|
||||
if (machineName case final name?)
|
||||
Text(
|
||||
@@ -159,11 +142,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoIcons.sidebar_left
|
||||
: Icons.menu_open,
|
||||
),
|
||||
const Icon(Icons.menu_open),
|
||||
const Text('Expand', textAlign: TextAlign.center),
|
||||
if (controller.repository.gateway is FederatedChatGateway)
|
||||
const Text('All machines', textAlign: TextAlign.center)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import '../../../../core/servers/server_context.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// The create flow's heading and confirm, verbatim from the web client.
|
||||
const String chatCreateTitle = 'Start a chat';
|
||||
const String chatCreateConfirmLabel = 'New chat';
|
||||
|
||||
/// Native chrome for the create dialog: standard Cupertino alert or Material
|
||||
/// alert, with the same disabled/submitting state in both hosts.
|
||||
/// Native chrome for the create dialog: a Material alert, with the same
|
||||
/// disabled/submitting state for the confirm action.
|
||||
class ChatCreateDialogFrame extends StatelessWidget {
|
||||
const ChatCreateDialogFrame({
|
||||
super.key,
|
||||
@@ -30,24 +27,6 @@ class ChatCreateDialogFrame extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final enabled = canSubmit && !submitting;
|
||||
final label = submitting ? 'Creating…' : chatCreateConfirmLabel;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(ServerContext.metadata(context, chatCreateTitle)),
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: submitting ? null : onCancel,
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('chat-create-confirm'),
|
||||
isDefaultAction: true,
|
||||
onPressed: enabled ? onSubmit : null,
|
||||
child: Text(label),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AlertDialog(
|
||||
title: Text(ServerContext.metadata(context, chatCreateTitle)),
|
||||
content: content,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// The web's directory prompt, also the directory picker's label.
|
||||
const String chatCreatePrompt = 'Where should this chat live?';
|
||||
|
||||
@@ -70,11 +67,9 @@ class ChatCatalogFields extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
if (loading) return const Text('Loading directories…');
|
||||
if (error != null) {
|
||||
return _message(cupertino, 'Unable to load chat options: $error');
|
||||
return _message('Unable to load chat options: $error');
|
||||
}
|
||||
final choices = chatDirectoryChoices(directories);
|
||||
String directoryLabel(String choice) =>
|
||||
@@ -82,90 +77,50 @@ class ChatCatalogFields extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (cupertino)
|
||||
CupertinoPickerField(
|
||||
// Keyed by the value so a folder chosen in the picker replaces the
|
||||
// dropdown's retained initial value.
|
||||
KeyedSubtree(
|
||||
key: ValueKey('chat-create-directory-$directory'),
|
||||
child: MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-server-directory'),
|
||||
label: chatCreatePrompt,
|
||||
value: directory,
|
||||
values: choices,
|
||||
labelOf: directoryLabel,
|
||||
onSelected: onDirectory,
|
||||
)
|
||||
else
|
||||
// Keyed by the value so a folder chosen in the picker replaces the
|
||||
// dropdown's retained initial value.
|
||||
KeyedSubtree(
|
||||
key: ValueKey('chat-create-directory-$directory'),
|
||||
child: MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-server-directory'),
|
||||
label: chatCreatePrompt,
|
||||
value: directory,
|
||||
values: choices,
|
||||
labelOf: directoryLabel,
|
||||
onSelected: onDirectory,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (onBrowse != null)
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('chat-create-choose-folder'),
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
onPressed: onBrowse,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(CupertinoIcons.folder),
|
||||
SizedBox(width: 6),
|
||||
Flexible(child: Text(chatChooseFolderLabel)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: TextButton.icon(
|
||||
key: const Key('chat-create-choose-folder'),
|
||||
onPressed: onBrowse,
|
||||
icon: const Icon(Icons.folder_open),
|
||||
label: const Text(chatChooseFolderLabel),
|
||||
),
|
||||
child: TextButton.icon(
|
||||
key: const Key('chat-create-choose-folder'),
|
||||
onPressed: onBrowse,
|
||||
icon: const Icon(Icons.folder_open),
|
||||
label: const Text(chatChooseFolderLabel),
|
||||
),
|
||||
),
|
||||
if (backends.length > 1)
|
||||
if (cupertino)
|
||||
CupertinoPickerField(
|
||||
fieldKey: const Key('chat-create-backend'),
|
||||
label: 'Chat harness',
|
||||
value: backend,
|
||||
values: backends,
|
||||
labelOf: chatBackendLabel,
|
||||
onSelected: onBackend,
|
||||
)
|
||||
else
|
||||
MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-backend'),
|
||||
label: 'Chat harness',
|
||||
value: backend,
|
||||
values: backends,
|
||||
labelOf: chatBackendLabel,
|
||||
onSelected: onBackend,
|
||||
),
|
||||
MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-backend'),
|
||||
label: 'Chat harness',
|
||||
value: backend,
|
||||
values: backends,
|
||||
labelOf: chatBackendLabel,
|
||||
onSelected: onBackend,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _message(bool cupertino, String text) {
|
||||
Widget _message(String text) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(text),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRetry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
child: TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -221,68 +176,3 @@ class MaterialPickerField extends StatelessWidget {
|
||||
return Text(_text(item), maxLines: 1, overflow: TextOverflow.ellipsis);
|
||||
}
|
||||
}
|
||||
|
||||
class CupertinoPickerField extends StatelessWidget {
|
||||
const CupertinoPickerField({
|
||||
super.key,
|
||||
required this.fieldKey,
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.values,
|
||||
required this.onSelected,
|
||||
this.labelOf,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String? value;
|
||||
final List<String> values;
|
||||
final ValueChanged<String> onSelected;
|
||||
final Key fieldKey;
|
||||
|
||||
/// The visible text of a value; the value itself is what is sent.
|
||||
final String Function(String value)? labelOf;
|
||||
|
||||
String _text(String value) => labelOf?.call(value) ?? value;
|
||||
|
||||
Future<void> _choose(BuildContext context) async {
|
||||
final choice = await showCupertinoModalPopup<String>(
|
||||
context: context,
|
||||
builder: (sheetContext) => CupertinoActionSheet(
|
||||
title: Text(label),
|
||||
actions: [
|
||||
for (final item in values)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(sheetContext, item),
|
||||
child: Text(_text(item)),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(sheetContext),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (choice != null) onSelected(choice);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Semantics(
|
||||
label: '$label: ${value == null ? '' : _text(value!)}',
|
||||
button: true,
|
||||
child: CupertinoButton(
|
||||
key: fieldKey,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
onPressed: () => _choose(context),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text('$label: ${value == null ? '' : _text(value!)}'),
|
||||
),
|
||||
const Icon(CupertinoIcons.chevron_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/servers/server_catalog.dart';
|
||||
import '../../../../core/servers/server_context.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// Select the machine before reading its harnesses or directory listing.
|
||||
Future<SavedServer?> chooseChatMachine(BuildContext context) async {
|
||||
@@ -11,28 +9,6 @@ Future<SavedServer?> chooseChatMachine(BuildContext context) async {
|
||||
final servers = scope?.notifier?.catalog.servers ?? const <SavedServer>[];
|
||||
if (servers.isEmpty) return null;
|
||||
if (servers.length == 1) return servers.single;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return showCupertinoModalPopup<SavedServer>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: const Text('New chat on…'),
|
||||
message: const Text(
|
||||
'Choose a machine. Its configured harnesses appear next.',
|
||||
),
|
||||
actions: [
|
||||
for (final server in servers)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context, server),
|
||||
child: Text(server.name),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return showDialog<SavedServer>(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
@@ -53,21 +29,6 @@ Future<SavedServer?> chooseChatMachine(BuildContext context) async {
|
||||
}
|
||||
|
||||
Future<void> showChatMachineError(BuildContext context, String message) {
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: const Text('Machine unavailable'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'chat_create_fields.dart';
|
||||
@@ -19,6 +18,7 @@ class ChatPromptChooser extends StatelessWidget {
|
||||
static const careful = 'careful';
|
||||
static const lastUsed = 'last-used';
|
||||
|
||||
/// Kept for callers; the Material switch and picker are always drawn.
|
||||
final bool cupertino;
|
||||
final bool enabled;
|
||||
final String choice;
|
||||
@@ -42,39 +42,22 @@ class ChatPromptChooser extends StatelessWidget {
|
||||
Row(
|
||||
children: [
|
||||
const Expanded(child: Text('Start with a prompt')),
|
||||
if (cupertino)
|
||||
CupertinoSwitch(
|
||||
key: const Key('chat-create-send-prompt'),
|
||||
value: enabled,
|
||||
onChanged: onEnabled,
|
||||
)
|
||||
else
|
||||
Switch(
|
||||
key: const Key('chat-create-send-prompt'),
|
||||
value: enabled,
|
||||
onChanged: onEnabled,
|
||||
),
|
||||
Switch(
|
||||
key: const Key('chat-create-send-prompt'),
|
||||
value: enabled,
|
||||
onChanged: onEnabled,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (enabled)
|
||||
if (cupertino)
|
||||
CupertinoPickerField(
|
||||
fieldKey: const Key('chat-create-prompt-choice'),
|
||||
label: 'Prompt',
|
||||
value: choices.contains(choice) ? choice : custom,
|
||||
values: choices,
|
||||
labelOf: label,
|
||||
onSelected: onChoice,
|
||||
)
|
||||
else
|
||||
MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-prompt-choice'),
|
||||
label: 'Prompt',
|
||||
value: choices.contains(choice) ? choice : custom,
|
||||
values: choices,
|
||||
labelOf: label,
|
||||
onSelected: onChoice,
|
||||
),
|
||||
MaterialPickerField(
|
||||
fieldKey: const Key('chat-create-prompt-choice'),
|
||||
label: 'Prompt',
|
||||
value: choices.contains(choice) ? choice : custom,
|
||||
values: choices,
|
||||
labelOf: label,
|
||||
onSelected: onChoice,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import '../../../../core/servers/server_context.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// State uses neutral text and shapes; the chat's chosen color stays identity.
|
||||
Color chatStateForeground(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
Color chatMetadataForeground(BuildContext context) =>
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoColors.label.resolveFrom(context).withValues(alpha: .82)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
class ChatSessionStateLine extends StatelessWidget {
|
||||
const ChatSessionStateLine({
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'session_list_cupertino.dart';
|
||||
import 'session_list_material.dart';
|
||||
import 'session_row_style.dart';
|
||||
|
||||
@@ -90,30 +89,6 @@ class ChatSessionsBody extends StatelessWidget {
|
||||
if (loading && sessions.isEmpty) return const ChatLoadingIndicator();
|
||||
final clearSearch = query.trim().isEmpty ? null : onClearSearch;
|
||||
final duplicateTitles = duplicateChatTitles(visible);
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return CupertinoSessionList(
|
||||
selectionOnly: selectionOnly,
|
||||
sections: sections,
|
||||
folds: folds,
|
||||
activeSessionId: activeSessionId,
|
||||
visibleSessionIds: visibleSessionIds,
|
||||
emptyMessage: visible.isEmpty ? emptyMessage : null,
|
||||
duplicateTitles: duplicateTitles,
|
||||
onOpen: onOpen,
|
||||
onOpenBeside: onOpenBeside,
|
||||
onOpenBelow: onOpenBelow,
|
||||
onRename: onRename,
|
||||
onClose: onClose,
|
||||
onReopen: onReopen,
|
||||
onStar: onStar,
|
||||
onColor: onColor,
|
||||
onHide: onHide,
|
||||
onClearSearch: clearSearch,
|
||||
isUnseen: isUnseen,
|
||||
errorFor: errorFor,
|
||||
onDismissError: onDismissError,
|
||||
);
|
||||
}
|
||||
return MaterialSessionList(
|
||||
selectionOnly: selectionOnly,
|
||||
sections: sections,
|
||||
|
||||
@@ -416,18 +416,6 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
title: 'Chats',
|
||||
actions: _actions(),
|
||||
),
|
||||
// The list scrolls behind the bar, which does not fully obstruct;
|
||||
// it pads its first row by the bar's height itself.
|
||||
child: SafeArea(top: false, child: body),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import '../../../../core/servers/server_context.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
@@ -11,7 +10,6 @@ import '../../data/chat_repository.dart';
|
||||
import '../../data/directory_listing.dart';
|
||||
import '../../domain/chat_commands.dart';
|
||||
import '../folder_picker/folder_picker_route.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_create_dialog_frame.dart';
|
||||
import 'chat_create_fields.dart';
|
||||
import 'chat_prompt_chooser.dart';
|
||||
@@ -58,9 +56,7 @@ Future<JsonMap?> showChatCreateDialog(
|
||||
prompts: prompts,
|
||||
),
|
||||
);
|
||||
return chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? showCupertinoDialog<JsonMap>(context: context, builder: (_) => dialog)
|
||||
: showDialog<JsonMap>(context: context, builder: (_) => dialog);
|
||||
return showDialog<JsonMap>(context: context, builder: (_) => dialog);
|
||||
}
|
||||
|
||||
class CreateChatDialog extends StatefulWidget {
|
||||
@@ -306,8 +302,6 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final content = SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -334,21 +328,14 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
const SizedBox(height: 12),
|
||||
const Text('Name'),
|
||||
const SizedBox(height: 4),
|
||||
if (cupertino)
|
||||
CupertinoTextField(
|
||||
key: const Key('chat-create-name'),
|
||||
controller: _name,
|
||||
onChanged: (_) => _nameEdited = true,
|
||||
)
|
||||
else
|
||||
TextField(
|
||||
key: const Key('chat-create-name'),
|
||||
controller: _name,
|
||||
onChanged: (_) => _nameEdited = true,
|
||||
),
|
||||
TextField(
|
||||
key: const Key('chat-create-name'),
|
||||
controller: _name,
|
||||
onChanged: (_) => _nameEdited = true,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ChatPromptChooser(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
enabled: _sendPrompt,
|
||||
choice: _promptChoice,
|
||||
hasLastUsed: _savedPrompt?.text.trim().isNotEmpty == true,
|
||||
@@ -360,38 +347,22 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
),
|
||||
if (_sendPrompt) ...[
|
||||
const SizedBox(height: 4),
|
||||
if (cupertino)
|
||||
CupertinoTextField(
|
||||
key: const Key('chat-create-instructions'),
|
||||
controller: _instructions,
|
||||
minLines: 2,
|
||||
maxLines: 4,
|
||||
placeholder: 'Write your custom prompt',
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_promptTouched = true;
|
||||
_promptChoice = ChatPromptChooser.custom;
|
||||
_customPrompt = value;
|
||||
});
|
||||
},
|
||||
)
|
||||
else
|
||||
TextField(
|
||||
key: const Key('chat-create-instructions'),
|
||||
controller: _instructions,
|
||||
minLines: 2,
|
||||
maxLines: 4,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Write your custom prompt',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_promptTouched = true;
|
||||
_promptChoice = ChatPromptChooser.custom;
|
||||
_customPrompt = value;
|
||||
});
|
||||
},
|
||||
TextField(
|
||||
key: const Key('chat-create-instructions'),
|
||||
controller: _instructions,
|
||||
minLines: 2,
|
||||
maxLines: 4,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Write your custom prompt',
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_promptTouched = true;
|
||||
_promptChoice = ChatPromptChooser.custom;
|
||||
_customPrompt = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(chatCreateInstructionsHelper),
|
||||
],
|
||||
@@ -408,11 +379,7 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_formError!,
|
||||
style: TextStyle(
|
||||
color: cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
|
||||
/// Renames one session through the shared server field. Save is disabled while
|
||||
/// the trimmed name is blank, matching the web dialog. A refusal keeps the
|
||||
@@ -17,9 +15,7 @@ Future<String?> showRenameChatDialog(
|
||||
initialTitle: chatSessionTitle(session),
|
||||
onSubmit: onSubmit,
|
||||
);
|
||||
return chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? showCupertinoDialog<String>(context: context, builder: (_) => dialog)
|
||||
: showDialog<String>(context: context, builder: (_) => dialog);
|
||||
return showDialog<String>(context: context, builder: (_) => dialog);
|
||||
}
|
||||
|
||||
class _RenameChatDialog extends StatefulWidget {
|
||||
@@ -76,44 +72,6 @@ class _RenameChatDialogState extends State<_RenameChatDialog> {
|
||||
builder: (context, value, _) {
|
||||
final canSave = !_saving && value.text.trim().isNotEmpty;
|
||||
final error = _error;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('Rename chat'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CupertinoTextField(
|
||||
key: const Key('chat-rename-field'),
|
||||
controller: _title,
|
||||
autofocus: true,
|
||||
placeholder: 'Name',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text('This name is shared with every device.'),
|
||||
if (error != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
error,
|
||||
style: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: _saving ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: canSave ? _save : null,
|
||||
child: const Text('Save'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AlertDialog(
|
||||
// A long server refusal plus a 2x helper text can exceed the dialog
|
||||
// height at 320px; scroll the content instead of clipping it.
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'session_row_style.dart';
|
||||
import '../../../../ui/layout/app_overflow_menu.dart';
|
||||
|
||||
@@ -84,41 +82,22 @@ List<({SessionAction action, String label})> _items(JsonMap session) {
|
||||
Future<bool> confirmCloseChat(BuildContext context, JsonMap session) async {
|
||||
final title = chatSessionTitle(session);
|
||||
final body = closeChatConfirmation(title);
|
||||
final confirmed = chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: const Text('Close chat?'),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Close chat'),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Close chat?'),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Close chat'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Close chat?'),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Close chat'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return confirmed == true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The corner badge a chat's avatar wears for its live activity: the
|
||||
@@ -14,7 +13,7 @@ Widget? chatSessionActivityBadge({
|
||||
return Semantics(
|
||||
key: const Key('chat-row-working'),
|
||||
label: 'Chat is working',
|
||||
child: _WorkingBadge(cupertino: cupertino),
|
||||
child: const _WorkingBadge(),
|
||||
);
|
||||
}
|
||||
if (backgroundTasks <= 0) return null;
|
||||
@@ -28,23 +27,20 @@ Widget? chatSessionActivityBadge({
|
||||
excludeFromSemantics: true,
|
||||
child: Semantics(
|
||||
label: label,
|
||||
child: _BackgroundBadge(cupertino: cupertino, count: backgroundTasks),
|
||||
child: _BackgroundBadge(count: backgroundTasks),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The badge's own disc in the surface colour, so it reads over any avatar.
|
||||
class _BadgeDisc extends StatelessWidget {
|
||||
const _BadgeDisc({required this.cupertino, required this.child});
|
||||
const _BadgeDisc({required this.child});
|
||||
|
||||
final bool cupertino;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final background = cupertino
|
||||
? CupertinoColors.systemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surface;
|
||||
final background = Theme.of(context).colorScheme.surface;
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(color: background, shape: BoxShape.circle),
|
||||
child: Padding(padding: const EdgeInsets.all(2), child: child),
|
||||
@@ -53,37 +49,28 @@ class _BadgeDisc extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _WorkingBadge extends StatelessWidget {
|
||||
const _WorkingBadge({required this.cupertino});
|
||||
|
||||
final bool cupertino;
|
||||
const _WorkingBadge();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _BadgeDisc(
|
||||
cupertino: cupertino,
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator(radius: 6)
|
||||
: const SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
return const _BadgeDisc(
|
||||
child: SizedBox.square(
|
||||
dimension: 12,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BackgroundBadge extends StatelessWidget {
|
||||
const _BackgroundBadge({required this.cupertino, required this.count});
|
||||
const _BackgroundBadge({required this.count});
|
||||
|
||||
final bool cupertino;
|
||||
final int count;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
final color = Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
return _BadgeDisc(
|
||||
cupertino: cupertino,
|
||||
child: Text(
|
||||
'$count',
|
||||
style: TextStyle(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_create_fields.dart';
|
||||
|
||||
/// Harness identity, independent of favorite/activity state. Native icon sizing
|
||||
@@ -17,29 +15,14 @@ class SessionHarnessIcon extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final value = '${session['backend'] ?? ''}'.trim();
|
||||
final backend = value.isEmpty ? 'opencode' : value;
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final Widget mark = switch (backend) {
|
||||
'opencode' || 'claude' => ImageIcon(
|
||||
AssetImage('assets/harnesses/$backend.png'),
|
||||
color: color,
|
||||
),
|
||||
'codex' => Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.code,
|
||||
color: color,
|
||||
),
|
||||
'pi' => Icon(
|
||||
cupertino ? CupertinoIcons.function : Icons.functions,
|
||||
color: color,
|
||||
),
|
||||
_ => Icon(
|
||||
cupertino
|
||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
||||
: Icons.terminal,
|
||||
color: color,
|
||||
),
|
||||
'codex' => Icon(Icons.code, color: color),
|
||||
'pi' => Icon(Icons.functions, color: color),
|
||||
_ => Icon(Icons.terminal, color: color),
|
||||
};
|
||||
return Semantics(
|
||||
label: '${chatBackendLabel(backend)} harness',
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_sessions_body.dart';
|
||||
import 'chat_list_viewport.dart';
|
||||
import 'session_list_items.dart';
|
||||
import '../../../../ui/adaptive/floating_bar_layout.dart';
|
||||
|
||||
class CupertinoSessionList extends StatelessWidget {
|
||||
const CupertinoSessionList({
|
||||
super.key,
|
||||
required this.sections,
|
||||
required this.emptyMessage,
|
||||
required this.duplicateTitles,
|
||||
required this.onOpen,
|
||||
this.onOpenBeside,
|
||||
this.onOpenBelow,
|
||||
required this.onRename,
|
||||
required this.onClose,
|
||||
required this.onReopen,
|
||||
required this.onStar,
|
||||
this.onColor,
|
||||
required this.onHide,
|
||||
required this.onClearSearch,
|
||||
required this.isUnseen,
|
||||
required this.errorFor,
|
||||
this.folds,
|
||||
this.activeSessionId,
|
||||
this.visibleSessionIds = const {},
|
||||
this.onDismissError,
|
||||
this.selectionOnly = false,
|
||||
});
|
||||
|
||||
final List<ChatSessionSection> sections;
|
||||
final bool selectionOnly;
|
||||
final ChatSectionFolds? folds;
|
||||
final String? activeSessionId;
|
||||
final Set<String> visibleSessionIds;
|
||||
final String? emptyMessage;
|
||||
final Set<String> duplicateTitles;
|
||||
final ValueChanged<JsonMap> onOpen;
|
||||
final ValueChanged<JsonMap>? onOpenBeside;
|
||||
final ValueChanged<JsonMap>? onOpenBelow;
|
||||
final ValueChanged<JsonMap> onRename;
|
||||
final ValueChanged<JsonMap> onClose;
|
||||
final ValueChanged<JsonMap> onReopen;
|
||||
final ValueChanged<JsonMap> onStar;
|
||||
final ValueChanged<JsonMap>? onColor;
|
||||
final ValueChanged<JsonMap> onHide;
|
||||
final VoidCallback? onClearSearch;
|
||||
final bool Function(JsonMap) isUnseen;
|
||||
final String? Function(String sessionId) errorFor;
|
||||
final ValueChanged<String>? onDismissError;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ChatListViewport(
|
||||
builder: (context) {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
// Starts below a floating top bar (its height arrives as media top
|
||||
// padding) and ends clear of a floating bottom bar.
|
||||
padding: withFloatingBarClearance(
|
||||
context,
|
||||
EdgeInsets.only(
|
||||
top: MediaQuery.paddingOf(context).top,
|
||||
bottom: 24,
|
||||
),
|
||||
),
|
||||
sliver: SliverMainAxisGroup(
|
||||
slivers: [
|
||||
for (final section in sections) _section(section),
|
||||
if (emptyMessage != null)
|
||||
SliverToBoxAdapter(
|
||||
child: ChatCupertinoMessage(
|
||||
message: emptyMessage!,
|
||||
actionLabel: onClearSearch == null
|
||||
? null
|
||||
: 'Clear search',
|
||||
onAction: onClearSearch,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Widget _section(ChatSessionSection section) => chatSessionSection(
|
||||
section: section,
|
||||
folds: folds ?? ChatSectionFolds(),
|
||||
directoryHeader: _DirectoryHeader.new,
|
||||
row: (session, {required divider}) => chatSessionRowItem(
|
||||
session,
|
||||
selectionOnly: selectionOnly,
|
||||
divider: divider,
|
||||
activeSessionId: activeSessionId,
|
||||
visibleSessionIds: visibleSessionIds,
|
||||
duplicateTitles: duplicateTitles,
|
||||
isUnseen: isUnseen,
|
||||
onOpen: onOpen,
|
||||
onOpenBeside: onOpenBeside,
|
||||
onOpenBelow: onOpenBelow,
|
||||
onStar: onStar,
|
||||
onColor: onColor,
|
||||
onRename: onRename,
|
||||
onClose: onClose,
|
||||
onReopen: onReopen,
|
||||
onHide: onHide,
|
||||
),
|
||||
errorFor: errorFor,
|
||||
onDismissError: onDismissError,
|
||||
);
|
||||
}
|
||||
|
||||
/// A directory's name above its chats, like a grouped table's header.
|
||||
class _DirectoryHeader extends StatelessWidget {
|
||||
const _DirectoryHeader(this.directory);
|
||||
|
||||
final String directory;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 6),
|
||||
child: Text(
|
||||
directory,
|
||||
style: style,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import 'session_row_memo.dart';
|
||||
typedef SessionListItem = ({Key key, WidgetBuilder build});
|
||||
|
||||
/// A chat section as a sliver: its heading and its rows, built only when on
|
||||
/// screen. Material and Cupertino supply their own directory header.
|
||||
/// screen. Material supplies its own directory header.
|
||||
Widget chatSessionSection({
|
||||
required ChatSessionSection section,
|
||||
required ChatSectionFolds folds,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import '../../../../core/servers/server_context.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
@@ -10,7 +9,6 @@ import '../../../../ui/motion/container_transform_source.dart';
|
||||
import '../../domain/chat_colors.dart';
|
||||
import '../../domain/chat_list_activity.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_color_palette.dart';
|
||||
import 'chat_visibility_marker.dart';
|
||||
import 'chat_session_state.dart';
|
||||
@@ -63,20 +61,11 @@ class ChatSessionRow extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final id = '${session['id'] ?? ''}';
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final accent = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final accent = Theme.of(context).colorScheme.primary;
|
||||
final shade = chatColorShade(context, chatSessionColor(session));
|
||||
final marker = shade ?? accent;
|
||||
final tint = AppListRow.tintFor(context, shade, cupertino: cupertino);
|
||||
final background = cupertino
|
||||
? CupertinoDynamicColor.resolve(
|
||||
CupertinoTheme.of(context).scaffoldBackgroundColor,
|
||||
context,
|
||||
)
|
||||
: Theme.of(context).scaffoldBackgroundColor;
|
||||
final tint = AppListRow.tintFor(context, shade, cupertino: false);
|
||||
final background = Theme.of(context).scaffoldBackgroundColor;
|
||||
// On a phone the chat's page grows out of this row and shrinks back
|
||||
// into it; the surface it starts from is the row's tint over the list.
|
||||
return ContainerTransformSource(
|
||||
@@ -89,8 +78,6 @@ class ChatSessionRow extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _marked(BuildContext context, String id, Color marker, Color accent) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed';
|
||||
final unread = unseen && !closed;
|
||||
final text = chatSessionSubtitle(session);
|
||||
@@ -110,7 +97,7 @@ class ChatSessionRow extends StatelessWidget {
|
||||
active: selected,
|
||||
child: AppListRow(
|
||||
key: Key('chat-row-$id'),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
selected: selected,
|
||||
selectedFill: Colors.transparent,
|
||||
emphasized: unread,
|
||||
@@ -131,7 +118,7 @@ class ChatSessionRow extends StatelessWidget {
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 4),
|
||||
child: _Star(cupertino: cupertino, color: accent),
|
||||
child: _Star(color: accent),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -191,16 +178,15 @@ DateTime? _chatSessionInstant(Object? updatedAt) {
|
||||
|
||||
/// As tall as the title's text, so it follows text scaling.
|
||||
class _Star extends StatelessWidget {
|
||||
const _Star({required this.cupertino, required this.color});
|
||||
const _Star({required this.color});
|
||||
|
||||
final bool cupertino;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = DefaultTextStyle.of(context).style.fontSize ?? 14;
|
||||
return Icon(
|
||||
cupertino ? CupertinoIcons.star_fill : Icons.star,
|
||||
Icons.star,
|
||||
key: const Key('chat-row-starred'),
|
||||
size: MediaQuery.textScalerOf(context).scale(size),
|
||||
color: color,
|
||||
@@ -229,8 +215,6 @@ class ChatSessionAvatar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final Color fill;
|
||||
final Color mark;
|
||||
final color = chatColorShade(context, chatSessionColor(session));
|
||||
@@ -241,12 +225,6 @@ class ChatSessionAvatar extends StatelessWidget {
|
||||
fill = color.withValues(
|
||||
alpha: chatColorDarkSurface(context) ? 0.26 : 0.16,
|
||||
);
|
||||
} else if (cupertino) {
|
||||
final primary = CupertinoTheme.of(context).primaryColor;
|
||||
fill = selected
|
||||
? primary.withValues(alpha: 0.2)
|
||||
: CupertinoColors.systemGrey5.resolveFrom(context);
|
||||
mark = selected ? primary : CupertinoColors.label.resolveFrom(context);
|
||||
} else {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
fill = selected
|
||||
@@ -258,7 +236,7 @@ class ChatSessionAvatar extends StatelessWidget {
|
||||
foreground: mark,
|
||||
background: fill,
|
||||
badge: chatSessionActivityBadge(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
running: running,
|
||||
backgroundTasks: backgroundTasks,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user