Skip to content

Commit

Permalink
Optimize Query Action Search
Browse files Browse the repository at this point in the history
  • Loading branch information
lylwx committed Dec 22, 2023
1 parent aebd386 commit eef664f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,18 @@ class WoxQueryResultView extends GetView<WoxLauncherController> {
borderRadius: BorderRadius.circular(controller.woxTheme.value.actionQueryBoxBorderRadius.toDouble()),
),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 320),
constraints: const BoxConstraints(maxWidth: 320, minHeight: 210),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Actions", style: TextStyle(color: fromCssColor(controller.woxTheme.value.actionContainerHeaderFontColor), fontSize: 16.0)),
const Divider(),
getActionListView(),
getActionQueryBox(),
ConstrainedBox(
constraints: const BoxConstraints(minHeight: 120),
child: getActionListView(),
),
getActionQueryBox()
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lpinyin/lpinyin.dart';
import 'package:uuid/v4.dart';
import 'package:window_manager/window_manager.dart';
import 'package:wox/entity/wox_preview.dart';
Expand Down Expand Up @@ -229,7 +230,7 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa

@override
void onQueryActionChanged(String queryAction) {
filterResultActions.value = _resultActions.where((element) => element.name.toLowerCase().contains(queryAction.toLowerCase())).toList().obs();
filterResultActions.value = _resultActions.where((element) => transferChineseToPinYin(element.name.toLowerCase()).contains(queryAction.toLowerCase())).toList().obs();
filterResultActions.refresh();
}

Expand Down Expand Up @@ -554,4 +555,12 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa
canArrowUpHistory = false;
changeResultScrollPosition(WoxEventDeviceTypeEnum.WOX_EVENT_DEVEICE_TYPE_KEYBOARD.code, WoxDirectionEnum.WOX_DIRECTION_DOWN.code);
}

String transferChineseToPinYin(String str) {
RegExp regExp = RegExp(r'[\u4e00-\u9fa5]');
if (regExp.hasMatch(str)) {
return PinyinHelper.getPinyin(str, separator: "", format: PinyinFormat.WITHOUT_TONE);
}
return str;
}
}
2 changes: 1 addition & 1 deletion Wox.UI.Flutter/wox/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 16208599a12443d53889ba2270a4985981cfb204

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
8 changes: 8 additions & 0 deletions Wox.UI.Flutter/wox/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.2+1"
lpinyin:
dependency: "direct main"
description:
name: lpinyin
sha256: "0bb843363f1f65170efd09fbdfc760c7ec34fc6354f9fcb2f89e74866a0d814a"
url: "https://pub.dev"
source: hosted
version: "2.0.3"
macos_window_utils:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions Wox.UI.Flutter/wox/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
from_css_color: ^2.0.0
path: ^1.8.3
chinese_font_library: ^1.1.0
lpinyin: ^2.0.3

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit eef664f

Please sign in to comment.