ui: fold the composer to one line until it has focus
dsh-Go opens the input into two rows only while focused: the text above, the model / mode / keys below, folding back when focus leaves. ComposerBox keeps the field across the two layouts with a GlobalKey and animates the swap. Model and thinking level are now one control (ModelPill shows "model · effort" and the sheet offers the level after choosing a model); Build/Plan is a separate ModeChip. The draft page uses the same box, with its project chip above it. 0.3.15 (315).
This commit is contained in:
1 parent
7f2f454539
commit
ea3b1f0f5e
8 files changed
+553
-430
No files matched your search
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
|
||||
import '../api/models.dart';
|
||||
import '../state.dart';
|
||||
import '../widgets/composer_attachment.dart';
|
||||
import '../widgets/composer_box.dart';
|
||||
import '../widgets/model_controls.dart';
|
||||
import '../widgets/slash_palette.dart';
|
||||
import 'files_panel.dart';
|
||||
@@ -244,16 +245,11 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
|
||||
fontSize: 12.5, color: scheme.error),
|
||||
),
|
||||
),
|
||||
ModelControlsBar(
|
||||
app: widget.app,
|
||||
model: draft.model,
|
||||
agent: draft.agent,
|
||||
leading: _projectChip(draft),
|
||||
onModel: (m) => widget.app.updateDraftModel(m),
|
||||
onAgent: (a) =>
|
||||
widget.app.updateDraftModel(null, agent: a),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: _projectChip(draft),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
const SizedBox(height: 4),
|
||||
if (_attachments.isNotEmpty)
|
||||
AttachmentTray(
|
||||
items: _attachments,
|
||||
@@ -305,68 +301,75 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
|
||||
final sending = widget.app.sendingDraft;
|
||||
final slash = _slashMatches();
|
||||
final slashRows = slash ?? const <SlashItem>[];
|
||||
Widget body = Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(26),
|
||||
Widget body = ComposerBox(
|
||||
controller: _text,
|
||||
focusNode: _inputFocus,
|
||||
hint: '规划、构建或提问',
|
||||
maxLines: 5,
|
||||
textInputAction:
|
||||
slash != null ? TextInputAction.send : TextInputAction.newline,
|
||||
onSubmitted: slash == null || slashRows.isEmpty
|
||||
? null
|
||||
: (_) => _pickSlash(
|
||||
slashRows[_slashIndex.clamp(0, slashRows.length - 1)]),
|
||||
onChanged: (v) {
|
||||
widget.app.updateDraftText(v);
|
||||
_slashIndex = 0;
|
||||
if (_slashDismissed != null && v != _slashDismissed) {
|
||||
_slashDismissed = null;
|
||||
}
|
||||
if (v.trimLeft().startsWith('/')) _ensureSlash();
|
||||
setState(() {});
|
||||
if (slash != null && v.endsWith('\n')) {
|
||||
final trimmed = v.trimRight();
|
||||
_text.value = TextEditingValue(
|
||||
text: trimmed,
|
||||
selection: TextSelection.collapsed(offset: trimmed.length),
|
||||
);
|
||||
widget.app.updateDraftText(trimmed);
|
||||
final rows = _slashMatches() ?? const <SlashItem>[];
|
||||
if (rows.isNotEmpty) {
|
||||
_pickSlash(rows[_slashIndex.clamp(0, rows.length - 1)]);
|
||||
}
|
||||
}
|
||||
},
|
||||
leading: _roundKey(
|
||||
icon: Icons.attach_file,
|
||||
label: '添加附件',
|
||||
onTap: _pickFiles,
|
||||
busy: _attaching,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
_roundKey(
|
||||
icon: Icons.attach_file,
|
||||
label: '添加附件',
|
||||
onTap: _pickFiles,
|
||||
busy: _attaching,
|
||||
model: ModelPill(
|
||||
app: widget.app,
|
||||
model: _draft.model,
|
||||
onModel: (m) => widget.app.updateDraftModel(m),
|
||||
),
|
||||
mode: ModeChip(
|
||||
app: widget.app,
|
||||
agent: _draft.agent,
|
||||
onAgent: (a) => widget.app.updateDraftModel(null, agent: a),
|
||||
),
|
||||
trailing: InkWell(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
onTap: sending || !_canSend ? null : _send,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: _canSend || sending ? scheme.primary : scheme.surface,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _text,
|
||||
focusNode: _inputFocus,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
keyboardType: TextInputType.multiline,
|
||||
textInputAction: slash != null
|
||||
? TextInputAction.send
|
||||
: TextInputAction.newline,
|
||||
onSubmitted: slash == null || slashRows.isEmpty
|
||||
? null
|
||||
: (_) => _pickSlash(
|
||||
slashRows[_slashIndex.clamp(0, slashRows.length - 1)]),
|
||||
onChanged: (v) {
|
||||
widget.app.updateDraftText(v);
|
||||
_slashIndex = 0;
|
||||
if (_slashDismissed != null && v != _slashDismissed) {
|
||||
_slashDismissed = null;
|
||||
}
|
||||
if (v.trimLeft().startsWith('/')) _ensureSlash();
|
||||
setState(() {});
|
||||
if (slash != null && v.endsWith('\n')) {
|
||||
final trimmed = v.trimRight();
|
||||
_text.value = TextEditingValue(
|
||||
text: trimmed,
|
||||
selection: TextSelection.collapsed(offset: trimmed.length),
|
||||
);
|
||||
widget.app.updateDraftText(trimmed);
|
||||
final rows = _slashMatches() ?? const <SlashItem>[];
|
||||
if (rows.isNotEmpty) {
|
||||
_pickSlash(rows[_slashIndex.clamp(0, rows.length - 1)]);
|
||||
}
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
isCollapsed: true,
|
||||
border: InputBorder.none,
|
||||
hintText: '规划、构建或提问',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
_sendKey(theme, sending),
|
||||
],
|
||||
child: sending
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2, color: scheme.onPrimary))
|
||||
: Icon(Icons.arrow_upward,
|
||||
size: 20,
|
||||
color: _canSend ? scheme.onPrimary : theme.hintColor),
|
||||
),
|
||||
),
|
||||
);
|
||||
return Column(
|
||||
@@ -437,34 +440,6 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sendKey(ThemeData theme, bool sending) {
|
||||
final scheme = theme.colorScheme;
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
onTap: sending || !_canSend ? null : _send,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: _canSend || sending
|
||||
? scheme.primary
|
||||
: scheme.surface,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: sending
|
||||
? SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2, color: scheme.onPrimary))
|
||||
: Icon(Icons.arrow_upward,
|
||||
size: 20,
|
||||
color: _canSend ? scheme.onPrimary : theme.hintColor),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pickProject() async {
|
||||
final app = widget.app;
|
||||
await app.refreshProjects();
|
||||
|
||||
Reference in new issue
Block a user