Skip to content

Commit

Permalink
Redesign search
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 15, 2024
1 parent be13d38 commit 6563df8
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 259 deletions.
8 changes: 0 additions & 8 deletions api/lib/src/helpers/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ sealed class SearchResult with _$SearchResult {
int index,
) = ToolResult;

String getDisplay() => switch (this) {
PageResult e => e.name,
ElementResult e => e.text,
AreaResult e => e.area.name,
WaypointResult e => e.waypoint.name,
ToolResult e => e.name,
};

String? getPage() => switch (this) {
PageResult e => e.name,
ElementResult e => e.page,
Expand Down
41 changes: 0 additions & 41 deletions app/lib/actions/search.dart

This file was deleted.

2 changes: 2 additions & 0 deletions app/lib/dialogs/export/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class _GeneralExportDialogState extends State<GeneralExportDialog> {
_regeneratePreviewImage();
},
icon: const PhosphorIcon(PhosphorIconsLight.userRectangle),
tooltip: AppLocalizations.of(context).view,
selectedIcon:
const PhosphorIcon(PhosphorIconsFill.userRectangle),
isSelected: _preset == ExportTransformPreset.view,
Expand Down Expand Up @@ -289,6 +290,7 @@ class _GeneralExportDialogState extends State<GeneralExportDialog> {
_regeneratePreviewImage();
},
icon: const PhosphorIcon(PhosphorIconsLight.file),
tooltip: AppLocalizations.of(context).page,
selectedIcon: const PhosphorIcon(PhosphorIconsFill.file),
isSelected: _preset == ExportTransformPreset.page,
),
Expand Down
196 changes: 0 additions & 196 deletions app/lib/dialogs/search.dart

This file was deleted.

11 changes: 2 additions & 9 deletions app/lib/views/app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:math';

import 'package:butterfly/actions/change_path.dart';
import 'package:butterfly/actions/search.dart';
import 'package:butterfly/actions/settings.dart';
import 'package:butterfly/actions/svg_export.dart';
import 'package:butterfly/api/file_system.dart';
Expand All @@ -12,6 +11,7 @@ import 'package:butterfly/services/import.dart';
import 'package:butterfly/services/network.dart';
import 'package:butterfly/views/edit.dart';
import 'package:butterfly/visualizer/asset.dart';
import 'package:butterfly/widgets/search.dart';
import 'package:butterfly_api/butterfly_api.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -298,14 +298,7 @@ class _AppBarTitleState extends State<_AppBarTitle> {
state.location.fileType.icon(PhosphorIconsStyle.light)),
tooltip: AppLocalizations.of(context).export,
onPressed: () => context.read<ImportService>().export()),
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.magnifyingGlass),
tooltip: AppLocalizations.of(context).search,
onPressed: () {
Actions.maybeInvoke<SearchIntent>(
context, SearchIntent(context));
},
),
SearchButton(),
if (state.location.path != '' && state.embedding == null) ...[
IconButton(
icon: const PhosphorIcon(PhosphorIconsLight.folder),
Expand Down
5 changes: 0 additions & 5 deletions app/lib/views/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';

import 'package:butterfly/actions/search.dart';
import 'package:butterfly/api/close.dart';
import 'package:butterfly/api/file_system.dart';
import 'package:butterfly/bloc/document_bloc.dart';
Expand Down Expand Up @@ -98,7 +97,6 @@ class _ProjectPageState extends State<ProjectPage> {
ImageExportIntent: ImageExportAction(),
PdfExportIntent: PdfExportAction(),
ExportIntent: ExportAction(),
SearchIntent: SearchAction(),
SettingsIntent: SettingsAction(),
ColorPaletteIntent: ColorPaletteAction(),
BackgroundIntent: BackgroundAction(),
Expand Down Expand Up @@ -366,9 +364,6 @@ class _ProjectPageState extends State<ProjectPage> {
LogicalKeySet(LogicalKeyboardKey.control,
LogicalKeyboardKey.keyA):
SelectAllIntent(context),
LogicalKeySet(LogicalKeyboardKey.control,
LogicalKeyboardKey.keyK):
SearchIntent(context),
if (widget.embedding == null) ...{
LogicalKeySet(LogicalKeyboardKey.control,
LogicalKeyboardKey.keyE):
Expand Down
5 changes: 5 additions & 0 deletions app/lib/visualizer/tool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import 'package:material_leap/material_leap.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';

extension ToolVisualizer on Tool {
String getDisplay(BuildContext context) {
if (name.trim().isEmpty) return getLocalizedName(context);
return name;
}

String getLocalizedName(BuildContext context) {
final loc = AppLocalizations.of(context);
return switch (this) {
Expand Down
Loading

0 comments on commit 6563df8

Please sign in to comment.