Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: harmonize search modals #3085

Merged
merged 4 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/smooth_app/lib/generic_lib/widgets/language_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'
import 'package:openfoodfacts/utils/LanguageHelper.dart';
import 'package:smooth_app/data_models/user_preferences.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_text_form_field.dart';
import 'package:smooth_app/pages/preferences/user_preferences_languages_list.dart';

class LanguageSelectorSettings extends StatelessWidget {
Expand Down Expand Up @@ -32,6 +33,8 @@ class LanguageSelectorSettings extends StatelessWidget {
_languages.getLanguageNameInLanguageFromOpenFoodFactsLanguage(
language,
);
final TextEditingController languageSelectorController =
TextEditingController();
return ListTile(
leading: const Icon(Icons.language),
title: Text(
Expand Down Expand Up @@ -61,13 +64,12 @@ class LanguageSelectorSettings extends StatelessWidget {
width: MediaQuery.of(context).size.width,
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
prefixIcon: const Icon(Icons.search),
enabledBorder: const UnderlineInputBorder(),
labelText: appLocalizations.search,
),
onChanged: (String query) {
SmoothTextFormField(
type: TextFieldTypes.PLAIN_TEXT,
hintText: appLocalizations.search,
prefixIcon: const Icon(Icons.search),
controller: languageSelectorController,
onChanged: (String? query) {
setState(
() {
filteredList = leftovers
Expand All @@ -76,7 +78,7 @@ class LanguageSelectorSettings extends StatelessWidget {
.getLanguageNameInEnglishFromOpenFoodFactsLanguage(
item)
.toLowerCase()
.contains(query.toLowerCase()) ||
.contains(query!.toLowerCase()) ||
_languages
.getLanguageNameInLanguageFromOpenFoodFactsLanguage(
item)
Expand Down
21 changes: 10 additions & 11 deletions packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_card.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_text_form_field.dart';
import 'package:smooth_app/helpers/text_input_formatters_helper.dart';
import 'package:smooth_app/pages/product/nutrition_container.dart';
import 'package:smooth_app/query/product_query.dart';
Expand Down Expand Up @@ -45,6 +46,7 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
late final NutritionContainer _nutritionContainer;

late bool _noNutritionData;
final TextEditingController nutritonTextController = TextEditingController();

// If true then serving, if false then 100g.
bool _servingOr100g = false;
Expand Down Expand Up @@ -383,27 +385,24 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
builder: (BuildContext context,
void Function(VoidCallback fn) setState) {
return SmoothAlertDialog(
close: true,
title: appLocalizations.nutrition_page_add_nutrient,
body: SizedBox(
height: MediaQuery.of(context).size.height / 2,
width: MediaQuery.of(context).size.width,
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
prefixIcon: const Icon(Icons.search),
enabledBorder: const UnderlineInputBorder(),
labelText: appLocalizations.search,
),
onChanged: (String query) {
SmoothTextFormField(
prefixIcon: const Icon(Icons.search),
hintText: appLocalizations.search,
type: TextFieldTypes.PLAIN_TEXT,
controller: nutritonTextController,
onChanged: (String? query) {
setState(
() {
filteredList = leftovers
.where((OrderedNutrient item) => item
.name!
.toLowerCase()
.contains(query.toLowerCase()))
.contains(query!.toLowerCase()))
.toList();
},
);
Expand All @@ -427,7 +426,7 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
],
),
),
negativeAction: SmoothActionButton(
positiveAction: SmoothActionButton(
onPressed: () => Navigator.pop(context),
text: appLocalizations.cancel,
),
Expand Down