feat: Search feature
This commit is contained in:
parent
8260480d90
commit
6ea4d0c263
10 changed files with 836 additions and 72 deletions
105
lib/pages/chat_search/chat_search_view.dart
Normal file
105
lib/pages/chat_search/chat_search_view.dart
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/pages/chat_search/chat_search_files_tab.dart';
|
||||
import 'package:fluffychat/pages/chat_search/chat_search_images_tab.dart';
|
||||
import 'package:fluffychat/pages/chat_search/chat_search_message_tab.dart';
|
||||
import 'package:fluffychat/pages/chat_search/chat_search_page.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
|
||||
class ChatSearchView extends StatelessWidget {
|
||||
final ChatSearchController controller;
|
||||
|
||||
const ChatSearchView(this.controller, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final room = controller.room;
|
||||
if (room == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(L10n.of(context)!.oopsSomethingWentWrong)),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child:
|
||||
Text(L10n.of(context)!.youAreNoLongerParticipatingInThisChat),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: const Center(child: BackButton()),
|
||||
titleSpacing: 0,
|
||||
title: Text(
|
||||
L10n.of(context)!.searchIn(
|
||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
||||
),
|
||||
),
|
||||
),
|
||||
body: MaxWidthBody(
|
||||
withScrolling: false,
|
||||
child: Column(
|
||||
children: [
|
||||
if (FluffyThemes.isThreeColumnMode(context))
|
||||
const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller.searchController,
|
||||
onSubmitted: (_) => controller.restartSearch(),
|
||||
autofocus: true,
|
||||
enabled: controller.tabController.index == 0,
|
||||
decoration: InputDecoration(
|
||||
hintText: L10n.of(context)!.searchIn(
|
||||
room.getLocalizedDisplayname(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
),
|
||||
),
|
||||
suffixIcon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
),
|
||||
),
|
||||
TabBar(
|
||||
controller: controller.tabController,
|
||||
tabs: [
|
||||
Tab(child: Text(L10n.of(context)!.messages)),
|
||||
Tab(child: Text(L10n.of(context)!.photos)),
|
||||
Tab(child: Text(L10n.of(context)!.files)),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller.tabController,
|
||||
children: [
|
||||
ChatSearchMessageTab(
|
||||
searchQuery: controller.searchController.text,
|
||||
room: room,
|
||||
startSearch: controller.startSearch,
|
||||
searchStream: controller.searchStream,
|
||||
),
|
||||
ChatSearchImagesTab(
|
||||
room: room,
|
||||
startSearch: controller.startSearch,
|
||||
searchStream: controller.searchStream,
|
||||
),
|
||||
ChatSearchFilesTab(
|
||||
room: room,
|
||||
startSearch: controller.startSearch,
|
||||
searchStream: controller.searchStream,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue