Files
Forge/lib/src/ui/widgets/keyboard_shortcuts_dialog.dart
T

194 lines
6.9 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart' show Divider;
import 'package:macos_ui/macos_ui.dart';
class KeyboardShortcutsDialog extends StatelessWidget {
const KeyboardShortcutsDialog({super.key});
static Future<void> show(BuildContext context) {
return showMacosSheet(
context: context,
barrierDismissible: true,
builder: (context) => const KeyboardShortcutsDialog(),
);
}
@override
Widget build(BuildContext context) {
final theme = MacosTheme.of(context);
final shortcuts = [
(
keys: ['Ctrl', 'K'],
action: 'Быстрый поиск приложений (Spotlight)',
category: 'Навигация',
),
(
keys: ['Ctrl', '1…7'],
action: 'Быстрый переход между экранами (Каталог, Установленные и др.)',
category: 'Навигация',
),
(
keys: ['Ctrl', '/'],
action: 'Шпаргалка горячих клавиш (это окно)',
category: 'Помощь',
),
(
keys: ['F1'],
action: 'Справка и горячие клавиши',
category: 'Помощь',
),
(
keys: ['Esc'],
action: 'Закрыть модальное окно / отменить действие',
category: 'Общее',
),
];
return Center(
child: Container(
width: 520,
decoration: BoxDecoration(
color: theme.canvasColor,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: CupertinoColors.white.withValues(alpha: 0.12)),
boxShadow: [
BoxShadow(
color: CupertinoColors.black.withValues(alpha: 0.45),
blurRadius: 28,
offset: const Offset(0, 10),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Шапка
Padding(
padding: const EdgeInsets.fromLTRB(20, 18, 20, 14),
child: Row(
children: [
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: const Color(0xFF34C759).withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(10),
),
child: const Center(
child: MacosIcon(
CupertinoIcons.keyboard,
color: Color(0xFF34C759),
size: 20,
),
),
),
const SizedBox(width: 12),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Горячие клавиши Forge',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 2),
Text(
'Удобное управление менеджером пакетов с клавиатуры',
style: TextStyle(
fontSize: 12,
color: CupertinoColors.systemGrey,
),
),
],
),
),
MacosIconButton(
icon: const MacosIcon(CupertinoIcons.xmark, size: 16),
onPressed: () => Navigator.of(context).pop(),
),
],
),
),
const Divider(height: 1, color: CupertinoColors.separator),
// Список шорткатов
Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: shortcuts.map((item) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Row(
children: [
Row(
children: item.keys.map((k) {
return Container(
margin: const EdgeInsets.only(right: 4),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: theme.dividerColor.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(6),
border: Border.all(
color: CupertinoColors.white.withValues(alpha: 0.2),
),
boxShadow: [
BoxShadow(
color: CupertinoColors.black.withValues(alpha: 0.2),
blurRadius: 2,
offset: const Offset(0, 1),
),
],
),
child: Text(
k,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
fontFamily: 'monospace',
),
),
);
}).toList(),
),
const SizedBox(width: 14),
Expanded(
child: Text(
item.action,
style: const TextStyle(fontSize: 13),
),
),
],
),
);
}).toList(),
),
),
const Divider(height: 1, color: CupertinoColors.separator),
Padding(
padding: const EdgeInsets.all(14),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
PushButton(
controlSize: ControlSize.regular,
secondary: true,
onPressed: () => Navigator.of(context).pop(),
child: const Text('Понятно'),
),
],
),
),
],
),
),
);
}
}