✨ Configurable command pattle search engine
This commit is contained in:
@@ -1534,5 +1534,8 @@
|
|||||||
"chatRoomPinned": "Chat room pinned successfully.",
|
"chatRoomPinned": "Chat room pinned successfully.",
|
||||||
"chatRoomUnpinned": "Chat room unpinned successfully.",
|
"chatRoomUnpinned": "Chat room unpinned successfully.",
|
||||||
"pinnedChatRoom": "Pinned Rooms",
|
"pinnedChatRoom": "Pinned Rooms",
|
||||||
"settingsGroupedChatList": "Grouped Chat List"
|
"settingsGroupedChatList": "Grouped Chat List",
|
||||||
|
"settingsNotifyWithHaptic": "Notification with Haptic Feedback",
|
||||||
|
"settingsDashSearchEngine": "Search Engine for web",
|
||||||
|
"settingsDashSearchEngineHelper": "Use %s as the placeholder for the query."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -846,7 +846,7 @@ class SettingsScreen extends HookConsumerWidget {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
controller: TextEditingController(text: settings.dashSearchEngine),
|
controller: TextEditingController(text: settings.dashSearchEngine),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'https://duckduckgo.com/?q=%s',
|
hintText: 'https://google.com/?q=%s',
|
||||||
helperText: 'settingsDashSearchEngineHelper'.tr(),
|
helperText: 'settingsDashSearchEngineHelper'.tr(),
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: const Icon(Symbols.restart_alt),
|
icon: const Icon(Symbols.restart_alt),
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:island/models/chat.dart';
|
|||||||
import 'package:island/models/route_item.dart';
|
import 'package:island/models/route_item.dart';
|
||||||
import 'package:island/pods/chat/chat_room.dart';
|
import 'package:island/pods/chat/chat_room.dart';
|
||||||
import 'package:island/pods/chat/chat_summary.dart';
|
import 'package:island/pods/chat/chat_summary.dart';
|
||||||
|
import 'package:island/pods/config.dart';
|
||||||
import 'package:island/pods/userinfo.dart';
|
import 'package:island/pods/userinfo.dart';
|
||||||
import 'package:island/route.dart';
|
import 'package:island/route.dart';
|
||||||
import 'package:island/services/responsive.dart';
|
import 'package:island/services/responsive.dart';
|
||||||
@@ -150,7 +151,7 @@ class CommandPattleWidget extends HookConsumerWidget {
|
|||||||
filteredChats.isEmpty &&
|
filteredChats.isEmpty &&
|
||||||
filteredSpecialActions.isEmpty &&
|
filteredSpecialActions.isEmpty &&
|
||||||
filteredRoutes.isEmpty
|
filteredRoutes.isEmpty
|
||||||
? _getFallbackActions(context, searchQuery.value)
|
? _getFallbackActions(ref, context, searchQuery.value)
|
||||||
: <FallbackAction>[];
|
: <FallbackAction>[];
|
||||||
|
|
||||||
// Combine results: fallbacks first, then chats, special actions, routes
|
// Combine results: fallbacks first, then chats, special actions, routes
|
||||||
@@ -402,9 +403,12 @@ class CommandPattleWidget extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static List<FallbackAction> _getFallbackActions(
|
static List<FallbackAction> _getFallbackActions(
|
||||||
|
WidgetRef ref,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
String query,
|
String query,
|
||||||
) {
|
) {
|
||||||
|
final settings = ref.watch(appSettingsProvider);
|
||||||
|
|
||||||
final List<FallbackAction> actions = [];
|
final List<FallbackAction> actions = [];
|
||||||
|
|
||||||
// Check if query is a URL
|
// Check if query is a URL
|
||||||
@@ -448,12 +452,14 @@ class CommandPattleWidget extends HookConsumerWidget {
|
|||||||
actions.add(
|
actions.add(
|
||||||
FallbackAction(
|
FallbackAction(
|
||||||
name: 'Search the web',
|
name: 'Search the web',
|
||||||
description: 'Search "$query" on Google',
|
description: 'Search "$query" on the Internet',
|
||||||
icon: Symbols.search,
|
icon: Symbols.search,
|
||||||
action: () async {
|
action: () async {
|
||||||
final searchUri = Uri.https('www.google.com', '/search', {
|
final searchUri = Uri.parse(
|
||||||
'q': query,
|
settings.dashSearchEngine != null
|
||||||
});
|
? settings.dashSearchEngine!.replaceFirst('%s', query)
|
||||||
|
: 'https://www.google.com/search?q=$query',
|
||||||
|
);
|
||||||
if (await canLaunchUrl(searchUri)) {
|
if (await canLaunchUrl(searchUri)) {
|
||||||
await launchUrl(searchUri, mode: LaunchMode.externalApplication);
|
await launchUrl(searchUri, mode: LaunchMode.externalApplication);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user