Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions lib/features/erd/widgets/erd_export_menu.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart' as material;
import 'package:querya_desktop/core/theme/querya_theme_scope.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart'
show QueryaActionMenuItem;
import 'package:querya_desktop/shared/widgets/querya_menu_button.dart';

/// Entries of the diagram's Export menu.
enum ErdExportAction {
Expand All @@ -24,8 +24,8 @@ class ErdExportMenu extends material.StatelessWidget {

@override
material.Widget build(material.BuildContext context) {
final wb = context.workbench;
return QueryaActionMenu<ErdExportAction>(
return QueryaMenuButton<ErdExportAction>(
key: const material.ValueKey('erd_export'),
items: const [
QueryaActionMenuItem(
value: ErdExportAction.toggleTheme,
Expand Down Expand Up @@ -74,23 +74,8 @@ class ErdExportMenu extends material.StatelessWidget {
),
],
onSelected: onSelected,
child: material.Padding(
key: const material.ValueKey('erd_export'),
padding:
const material.EdgeInsets.symmetric(horizontal: 10, vertical: 6),
child: material.Row(
mainAxisSize: material.MainAxisSize.min,
children: [
material.Icon(material.Icons.file_download_outlined,
size: 16, color: wb.mutedForeground),
const material.SizedBox(width: 6),
const Text('Export'),
const material.SizedBox(width: 4),
material.Icon(material.Icons.expand_more_rounded,
size: 16, color: wb.mutedForeground),
],
),
),
label: 'Export',
icon: material.Icons.file_download_outlined,
);
}
}
29 changes: 7 additions & 22 deletions lib/features/erd/widgets/erd_views_menu.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart' as material;
import 'package:querya_desktop/core/erd/erd_saved_layout.dart';
import 'package:querya_desktop/core/theme/querya_theme_scope.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart'
show QueryaActionMenuItem;
import 'package:querya_desktop/shared/widgets/querya_menu_button.dart';

/// The toolbar's view switcher: All tables, the saved views, and the
/// commands to save, rename and delete one.
Expand Down Expand Up @@ -34,9 +34,9 @@ class ErdViewsMenu extends material.StatelessWidget {

@override
material.Widget build(material.BuildContext context) {
final wb = context.workbench;
final current = active;
return QueryaActionMenu<String>(
return QueryaMenuButton<String>(
key: const material.ValueKey('erd_views'),
items: [
// A mark on every row, so the labels line up.
QueryaActionMenuItem(
Expand Down Expand Up @@ -86,23 +86,8 @@ class ErdViewsMenu extends material.StatelessWidget {
if (v.startsWith('view:')) onSwitch(v.substring(5));
}
},
child: material.Padding(
key: const material.ValueKey('erd_views'),
padding:
const material.EdgeInsets.symmetric(horizontal: 10, vertical: 6),
child: material.Row(
mainAxisSize: material.MainAxisSize.min,
children: [
material.Icon(material.Icons.bookmarks_outlined,
size: 16, color: wb.mutedForeground),
const material.SizedBox(width: 6),
Text(current == null ? 'All tables' : shortName(current.name)),
const material.SizedBox(width: 4),
material.Icon(material.Icons.expand_more_rounded,
size: 16, color: wb.mutedForeground),
],
),
),
label: current == null ? 'All tables' : shortName(current.name),
icon: material.Icons.bookmarks_outlined,
);
}
}
25 changes: 7 additions & 18 deletions lib/features/results/charts/quick_chart_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import 'package:querya_desktop/core/storage/app_settings.dart';
import 'package:querya_desktop/features/results/charts/chart_data.dart';
import 'package:querya_desktop/features/results/charts/chart_format.dart';
import 'package:querya_desktop/features/results/charts/chart_svg.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart';
import 'package:querya_desktop/shared/widgets/widgets.dart';
import 'package:querya_desktop/core/ui/querya_control_tokens.dart';

/// Formats of the chart export menu.
enum _ChartExport { png, svg, toggleTheme }
Expand Down Expand Up @@ -379,7 +379,8 @@ class _QuickChartViewState extends material.State<QuickChartView> {
),
const material.SizedBox(width: 8),
],
QueryaActionMenu<_ChartExport>(
QueryaMenuButton<_ChartExport>(
key: const material.ValueKey('chart_export'),
items: const [
QueryaActionMenuItem(
value: _ChartExport.png,
Expand All @@ -406,22 +407,10 @@ class _QuickChartViewState extends material.State<QuickChartView> {
_exportSvg();
}
},
child: material.Padding(
key: const material.ValueKey('chart_export'),
padding: const material.EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
child: material.Row(
mainAxisSize: material.MainAxisSize.min,
children: [
material.Icon(material.Icons.file_download_outlined,
size: 16, color: wb.mutedForeground),
const material.SizedBox(width: 4),
const Text('Export'),
material.Icon(material.Icons.expand_more_rounded,
size: 16, color: wb.mutedForeground),
],
),
),
label: 'Export',
icon: material.Icons.file_download_outlined,
variant: QueryaButtonVariant.ghost,
size: QueryaControlSize.sm,
),
],
),
Expand Down
63 changes: 13 additions & 50 deletions lib/features/workspace/sql_workspace_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:querya_desktop/features/settings/preferences_dialog.dart';
import 'package:querya_desktop/features/settings/sql_statement_timeout_dropdown.dart';
import 'package:querya_desktop/features/workspace/sql_execution_delegate.dart';
import 'package:querya_desktop/features/workspace/sql_query_tab_session.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart';
import 'package:querya_desktop/shared/widgets/widgets.dart';

/// Choices for the session options dropdown.
Expand Down Expand Up @@ -147,7 +146,6 @@ class SqlWorkspaceToolbar extends StatelessWidget {

@override
material.Widget build(material.BuildContext context) {
final accent = context.workbench.accent;
return material.LayoutBuilder(
builder: (context, constraints) {
final compact = constraints.maxWidth < compactWidthBreakpoint;
Expand All @@ -159,17 +157,15 @@ class SqlWorkspaceToolbar extends StatelessWidget {
headerBadge!,
const material.SizedBox(width: 12),
],
QueryaActionButton(
key: const material.ValueKey('run_script'),
QueryaSplitButton<bool>(
mainKey: const material.ValueKey('run_script'),
menuKey: const material.ValueKey('run_menu'),
label: 'Execute (F5)',
icon: material.Icons.play_arrow_rounded,
compact: compact,
loading: session.running,
onPressed: () => onExecute(false),
),
const material.SizedBox(width: 4),
QueryaActionMenu<bool>(
key: const material.ValueKey('run_menu'),
menuTooltip: 'Run options',
items: [
QueryaActionMenuItem(
value: true,
Expand All @@ -187,10 +183,6 @@ class SqlWorkspaceToolbar extends StatelessWidget {
onExecute(atCursor);
}
},
child: const material.Icon(
material.Icons.expand_more_rounded,
size: 16,
),
),
if (delegate.supportsExplain) ...[
const material.SizedBox(width: 8),
Expand Down Expand Up @@ -267,44 +259,15 @@ class SqlWorkspaceToolbar extends StatelessWidget {
],
const material.SizedBox(width: 8),
],
material.IgnorePointer(
ignoring: session.running,
child: material.Opacity(
opacity: session.running ? 0.5 : 1,
child: QueryaActionMenu<SqlWorkspaceSessionChoice>(
key: const material.ValueKey('session_menu'),
items: _sessionMenuItems(),
onSelected: (choice) => _onSessionChoice(context, choice),
child: material.Padding(
padding: const material.EdgeInsets.symmetric(
horizontal: 10,
vertical: 6,
),
child: material.Row(
mainAxisSize: material.MainAxisSize.min,
children: [
material.Icon(
material.Icons.tune_rounded,
size: 16,
color: accent,
),
const material.SizedBox(width: 6),
if (!compact) ...[
Text(autocommit
? 'Session · auto-commit'
: 'Session · manual'),
const material.SizedBox(width: 4),
],
material.Icon(
material.Icons.expand_more_rounded,
size: 16,
color: accent,
),
],
),
),
),
),
QueryaMenuButton<SqlWorkspaceSessionChoice>(
key: const material.ValueKey('session_menu'),
items: _sessionMenuItems(),
onSelected: (choice) => _onSessionChoice(context, choice),
enabled: !session.running,
icon: material.Icons.tune_rounded,
label: compact
? null
: (autocommit ? 'Session · auto-commit' : 'Session · manual'),
),
if (extraTrailing != null) ...[
const material.SizedBox(width: 8),
Expand Down
25 changes: 12 additions & 13 deletions lib/shared/widgets/export_menu_button.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'package:flutter/material.dart' as material;
import 'package:querya_desktop/core/ui/querya_control_tokens.dart';
import 'package:querya_desktop/shared/services/data_export_service.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart';
import 'package:shadcn_flutter/shadcn_flutter.dart';
import 'package:querya_desktop/shared/widgets/querya_action_menu.dart'
show QueryaActionMenuItem;
import 'package:querya_desktop/shared/widgets/querya_menu_button.dart';

class ExportMenuButton extends StatelessWidget {
/// The Export / Copy menu of result and table toolbars: CSV, JSON, Markdown
/// and SQL dump, saved to a file or copied ([isSave]).
class ExportMenuButton extends material.StatelessWidget {
const ExportMenuButton({
super.key,
required this.label,
Expand All @@ -18,8 +22,11 @@ class ExportMenuButton extends StatelessWidget {
final bool isSave;

@override
Widget build(BuildContext context) {
return QueryaActionMenu<DataExportFormat>(
material.Widget build(material.BuildContext context) {
return QueryaMenuButton<DataExportFormat>(
label: label,
icon: icon,
size: QueryaControlSize.sm,
onSelected: onSelected,
items: [
QueryaActionMenuItem(
Expand All @@ -43,14 +50,6 @@ class ExportMenuButton extends StatelessWidget {
label: isSave ? 'SQL INSERT Dump (.sql)' : 'Copy as SQL Dump',
),
],
child: material.Row(
mainAxisSize: material.MainAxisSize.min,
children: [
material.Icon(icon, size: 14),
const material.SizedBox(width: 6),
Text(label),
],
),
);
}
}
Loading
Loading