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

wtf #20

Merged
merged 3 commits into from
Jan 3, 2022
Merged

wtf #20

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
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