feat: English and Chinese, and selectable chat text

- settings → general → language picks system, Chinese or English; the
  choice is stored on the device and read before the first frame
- our Chinese strings are translated through tr()/trArgs() and AppText,
  with the English in lib/l10n/en_*.dart; a missing entry falls back to
  Chinese and a test checks that every literal in lib has one
- AppText rebuilds on a language change (it depends on the resolved
  locale), so const text and whole pages switch at once; the built-in
  date/time pickers and selection menu follow the same language
- server and user data (titles, messages, prompts, paths) is never
  translated
- the chat list sits in a SelectionArea: long-press selects message text
  and shows the copy/select-all menu
- bump to 0.5.2
This commit is contained in:
blumia committed 2026-11-26 09:04:25 +08:00
1 parent da4bfb6826
commit 7b5bccf28f
42 files changed
+1943 -735

No files matched your search

+4 -3
View File
@@ -6,6 +6,7 @@ import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import '../l10n.dart';
class ComposerAttachment {
final String name;
@@ -35,7 +36,7 @@ Future<List<ComposerAttachment>> pickComposerAttachments(
if (bytes.length > 10 * 1024 * 1024) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('附件不能超过 10MB')));
const SnackBar(content: AppText('附件不能超过 10MB')));
}
continue;
}
@@ -83,7 +84,7 @@ class AttachmentTray extends StatelessWidget {
: const Icon(Icons.insert_drive_file, size: 16),
label: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 160),
child: Text(items[i].name,
child: AppText(items[i].name,
maxLines: 1, overflow: TextOverflow.ellipsis),
),
onDeleted: () => onRemove(i),
@@ -132,4 +133,4 @@ Future<String?> _keepImage(String src, String name) async {
} catch (_) {
return null;
}
}
}
+8 -7
View File
@@ -6,6 +6,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../api/models.dart';
import '../l10n.dart';
enum DiffLineKind { context, add, del, hunk, meta }
@@ -246,8 +247,8 @@ class DiffView extends StatelessWidget {
child: Row(
children: [
Expanded(
child: Text(
file.path ?? '文件 ${fileIndex + 1}',
child: AppText(
file.path ?? trArgs('文件 {0}', [fileIndex + 1]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -278,7 +279,7 @@ class DiffView extends StatelessWidget {
rows.add(Container(
color: background,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 1),
child: Text(
child: AppText(
line.text.isEmpty ? ' ' : line.text,
style: mono.copyWith(color: foreground),
),
@@ -288,8 +289,8 @@ class DiffView extends StatelessWidget {
if (total > maxLines) {
rows.add(Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
child: Text(
'仅显示前 $maxLines 行,共 $total 行',
child: AppText(
trArgs('仅显示前 {0} 行,共 {1} 行', [maxLines, total]),
style: TextStyle(fontSize: 11, color: theme.hintColor),
),
));
@@ -332,10 +333,10 @@ class DiffStats extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (added > 0) Text('+$added', style: style.copyWith(color: addFg)),
if (added > 0) AppText('+$added', style: style.copyWith(color: addFg)),
if (added > 0 && removed > 0) const SizedBox(width: 4),
if (removed > 0)
Text('−$removed', style: style.copyWith(color: delFg)),
AppText('−$removed', style: style.copyWith(color: delFg)),
],
);
}
+5 -4
View File
@@ -6,6 +6,7 @@ import '../api/models.dart';
import '../model_prefs.dart';
import '../state.dart';
import 'model_picker.dart';
import '../l10n.dart';
/// `deepseek-flash · 高` — model and effort together, as dsh-Go shows them.
class ModelPill extends StatelessWidget {
@@ -89,7 +90,7 @@ class ModeChip extends StatelessWidget {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(20, 4, 20, 8),
child: Text('模式',
child: AppText('模式',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700)),
),
for (final id in ids)
@@ -98,13 +99,13 @@ class ModeChip extends StatelessWidget {
id == 'plan' ? Icons.map_outlined : Icons.construction_outlined,
color: id == current ? scheme.primary : null,
),
title: Text(
title: AppText(
names[id]?.isNotEmpty == true ? names[id]! : _label(id),
style: TextStyle(
fontWeight: id == current ? FontWeight.w700 : FontWeight.w400,
),
),
subtitle: Text(id == 'plan' ? '先规划,不改动文件' : '直接构建',
subtitle: AppText(id == 'plan' ? '先规划,不改动文件' : '直接构建',
style: const TextStyle(fontSize: 12)),
trailing: id == current
? Icon(Icons.check, size: 20, color: scheme.primary)
@@ -150,7 +151,7 @@ class _Pill extends StatelessWidget {
Icon(icon, size: 14, color: theme.hintColor),
const SizedBox(width: 4),
Flexible(
child: Text(
child: AppText(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
+20 -18
View File
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import '../api/models.dart';
import '../model_prefs.dart';
import '../state.dart';
import '../l10n.dart';
Future<void> showModelPickerSheet(
BuildContext context, {
@@ -69,16 +70,16 @@ class _PickerSheetState extends State<_PickerSheet> {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(12, 12, 12, 4),
child: Text('选择模型',
child: AppText('选择模型',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
Padding(
padding: const EdgeInsets.all(12),
child: TextField(
onChanged: (v) => setState(() => _filter = v),
decoration: const InputDecoration(
hintText: '搜索',
border: OutlineInputBorder(),
decoration: InputDecoration(
hintText: tr('搜索'),
border: const OutlineInputBorder(),
isDense: true),
),
),
@@ -92,7 +93,7 @@ class _PickerSheetState extends State<_PickerSheet> {
Widget _models() {
final all = widget.app.modelList;
if (all.isEmpty) {
return const Center(child: Text('正在载入模型…'));
return const Center(child: AppText('正在载入模型…'));
}
final filter = _filter.trim().toLowerCase();
final matching = filter.isEmpty
@@ -103,7 +104,7 @@ class _PickerSheetState extends State<_PickerSheet> {
m.id.toLowerCase().contains(filter))
m,
];
if (matching.isEmpty) return const Center(child: Text('没有结果'));
if (matching.isEmpty) return const Center(child: AppText('没有结果'));
final byKey = {
for (final m in all) ModelPrefs.keyFor(m.providerId, m.id): m,
@@ -125,7 +126,7 @@ class _PickerSheetState extends State<_PickerSheet> {
final children = <Widget>[];
if (filter.isEmpty) {
if (favorites.isNotEmpty) {
children.add(_sectionHeader('收藏', 'favorites', count: favorites.length));
children.add(_sectionHeader(tr('收藏'), 'favorites', count: favorites.length));
if (!_collapsed.contains('favorites')) {
for (final model in favorites) {
children.add(_modelRow(model));
@@ -133,7 +134,7 @@ class _PickerSheetState extends State<_PickerSheet> {
}
}
if (recents.isNotEmpty) {
children.add(_sectionHeader('最近', 'recents', count: recents.length));
children.add(_sectionHeader(tr('最近'), 'recents', count: recents.length));
if (!_collapsed.contains('recents')) {
for (final model in recents) {
children.add(_modelRow(model));
@@ -142,7 +143,7 @@ class _PickerSheetState extends State<_PickerSheet> {
}
}
for (final entry in providers.entries) {
final label = entry.key.isEmpty ? '其它' : entry.key;
final label = entry.key.isEmpty ? tr('其它') : entry.key;
children.add(_sectionHeader(label, 'provider:${entry.key}',
count: entry.value.length));
if (!_collapsed.contains('provider:${entry.key}')) {
@@ -172,8 +173,8 @@ class _PickerSheetState extends State<_PickerSheet> {
size: 16, color: Theme.of(context).hintColor),
const SizedBox(width: 4),
Expanded(
child: Text(
count == null ? label : '$label($count)',
child: AppText(
count == null ? label : trArgs('{0}({1})', [label, count]),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w700,
@@ -199,7 +200,7 @@ class _PickerSheetState extends State<_PickerSheet> {
title: Row(
children: [
Flexible(
child: Text(model.name,
child: AppText(model.name,
maxLines: 1, overflow: TextOverflow.ellipsis),
),
if (model.reasoning)
@@ -211,7 +212,8 @@ class _PickerSheetState extends State<_PickerSheet> {
],
),
subtitle: model.context > 0
? Text('${formatTokenCount(model.context)} 上下文',
? AppText(
trArgs('{0} 上下文', [formatTokenCount(model.context)]),
style: TextStyle(fontSize: 11, color: theme.hintColor))
: null,
trailing: Row(
@@ -230,7 +232,7 @@ class _PickerSheetState extends State<_PickerSheet> {
size: 18,
color: favorite ? theme.colorScheme.primary : theme.hintColor,
),
tooltip: favorite ? '取消收藏' : '收藏',
tooltip: favorite ? tr('取消收藏') : tr('收藏'),
onPressed: () async {
await _prefs.toggleFavorite(key);
if (mounted) setState(() {});
@@ -287,12 +289,12 @@ class _PickerSheetState extends State<_PickerSheet> {
children: [
Row(
children: [
const Text('思考强度',
const AppText('思考强度',
style: TextStyle(
fontSize: 13, fontWeight: FontWeight.w700)),
const SizedBox(width: 6),
Expanded(
child: Text(model.name,
child: AppText(model.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style:
@@ -300,7 +302,7 @@ class _PickerSheetState extends State<_PickerSheet> {
),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('完成'),
child: const AppText('完成'),
),
],
),
@@ -310,7 +312,7 @@ class _PickerSheetState extends State<_PickerSheet> {
children: [
for (final option in options)
ChoiceChip(
label: Text(effortLabel(option),
label: AppText(effortLabel(option),
style: const TextStyle(fontSize: 12.5)),
selected: (_effortVariant ?? '') == (option ?? ''),
onSelected: (_) => _pickEffort(model, option),
+40 -39
View File
@@ -7,6 +7,7 @@ import '../api/models.dart';
import '../api/scheduled_tasks.dart';
import '../state.dart';
import 'model_picker.dart';
import '../l10n.dart';
class ScheduledTaskEditor extends StatefulWidget {
final AppState app;
@@ -120,7 +121,7 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
child: Row(
children: [
Expanded(
child: Text(
child: AppText(
widget.initial == null ? '新建计划任务' : '编辑计划任务',
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
@@ -128,7 +129,7 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
),
TextButton(
onPressed: _saving ? null : _save,
child: Text(_saving ? '保存中…' : '保存'),
child: AppText(_saving ? '保存中…' : '保存'),
),
],
),
@@ -137,16 +138,16 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
child: ListView(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 32),
children: [
Text('运行位置:${widget.scopeLabel}',
AppText(trArgs('运行位置:{0}', [widget.scopeLabel]),
style: TextStyle(fontSize: 12.5, color: theme.hintColor)),
const SizedBox(height: 12),
TextField(
controller: _name,
maxLength: 80,
decoration: const InputDecoration(
labelText: '任务名称',
hintText: '每日同步',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: tr('任务名称'),
hintText: tr('每日同步'),
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 8),
@@ -154,10 +155,10 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
controller: _prompt,
minLines: 4,
maxLines: 10,
decoration: const InputDecoration(
labelText: '提示词',
hintText: '总结未完成任务并给出下一步建议',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: tr('提示词'),
hintText: tr('总结未完成任务并给出下一步建议'),
border: const OutlineInputBorder(),
alignLabelWithHint: true,
),
),
@@ -169,7 +170,7 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
children: [
for (final entry in scheduledTaskKindLabels.entries)
ChoiceChip(
label: Text(entry.value),
label: AppText(entry.value),
selected: _kind == entry.key,
onSelected: (_) => setState(() => _kind = entry.key),
),
@@ -180,23 +181,23 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
const SizedBox(height: 8),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: const Text('使用默认模型与智能体'),
subtitle: const Text('关闭后可固定这次运行使用的模型和智能体。'),
title: const AppText('使用默认模型与智能体'),
subtitle: const AppText('关闭后可固定这次运行使用的模型和智能体。'),
value: _useDefaults,
onChanged: (v) => setState(() => _useDefaults = v),
),
if (!_useDefaults) ..._executionFields(theme),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: const Text('已启用'),
subtitle: const Text('暂停的任务不会按计划运行,但可以手动运行。'),
title: const AppText('已启用'),
subtitle: const AppText('暂停的任务不会按计划运行,但可以手动运行。'),
value: _enabled,
onChanged: (v) => setState(() => _enabled = v),
),
const SizedBox(height: 8),
FilledButton(
onPressed: _saving ? null : _save,
child: Text(_saving ? '保存中…' : '保存'),
child: AppText(_saving ? '保存中…' : '保存'),
),
],
),
@@ -219,7 +220,7 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
children: [
for (var day = 0; day < scheduledWeekdays.length; day++)
FilterChip(
label: Text(scheduledWeekdays[day]),
label: AppText(scheduledWeekdays[day]),
selected: _weekdays.contains(day),
onSelected: (selected) => setState(() {
if (selected) {
@@ -238,14 +239,14 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
return [
ListTile(
contentPadding: EdgeInsets.zero,
title: const Text('日期'),
trailing: Text(_dateText(_date)),
title: const AppText('日期'),
trailing: AppText(_dateText(_date)),
onTap: _pickDate,
),
ListTile(
contentPadding: EdgeInsets.zero,
title: const Text('时间'),
trailing: Text(_time),
title: const AppText('时间'),
trailing: AppText(_time),
onTap: () async {
final picked = await _pickTime(_time);
if (picked != null) setState(() => _time = picked);
@@ -256,10 +257,10 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
return [
TextField(
controller: _cron,
decoration: const InputDecoration(
labelText: 'Cron 表达式',
decoration: InputDecoration(
labelText: tr('Cron 表达式'),
hintText: '*/5 * * * *',
border: OutlineInputBorder(),
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 8),
@@ -275,7 +276,7 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
('每月 1 日', '0 9 1 * *'),
])
ActionChip(
label: Text(example.$1),
label: AppText(example.$1),
onPressed: () =>
setState(() => _cron.text = example.$2),
),
@@ -302,12 +303,12 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
final picked = await _pickTime(_times[i]);
if (picked != null) setState(() => _times[i] = picked);
},
child: Text(_times[i]),
child: AppText(_times[i]),
),
),
IconButton(
icon: const Icon(Icons.remove_circle_outline, size: 20),
tooltip: '移除时间',
tooltip: tr('移除时间'),
onPressed: _times.length <= 1
? null
: () => setState(() => _times.removeAt(i)),
@@ -321,9 +322,9 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
if (picked != null) setState(() => _times.add(picked));
},
icon: const Icon(Icons.add, size: 18),
label: const Text('添加时间'),
label: const AppText('添加时间'),
),
Text('时间按服务器所在时区。', style: TextStyle(fontSize: 11.5, color: theme.hintColor)),
AppText('时间按服务器所在时区。', style: TextStyle(fontSize: 11.5, color: theme.hintColor)),
],
);
}
@@ -337,15 +338,15 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
ListTile(
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.memory, size: 20),
title: const Text('模型'),
trailing: Text(model, overflow: TextOverflow.ellipsis),
title: const AppText('模型'),
trailing: AppText(model, overflow: TextOverflow.ellipsis),
onTap: _pickModel,
),
ListTile(
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.smart_toy_outlined, size: 20),
title: const Text('智能体'),
trailing: Text(agent, overflow: TextOverflow.ellipsis),
title: const AppText('智能体'),
trailing: AppText(agent, overflow: TextOverflow.ellipsis),
onTap: _pickAgent,
),
];
@@ -403,13 +404,13 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
shrinkWrap: true,
children: [
ListTile(
title: const Text('默认智能体'),
title: const AppText('默认智能体'),
trailing: _agent.isEmpty ? const Icon(Icons.check, size: 20) : null,
onTap: () => Navigator.pop(sheet, ''),
),
for (final agent in widget.app.agentList)
ListTile(
title: Text(agent.name.isEmpty ? agent.id : agent.name),
title: AppText(agent.name.isEmpty ? agent.id : agent.name),
trailing: _agent == agent.id
? const Icon(Icons.check, size: 20)
: null,
@@ -446,7 +447,7 @@ class _ScheduledTaskEditorState extends State<ScheduledTaskEditor> {
problem = '请选择模型,或改回使用默认模型';
}
if (problem != null) {
messenger.showSnackBar(SnackBar(content: Text(problem)));
messenger.showSnackBar(SnackBar(content: AppText(problem)));
return;
}
setState(() => _saving = true);
@@ -487,8 +488,8 @@ class _FieldLabel extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Text(text,
child: AppText(text,
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
);
}
}
}
+25 -24
View File
@@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
import '../api/client.dart';
import '../api/shells.dart';
import '../l10n.dart';
/// One line of "正在执行 N 条命令", folding when there are many.
class ShellTaskBar extends StatefulWidget {
@@ -86,8 +87,8 @@ class _ShellTaskBarState extends State<ShellTaskBar> {
Icon(Icons.terminal, size: 15, color: theme.hintColor),
const SizedBox(width: 8),
Expanded(
child: Text(
'正在执行 $count 条命令',
child: AppText(
trArgs('正在执行 {0} 条命令', [count]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -130,7 +131,7 @@ class _ShellTaskRow extends StatelessWidget {
Icon(Icons.terminal, size: 15, color: theme.hintColor),
const SizedBox(width: 8),
Expanded(
child: Text(
child: AppText(
task.command.replaceAll(RegExp(r'\s+'), ' ').trim(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -140,7 +141,7 @@ class _ShellTaskRow extends StatelessWidget {
),
if (subagent) ...[
const SizedBox(width: 6),
Text('子代理',
AppText('子代理',
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.onSurfaceVariant,
@@ -194,7 +195,7 @@ class _ShellElapsedState extends State<ShellElapsed> {
if (widget.startedAt <= 0 || !widget.running) return const SizedBox.shrink();
final label =
formatElapsed(DateTime.now().millisecondsSinceEpoch - widget.startedAt);
return Text(
return AppText(
label,
style: TextStyle(
fontSize: 12,
@@ -337,7 +338,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
Icon(Icons.terminal, size: 18, color: theme.hintColor),
const SizedBox(width: 10),
Expanded(
child: Text(
child: AppText(
widget.task.command,
maxLines: 2,
overflow: TextOverflow.ellipsis,
@@ -361,7 +362,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
Icon(Icons.check_circle_outline,
size: 15, color: theme.hintColor),
const SizedBox(width: 6),
Text('已结束',
AppText('已结束',
style:
TextStyle(fontSize: 12, color: theme.hintColor)),
],
@@ -370,7 +371,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
TextButton.icon(
onPressed: _stopping ? null : _stop,
icon: const Icon(Icons.stop_rounded, size: 17),
label: Text(_stopping ? '停止中…' : '停止'),
label: AppText(_stopping ? '停止中…' : '停止'),
style: TextButton.styleFrom(
foregroundColor: theme.colorScheme.error,
minimumSize: const Size(0, 32),
@@ -380,7 +381,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
TextButton.icon(
onPressed: _text.isEmpty ? null : _copy,
icon: const Icon(Icons.copy, size: 15),
label: const Text('复制'),
label: const AppText('复制'),
style: TextButton.styleFrom(
minimumSize: const Size(0, 32),
padding: const EdgeInsets.symmetric(horizontal: 10),
@@ -408,7 +409,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
),
const SizedBox(height: 10),
],
Text(
AppText(
_feed.error ??
(!_feed.loaded
? '读取输出…'
@@ -446,7 +447,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
_onFeed();
},
icon: const Icon(Icons.arrow_downward, size: 15),
label: const Text('回到最新'),
label: const AppText('回到最新'),
style: FilledButton.styleFrom(
visualDensity: VisualDensity.compact,
),
@@ -464,7 +465,7 @@ class _ShellOutputSheetState extends State<ShellOutputSheet> {
await Clipboard.setData(ClipboardData(text: _text));
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('已复制输出')));
.showSnackBar(const SnackBar(content: AppText('已复制输出')));
}
}
}
@@ -541,15 +542,15 @@ class _ShellOutputInlineState extends State<ShellOutputInline> {
children: [
Icon(Icons.terminal, size: 15, color: theme.hintColor),
const SizedBox(width: 8),
Text('后台输出',
AppText('后台输出',
style: TextStyle(fontSize: 12, color: theme.hintColor)),
const SizedBox(width: 8),
if (!ended)
Text('运行中',
AppText('运行中',
style: TextStyle(
fontSize: 12, color: theme.colorScheme.primary)),
if (ended && text.isEmpty)
Text('已结束',
AppText('已结束',
style:
TextStyle(fontSize: 12, color: theme.hintColor)),
const Spacer(),
@@ -562,7 +563,7 @@ class _ShellOutputInlineState extends State<ShellOutputInline> {
padding: const EdgeInsets.symmetric(horizontal: 8),
textStyle: const TextStyle(fontSize: 12.5),
),
child: const Text('停止'),
child: const AppText('停止'),
),
TextButton(
onPressed: widget.onOpen,
@@ -571,14 +572,14 @@ class _ShellOutputInlineState extends State<ShellOutputInline> {
padding: const EdgeInsets.symmetric(horizontal: 8),
textStyle: const TextStyle(fontSize: 12.5),
),
child: const Text('查看全部'),
child: const AppText('查看全部'),
),
],
),
if (tail.isEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Text(
child: AppText(
_feed.error ?? (ended ? '没有输出' : '等待输出…'),
style: TextStyle(fontSize: 12, color: theme.hintColor)),
)
@@ -614,8 +615,8 @@ Future<bool?> confirmStopShell(BuildContext context, String command) {
return showDialog<bool>(
context: context,
builder: (dialog) => AlertDialog(
title: const Text('停止这个任务?'),
content: Text(
title: const AppText('停止这个任务?'),
content: AppText(
command,
maxLines: 4,
overflow: TextOverflow.ellipsis,
@@ -624,14 +625,14 @@ Future<bool?> confirmStopShell(BuildContext context, String command) {
actions: [
TextButton(
onPressed: () => Navigator.pop(dialog, false),
child: const Text('取消')),
child: const AppText('取消')),
FilledButton(
style: FilledButton.styleFrom(
backgroundColor: Theme.of(dialog).colorScheme.error,
foregroundColor: Theme.of(dialog).colorScheme.onError,
),
onPressed: () => Navigator.pop(dialog, true),
child: const Text('停止'),
child: const AppText('停止'),
),
],
),
@@ -727,11 +728,11 @@ class ShellOutputFeed {
_timer?.cancel();
_timer = null;
} else {
error = '读取输出失败:${e.message}';
error = trArgs('读取输出失败:{0}', [e.message]);
}
_onUpdate?.call();
} catch (e) {
error = '读取输出失败:$e';
error = trArgs('读取输出失败:{0}', ['$e']);
_onUpdate?.call();
} finally {
_busy = false;
+6 -5
View File
@@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import '../state.dart';
import '../l10n.dart';
const _slashLabels = {
'compact': '压缩',
@@ -83,11 +84,11 @@ class SlashPalette extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
AppText(title,
style:
TextStyle(fontSize: 14, color: scheme.onSurface)),
if (subtitle.isNotEmpty)
Text(subtitle,
AppText(subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -159,7 +160,7 @@ class SlashPalette extends StatelessWidget {
children: [
Row(
children: [
Text('/${item.name}',
AppText('/${item.name}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
@@ -167,7 +168,7 @@ class SlashPalette extends StatelessWidget {
if (label != null)
Padding(
padding: const EdgeInsets.only(left: 6),
child: Text(label,
child: AppText(label,
style: TextStyle(
fontSize: 12,
color: scheme.onSurfaceVariant)),
@@ -175,7 +176,7 @@ class SlashPalette extends StatelessWidget {
],
),
if (item.description.isNotEmpty)
Text(item.description,
AppText(item.description,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(