1
0
mirror of https://github.com/krawieck/lemmur/ synced 2024-12-25 23:53:27 +01:00

change all variables with name instance to instanceHost

This commit is contained in:
krawieck 2021-01-10 01:51:26 +01:00
parent 586f26c277
commit f80ab01e04
2 changed files with 20 additions and 16 deletions

View File

@ -11,15 +11,15 @@ import 'communities_list.dart';
import 'users_list.dart'; import 'users_list.dart';
class SearchResultsPage extends HookWidget { class SearchResultsPage extends HookWidget {
final String instance; final String instanceHost;
final String query; final String query;
SearchResultsPage({ SearchResultsPage({
@required this.instance, @required this.instanceHost,
@required this.query, @required this.query,
}) : assert(instance != null), }) : assert(instanceHost != null),
assert(query != null), assert(query != null),
assert(instance.isNotEmpty), assert(instanceHost.isNotEmpty),
assert(query.isNotEmpty); assert(query.isNotEmpty);
@override @override
@ -42,15 +42,19 @@ class SearchResultsPage extends HookWidget {
body: TabBarView( body: TabBarView(
children: [ children: [
_SearchResultsList( _SearchResultsList(
instanceHost: instance, query: query, type: SearchType.posts), instanceHost: instanceHost,
query: query,
type: SearchType.posts),
_SearchResultsList( _SearchResultsList(
instanceHost: instance, instanceHost: instanceHost,
query: query, query: query,
type: SearchType.comments), type: SearchType.comments),
_SearchResultsList( _SearchResultsList(
instanceHost: instance, query: query, type: SearchType.users), instanceHost: instanceHost,
query: query,
type: SearchType.users),
_SearchResultsList( _SearchResultsList(
instanceHost: instance, instanceHost: instanceHost,
query: query, query: query,
type: SearchType.communities), type: SearchType.communities),
], ],

View File

@ -15,7 +15,7 @@ class SearchTab extends HookWidget {
final searchInputController = useTextEditingController(); final searchInputController = useTextEditingController();
final accStore = useAccountsStore(); final accStore = useAccountsStore();
final instance = useState(accStore.instances.first); final instanceHost = useState(accStore.instances.first);
useValueListenable(searchInputController); useValueListenable(searchInputController);
return Scaffold( return Scaffold(
@ -51,8 +51,8 @@ class SearchTab extends HookWidget {
), ),
Expanded( Expanded(
child: SelectInstanceButton( child: SelectInstanceButton(
instance: instance.value, instanceHost: instanceHost.value,
onChange: (s) => instance.value = s, onChange: (s) => instanceHost.value = s,
), ),
), ),
], ],
@ -62,7 +62,7 @@ class SearchTab extends HookWidget {
onPressed: () => goTo( onPressed: () => goTo(
context, context,
(c) => SearchResultsPage( (c) => SearchResultsPage(
instance: instance.value, instanceHost: instanceHost.value,
query: searchInputController.text, query: searchInputController.text,
)), )),
child: const Text('search'), child: const Text('search'),
@ -76,9 +76,9 @@ class SearchTab extends HookWidget {
class SelectInstanceButton extends HookWidget { class SelectInstanceButton extends HookWidget {
final ValueChanged<String> onChange; final ValueChanged<String> onChange;
final String instance; final String instanceHost;
const SelectInstanceButton( const SelectInstanceButton(
{@required this.onChange, @required this.instance}); {@required this.onChange, @required this.instanceHost});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -95,7 +95,7 @@ class SelectInstanceButton extends HookWidget {
children: [ children: [
for (final inst in accStore.instances) for (final inst in accStore.instances)
ListTile( ListTile(
leading: inst == instance leading: inst == instanceHost
? Icon( ? Icon(
Icons.radio_button_on, Icons.radio_button_on,
color: theme.accentColor, color: theme.accentColor,
@ -120,7 +120,7 @@ class SelectInstanceButton extends HookWidget {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text(instance), Text(instanceHost),
const Icon(Icons.arrow_drop_down), const Icon(Icons.arrow_drop_down),
], ],
), ),