Skip to content

Commit

Permalink
Merge pull request #20 from openfoodfacts/develop
Browse files Browse the repository at this point in the history
wtf
  • Loading branch information
monsieurtanuki authored Jan 3, 2022
2 parents ebcc532 + 279373e commit 66a4f82
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 293 deletions.
11 changes: 4 additions & 7 deletions packages/smooth_app/lib/cards/data_cards/image_upload_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,11 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
imageUri: croppedImageFile.uri,
);

// a registered user login for https://world.openfoodfacts.org/ is required
//ToDo: Add user
const User myUser =
User(userId: 'smoothie-app', password: 'strawberrybanana');

// query the OpenFoodFacts API
final Status result =
await OpenFoodAPIClient.addProductImage(myUser, image);
final Status result = await OpenFoodAPIClient.addProductImage(
ProductQuery.getUser(),
image,
);

if (result.status != 'status ok') {
throw Exception(
Expand Down
3 changes: 2 additions & 1 deletion packages/smooth_app/lib/database/keywords_product_query.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';

import 'package:openfoodfacts/model/parameter/SearchTerms.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/data_models/product_list.dart';
Expand All @@ -16,7 +17,7 @@ class KeywordsProductQuery implements ProductQuery {
@override
Future<SearchResult> getSearchResult() async =>
OpenFoodAPIClient.searchProducts(
ProductQuery.SMOOTH_USER,
ProductQuery.getUser(),
ProductSearchQueryConfiguration(
fields: ProductQuery.fields,
parametersList: <Parameter>[
Expand Down
12 changes: 7 additions & 5 deletions packages/smooth_app/lib/database/product_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ abstract class ProductQuery {
static void setCountry(final String? isoCode) =>
OpenFoodAPIConfiguration.globalCountry = CountryHelper.fromJson(isoCode);

static const User SMOOTH_USER = User(
userId: 'project-smoothie',
password: 'smoothie',
comment: 'Test user for project smoothie',
);
static User getUser() =>
OpenFoodAPIConfiguration.globalUser ??
const User(
userId: 'smoothie-app',
password: 'strawberrybanana',
comment: 'Test user for project smoothie',
);

static List<ProductField> get fields => <ProductField>[
ProductField.NAME,
Expand Down
6 changes: 6 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@
"@myPreferences": {
"description": "Page title: Page where the ranking preferences can be changed"
},
"myPreferences_profile_title": "Your Profile",
"myPreferences_profile_subtitle": "Set app settings and find out advices.",
"myPreferences_settings_title": "App Settings",
"myPreferences_settings_subtitle": "Dark mode, country, color, ...",
"myPreferences_food_title": "Food Preferences",
"myPreferences_food_subtitle": "Choose what information about food matters most to you.",
"confirmResetPreferences": "Reset your preferences?",
"@confirmResetPreferences": {
"description": "Pop up title: Reassuring if the food preferences should really be reset"
Expand Down
6 changes: 6 additions & 0 deletions packages/smooth_app/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@
"@myPreferences": {
"description": "Page title: Page where the ranking preferences can be changed"
},
"myPreferences_profile_title": "Votre profil",
"myPreferences_profile_subtitle": "Paramétrez l'appli pour trouver des conseils judicieux.",
"myPreferences_settings_title": "Paramètres d'affichage",
"myPreferences_settings_subtitle": "Mode nuit, pays, couleurs, ...",
"myPreferences_food_title": "Préférences alimentaires",
"myPreferences_food_subtitle": "Choisissez les informations qui comptent le plus pour vous.",
"confirmResetPreferences": "Réinitialiser vos préférences ?",
"@confirmResetPreferences": {
"description": "Pop up title: Reassuring if the food preferences should really be reset"
Expand Down
60 changes: 26 additions & 34 deletions packages/smooth_app/lib/pages/abstract_user_preferences.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/data_models/user_preferences.dart';
import 'package:smooth_app/themes/theme_provider.dart';

/// Abstraction of a collapsed/expanded display for the preferences page.
abstract class AbstractUserPreferences {
AbstractUserPreferences(this.setState);
AbstractUserPreferences({
required this.setState,
required this.context,
required this.userPreferences,
required this.appLocalizations,
required this.themeData,
});

/// Function that refreshes the page.
final Function(Function()) setState;

final BuildContext context;
final UserPreferences userPreferences;
final AppLocalizations appLocalizations;
final ThemeData themeData;

/// Flag Key to store the collapsed/expanded status
@protected
String getPreferenceFlagKey();
Expand All @@ -20,50 +30,32 @@ abstract class AbstractUserPreferences {

/// Title of the header, always visible.
@protected
String getTitle();
Widget getTitle();

/// Subtitle of the header, always visible.
@protected
String getSubtitle();
Widget? getSubtitle();

/// Returns the header.
Widget _getHeader(
final UserPreferences userPreferences,
final ThemeData themeData,
) {
return ListTile(
title: Text(getTitle(), style: themeData.textTheme.headline2),
subtitle: Text(getSubtitle()),
trailing: Icon(
_isCollapsed(userPreferences) ? Icons.expand_more : Icons.expand_less,
),
onTap: () => _switchCollapsed(userPreferences),
);
}
Widget _getHeader(final UserPreferences userPreferences) => ListTile(
title: getTitle(),
subtitle: getSubtitle(),
trailing: Icon(
_isCollapsed(userPreferences) ? Icons.expand_more : Icons.expand_less,
),
onTap: () => _switchCollapsed(userPreferences),
);

/// Body of the content.
@protected
List<Widget> getBody(
final BuildContext context,
final AppLocalizations appLocalizations,
final ThemeProvider themeProvider,
final ThemeData themeData,
);
List<Widget> getBody();

/// Returns the header, and the body if expanded.
List<Widget> getContent(
final BuildContext context,
final UserPreferences userPreferences,
final ThemeProvider themeProvider,
final AppLocalizations appLocalizations,
final ThemeData themeData,
) {
List<Widget> getContent() {
final List<Widget> result = <Widget>[];
result.add(_getHeader(userPreferences, themeData));
result.add(_getHeader(userPreferences));
if (!_isCollapsed(userPreferences)) {
result.addAll(
getBody(context, appLocalizations, themeProvider, themeData),
);
result.addAll(getBody());
}
return result;
}
Expand Down
71 changes: 0 additions & 71 deletions packages/smooth_app/lib/pages/smooth_it_page.dart

This file was deleted.

38 changes: 0 additions & 38 deletions packages/smooth_app/lib/pages/tracking_page.dart

This file was deleted.

Loading

0 comments on commit 66a4f82

Please sign in to comment.