Skip to content

Commit cab9a7a

Browse files
committed
feat: add emoji selector component and update image handling in plugin settings
1 parent be50a34 commit cab9a7a

File tree

7 files changed

+740
-124
lines changed

7 files changed

+740
-124
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ This document guides AI coding agents working in this repository.
142142
- **Refactors**: Scan `AGENTS.md` and `README.md` files first
143143
- **Build**: Verify with `make build` in wox.core (you can skip UI build for small changes)
144144
- **Tests**: Run narrowest relevant tests after changes, avoid breaking unrelated tests
145+
- **Format**: When formatting your code, you must adhere to the coding style guidelines specified in Wox.code-workspace file.

wox.core/resource/lang/en_US.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@
280280
"ui_about_description": "Wox is a launcher for Windows, macOS and Linux that simply works.",
281281
"ui_image_editor_emoji": "Emoji",
282282
"ui_image_editor_upload_image": "Upload Image",
283+
"ui_select_emoji": "Select Emoji",
284+
"ui_select_emoji_group_recommended": "Recommended",
285+
"ui_select_emoji_group_faces": "Smileys",
286+
"ui_select_emoji_group_people": "People",
287+
"ui_select_emoji_group_animals": "Animals",
288+
"ui_select_emoji_group_food": "Food",
289+
"ui_select_emoji_group_activities": "Activities",
290+
"ui_select_emoji_group_travel": "Travel",
291+
"ui_select_emoji_group_objects": "Objects",
292+
"ui_select_emoji_group_symbols": "Symbols",
283293
"ui_theme_preview_title": "Wox Theme Preview",
284294
"ui_theme_preview_text_1": "Search for applications, folders, files and more",
285295
"ui_theme_preview_text_2": "Plenty of Plugins and AI Themes",
@@ -865,4 +875,4 @@
865875
"ui_ai_chat_history_history": "History",
866876
"ui_ai_chat_failed_to_chat": "Failed to chat, please try again",
867877
"ui_ai_chat_error": "Error: %s"
868-
}
878+
}

wox.core/resource/lang/pt_BR.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@
277277
"ui_about_description": "Wox é um launcher para Windows, macOS e Linux que simplesmente funciona.",
278278
"ui_image_editor_emoji": "Emoji",
279279
"ui_image_editor_upload_image": "Carregar imagem",
280+
"ui_select_emoji": "Selecionar emoji",
281+
"ui_select_emoji_group_recommended": "Recomendados",
282+
"ui_select_emoji_group_faces": "Carinhas",
283+
"ui_select_emoji_group_people": "Pessoas",
284+
"ui_select_emoji_group_animals": "Animais",
285+
"ui_select_emoji_group_food": "Comida",
286+
"ui_select_emoji_group_activities": "Atividades",
287+
"ui_select_emoji_group_travel": "Viagem",
288+
"ui_select_emoji_group_objects": "Objetos",
289+
"ui_select_emoji_group_symbols": "Símbolos",
280290
"ui_theme_preview_title": "Visualização do Tema Wox",
281291
"ui_theme_preview_text_1": "Pesquisar aplicativos, pastas, arquivos e mais",
282292
"ui_theme_preview_text_2": "Muitos Plugins e Temas de IA",
@@ -852,4 +862,4 @@
852862
"ui_ai_chat_history_history": "Histórico",
853863
"ui_ai_chat_failed_to_chat": "Falha ao conversar, tente novamente",
854864
"ui_ai_chat_error": "Erro: %s"
855-
}
865+
}

wox.core/resource/lang/ru_RU.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@
277277
"ui_about_description": "Wox - это лаунчер для Windows, macOS и Linux, который просто работает.",
278278
"ui_image_editor_emoji": "Эмодзи",
279279
"ui_image_editor_upload_image": "Загрузить изображение",
280+
"ui_select_emoji": "Выбрать эмодзи",
281+
"ui_select_emoji_group_recommended": "Рекомендуемые",
282+
"ui_select_emoji_group_faces": "Смайлы",
283+
"ui_select_emoji_group_people": "Люди",
284+
"ui_select_emoji_group_animals": "Животные",
285+
"ui_select_emoji_group_food": "Еда",
286+
"ui_select_emoji_group_activities": "Активности",
287+
"ui_select_emoji_group_travel": "Путешествия",
288+
"ui_select_emoji_group_objects": "Объекты",
289+
"ui_select_emoji_group_symbols": "Символы",
280290
"ui_theme_preview_title": "Предпросмотр темы Wox",
281291
"ui_theme_preview_text_1": "Поиск приложений, папок, файлов и многого другого",
282292
"ui_theme_preview_text_2": "Множество плагинов и AI тем",
@@ -853,4 +863,4 @@
853863
"ui_ai_chat_history_history": "История",
854864
"ui_ai_chat_failed_to_chat": "Не удалось отправить сообщение, попробуйте еще раз",
855865
"ui_ai_chat_error": "Ошибка: %s"
856-
}
866+
}

wox.core/resource/lang/zh_CN.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@
280280
"ui_about_description": "Wox 是一个适用于 Windows、macOS 和 Linux 的启动器,简单易用。",
281281
"ui_image_editor_emoji": "表情符号",
282282
"ui_image_editor_upload_image": "上传图片",
283+
"ui_select_emoji": "选择表情",
284+
"ui_select_emoji_group_recommended": "推荐",
285+
"ui_select_emoji_group_faces": "笑脸",
286+
"ui_select_emoji_group_people": "人物",
287+
"ui_select_emoji_group_animals": "动物",
288+
"ui_select_emoji_group_food": "食物",
289+
"ui_select_emoji_group_activities": "活动",
290+
"ui_select_emoji_group_travel": "出行",
291+
"ui_select_emoji_group_objects": "物品",
292+
"ui_select_emoji_group_symbols": "符号",
283293
"ui_theme_preview_title": "Wox 主题预览",
284294
"ui_theme_preview_text_1": "搜索应用程序、文件夹、文件等",
285295
"ui_theme_preview_text_2": "丰富的插件和 AI 主题",
@@ -865,4 +875,4 @@
865875
"ui_ai_chat_history_history": "历史",
866876
"ui_ai_chat_failed_to_chat": "对话失败,请重试",
867877
"ui_ai_chat_error": "错误:%s"
868-
}
878+
}

wox.ui.flutter/wox/lib/components/plugin/wox_setting_plugin_table_update_view.dart

Lines changed: 21 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import 'dart:convert';
2-
import 'dart:io';
31
import 'dart:math' as math;
42
import 'package:flutter/material.dart';
5-
import 'package:file_picker/file_picker.dart';
63
import 'package:flutter/services.dart';
74
import 'package:uuid/v4.dart';
85
import 'package:wox/api/wox_api.dart';
96
import 'package:wox/components/wox_ai_model_selector_view.dart';
107
import 'package:wox/components/wox_button.dart';
118
import 'package:wox/components/wox_dropdown_button.dart';
129
import 'package:wox/components/wox_hotkey_recorder_view.dart';
13-
import 'package:wox/components/wox_image_view.dart';
10+
import 'package:wox/components/wox_image_selector.dart';
1411
import 'package:wox/components/wox_textfield.dart';
1512
import 'package:wox/components/wox_checkbox.dart';
1613
import 'package:wox/components/wox_checkbox_tile.dart';
@@ -152,124 +149,20 @@ class _WoxSettingPluginTableUpdateState extends State<WoxSettingPluginTableUpdat
152149
return Get.find<WoxSettingController>().tr(key);
153150
}
154151

155-
Widget _buildWoxImageEditor(PluginSettingValueTableColumn column) {
156-
WoxImage? currentImage;
157-
dynamic imgJson = getValue(column.key);
158-
152+
WoxImage getWoxImageValue(String key) {
153+
final imgJson = getValue(key);
154+
if (imgJson is WoxImage) {
155+
return imgJson;
156+
}
159157
if (imgJson is String && imgJson == "") {
160-
currentImage = WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_EMOJI.code, imageData: "🤖");
161-
} else if (imgJson is WoxImage) {
162-
currentImage = imgJson;
163-
} else {
164-
//image sholuld be WoxImage map
165-
try {
166-
currentImage = WoxImage.fromJson(imgJson);
167-
} catch (e) {
168-
currentImage = WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_EMOJI.code, imageData: "🤖");
169-
}
158+
return WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_EMOJI.code, imageData: "🤖");
170159
}
171160

172-
return Row(
173-
crossAxisAlignment: CrossAxisAlignment.center,
174-
children: [
175-
Container(
176-
width: 80,
177-
height: 80,
178-
decoration: BoxDecoration(border: Border.all(color: getThemeSubTextColor().withAlpha(76)), borderRadius: BorderRadius.circular(8)),
179-
child: ClipRRect(
180-
borderRadius: BorderRadius.circular(8),
181-
child: Center(
182-
// Center the preview content (especially emoji) in the 80x80 box
183-
child: WoxImageView(woxImage: currentImage, width: 80, height: 80),
184-
),
185-
),
186-
),
187-
const SizedBox(width: 16),
188-
Wrap(
189-
spacing: 8,
190-
runSpacing: 8,
191-
children: [
192-
WoxButton.secondary(
193-
text: tr('ui_image_editor_emoji'),
194-
icon: Icon(Icons.emoji_emotions_outlined, size: 14, color: getThemeTextColor()),
195-
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
196-
onPressed: () async {
197-
final emojiResult = await _showEmojiPicker(context);
198-
if (emojiResult != null && emojiResult.isNotEmpty) {
199-
final newImage = WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_EMOJI.code, imageData: emojiResult);
200-
updateValue(column.key, newImage);
201-
setState(() {});
202-
}
203-
},
204-
),
205-
WoxButton.secondary(
206-
text: tr('ui_image_editor_upload_image'),
207-
icon: Icon(Icons.file_upload_outlined, size: 14, color: getThemeTextColor()),
208-
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
209-
onPressed: () async {
210-
final result = await FilePicker.platform.pickFiles(type: FileType.image, allowMultiple: false);
211-
212-
if (result != null && result.files.isNotEmpty && result.files.first.path != null) {
213-
final filePath = result.files.first.path!;
214-
final file = File(filePath);
215-
if (await file.exists()) {
216-
final bytes = await file.readAsBytes();
217-
final base64Image = base64Encode(bytes);
218-
219-
final newImage = WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_BASE64.code, imageData: "data:image/png;base64,$base64Image");
220-
221-
updateValue(column.key, newImage);
222-
setState(() {});
223-
}
224-
}
225-
},
226-
),
227-
],
228-
),
229-
],
230-
);
231-
}
232-
233-
Future<String?> _showEmojiPicker(BuildContext context) async {
234-
final commonEmojis = ["🤖", "👨", "👩", "🧠", "💡", "🔍", "📊", "📈", "📝", "🛠", "⚙️", "🧩", "🎮", "🎯", "🏆", "🎨", "🎭", "🎬", "📱", "💻"];
235-
236-
String? selectedEmoji;
237-
238-
await showDialog(
239-
context: context,
240-
builder: (context) {
241-
return AlertDialog(
242-
title: Text(tr('ui_select_emoji')),
243-
content: SizedBox(
244-
width: 300,
245-
height: 200,
246-
child: GridView.builder(
247-
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5, childAspectRatio: 1),
248-
itemCount: commonEmojis.length,
249-
itemBuilder: (context, index) {
250-
return InkWell(
251-
onTap: () {
252-
selectedEmoji = commonEmojis[index];
253-
Navigator.pop(context);
254-
},
255-
child: Center(child: Text(commonEmojis[index], style: const TextStyle(fontSize: 24))),
256-
);
257-
},
258-
),
259-
),
260-
actions: [
261-
WoxButton.secondary(
262-
text: tr('ui_cancel'),
263-
onPressed: () {
264-
Navigator.pop(context);
265-
},
266-
),
267-
],
268-
);
269-
},
270-
);
271-
272-
return selectedEmoji;
161+
try {
162+
return WoxImage.fromJson(imgJson);
163+
} catch (e) {
164+
return WoxImage(imageType: WoxImageTypeEnum.WOX_IMAGE_TYPE_EMOJI.code, imageData: "🤖");
165+
}
273166
}
274167

275168
// Load all tools list
@@ -509,7 +402,15 @@ class _WoxSettingPluginTableUpdateState extends State<WoxSettingPluginTableUpdat
509402
),
510403
);
511404
case PluginSettingValueType.pluginSettingValueTableColumnTypeWoxImage:
512-
return Expanded(child: _buildWoxImageEditor(column));
405+
return Expanded(
406+
child: WoxImageSelector(
407+
value: getWoxImageValue(column.key),
408+
onChanged: (newImage) {
409+
updateValue(column.key, newImage);
410+
setState(() {});
411+
},
412+
),
413+
);
513414
case PluginSettingValueType.pluginSettingValueTableColumnTypeTextList:
514415
var columnValues = getValue(column.key);
515416
return Expanded(

0 commit comments

Comments
 (0)