Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions assets/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,10 @@
"selectedCount": "Vybráno: %d",
"moreActions": "Další akce",
"jumpToLatest": "Skočit na nejnovější",
"searchMessages": "Hledat zprávy",
"searchInChat": "Hledat v tomto chatu",
"searchHint": "Hledat v lokální historii",
"searchEmptyHint": "Napiš text nebo zvol filtr. Zprávy se hledají jen v tomto zařízení.",
"searchEmptyHint": "Napiš text. Hledá se jen v této konverzaci a jen v tomto zařízení.",
"noSearchResults": "Nic nenalezeno",
"anyType": "Jakýkoli typ",
"textOnly": "Text",
"anyDate": "Kdykoli",
"anySender": "Kdokoli",
"jumpToDate": "Skočit na datum",
"noMessagesOnDate": "Žádné zprávy od toho dne",
"allChats": "Vše",
Expand Down
7 changes: 1 addition & 6 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,10 @@
"selectedCount": "%d selected",
"moreActions": "More actions",
"jumpToLatest": "Jump to latest",
"searchMessages": "Search messages",
"searchInChat": "Search in this chat",
"searchHint": "Search the local history",
"searchEmptyHint": "Type something, or pick a filter. Messages are searched on this device only.",
"searchEmptyHint": "Type to search this conversation. Messages are searched on this device only.",
"noSearchResults": "Nothing found",
"anyType": "Any type",
"textOnly": "Text",
"anyDate": "Any date",
"anySender": "Anyone",
"jumpToDate": "Jump to date",
"noMessagesOnDate": "No messages from that day or later",
"allChats": "All",
Expand Down
21 changes: 21 additions & 0 deletions lib/pages/chat_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '../widgets/media_bubble.dart';
import '../widgets/settings_tile.dart';
import 'home_page.dart';
import 'media_viewer_page.dart';
import 'search_page.dart';

class ChatInfoPage extends StatefulWidget {
const ChatInfoPage(this.userId, {super.key});
Expand Down Expand Up @@ -98,6 +99,20 @@ class _ChatInfoPageState extends State<ChatInfoPage> {
);
}

/// Search this conversation. A picked hit is handed back to the chat page,
/// which jumps to it.
Future<void> _openSearch() async {
final user = await CacheUtils.getUserById(widget.userId);
if (user == null || !mounted) {
return;
}
final picked = await Navigator.of(context)
.push<DateTime>(stepRoute(MessageSearchPage(user)));
if (picked != null && mounted) {
Navigator.pop(context, picked);
}
}

@override
Widget build(BuildContext context) {
return Theme(
Expand All @@ -112,6 +127,12 @@ class _ChatInfoPageState extends State<ChatInfoPage> {
SliverToBoxAdapter(
child: Column(
children: [
// Search in this conversation
SettingsTile(
icon: Icons.search,
label: 'searchInChat'.tr(),
onPressed: _openSearch,
),
// Chat theme
SettingsTile(
icon: Icons.palette,
Expand Down
59 changes: 10 additions & 49 deletions lib/pages/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ import '../widgets/attachment_confirm_sheet.dart';
import '../widgets/chat_bubble.dart';
import 'chat_info_page.dart';
import 'forward_page.dart';
import 'search_page.dart';

class ChatPage extends StatefulWidget {
const ChatPage(this.user, {this.jumpTo, super.key});
const ChatPage(this.user, {super.key});
final User user;

/// Opens the conversation at this message instead of the newest one.
final DateTime? jumpTo;

@override
State<ChatPage> createState() => _ChatPageState();
}
Expand Down Expand Up @@ -127,10 +123,6 @@ class _ChatPageState extends State<ChatPage> {
await _loadMessages();
// Then top the conversation up from the server archive
_loadHistory();
final jumpTo = widget.jumpTo;
if (jumpTo != null) {
await _jumpToMessage(jumpTo);
}
}

/// Keeps the newest message on screen when the keyboard opens.
Expand Down Expand Up @@ -385,18 +377,14 @@ class _ChatPageState extends State<ChatPage> {
}

Future<void> _openChatInfo() async {
await Navigator.of(context).push(stepRoute(ChatInfoPage(widget.user.id)));
// The info page hands back a timestamp when a search hit was picked there.
final jumpTo = await Navigator.of(context)
.push<DateTime>(stepRoute(ChatInfoPage(widget.user.id)));
// The theme (and possibly the user) may have changed while it was open.
await _loadChatTheme();
await _loadMessages();
}

/// Search this conversation; the picked result is jumped to.
Future<void> _openSearch() async {
final picked = await Navigator.of(context)
.push<DateTime>(stepRoute(MessageSearchPage(peer: widget.user)));
if (picked != null && mounted) {
await _jumpToMessage(picked);
if (jumpTo != null && mounted) {
await _jumpToMessage(jumpTo);
}
}

Expand Down Expand Up @@ -1380,37 +1368,10 @@ class _ChatPageState extends State<ChatPage> {
),
// Action buttons
actions: [
PopupMenuButton<String>(
tooltip: 'moreActions'.tr(),
onSelected: (value) {
if (value == 'search') {
_openSearch();
} else {
_jumpToDate();
}
},
itemBuilder: (context) => [
PopupMenuItem(
value: 'search',
child: Row(
children: [
const Icon(Icons.search),
const SizedBox(width: 12),
Text('searchInChat'.tr()),
],
),
),
PopupMenuItem(
value: 'jumpDate',
child: Row(
children: [
const Icon(Icons.event),
const SizedBox(width: 12),
Text('jumpToDate'.tr()),
],
),
),
],
IconButton(
icon: const Icon(Icons.event),
tooltip: 'jumpToDate'.tr(),
onPressed: _jumpToDate,
),
IconButton(
icon: const Icon(Icons.info),
Expand Down
10 changes: 0 additions & 10 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import '../utils/message_notifier.dart';
import '../utils/notification_service.dart';
import 'search_user_page.dart';
import 'settings_page.dart';
import 'search_page.dart';
import '../utils/dialog_utils.dart';
import '../widgets/invite_list_item.dart';
import 'package:whisper_openapi_client_dart/api.dart';
Expand Down Expand Up @@ -484,15 +483,6 @@ class _HomePageState extends State<HomePage>
title: Text('msgPage'.tr()),
// Action buttons
actions: [
// Search across every locally stored conversation
IconButton(
icon: const Icon(Icons.search),
tooltip: 'searchMessages'.tr(),
onPressed: () {
Navigator.of(context)
.push(stepRoute(const MessageSearchPage()));
},
),
// Settings
IconButton(
icon: const Icon(Icons.settings),
Expand Down
Loading
Loading