This commit is contained in:
LZX committed 2026-09-13 20:22:34 +08:00
1 parent 55f35673df
commit 9fbb414ee6
29 files changed
+3480 -460

No files matched your search

+8
View File
@@ -1,6 +1,7 @@
import 'package:code_editor/l10n/app_localizations.dart';
import 'package:code_editor/views/terminal_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:path/path.dart' as p;
import 'package:re_editor/re_editor.dart';
@@ -65,8 +66,15 @@ class CodeEditorAppBar extends StatelessWidget implements PreferredSizeWidget {
subtitleText = null;
}
final isDark = theme.brightness == Brightness.dark;
return CodeEditorTapRegion(
child: AppBar(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
statusBarBrightness: isDark ? Brightness.dark : Brightness.light,
),
backgroundColor: theme.colorScheme.primaryContainer,
foregroundColor: theme.colorScheme.onSurface,
title: Column(
+25 -18
View File
@@ -43,11 +43,11 @@ class CodeEditorTabBar extends StatelessWidget {
)..layout();
// 实际所需完整宽度(向上取整避免浮点精度缺失):
// 文本宽度 + 脏标记 (12.0) + 内外间距与关闭按钮 (33.0) + 安全呼吸缓冲空间 (16.0)
// 文本宽度 + 脏标记 (10.0) + 内外间距与关闭按钮 (26.0) + 安全缓冲空间 (10.0)
final textWidth = textPainter.width.ceilToDouble();
final dirtyWidth = isModified ? 12.0 : 0.0;
const fixedElementsWidth = 33.0; // 容器内边距(8) + 关闭按钮(24) + 边框(1)
const safetyBuffer = 16.0; // 安全呼吸空间,杜绝亚像素及字体微偏差导致的省略号
final dirtyWidth = isModified ? 10.0 : 0.0;
const fixedElementsWidth = 26.0; // 容器内边距(8) + 关闭按钮(18)
const safetyBuffer = 10.0; // 安全呼吸空间
return textWidth + dirtyWidth + fixedElementsWidth + safetyBuffer;
}
@@ -67,7 +67,7 @@ class CodeEditorTabBar extends StatelessWidget {
return CodeEditorTapRegion(
child: Container(
height: 36.0,
height: 28.0,
width: double.infinity,
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.2),
@@ -94,9 +94,16 @@ class CodeEditorTabBar extends StatelessWidget {
buildDefaultDragHandles: false,
itemCount: tabs.length,
onReorderItem: (oldIndex, newIndex) {
tabProvider.reorderTabs(oldIndex, newIndex);
int targetIndex = newIndex;
if (oldIndex < newIndex) {
targetIndex -= 1;
}
tabProvider.reorderTabs(oldIndex, targetIndex);
},
itemBuilder: (context, index) {
if (index < 0 || index >= tabs.length) {
return const SizedBox.shrink(key: ValueKey('empty_tab_placeholder'));
}
final tab = tabs[index];
final isSelected = activePath != null && tab.path == activePath;
final displayName = tab.getDisplayName(tabs, rootPath);
@@ -142,7 +149,7 @@ class CodeEditorTabBar extends StatelessWidget {
index: index,
child: Container(
width: width,
height: 36.0,
height: 28.0,
decoration: BoxDecoration(
color: isSelected
? theme.colorScheme.surface
@@ -153,11 +160,11 @@ class CodeEditorTabBar extends StatelessWidget {
width: 1.0,
),
bottom: isSelected
? BorderSide(
color: theme.colorScheme.primary,
width: 2.0,
)
: BorderSide.none,
? BorderSide(
color: theme.colorScheme.primary,
width: 2.0,
)
: BorderSide.none,
),
),
child: Material(
@@ -167,7 +174,7 @@ class CodeEditorTabBar extends StatelessWidget {
tabProvider.openFile(tab.path);
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
padding: const EdgeInsets.only(left: 6.0, right: 2.0),
child: Row(
children: [
Expanded(
@@ -182,7 +189,7 @@ class CodeEditorTabBar extends StatelessWidget {
style: TextStyle(
color: theme.colorScheme.error,
fontWeight: FontWeight.bold,
fontSize: 13.0,
fontSize: 12.0,
),
),
),
@@ -204,18 +211,18 @@ class CodeEditorTabBar extends StatelessWidget {
),
),
InkResponse(
radius: 12,
radius: 10,
borderRadius: BorderRadius.circular(4.0),
hoverColor: theme.colorScheme.onSurface.withValues(alpha: 0.12),
highlightColor: theme.colorScheme.onSurface.withValues(alpha: 0.18),
onTap: () {
tabProvider.closeTab(context, index);
tabProvider.closeTabByPath(context, tab.path);
},
child: Padding(
padding: const EdgeInsets.all(3.0),
padding: const EdgeInsets.all(2.0),
child: Icon(
Icons.close,
size: 14.0,
size: 13.0,
color: isSelected
? theme.colorScheme.onSurface
: theme.colorScheme.onSurfaceVariant,
+172 -53
View File
@@ -51,6 +51,77 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
int? _currentIndentSize;
bool _isShowingConflictDialog = false;
// 双指捏合缩放字号状态
final Map<int, Offset> _pointerPositions = {};
double? _initialPinchDistance;
double? _initialPinchFontSize;
double? _activeZoomFontSize;
bool _isPinching = false;
void _handlePointerDown(PointerDownEvent event, double currentFontSize) {
_pointerPositions[event.pointer] = event.position;
if (_pointerPositions.length == 2) {
final points = _pointerPositions.values.toList();
_initialPinchDistance = (points[0] - points[1]).distance;
_initialPinchFontSize = _activeZoomFontSize ?? currentFontSize;
setState(() {
_isPinching = true;
});
}
}
void _handlePointerMove(PointerMoveEvent event) {
if (!_pointerPositions.containsKey(event.pointer)) return;
_pointerPositions[event.pointer] = event.position;
if (_pointerPositions.length >= 2 &&
_initialPinchDistance != null &&
_initialPinchDistance! > 10.0 &&
_initialPinchFontSize != null) {
final points = _pointerPositions.values.toList();
final currentDistance = (points[0] - points[1]).distance;
final scale = currentDistance / _initialPinchDistance!;
final rawFontSize = (_initialPinchFontSize! * scale).clamp(10.0, 30.0);
final newFontSize = (rawFontSize * 10).round() / 10.0;
if (_activeZoomFontSize != newFontSize) {
setState(() {
_activeZoomFontSize = newFontSize;
});
}
}
}
void _handlePointerUp(PointerUpEvent event) {
_pointerPositions.remove(event.pointer);
if (_pointerPositions.length < 2 && _isPinching) {
_finishPinchZoom();
}
}
void _handlePointerCancel(PointerCancelEvent event) {
_pointerPositions.remove(event.pointer);
if (_pointerPositions.length < 2 && _isPinching) {
_finishPinchZoom();
}
}
void _finishPinchZoom() {
final finalSize = _activeZoomFontSize;
setState(() {
_isPinching = false;
_initialPinchDistance = null;
_initialPinchFontSize = null;
_activeZoomFontSize = null;
});
if (finalSize != null) {
try {
final settings = _getSettingsProvider(context);
settings.setFontSize(finalSize.roundToDouble());
} catch (_) {}
}
}
EditorTabItem? _getCurrentTab() {
final filePath = widget.filePath;
if (filePath == null || filePath.isEmpty) return null;
@@ -348,7 +419,7 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
bool activeWordWrap = true;
bool enableVirtualKeyboard = false;
VirtualKeyboardConfig? keyboardConfig;
AppFontItem activeEditorFont = AppFonts.editorMonospace;
AppFontItem activeEditorFont = AppFonts.editorJetBrainsMono;
try {
final settings = _getSettingsProvider(context, listen: true);
activeTheme = settings.editorTheme;
@@ -364,6 +435,8 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
}
} catch (_) {}
final double displayFontSize = _activeZoomFontSize ?? activeFontSize;
return Container(
color: activeTheme.backgroundColor,
width: double.infinity,
@@ -371,61 +444,107 @@ class _CodeEditorWidgetState extends State<CodeEditorWidget> {
child: Column(
children: [
Expanded(
child: CodeEditor(
key: ValueKey(_currentLoadedPath),
controller: controller,
focusNode: _focusNode,
scrollController: _scrollController,
wordWrap: activeWordWrap,
toolbarController: _toolbarController,
style: CodeEditorStyle(
fontSize: activeFontSize,
textColor: activeTheme.textColor,
backgroundColor: activeTheme.backgroundColor,
cursorColor: activeTheme.cursorColor,
cursorLineColor: activeTheme.cursorLineColor,
selectionColor: activeTheme.selectionColor,
fontFamily: activeEditorFont.fontFamily,
fontFamilyFallback: activeEditorFont.fallback,
codeTheme: CodeHighlightTheme(
languages: SyntaxHighlightHelper.getLanguagesForFile(_currentLoadedPath ?? widget.filePath),
theme: activeTheme.highlightTheme,
),
child: Listener(
behavior: HitTestBehavior.translucent,
onPointerDown: (event) => _handlePointerDown(event, activeFontSize),
onPointerMove: _handlePointerMove,
onPointerUp: _handlePointerUp,
onPointerCancel: _handlePointerCancel,
child: Stack(
children: [
CodeEditor(
key: ValueKey(_currentLoadedPath),
controller: controller,
focusNode: _focusNode,
scrollController: _scrollController,
wordWrap: activeWordWrap,
toolbarController: _toolbarController,
style: CodeEditorStyle(
fontSize: displayFontSize,
textColor: activeTheme.textColor,
backgroundColor: activeTheme.backgroundColor,
cursorColor: activeTheme.cursorColor,
cursorLineColor: activeTheme.cursorLineColor,
selectionColor: activeTheme.selectionColor,
fontFamily: activeEditorFont.fontFamily,
fontFamilyFallback: activeEditorFont.fallback,
codeTheme: CodeHighlightTheme(
languages: SyntaxHighlightHelper.getLanguagesForFile(_currentLoadedPath ?? widget.filePath),
theme: activeTheme.highlightTheme,
),
),
indicatorBuilder: (context, editingController, chunkController, notifier) {
return Row(
children: [
DefaultCodeLineNumber(
controller: editingController,
notifier: notifier,
textStyle: TextStyle(
color: activeTheme.gutterTextColor,
fontSize: (displayFontSize - 1).clamp(9.0, 30.0),
fontFamily: activeEditorFont.fontFamily,
fontFamilyFallback: activeEditorFont.fallback,
),
focusedTextStyle: TextStyle(
color: activeTheme.focusedGutterTextColor,
fontSize: (displayFontSize - 1).clamp(9.0, 30.0),
fontWeight: FontWeight.bold,
fontFamily: activeEditorFont.fontFamily,
fontFamilyFallback: activeEditorFont.fallback,
),
),
DefaultCodeChunkIndicator(
width: 20,
controller: chunkController,
notifier: notifier,
painter: DefaultCodeChunkIndicatorPainter(
color: activeTheme.gutterTextColor,
),
),
],
);
},
),
if (_isPinching && _activeZoomFontSize != null)
Center(
child: IgnorePointer(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
decoration: BoxDecoration(
color: Colors.black.withValues(alpha: 0.75),
borderRadius: BorderRadius.circular(24),
boxShadow: const [
BoxShadow(
color: Colors.black26,
blurRadius: 8,
offset: Offset(0, 2),
),
],
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.format_size, color: Colors.white, size: 18),
const SizedBox(width: 8),
Text(
'${_activeZoomFontSize!.round()} pt',
style: const TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.bold,
decoration: TextDecoration.none,
),
),
],
),
),
),
),
],
),
indicatorBuilder: (context, editingController, chunkController, notifier) {
return Row(
children: [
DefaultCodeLineNumber(
controller: editingController,
notifier: notifier,
textStyle: TextStyle(
color: activeTheme.gutterTextColor,
fontSize: (activeFontSize - 1).clamp(9.0, 30.0),
fontFamily: activeEditorFont.fontFamily,
fontFamilyFallback: activeEditorFont.fallback,
),
focusedTextStyle: TextStyle(
color: activeTheme.focusedGutterTextColor,
fontSize: (activeFontSize - 1).clamp(9.0, 30.0),
fontWeight: FontWeight.bold,
fontFamily: activeEditorFont.fontFamily,
fontFamilyFallback: activeEditorFont.fallback,
),
),
DefaultCodeChunkIndicator(
width: 20,
controller: chunkController,
notifier: notifier,
painter: DefaultCodeChunkIndicatorPainter(
color: activeTheme.gutterTextColor,
),
),
],
);
},
),
),
if (enableVirtualKeyboard && keyboardConfig != null)
if (enableVirtualKeyboard && keyboardConfig != null && keyboardConfig.hasKeys)
VirtualKeyboardWidget(
controller: controller,
focusNode: _focusNode,
+18 -9
View File
@@ -33,17 +33,26 @@ class TerminalDrawer extends StatelessWidget {
padding: const EdgeInsets.only(left: 16.0, right: 8.0, top: 4.0, bottom: 4.0),
child: Row(
children: [
Text(
l10n.sessionDrawerTitle,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface,
Expanded(
child: Text(
l10n.sessionDrawerTitle,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
const Spacer(),
IconButton(
icon: const Icon(Icons.add),
tooltip: l10n.addTerminalTooltip,
const SizedBox(width: 8),
TextButton.icon(
icon: const Icon(Icons.add, size: 18),
label: Text(l10n.addSession),
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(horizontal: 8),
foregroundColor: theme.colorScheme.onSurface,
),
onPressed: () {
final distroProvider = context.read<DistroProvider?>();
final currentSystem = distroProvider?.selectedSystem;
@@ -0,0 +1,390 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../models/virtual_keyboard_config.dart';
/// 编辑或添加虚拟小键盘按键的独立弹窗
class KeyEditDialog extends StatefulWidget {
final KeyboardScope scope;
final KeyboardKeyItem? initialKey;
const KeyEditDialog({
super.key,
required this.scope,
this.initialKey,
});
@override
State<KeyEditDialog> createState() => _KeyEditDialogState();
}
class _KeyEditDialogState extends State<KeyEditDialog> {
final _formKey = GlobalKey<FormState>();
late TextEditingController _labelController;
late TextEditingController _valueInputController;
late TextEditingController _cursorOffsetController;
String? _selectedIcon;
late String _selectedAction;
String? _selectedPresetValue;
@override
void initState() {
super.initState();
final init = widget.initialKey;
_labelController = TextEditingController(text: init?.label ?? '');
_valueInputController = TextEditingController(text: init?.value ?? '');
_cursorOffsetController = TextEditingController(
text: (init?.cursorOffset ?? (init?.action == 'pair' ? -1 : 0)).toString(),
);
_selectedIcon = (init?.icon != null && KeyboardIconHelper.getIcon(init!.icon) != null)
? init.icon
: null;
final availableActions = widget.scope == KeyboardScope.editor
? KeyboardScopeHelper.editorActions
: KeyboardScopeHelper.terminalActions;
if (init != null && availableActions.any((a) => a.action == init.action)) {
_selectedAction = init.action;
} else {
_selectedAction = availableActions.first.action;
}
_syncPresetValueFromInitial();
}
void _syncPresetValueFromInitial() {
final currentVal = widget.initialKey?.value ?? '';
if (_selectedAction == 'command') {
if (KeyboardScopeHelper.editorCommands.any((c) => c.value == currentVal)) {
_selectedPresetValue = currentVal;
} else {
_selectedPresetValue = KeyboardScopeHelper.editorCommands.first.value;
}
} else if (_selectedAction == 'pair') {
if (KeyboardScopeHelper.editorPairs.any((p) => p.value == currentVal)) {
_selectedPresetValue = currentVal;
} else {
_selectedPresetValue = KeyboardScopeHelper.editorPairs.first.value;
}
} else if (_selectedAction == 'modifier') {
if (KeyboardScopeHelper.terminalModifiers.any((m) => m.value == currentVal)) {
_selectedPresetValue = currentVal;
} else {
_selectedPresetValue = KeyboardScopeHelper.terminalModifiers.first.value;
}
} else if (_selectedAction == 'terminal_key') {
if (KeyboardScopeHelper.terminalKeys.any((k) => k.value == currentVal)) {
_selectedPresetValue = currentVal;
} else {
_selectedPresetValue = KeyboardScopeHelper.terminalKeys.first.value;
}
} else {
_selectedPresetValue = null;
}
}
@override
void dispose() {
_labelController.dispose();
_valueInputController.dispose();
_cursorOffsetController.dispose();
super.dispose();
}
void _onActionChanged(String? newAction) {
if (newAction == null || newAction == _selectedAction) return;
setState(() {
_selectedAction = newAction;
if (_selectedAction == 'pair') {
_selectedPresetValue = KeyboardScopeHelper.editorPairs.first.value;
if (_cursorOffsetController.text.isEmpty || _cursorOffsetController.text == '0') {
_cursorOffsetController.text = '-1';
}
if (_labelController.text.isEmpty) {
_labelController.text = _selectedPresetValue!;
}
} else if (_selectedAction == 'command') {
_selectedPresetValue = KeyboardScopeHelper.editorCommands.first.value;
} else if (_selectedAction == 'modifier') {
_selectedPresetValue = KeyboardScopeHelper.terminalModifiers.first.value;
} else if (_selectedAction == 'terminal_key') {
_selectedPresetValue = KeyboardScopeHelper.terminalKeys.first.value;
} else {
_selectedPresetValue = null;
}
});
}
void _onSave() {
if (!_formKey.currentState!.validate()) return;
final String label = _labelController.text.trim();
String value;
int cursorOffset = 0;
if (_selectedAction == 'input') {
value = _valueInputController.text;
} else {
value = _selectedPresetValue ?? '';
}
if (_selectedAction == 'pair') {
cursorOffset = int.tryParse(_cursorOffsetController.text.trim()) ?? -1;
}
final keyItem = KeyboardKeyItem(
label: label.isNotEmpty ? label : value,
icon: (_selectedIcon != null && _selectedIcon!.isNotEmpty) ? _selectedIcon : null,
action: _selectedAction,
value: value,
cursorOffset: cursorOffset,
);
Navigator.of(context).pop(keyItem);
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final availableActions = widget.scope == KeyboardScope.editor
? KeyboardScopeHelper.editorActions
: KeyboardScopeHelper.terminalActions;
return AlertDialog(
title: Text(widget.initialKey == null ? l10n.keyboardAddKeyTitle : l10n.keyboardEditKeyTitle),
content: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: SingleChildScrollView(
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 显示标签 Label
TextFormField(
controller: _labelController,
decoration: InputDecoration(
labelText: l10n.keyboardLabelFormField,
hintText: l10n.keyboardLabelFormFieldHint,
border: const OutlineInputBorder(),
isDense: true,
),
validator: (val) {
if ((val == null || val.trim().isEmpty) &&
(_selectedIcon == null || _selectedIcon!.isEmpty) &&
_selectedAction == 'input' &&
_valueInputController.text.trim().isEmpty) {
return l10n.keyboardLabelOrIconRequiredError;
}
return null;
},
),
const SizedBox(height: 14),
// 内置图标选择 Icon
DropdownButtonFormField<String?>(
isExpanded: true,
initialValue: _selectedIcon,
decoration: InputDecoration(
labelText: l10n.keyboardIconFormField,
border: const OutlineInputBorder(),
isDense: true,
),
items: [
DropdownMenuItem<String?>(
value: null,
child: Text(l10n.keyboardNoIconOption, overflow: TextOverflow.ellipsis),
),
...KeyboardIconHelper.supportedIconKeys.map(
(iconKey) => DropdownMenuItem<String?>(
value: iconKey,
child: Row(
children: [
Icon(KeyboardIconHelper.getIcon(iconKey), size: 18),
const SizedBox(width: 8),
Expanded(
child: Text(iconKey, overflow: TextOverflow.ellipsis),
),
],
),
),
),
],
onChanged: (val) {
setState(() {
_selectedIcon = val;
});
},
),
const SizedBox(height: 14),
// 动作类型 Action
DropdownButtonFormField<String>(
isExpanded: true,
initialValue: _selectedAction,
decoration: InputDecoration(
labelText: l10n.keyboardActionFormField,
border: const OutlineInputBorder(),
isDense: true,
),
items: availableActions.map(
(actionOption) => DropdownMenuItem<String>(
value: actionOption.action,
child: Text(actionOption.label, overflow: TextOverflow.ellipsis),
),
).toList(),
onChanged: _onActionChanged,
),
const SizedBox(height: 14),
// 动作值 Value 控件联动
if (_selectedAction == 'input')
TextFormField(
controller: _valueInputController,
decoration: InputDecoration(
labelText: l10n.keyboardValueFormField,
hintText: l10n.keyboardValueFormFieldHint,
border: const OutlineInputBorder(),
isDense: true,
),
validator: (val) {
if (val == null || val.isEmpty) {
return l10n.keyboardValueRequiredError;
}
return null;
},
)
else if (_selectedAction == 'pair')
DropdownButtonFormField<String>(
isExpanded: true,
initialValue: _selectedPresetValue,
decoration: InputDecoration(
labelText: l10n.keyboardPairPresetFormField,
border: const OutlineInputBorder(),
isDense: true,
),
items: KeyboardScopeHelper.editorPairs.map(
(pair) => DropdownMenuItem<String>(
value: pair.value,
child: Text('${pair.label} (${pair.value})', overflow: TextOverflow.ellipsis),
),
).toList(),
onChanged: (val) {
setState(() {
_selectedPresetValue = val;
if (_labelController.text.isEmpty && val != null) {
_labelController.text = val;
}
});
},
)
else if (_selectedAction == 'command')
DropdownButtonFormField<String>(
isExpanded: true,
initialValue: _selectedPresetValue,
decoration: InputDecoration(
labelText: l10n.keyboardCommandPresetFormField,
border: const OutlineInputBorder(),
isDense: true,
),
items: KeyboardScopeHelper.editorCommands.map(
(cmd) => DropdownMenuItem<String>(
value: cmd.value,
child: Text('${cmd.label} [${cmd.value}]', overflow: TextOverflow.ellipsis),
),
).toList(),
onChanged: (val) {
setState(() {
_selectedPresetValue = val;
});
},
)
else if (_selectedAction == 'modifier')
DropdownButtonFormField<String>(
isExpanded: true,
initialValue: _selectedPresetValue,
decoration: InputDecoration(
labelText: l10n.keyboardModifierPresetFormField,
border: const OutlineInputBorder(),
isDense: true,
),
items: KeyboardScopeHelper.terminalModifiers.map(
(m) => DropdownMenuItem<String>(
value: m.value,
child: Text(m.label, overflow: TextOverflow.ellipsis),
),
).toList(),
onChanged: (val) {
setState(() {
_selectedPresetValue = val;
});
},
)
else if (_selectedAction == 'terminal_key')
DropdownButtonFormField<String>(
isExpanded: true,
initialValue: _selectedPresetValue,
decoration: InputDecoration(
labelText: l10n.keyboardTerminalKeyPresetFormField,
border: const OutlineInputBorder(),
isDense: true,
),
items: KeyboardScopeHelper.terminalKeys.map(
(k) => DropdownMenuItem<String>(
value: k.value,
child: Text(k.label, overflow: TextOverflow.ellipsis),
),
).toList(),
onChanged: (val) {
setState(() {
_selectedPresetValue = val;
});
},
),
// 仅当 action == pair 时显示 cursorOffset
if (_selectedAction == 'pair') ...[
const SizedBox(height: 14),
TextFormField(
controller: _cursorOffsetController,
keyboardType: const TextInputType.numberWithOptions(signed: true),
decoration: InputDecoration(
labelText: l10n.keyboardCursorOffsetFormField,
helperText: l10n.keyboardCursorOffsetHelper,
border: const OutlineInputBorder(),
isDense: true,
),
validator: (val) {
if (val == null || val.trim().isEmpty) {
return l10n.keyboardCursorOffsetRequiredError;
}
if (int.tryParse(val.trim()) == null) {
return l10n.keyboardCursorOffsetIntegerError;
}
return null;
},
),
],
],
),
),
),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(l10n.cancel),
),
FilledButton(
onPressed: _onSave,
child: Text(l10n.confirm),
),
],
);
}
}
@@ -0,0 +1,89 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../models/virtual_keyboard_config.dart';
/// 虚拟小键盘单行内的单个按键卡片组件
class VirtualKeyboardKeyTile extends StatelessWidget {
final int pageIndex;
final int rowIndex;
final int keyIndex;
final KeyboardKeyItem keyItem;
final VoidCallback onEdit;
final VoidCallback onDelete;
const VirtualKeyboardKeyTile({
super.key,
required this.pageIndex,
required this.rowIndex,
required this.keyIndex,
required this.keyItem,
required this.onEdit,
required this.onDelete,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
final hasIcon = keyItem.icon != null && keyItem.icon!.isNotEmpty;
final iconData = hasIcon ? KeyboardIconHelper.getIcon(keyItem.icon) : null;
return Card(
key: ValueKey('page_${pageIndex}_row_${rowIndex}_key_$keyIndex'),
margin: const EdgeInsets.only(bottom: 6),
color: theme.colorScheme.surfaceContainerHighest.withValues(alpha: 0.3),
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(color: theme.dividerColor.withValues(alpha: 0.2)),
),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
leading: Container(
width: 38,
height: 38,
alignment: Alignment.center,
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(6),
border: Border.all(color: theme.dividerColor.withValues(alpha: 0.4)),
),
child: iconData != null
? Icon(iconData, size: 20, color: theme.colorScheme.primary)
: Text(
keyItem.label.isNotEmpty ? keyItem.label : '?',
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
title: Text(
keyItem.label.isNotEmpty ? keyItem.label : l10n.keyboardNoLabel,
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.edit_outlined, size: 18),
tooltip: l10n.keyboardEditKeyTooltip,
onPressed: onEdit,
),
IconButton(
icon: const Icon(Icons.delete_outline, size: 18),
tooltip: l10n.keyboardDeleteKeyTooltip,
onPressed: onDelete,
),
ReorderableDragStartListener(
index: keyIndex,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 6),
child: Icon(Icons.drag_handle, size: 18, color: Colors.grey),
),
),
],
),
),
);
}
}
@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
/// 虚拟小键盘当前页的基础属性配置板块(行按钮数)
class VirtualKeyboardPageConfigSection extends StatelessWidget {
final int count;
final ValueChanged<int> onCountChanged;
const VirtualKeyboardPageConfigSection({
super.key,
required this.count,
required this.onCountChanged,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(Icons.tune, size: 20, color: theme.colorScheme.primary),
const SizedBox(width: 8),
Text(
l10n.keyboardPageConfigSectionTitle,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
),
],
),
const SizedBox(height: 8),
Card(
elevation: 0,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: theme.dividerColor.withValues(alpha: 0.3)),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(l10n.keyboardRowButtons, style: const TextStyle(fontWeight: FontWeight.w500)),
const SizedBox(height: 2),
Text(
l10n.keyboardRowGridDescription(count),
style: TextStyle(fontSize: 12, color: theme.hintColor),
),
],
),
Row(
children: [
IconButton.filledTonal(
icon: const Icon(Icons.remove, size: 18),
tooltip: l10n.keyboardDecreaseRowButtonsTooltip,
visualDensity: VisualDensity.compact,
onPressed: count > 3 ? () => onCountChanged(count - 1) : null,
),
Container(
constraints: const BoxConstraints(minWidth: 44),
alignment: Alignment.center,
child: Text(
'$count',
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
IconButton.filledTonal(
icon: const Icon(Icons.add, size: 18),
tooltip: l10n.keyboardIncreaseRowButtonsTooltip,
visualDensity: VisualDensity.compact,
onPressed: count < 12 ? () => onCountChanged(count + 1) : null,
),
],
),
],
),
),
),
],
);
}
}
@@ -0,0 +1,184 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../models/virtual_keyboard_config.dart';
/// 虚拟小键盘页面管理抽屉
class VirtualKeyboardPageDrawer extends StatelessWidget {
final List<KeyboardPageItem> pages;
final int currentPageIndex;
final VoidCallback onAddNewPage;
final ValueChanged<int> onSelectPage;
final ValueChanged<int> onDeletePage;
final void Function(int oldIndex, int newIndex) onReorderPages;
const VirtualKeyboardPageDrawer({
super.key,
required this.pages,
required this.currentPageIndex,
required this.onAddNewPage,
required this.onSelectPage,
required this.onDeletePage,
required this.onReorderPages,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
return Drawer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 抽屉头部
SafeArea(
bottom: false,
child: Padding(
padding: const EdgeInsets.only(left: 16.0, right: 8.0, top: 4.0, bottom: 4.0),
child: Row(
children: [
Expanded(
child: Text(
l10n.keyboardDrawerTitle,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 8),
// 单独加号,后面文本为新建页面
TextButton.icon(
icon: const Icon(Icons.add, size: 18),
label: Text(l10n.keyboardNewPage),
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(horizontal: 8),
),
onPressed: () {
onAddNewPage();
Navigator.of(context).pop(); // 关闭抽屉
},
),
],
),
),
),
const Divider(height: 1),
// 页面可拖动排序列表
Expanded(
child: ReorderableListView.builder(
buildDefaultDragHandles: false,
padding: const EdgeInsets.symmetric(vertical: 4.0),
itemCount: pages.length,
onReorderItem: onReorderPages,
itemBuilder: (context, index) {
final isSelected = index == currentPageIndex;
final pageItem = pages[index];
return VirtualKeyboardPageDrawerItem(
key: ValueKey('page_$index'),
index: index,
pageItem: pageItem,
isSelected: isSelected,
canDelete: pages.length > 1,
onSelect: () {
onSelectPage(index);
Navigator.of(context).pop();
},
onDelete: () => onDeletePage(index),
);
},
),
),
],
),
);
}
}
/// 抽屉内的独立页面列表项组件
class VirtualKeyboardPageDrawerItem extends StatelessWidget {
final int index;
final KeyboardPageItem pageItem;
final bool isSelected;
final bool canDelete;
final VoidCallback onSelect;
final VoidCallback onDelete;
const VirtualKeyboardPageDrawerItem({
super.key,
required this.index,
required this.pageItem,
required this.isSelected,
required this.canDelete,
required this.onSelect,
required this.onDelete,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 2.0),
child: Material(
color: Colors.transparent,
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 0.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
selected: isSelected,
selectedTileColor: theme.colorScheme.primaryContainer.withValues(alpha: 0.5),
leading: Icon(
Icons.dashboard_outlined,
size: 20,
color: isSelected ? theme.colorScheme.primary : theme.colorScheme.onSurfaceVariant,
),
title: Text(
l10n.keyboardPageItemTitle(index + 1),
style: TextStyle(
fontSize: 14.0,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: isSelected ? theme.colorScheme.primary : null,
),
),
subtitle: Text(
l10n.keyboardPageItemSubtitle(pageItem.keys.length),
style: TextStyle(
fontSize: 12.0,
color: theme.colorScheme.onSurfaceVariant,
),
),
dense: true,
onTap: onSelect,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.delete_outline, size: 20),
tooltip: l10n.keyboardDeletePageTooltip,
onPressed: canDelete ? onDelete : null,
),
ReorderableDragStartListener(
index: index,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 8.0),
child: Icon(
Icons.drag_handle,
size: 20,
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
),
),
),
],
),
),
),
);
}
}
+126
View File
@@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../models/virtual_keyboard_config.dart';
import 'virtual_keyboard_key_tile.dart';
/// 虚拟小键盘页面内的单个按键行(含 ExpansionTile 与行内按键列表)
class VirtualKeyboardRowTile extends StatelessWidget {
final int pageIndex;
final int rowIndex;
final List<KeyboardKeyItem> rowKeys;
final bool isExpanded;
final ValueChanged<bool> onExpansionChanged;
final VoidCallback onAddKey;
final VoidCallback onDeleteRow;
final void Function(int oldIndex, int newIndex) onReorderKeys;
final void Function(int keyIndex, KeyboardKeyItem key) onEditKey;
final ValueChanged<int> onDeleteKey;
const VirtualKeyboardRowTile({
super.key,
required this.pageIndex,
required this.rowIndex,
required this.rowKeys,
required this.isExpanded,
required this.onExpansionChanged,
required this.onAddKey,
required this.onDeleteRow,
required this.onReorderKeys,
required this.onEditKey,
required this.onDeleteKey,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
return Card(
key: ValueKey('page_${pageIndex}_row_$rowIndex'),
margin: const EdgeInsets.only(bottom: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: theme.dividerColor.withValues(alpha: 0.3)),
),
child: Theme(
data: theme.copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
key: ValueKey('page_${pageIndex}_row_${rowIndex}_$isExpanded'),
initiallyExpanded: isExpanded,
onExpansionChanged: onExpansionChanged,
leading: CircleAvatar(
radius: 14,
backgroundColor: theme.colorScheme.primary.withValues(alpha: 0.12),
child: Text(
'${rowIndex + 1}',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: theme.colorScheme.primary,
),
),
),
title: Text(l10n.keyboardRowKeyCount(rowKeys.length)),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.add, size: 20),
tooltip: l10n.keyboardAddKeyTooltip,
color: theme.colorScheme.primary,
onPressed: onAddKey,
),
IconButton(
icon: const Icon(Icons.delete_outline, size: 20),
tooltip: l10n.keyboardDeleteRowTooltip,
onPressed: onDeleteRow,
),
ReorderableDragStartListener(
index: rowIndex,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Icon(Icons.drag_handle, color: Colors.grey),
),
),
],
),
children: [
if (rowKeys.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Center(
child: Text(
l10n.keyboardEmptyRowKeysHint,
style: TextStyle(fontSize: 13, color: theme.hintColor),
),
),
)
else
Padding(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
child: ReorderableListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
buildDefaultDragHandles: false,
itemCount: rowKeys.length,
onReorderItem: onReorderKeys,
itemBuilder: (context, keyIndex) {
final keyItem = rowKeys[keyIndex];
return VirtualKeyboardKeyTile(
key: ValueKey('page_${pageIndex}_row_${rowIndex}_key_$keyIndex'),
pageIndex: pageIndex,
rowIndex: rowIndex,
keyIndex: keyIndex,
keyItem: keyItem,
onEdit: () => onEditKey(keyIndex, keyItem),
onDelete: () => onDeleteKey(keyIndex),
);
},
),
),
],
),
),
);
}
}
+183 -83
View File
@@ -22,19 +22,30 @@ class VirtualKeyboardWidget extends StatefulWidget {
State<VirtualKeyboardWidget> createState() => _VirtualKeyboardWidgetState();
}
class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget> {
class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget>
with SingleTickerProviderStateMixin {
late PageController _pageController;
late AnimationController _animationController;
int _currentPage = 0;
static const double _rowHeight = 30.0;
static const double _indicatorHeight = 12.0;
@override
void initState() {
super.initState();
_pageController = PageController(initialPage: 0);
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 200),
value: 0.0, // 默认折叠(0.0 表示仅显示第一行,1.0 表示完全展开)
);
}
@override
void dispose() {
_pageController.dispose();
_animationController.dispose();
super.dispose();
}
@@ -181,6 +192,10 @@ class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget> {
@override
Widget build(BuildContext context) {
if (!widget.config.hasKeys) {
return const SizedBox.shrink();
}
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
@@ -189,65 +204,143 @@ class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget> {
final borderColor = isDark ? const Color(0xFF333333) : const Color(0xFFDCDFE6);
final pages = widget.config.pages;
if (pages.isEmpty) {
return const SizedBox.shrink();
int maxRows = 1;
for (final p in pages) {
if (p.keys.length > maxRows) {
maxRows = p.keys.length;
}
}
final hasMultiplePages = pages.length > 1;
final double indicatorTargetHeight = hasMultiplePages ? _indicatorHeight : 0.0;
// 多出的行高 + 多页指示器高度
final double totalExpandableHeight = (maxRows - 1) * _rowHeight + indicatorTargetHeight;
return CodeEditorTapRegion(
child: Container(
decoration: BoxDecoration(
color: bgColor,
border: Border(
top: BorderSide(color: borderColor, width: 0.8),
),
),
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 84, // 两行按键的高度
child: PageView.builder(
controller: _pageController,
itemCount: pages.length,
onPageChanged: (idx) {
setState(() {
_currentPage = idx;
});
},
itemBuilder: (context, pageIndex) {
return _buildPage(pages[pageIndex], isDark);
},
child: AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
final progress = _animationController.value;
final currentIndicatorHeight = indicatorTargetHeight * progress;
final currentPageViewHeight = _rowHeight + ((maxRows - 1) * _rowHeight * progress);
return GestureDetector(
behavior: HitTestBehavior.translucent,
onVerticalDragStart: (details) {
_animationController.stop();
},
onVerticalDragUpdate: (details) {
if (totalExpandableHeight > 0) {
// 上拉 (delta.dy < 0) 增加展开进度,下拉 (delta.dy > 0) 减少展开进度
final deltaProgress = -details.delta.dy / totalExpandableHeight;
_animationController.value =
(_animationController.value + deltaProgress).clamp(0.0, 1.0);
}
},
onVerticalDragEnd: (details) {
final velocity = details.primaryVelocity ?? 0;
if (velocity < -250) {
_animationController.forward();
} else if (velocity > 250) {
_animationController.reverse();
} else if (_animationController.value > 0.5) {
_animationController.forward();
} else {
_animationController.reverse();
}
},
child: Container(
decoration: BoxDecoration(
color: bgColor,
border: Border(
top: BorderSide(color: borderColor, width: 0.8),
),
),
if (pages.length > 1) _buildPageIndicator(pages.length, theme),
],
),
),
child: SafeArea(
top: false,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (hasMultiplePages)
_buildPageIndicator(
pages.length,
theme,
progress,
currentIndicatorHeight,
),
SizedBox(
height: currentPageViewHeight,
child: PageView.builder(
controller: _pageController,
itemCount: pages.length,
onPageChanged: (idx) {
setState(() {
_currentPage = idx;
});
},
itemBuilder: (context, pageIndex) {
return _buildPage(pages[pageIndex], isDark);
},
),
),
],
),
),
),
);
},
),
);
}
Widget _buildPageIndicator(int pageCount, ThemeData theme) {
return Padding(
padding: const EdgeInsets.only(bottom: 3),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(pageCount, (index) {
final isSelected = index == _currentPage;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 2.5),
width: isSelected ? 12 : 4,
height: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: isSelected
? theme.colorScheme.primary
: theme.colorScheme.onSurface.withValues(alpha: 0.25),
/// 顶部分页指示圆点:
/// - 只有在有多页且上拉展开时动态显示,默认单行完全不显示
/// - 纯圆点展示,不添加任何背景条/把手条
/// - 点击圆点可在展开与折叠之间快速切换
Widget _buildPageIndicator(
int pageCount,
ThemeData theme,
double progress,
double height,
) {
if (pageCount <= 1 || progress <= 0.001 || height <= 0.5) {
return const SizedBox.shrink();
}
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (_animationController.value > 0.5) {
_animationController.reverse();
} else {
_animationController.forward();
}
},
child: SizedBox(
height: height,
child: Opacity(
opacity: progress.clamp(0.0, 1.0),
child: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(pageCount, (index) {
final isSelected = index == _currentPage;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 2.5),
width: isSelected ? 12 : 4,
height: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: isSelected
? theme.colorScheme.primary
: theme.colorScheme.onSurface.withValues(alpha: 0.25),
),
);
}),
),
);
}),
),
),
),
);
}
@@ -259,30 +352,38 @@ class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget> {
final cellWidth = constraints.maxWidth / count;
final rows = page.keys;
return Column(
children: rows.take(2).map((row) {
return SizedBox(
height: 42,
child: Row(
children: List.generate(count, (colIndex) {
if (colIndex < row.length) {
final keyItem = row[colIndex];
return SizedBox(
width: cellWidth,
height: 42,
child: _buildKeyButton(keyItem, isDark),
);
} else {
// 多余未配置的格子,正常渲染背景占位
return SizedBox(
width: cellWidth,
height: 42,
);
}
}),
),
);
}).toList(),
return ClipRect(
child: OverflowBox(
minHeight: 0,
maxHeight: double.infinity,
alignment: Alignment.topLeft,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: rows.map((row) {
return SizedBox(
height: _rowHeight,
child: Row(
children: List.generate(count, (colIndex) {
if (colIndex < row.length) {
final keyItem = row[colIndex];
return SizedBox(
width: cellWidth,
height: _rowHeight,
child: _buildKeyButton(keyItem, isDark),
);
} else {
return SizedBox(
width: cellWidth,
height: _rowHeight,
);
}
}),
),
);
}).toList(),
),
),
);
},
);
@@ -299,14 +400,14 @@ class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget> {
if (iconData != null) {
content = Icon(
iconData,
size: 18,
size: 15,
color: btnTextColor,
);
} else {
content = Text(
keyItem.label,
style: TextStyle(
fontSize: keyItem.label.length > 3 ? 12 : 15,
fontSize: keyItem.label.length > 3 ? 11 : 13,
fontWeight: FontWeight.w500,
color: btnTextColor,
fontFamily: 'Consolas, Monaco, monospace',
@@ -317,19 +418,18 @@ class _VirtualKeyboardWidgetState extends State<VirtualKeyboardWidget> {
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.5, vertical: 3),
padding: const EdgeInsets.symmetric(horizontal: 0.75, vertical: 0.75),
child: Material(
color: btnBgColor,
borderRadius: BorderRadius.circular(6),
elevation: 0.5,
shadowColor: Colors.black26,
borderRadius: BorderRadius.circular(4),
elevation: 0,
child: InkWell(
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(4),
onTap: () => _handleKeyTap(keyItem),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
border: Border.all(color: borderColor, width: 0.8),
borderRadius: BorderRadius.circular(4),
border: Border.all(color: borderColor, width: 0.6),
),
alignment: Alignment.center,
child: content,