fix: add search bar hints to i18n

This commit is contained in:
Alberto Ponces 2022-08-08 00:31:55 +01:00
parent 047e00cf2c
commit 960646ba77
4 changed files with 24 additions and 9 deletions

View File

@ -37,5 +37,11 @@
"patchSelectorCard": { "patchSelectorCard": {
"widgetTitle": "Select patches", "widgetTitle": "Select patches",
"widgetSubtitle": "Select an application first." "widgetSubtitle": "Select an application first."
},
"appSelectorView": {
"searchBarHint": "Search applications"
},
"patchesSelectorView": {
"searchBarHint": "Search patches"
} }
} }

View File

@ -6,7 +6,9 @@
// ignore_for_file: public_member_api_docs // ignore_for_file: public_member_api_docs
// ignore: depend_on_referenced_packages
import 'package:stacked_core/stacked_core.dart'; import 'package:stacked_core/stacked_core.dart';
// ignore: implementation_imports
import 'package:stacked_services/src/navigation/navigation_service.dart'; import 'package:stacked_services/src/navigation/navigation_service.dart';
import '../services/patcher_api.dart'; import '../services/patcher_api.dart';

View File

@ -40,7 +40,10 @@ class _AppSelectorViewState extends State<AppSelectorView> {
child: Column( child: Column(
children: [ children: [
SearchBar( SearchBar(
hintText: "Search applications", hintText: FlutterI18n.translate(
context,
'appSelectorView.searchBarHint',
),
onQueryChanged: (searchQuery) { onQueryChanged: (searchQuery) {
setState(() { setState(() {
query = searchQuery; query = searchQuery;

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/patch_item.dart'; import 'package:revanced_manager/ui/widgets/patch_item.dart';
@ -28,7 +29,10 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
Padding( Padding(
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
child: SearchBar( child: SearchBar(
hintText: "Search patches", hintText: FlutterI18n.translate(
context,
'patchesSelectorView.searchBarHint',
),
onQueryChanged: (searchQuery) { onQueryChanged: (searchQuery) {
setState( setState(
() { () {
@ -46,27 +50,27 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
return ListView.builder( return ListView.builder(
itemCount: snapshot.data!.length, itemCount: snapshot.data!.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (query.isEmpty || if (query.isEmpty || query.length < 2) {
query.length < 2) {
return PatchItem( return PatchItem(
name: snapshot.data![index].simpleName, name: snapshot.data![index].simpleName,
version: snapshot.data![index].version, version: snapshot.data![index].version,
description: snapshot.data![index].description, description: snapshot.data![index].description,
isSelected: false, isSelected: false,
); );
} } else if (query.isNotEmpty &&
else if(query.isNotEmpty &&
query.length >= 2 && query.length >= 2 &&
snapshot.data![index].simpleName.toLowerCase().contains(query.toLowerCase())) { snapshot.data![index].simpleName
.toLowerCase()
.contains(query.toLowerCase())) {
return PatchItem( return PatchItem(
name: snapshot.data![index].simpleName, name: snapshot.data![index].simpleName,
version: snapshot.data![index].version, version: snapshot.data![index].version,
description: snapshot.data![index].description, description: snapshot.data![index].description,
isSelected: false, isSelected: false,
); );
} else {
return Container();
} }
else {return Container();}
}, },
); );
} else if (snapshot.hasError) { } else if (snapshot.hasError) {