mirror of https://github.com/Wox-launcher/Wox
Add theme restore functionality and toolbar in the ui
This commit is contained in:
parent
8328c3f613
commit
f6470c7b46
|
@ -51,6 +51,10 @@ class WoxTheme {
|
|||
late String previewPropertyTitleColor;
|
||||
late String previewPropertyContentColor;
|
||||
late String previewTextSelectionColor;
|
||||
late String toolbarFontColor;
|
||||
late String toolbarBackgroundColor;
|
||||
late int toolbarPaddingLeft;
|
||||
late int toolbarPaddingRight;
|
||||
|
||||
WoxTheme(
|
||||
{themeId,
|
||||
|
@ -100,7 +104,11 @@ class WoxTheme {
|
|||
previewSplitLineColor,
|
||||
previewPropertyTitleColor,
|
||||
previewPropertyContentColor,
|
||||
previewTextSelectionColor});
|
||||
previewTextSelectionColor,
|
||||
toolbarFontColor,
|
||||
toolbarBackgroundColor,
|
||||
toolbarPaddingLeft,
|
||||
toolbarPaddingRight});
|
||||
|
||||
WoxTheme.fromJson(Map<String, dynamic> json) {
|
||||
themeId = json['ThemeId'];
|
||||
|
@ -153,6 +161,10 @@ class WoxTheme {
|
|||
previewPropertyTitleColor = json['PreviewPropertyTitleColor'];
|
||||
previewPropertyContentColor = json['PreviewPropertyContentColor'];
|
||||
previewTextSelectionColor = json['PreviewTextSelectionColor'];
|
||||
toolbarFontColor = json['ToolbarFontColor'];
|
||||
toolbarBackgroundColor = json['ToolbarBackgroundColor'];
|
||||
toolbarPaddingLeft = json['ToolbarPaddingLeft'];
|
||||
toolbarPaddingRight = json['ToolbarPaddingRight'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -207,6 +219,10 @@ class WoxTheme {
|
|||
data['PreviewPropertyTitleColor'] = previewPropertyTitleColor;
|
||||
data['PreviewPropertyContentColor'] = previewPropertyContentColor;
|
||||
data['PreviewTextSelectionColor'] = previewTextSelectionColor;
|
||||
data['ToolbarFontColor'] = toolbarFontColor;
|
||||
data['ToolbarBackgroundColor'] = toolbarBackgroundColor;
|
||||
data['ToolbarPaddingLeft'] = toolbarPaddingLeft;
|
||||
data['ToolbarPaddingRight'] = toolbarPaddingRight;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:from_css_color/from_css_color.dart';
|
|||
import 'package:get/get.dart';
|
||||
import 'package:wox/modules/launcher/views/wox_query_box_view.dart';
|
||||
import 'package:wox/modules/launcher/views/wox_query_result_view.dart';
|
||||
import 'package:wox/modules/launcher/views/wox_query_toolbar_view.dart';
|
||||
import 'package:wox/modules/launcher/wox_launcher_controller.dart';
|
||||
|
||||
class WoxLauncherView extends GetView<WoxLauncherController> {
|
||||
|
@ -14,20 +15,28 @@ class WoxLauncherView extends GetView<WoxLauncherController> {
|
|||
return Obx(() {
|
||||
return Scaffold(
|
||||
backgroundColor: fromCssColor(controller.woxTheme.value.appBackgroundColor),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: controller.woxTheme.value.appPaddingTop.toDouble(),
|
||||
right: controller.woxTheme.value.appPaddingRight.toDouble(),
|
||||
bottom: controller.woxTheme.value.appPaddingBottom.toDouble(),
|
||||
left: controller.woxTheme.value.appPaddingLeft.toDouble(),
|
||||
),
|
||||
child: DropTarget(
|
||||
onDragDone: (DropDoneDetails details) {
|
||||
controller.handleDropFiles(details);
|
||||
},
|
||||
child: const Column(
|
||||
children: [WoxQueryBoxView(), WoxQueryResultView()],
|
||||
),
|
||||
body: DropTarget(
|
||||
onDragDone: (DropDoneDetails details) {
|
||||
controller.handleDropFiles(details);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: controller.woxTheme.value.appPaddingTop.toDouble(),
|
||||
right: controller.woxTheme.value.appPaddingRight.toDouble(),
|
||||
bottom: controller.woxTheme.value.appPaddingBottom.toDouble(),
|
||||
left: controller.woxTheme.value.appPaddingLeft.toDouble(),
|
||||
),
|
||||
child: const Column(
|
||||
children: [
|
||||
WoxQueryBoxView(),
|
||||
WoxQueryResultView(),
|
||||
],
|
||||
),
|
||||
),
|
||||
controller.queryResults.isNotEmpty ? const WoxQueryToolbarView() : const SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -4,16 +4,10 @@ import 'package:from_css_color/from_css_color.dart';
|
|||
import 'package:get/get.dart';
|
||||
import 'package:uuid/v4.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:wox/api/wox_api.dart';
|
||||
import 'package:wox/components/wox_image_view.dart';
|
||||
import 'package:wox/entity/wox_image.dart';
|
||||
import 'package:wox/enums/wox_image_type_enum.dart';
|
||||
import 'package:wox/enums/wox_query_type_enum.dart';
|
||||
import 'package:wox/enums/wox_selection_type_enum.dart';
|
||||
import 'package:wox/modules/launcher/wox_launcher_controller.dart';
|
||||
import 'package:wox/utils/log.dart';
|
||||
|
||||
import '../wox_launcher_controller.dart';
|
||||
|
||||
class WoxQueryBoxView extends GetView<WoxLauncherController> {
|
||||
const WoxQueryBoxView({super.key});
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:from_css_color/from_css_color.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:wox/modules/launcher/wox_launcher_controller.dart';
|
||||
import 'package:wox/utils/wox_theme_util.dart';
|
||||
|
||||
class WoxQueryToolbarView extends GetView<WoxLauncherController> {
|
||||
const WoxQueryToolbarView({super.key});
|
||||
|
||||
Widget leftTip() {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
Widget rightTip() {
|
||||
return Row(
|
||||
children: [
|
||||
Text("Actions Command + J", style: TextStyle(color: fromCssColor(controller.woxTheme.value.toolbarFontColor))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() {
|
||||
return SizedBox(
|
||||
height: WoxThemeUtil.instance.getResultTipHeight(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: fromCssColor(controller.woxTheme.value.toolbarBackgroundColor),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: controller.woxTheme.value.toolbarPaddingLeft.toDouble(), right: controller.woxTheme.value.toolbarPaddingRight.toDouble()),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
leftTip(),
|
||||
rightTip(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -160,6 +160,10 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa
|
|||
resizeHeight();
|
||||
}
|
||||
|
||||
getActiveQueryResult() {
|
||||
return queryResults[_activeResultIndex.value];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> executeResultAction(String traceId) async {
|
||||
if (queryResults.isEmpty) {
|
||||
|
@ -167,7 +171,7 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa
|
|||
}
|
||||
|
||||
Logger.instance.debug(traceId, "user execute result action");
|
||||
WoxQueryResult woxQueryResult = queryResults[_activeResultIndex.value];
|
||||
WoxQueryResult woxQueryResult = getActiveQueryResult();
|
||||
WoxResultAction woxResultAction = WoxResultAction.empty();
|
||||
if (isShowActionPanel.value) {
|
||||
if (filterResultActions.isNotEmpty) {
|
||||
|
@ -508,9 +512,11 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa
|
|||
if (isShowActionPanel.value || isShowPreviewPanel.value) {
|
||||
resultHeight = WoxThemeUtil.instance.getResultListViewHeightByCount(10);
|
||||
}
|
||||
final totalHeight = WoxThemeUtil.instance.getQueryBoxHeight() +
|
||||
resultHeight +
|
||||
(queryResults.isNotEmpty ? woxTheme.value.resultContainerPaddingTop + woxTheme.value.resultContainerPaddingBottom : 0);
|
||||
if (queryResults.isNotEmpty) {
|
||||
resultHeight += woxTheme.value.resultContainerPaddingTop + woxTheme.value.resultContainerPaddingBottom;
|
||||
resultHeight += WoxThemeUtil.instance.getResultTipHeight();
|
||||
}
|
||||
final totalHeight = WoxThemeUtil.instance.getQueryBoxHeight() + resultHeight;
|
||||
if (Platform.isWindows) {
|
||||
// on windows, if I set screen ratio to 2.0, then the window height should add more 4.5 pixel, otherwise it will show render error
|
||||
// still don't know why. here is the test result: ratio -> additional window height
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const int MAX_LIST_VIEW_ITEM_COUNT = 10;
|
||||
const double QUERY_BOX_BASE_HEIGHT = 55.0;
|
||||
const double RESULT_ITEM_BASE_HEIGHT = 50.0;
|
||||
const double RESULT_BOTTOM_TIP_BASE_HEIGHT = 40.0;
|
||||
|
|
|
@ -30,6 +30,10 @@ class WoxThemeUtil {
|
|||
return RESULT_ITEM_BASE_HEIGHT + currentTheme.resultItemPaddingTop + currentTheme.resultItemPaddingBottom;
|
||||
}
|
||||
|
||||
double getResultTipHeight() {
|
||||
return RESULT_BOTTOM_TIP_BASE_HEIGHT;
|
||||
}
|
||||
|
||||
double getResultListViewHeightByCount(int count) {
|
||||
if (count == 0) {
|
||||
return 0;
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"wox/ai"
|
||||
"wox/plugin"
|
||||
"wox/resource"
|
||||
"wox/setting"
|
||||
"wox/setting/definition"
|
||||
"wox/share"
|
||||
"wox/util"
|
||||
|
@ -44,6 +45,10 @@ func (c *ThemePlugin) GetMetadata() plugin.Metadata {
|
|||
Command: "ai",
|
||||
Description: "Generate a new theme with AI",
|
||||
},
|
||||
{
|
||||
Command: "restore",
|
||||
Description: "Remove all custom themes and restore to default",
|
||||
},
|
||||
},
|
||||
SettingDefinitions: definition.PluginSettingDefinitions{
|
||||
{
|
||||
|
@ -76,12 +81,15 @@ func (c *ThemePlugin) Query(ctx context.Context, query plugin.Query) []plugin.Qu
|
|||
if query.Command == "ai" {
|
||||
return c.queryAI(ctx, query)
|
||||
}
|
||||
if query.Command == "restore" {
|
||||
return c.queryRestore(ctx, query)
|
||||
}
|
||||
|
||||
ui := plugin.GetPluginManager().GetUI()
|
||||
return lo.FilterMap(ui.GetAllThemes(ctx), func(theme share.Theme, _ int) (plugin.QueryResult, bool) {
|
||||
match, _ := IsStringMatchScore(ctx, theme.ThemeName, query.Search)
|
||||
if match {
|
||||
return plugin.QueryResult{
|
||||
result := plugin.QueryResult{
|
||||
Title: theme.ThemeName,
|
||||
Icon: themeIcon,
|
||||
Actions: []plugin.QueryResultAction{
|
||||
|
@ -93,7 +101,23 @@ func (c *ThemePlugin) Query(ctx context.Context, query plugin.Query) []plugin.Qu
|
|||
},
|
||||
},
|
||||
},
|
||||
}, true
|
||||
}
|
||||
if theme.IsSystem {
|
||||
result.Tails = append(result.Tails, plugin.QueryResultTail{
|
||||
Type: plugin.QueryResultTailTypeText,
|
||||
Text: "System",
|
||||
})
|
||||
}
|
||||
currentThemeId := setting.GetSettingManager().GetWoxSetting(ctx).ThemeId
|
||||
if currentThemeId == theme.ThemeId {
|
||||
result.Group = "Current"
|
||||
result.GroupScore = 100
|
||||
} else {
|
||||
result.Group = "Available"
|
||||
result.GroupScore = 50
|
||||
}
|
||||
|
||||
return result, true
|
||||
} else {
|
||||
return plugin.QueryResult{}, false
|
||||
}
|
||||
|
@ -238,3 +262,21 @@ func (c *ThemePlugin) queryAI(ctx context.Context, query plugin.Query) []plugin.
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ThemePlugin) queryRestore(ctx context.Context, query plugin.Query) []plugin.QueryResult {
|
||||
return []plugin.QueryResult{
|
||||
{
|
||||
Title: "Remove all custom themes and restore to default",
|
||||
Icon: themeIcon,
|
||||
Actions: []plugin.QueryResultAction{
|
||||
{
|
||||
Name: "Restore",
|
||||
PreventHideAfterAction: true,
|
||||
Action: func(ctx context.Context, actionContext plugin.ActionContext) {
|
||||
plugin.GetPluginManager().GetUI().RestoreTheme(ctx)
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,5 +51,9 @@
|
|||
"PreviewSplitLineColor": "#3a474e",
|
||||
"PreviewPropertyTitleColor": "#b0b3b5",
|
||||
"PreviewPropertyContentColor": "#f0f0f0",
|
||||
"PreviewTextSelectionColor": "rgba(31, 118, 124, 0.8)"
|
||||
"PreviewTextSelectionColor": "rgba(31, 118, 124, 0.8)",
|
||||
"ToolbarFontColor": "#f0f0f0",
|
||||
"ToolbarBackgroundColor": "rgba(24, 25, 26, 0.4)",
|
||||
"ToolbarPaddingLeft": 10,
|
||||
"ToolbarPaddingRight": 10
|
||||
}
|
|
@ -51,5 +51,9 @@
|
|||
"PreviewSplitLineColor": "#caced0",
|
||||
"PreviewPropertyTitleColor": "#716b6b",
|
||||
"PreviewPropertyContentColor": "#716b6b",
|
||||
"PreviewTextSelectionColor": "#529df7"
|
||||
"PreviewTextSelectionColor": "#529df7",
|
||||
"ToolbarFontColor": "#454545",
|
||||
"ToolbarBackgroundColor": "rgba(255,255,255,0.5)",
|
||||
"ToolbarPaddingLeft": 10,
|
||||
"ToolbarPaddingRight": 10
|
||||
}
|
||||
|
|
|
@ -51,5 +51,9 @@
|
|||
"PreviewSplitLineColor": "#CCCCCC",
|
||||
"PreviewPropertyTitleColor": "#999999",
|
||||
"PreviewPropertyContentColor": "#663399",
|
||||
"PreviewTextSelectionColor": "rgba(255, 192, 203, 0.8)"
|
||||
"PreviewTextSelectionColor": "rgba(255, 192, 203, 0.8)",
|
||||
"ToolbarFontColor": "#663399",
|
||||
"ToolbarBackgroundColor": "rgba(255, 235, 205, 0.4)",
|
||||
"ToolbarPaddingLeft": 10,
|
||||
"ToolbarPaddingRight": 10
|
||||
}
|
||||
|
|
|
@ -51,5 +51,9 @@
|
|||
"PreviewSplitLineColor": "#788494",
|
||||
"PreviewPropertyTitleColor": "#455A64",
|
||||
"PreviewPropertyContentColor": "#455A64",
|
||||
"PreviewTextSelectionColor": "rgba(173, 216, 230, 0.8)"
|
||||
"PreviewTextSelectionColor": "rgba(173, 216, 230, 0.8)",
|
||||
"ToolbarFontColor": "#455A64",
|
||||
"ToolbarBackgroundColor": "rgba(240, 235, 225, 0.4)",
|
||||
"ToolbarPaddingLeft": 10,
|
||||
"ToolbarPaddingRight": 10
|
||||
}
|
||||
|
|
|
@ -51,5 +51,9 @@
|
|||
"PreviewSplitLineColor": "#999999",
|
||||
"PreviewPropertyTitleColor": "#663300",
|
||||
"PreviewPropertyContentColor": "#663300",
|
||||
"PreviewTextSelectionColor": "rgba(255, 215, 0, 0.8)"
|
||||
"PreviewTextSelectionColor": "rgba(255, 215, 0, 0.8)",
|
||||
"ToolbarFontColor": "#663300",
|
||||
"ToolbarBackgroundColor": "rgba(245, 245, 220, 0.4)",
|
||||
"ToolbarPaddingLeft": 10,
|
||||
"ToolbarPaddingRight": 10
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package share
|
||||
|
||||
type Theme struct {
|
||||
ThemeId string
|
||||
ThemeName string
|
||||
ThemeAuthor string
|
||||
ThemeUrl string
|
||||
Version string
|
||||
IsSystem bool
|
||||
IsInstalled bool
|
||||
ThemeId string
|
||||
ThemeName string
|
||||
ThemeAuthor string
|
||||
ThemeUrl string
|
||||
Version string
|
||||
Description string
|
||||
ScreenshotUrls []string
|
||||
IsSystem bool
|
||||
IsInstalled bool
|
||||
|
||||
AppBackgroundColor string
|
||||
AppPaddingLeft int
|
||||
|
@ -54,6 +56,8 @@ type Theme struct {
|
|||
PreviewPropertyTitleColor string
|
||||
PreviewPropertyContentColor string
|
||||
PreviewTextSelectionColor string
|
||||
Description string
|
||||
ScreenshotUrls []string
|
||||
ToolbarFontColor string
|
||||
ToolbarBackgroundColor string
|
||||
ToolbarPaddingLeft int
|
||||
ToolbarPaddingRight int
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ type UI interface {
|
|||
GetAllThemes(ctx context.Context) []Theme
|
||||
ChangeTheme(ctx context.Context, theme Theme)
|
||||
InstallTheme(ctx context.Context, theme Theme)
|
||||
RestoreTheme(ctx context.Context)
|
||||
}
|
||||
|
||||
type ShowContext struct {
|
||||
|
|
|
@ -1,62 +1,5 @@
|
|||
package dto
|
||||
|
||||
type ThemeDto struct {
|
||||
ThemeId string
|
||||
ThemeName string
|
||||
ThemeAuthor string
|
||||
ThemeUrl string
|
||||
Version string
|
||||
IsInstalled bool
|
||||
IsSystem bool
|
||||
IsUpgradable bool
|
||||
|
||||
AppBackgroundColor string
|
||||
AppPaddingLeft int
|
||||
AppPaddingTop int
|
||||
AppPaddingRight int
|
||||
AppPaddingBottom int
|
||||
ResultContainerPaddingLeft int
|
||||
ResultContainerPaddingTop int
|
||||
ResultContainerPaddingRight int
|
||||
ResultContainerPaddingBottom int
|
||||
ResultItemBorderRadius int
|
||||
ResultItemPaddingLeft int
|
||||
ResultItemPaddingTop int
|
||||
ResultItemPaddingRight int
|
||||
ResultItemPaddingBottom int
|
||||
ResultItemTitleColor string
|
||||
ResultItemSubTitleColor string
|
||||
ResultItemTailTextColor string
|
||||
ResultItemBorderLeft string
|
||||
ResultItemActiveBackgroundColor string
|
||||
ResultItemActiveTitleColor string
|
||||
ResultItemActiveSubTitleColor string
|
||||
ResultItemActiveBorderLeft string
|
||||
ResultItemActiveTailTextColor string
|
||||
QueryBoxFontColor string
|
||||
QueryBoxBackgroundColor string
|
||||
QueryBoxBorderRadius int
|
||||
QueryBoxCursorColor string
|
||||
QueryBoxTextSelectionColor string
|
||||
ActionContainerBackgroundColor string
|
||||
ActionContainerHeaderFontColor string
|
||||
ActionContainerPaddingLeft int
|
||||
ActionContainerPaddingTop int
|
||||
ActionContainerPaddingRight int
|
||||
ActionContainerPaddingBottom int
|
||||
ActionItemActiveBackgroundColor string
|
||||
ActionItemActiveFontColor string
|
||||
ActionItemFontColor string
|
||||
ActionQueryBoxFontColor string
|
||||
ActionQueryBoxBackgroundColor string
|
||||
ActionQueryBoxBorderRadius int
|
||||
PreviewFontColor string
|
||||
PreviewSplitLineColor string
|
||||
PreviewPropertyTitleColor string
|
||||
PreviewPropertyContentColor string
|
||||
PreviewTextSelectionColor string
|
||||
}
|
||||
|
||||
type SettingTheme struct {
|
||||
ThemeId string
|
||||
ThemeName string
|
||||
|
|
|
@ -328,11 +328,26 @@ func (m *Manager) AddTheme(ctx context.Context, theme share.Theme) {
|
|||
|
||||
func (m *Manager) RemoveTheme(ctx context.Context, theme share.Theme) {
|
||||
m.themes.Delete(theme.ThemeId)
|
||||
}
|
||||
|
||||
func (m *Manager) ChangeToDefaultTheme(ctx context.Context) {
|
||||
if v, ok := m.themes.Load("53c1d0a4-ffc8-4d90-91dc-b408fb0b9a03"); ok {
|
||||
m.ChangeTheme(ctx, v)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) RestoreTheme(ctx context.Context) {
|
||||
var uninstallThemes = m.themes.FilterList(func(key string, theme share.Theme) bool {
|
||||
return !theme.IsSystem
|
||||
})
|
||||
|
||||
for _, theme := range uninstallThemes {
|
||||
GetStoreManager().Uninstall(ctx, theme)
|
||||
}
|
||||
|
||||
m.ChangeToDefaultTheme(ctx)
|
||||
}
|
||||
|
||||
func (m *Manager) GetThemeById(themeId string) share.Theme {
|
||||
if v, ok := m.themes.Load(themeId); ok {
|
||||
return v
|
||||
|
|
|
@ -421,6 +421,8 @@ func handleThemeUninstall(w http.ResponseWriter, r *http.Request) {
|
|||
if uninstallErr != nil {
|
||||
writeErrorResponse(w, "can't uninstall theme: "+uninstallErr.Error())
|
||||
return
|
||||
} else {
|
||||
GetUIManager().ChangeToDefaultTheme(ctx)
|
||||
}
|
||||
|
||||
writeSuccessResponse(w, "")
|
||||
|
|
|
@ -120,6 +120,8 @@ func (s *Store) Install(ctx context.Context, theme share.Theme) error {
|
|||
}
|
||||
|
||||
func (s *Store) Uninstall(ctx context.Context, theme share.Theme) error {
|
||||
logger.Info(ctx, fmt.Sprintf("uninstalling theme: %s", theme.ThemeName))
|
||||
|
||||
if GetUIManager().IsSystemTheme(theme.ThemeId) {
|
||||
return fmt.Errorf("can't uninstall system theme")
|
||||
}
|
||||
|
|
|
@ -73,6 +73,10 @@ func (u *uiImpl) GetAllThemes(ctx context.Context) []share.Theme {
|
|||
return GetUIManager().GetAllThemes(ctx)
|
||||
}
|
||||
|
||||
func (u *uiImpl) RestoreTheme(ctx context.Context) {
|
||||
GetUIManager().RestoreTheme(ctx)
|
||||
}
|
||||
|
||||
func (u *uiImpl) PickFiles(ctx context.Context, params share.PickFilesParams) []string {
|
||||
respData, err := u.invokeWebsocketMethod(ctx, "PickFiles", params)
|
||||
if err != nil {
|
||||
|
|
|
@ -100,6 +100,20 @@ func (h *HashMap[K, V]) Range(f func(K, V) bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (h *HashMap[K, V]) FilterList(f func(K, V) bool) []V {
|
||||
h.rw.RLock()
|
||||
defer h.rw.RUnlock()
|
||||
|
||||
var list []V
|
||||
for k, v := range h.inner {
|
||||
if f(k, v) {
|
||||
list = append(list, v)
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
func (h *HashMap[K, V]) String() (s string) {
|
||||
h.Range(func(k K, v V) bool {
|
||||
s += fmt.Sprintf("{%+v:%+v}, ", k, v)
|
||||
|
|
Loading…
Reference in New Issue