remove conversations from main ribbon and instead place search there
This commit is contained in:
parent
8e7b0e013d
commit
7933caa158
|
@ -1,134 +0,0 @@
|
||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:localization/localization.dart';
|
|
||||||
import 'package:loris/business_logic/account/account.dart';
|
|
||||||
import 'package:loris/business_logic/timeline/timeline.dart';
|
|
||||||
import 'package:loris/global.dart' as global;
|
|
||||||
import 'package:loris/business_logic/search/search.dart' as logic;
|
|
||||||
import 'package:loris/themes/themes.dart' as themes;
|
|
||||||
|
|
||||||
import '../partials/post.dart';
|
|
||||||
|
|
||||||
class SearchDialogue extends StatefulWidget {
|
|
||||||
const SearchDialogue({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<SearchDialogue> createState() => _SearchDialogueState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SearchDialogueState extends State<SearchDialogue> {
|
|
||||||
String searchText = "";
|
|
||||||
String searchTextControl = "";
|
|
||||||
Map<String, logic.SearchResult> results = {};
|
|
||||||
int searched = 0;
|
|
||||||
|
|
||||||
void searchSingle(String id) async {
|
|
||||||
final result = await logic.searchForEntry(searchText, id);
|
|
||||||
if (result.key == 200 && mounted) {
|
|
||||||
setState(() {
|
|
||||||
results.addAll({id: result.value!});
|
|
||||||
searched++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void search() {
|
|
||||||
searched = 0;
|
|
||||||
searchTextControl = searchText;
|
|
||||||
for (var id in global.settings!.identities.keys.toList()) {
|
|
||||||
searchSingle(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<AccountModel> accountModels = [];
|
|
||||||
List<PostModel> postModels = [];
|
|
||||||
results.forEach(
|
|
||||||
(key, value) {
|
|
||||||
for (var m in value.accountModels) {
|
|
||||||
accountModels.add(m);
|
|
||||||
}
|
|
||||||
for (var m in value.postModels) {
|
|
||||||
postModels.add(m);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return BackdropFilter(
|
|
||||||
filter:
|
|
||||||
ImageFilter.blur(sigmaX: 10, sigmaY: 10, tileMode: TileMode.mirror),
|
|
||||||
child: SimpleDialog(
|
|
||||||
contentPadding: const EdgeInsets.all(0),
|
|
||||||
titlePadding: const EdgeInsets.all(0),
|
|
||||||
title: Column(
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
|
||||||
autofocus: true,
|
|
||||||
keyboardType: TextInputType.url,
|
|
||||||
onEditingComplete: () {
|
|
||||||
if (searchText.isNotEmpty) {
|
|
||||||
search();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onChanged: ((value) => setState(() {
|
|
||||||
searchText = value;
|
|
||||||
})),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
prefixIcon: Icon(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
Icons.search,
|
|
||||||
))),
|
|
||||||
if (searched < global.settings!.identities.length &&
|
|
||||||
searchTextControl.isNotEmpty)
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
SelectableText(
|
|
||||||
"${"searched".i18n()} $searched ${searched == 1 ? "instance".i18n() : "instances".i18n()}"),
|
|
||||||
const LinearProgressIndicator(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: global.getWidth(context),
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: global.getConstraints(context).maxWidth,
|
|
||||||
maxHeight: MediaQuery.of(context).size.height * 2 / 3,
|
|
||||||
),
|
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: accountModels.length + postModels.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
if (index < accountModels.length) {
|
|
||||||
final model = accountModels[index];
|
|
||||||
return Padding(
|
|
||||||
padding: themes.defaultMargins,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SelectableText(model.identity),
|
|
||||||
DisplayName(account: model)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final model = postModels[index - accountModels.length];
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SelectableText(model.identity),
|
|
||||||
Post(
|
|
||||||
model: model,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +1,140 @@
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:localization/localization.dart';
|
||||||
|
import 'package:loris/business_logic/account/account.dart';
|
||||||
|
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||||
|
import 'package:loris/global.dart' as global;
|
||||||
|
import 'package:loris/business_logic/search/search.dart' as logic;
|
||||||
|
import 'package:loris/themes/themes.dart' as themes;
|
||||||
|
|
||||||
|
import '../../partials/post.dart';
|
||||||
|
|
||||||
|
class SearchPage extends StatefulWidget {
|
||||||
|
const SearchPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SearchPage> createState() => _SearchPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchPageState extends State<SearchPage> {
|
||||||
|
String searchText = "";
|
||||||
|
String searchTextControl = "";
|
||||||
|
Map<String, logic.SearchResult> results = {};
|
||||||
|
int searched = 0;
|
||||||
|
|
||||||
|
void searchSingle(String id) async {
|
||||||
|
final result = await logic.searchForEntry(searchText, id);
|
||||||
|
if (result.key == 200 && mounted) {
|
||||||
|
setState(() {
|
||||||
|
results.addAll({id: result.value!});
|
||||||
|
searched++;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void search() {
|
||||||
|
searched = 0;
|
||||||
|
searchTextControl = searchText;
|
||||||
|
for (var id in global.settings!.identities.keys.toList()) {
|
||||||
|
searchSingle(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<AccountModel> accountModels = [];
|
||||||
|
List<PostModel> postModels = [];
|
||||||
|
results.forEach(
|
||||||
|
(key, value) {
|
||||||
|
for (var m in value.accountModels) {
|
||||||
|
accountModels.add(m);
|
||||||
|
}
|
||||||
|
for (var m in value.postModels) {
|
||||||
|
postModels.add(m);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
width: 2,
|
||||||
|
))),
|
||||||
|
child: Material(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
autofocus: true,
|
||||||
|
keyboardType: TextInputType.url,
|
||||||
|
onEditingComplete: () {
|
||||||
|
if (searchText.isNotEmpty) {
|
||||||
|
search();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onChanged: ((value) => setState(() {
|
||||||
|
searchText = value;
|
||||||
|
})),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
prefixIcon: Icon(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
Icons.search,
|
||||||
|
))),
|
||||||
|
if (searched < global.settings!.identities.length &&
|
||||||
|
searchTextControl.isNotEmpty)
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
SelectableText(
|
||||||
|
"${"searched".i18n()} $searched ${searched == 1 ? "instance".i18n() : "instances".i18n()}"),
|
||||||
|
const LinearProgressIndicator(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
width: global.getWidth(context),
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: global.getConstraints(context).maxWidth,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemCount: accountModels.length + postModels.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index < accountModels.length) {
|
||||||
|
final model = accountModels[index];
|
||||||
|
return Padding(
|
||||||
|
padding: themes.defaultMargins,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SelectableText(model.identity),
|
||||||
|
DisplayName(account: model)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final model = postModels[index - accountModels.length];
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SelectableText(model.identity),
|
||||||
|
Post(
|
||||||
|
model: model,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -37,17 +37,18 @@ Widget settings(context) {
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
border: Border(
|
||||||
border: Border(
|
top: BorderSide(
|
||||||
top: BorderSide(
|
color: Theme.of(context).colorScheme.primary,
|
||||||
color: Theme.of(context).colorScheme.primary, width: 2))),
|
width: 2,
|
||||||
child: Wrap(
|
),
|
||||||
children: [
|
),
|
||||||
IconButton(
|
),
|
||||||
onPressed: () {},
|
child: Material(
|
||||||
icon: const Icon(Icons.search),
|
child: Wrap(
|
||||||
)
|
alignment: WrapAlignment.center,
|
||||||
],
|
children: [],
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:localization/localization.dart';
|
import 'package:localization/localization.dart';
|
||||||
import 'package:loris/dialogues/makepost.dart';
|
import 'package:loris/dialogues/makepost.dart';
|
||||||
import 'package:loris/dialogues/search.dart';
|
|
||||||
import 'package:loris/partials/thread.dart';
|
import 'package:loris/partials/thread.dart';
|
||||||
import '../../business_logic/timeline/timeline.dart' as tl;
|
import '../../business_logic/timeline/timeline.dart' as tl;
|
||||||
import '../../global.dart' as global;
|
import '../../global.dart' as global;
|
||||||
|
@ -145,13 +144,6 @@ class TimelineState extends State<Timeline> {
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.refresh),
|
icon: const Icon(Icons.refresh),
|
||||||
),
|
),
|
||||||
IconButton(
|
|
||||||
onPressed: () => showDialog(
|
|
||||||
barrierColor: Colors.transparent,
|
|
||||||
context: context,
|
|
||||||
builder: (context) => const SearchDialogue(),
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.search)),
|
|
||||||
DropdownButtonHideUnderline(
|
DropdownButtonHideUnderline(
|
||||||
child: DropdownButton(
|
child: DropdownButton(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:localization/localization.dart';
|
import 'package:localization/localization.dart';
|
||||||
import 'package:loris/pages/chat/chat.dart';
|
|
||||||
import 'package:loris/pages/notifications/notifications.dart';
|
import 'package:loris/pages/notifications/notifications.dart';
|
||||||
|
import 'package:loris/pages/search/search.dart';
|
||||||
import 'package:loris/pages/timeline/timeline.dart';
|
import 'package:loris/pages/timeline/timeline.dart';
|
||||||
import 'package:loris/pages/settings/settings.dart';
|
import 'package:loris/pages/settings/settings.dart';
|
||||||
import '../business_logic/websocket.dart' as websocket;
|
import '../business_logic/websocket.dart' as websocket;
|
||||||
|
@ -41,7 +41,7 @@ class _MainScaffoldState extends State<MainScaffold> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screens = [
|
final screens = [
|
||||||
const Timeline(),
|
const Timeline(),
|
||||||
const Chat(),
|
const SearchPage(),
|
||||||
const Notifications(),
|
const Notifications(),
|
||||||
settings(context),
|
settings(context),
|
||||||
];
|
];
|
||||||
|
@ -68,7 +68,7 @@ class _MainScaffoldState extends State<MainScaffold> {
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.forum), label: "timeline".i18n()),
|
icon: const Icon(Icons.forum), label: "timeline".i18n()),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.chat), label: "chat".i18n()),
|
icon: const Icon(Icons.search), label: "chat".i18n()),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: Icon((unreadNotifs >= 1)
|
icon: Icon((unreadNotifs >= 1)
|
||||||
? Icons.notifications_active
|
? Icons.notifications_active
|
||||||
|
|
Loading…
Reference in New Issue