Skip to content

Commit

Permalink
fix: harmonize search modals (#3085)
Browse files Browse the repository at this point in the history
* make harmonized search models

* similar buttons in nutrition search page
  • Loading branch information
AshAman999 authored Oct 4, 2022
1 parent a3d9e0b commit f277e3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
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

0 comments on commit f277e3e

Please sign in to comment.