Initial commit
This commit is contained in:
122
lib/pages/chat_search/chat_search_view.dart
Normal file
122
lib/pages/chat_search/chat_search_view.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
|
||||
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import 'package:tatchat/config/themes.dart';
|
||||
import 'package:tatchat/l10n/l10n.dart';
|
||||
import 'package:tatchat/pages/chat_search/chat_search_files_tab.dart';
|
||||
import 'package:tatchat/pages/chat_search/chat_search_images_tab.dart';
|
||||
import 'package:tatchat/pages/chat_search/chat_search_message_tab.dart';
|
||||
import 'package:tatchat/pages/chat_search/chat_search_page.dart';
|
||||
import 'package:tatchat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:tatchat/widgets/layouts/max_width_body.dart';
|
||||
import 'package:material_ui/material_ui.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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final theme = Theme.of(context);
|
||||
|
||||
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).search,
|
||||
prefixIcon: const Icon(Icons.search_outlined),
|
||||
filled: true,
|
||||
fillColor: theme.colorScheme.secondaryContainer,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
color: theme.colorScheme.onPrimaryContainer,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TabBar(
|
||||
controller: controller.tabController,
|
||||
tabs: [
|
||||
Tab(child: Text(L10n.of(context).messages)),
|
||||
Tab(child: Text(L10n.of(context).gallery)),
|
||||
Tab(child: Text(L10n.of(context).files)),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: controller.tabController,
|
||||
children: [
|
||||
ChatSearchMessageTab(
|
||||
searchQuery: controller.searchController.text,
|
||||
room: room,
|
||||
onStartSearch: controller.startSearch,
|
||||
events: controller.messages,
|
||||
endReached: controller.messagesEndReached,
|
||||
isLoading: controller.isLoading,
|
||||
searchedUntil: controller.searchedUntil,
|
||||
),
|
||||
ChatSearchImagesTab(
|
||||
room: room,
|
||||
onStartSearch: controller.startSearch,
|
||||
events: controller.images,
|
||||
endReached: controller.imagesEndReached,
|
||||
isLoading: controller.isLoading,
|
||||
searchedUntil: controller.searchedUntil,
|
||||
),
|
||||
ChatSearchFilesTab(
|
||||
room: room,
|
||||
onStartSearch: controller.startSearch,
|
||||
events: controller.files,
|
||||
endReached: controller.filesEndReached,
|
||||
isLoading: controller.isLoading,
|
||||
searchedUntil: controller.searchedUntil,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user