Skip to content

Commit

Permalink
feat: 5207 - new "My proofs" and "Proof" pages
Browse files Browse the repository at this point in the history
New files:
* `price_proof_page.dart`: Full page display of a proof.
* `prices_proofs_page.dart`: Page that displays the latest proofs of the current user.

Impacted files:
* `app_en.arb`: added 3 labels for "my proofs"
* `app_fr.arb`: added 3 labels for "my proofs"
* `price_data_widget.dart`: instead of a web app link, we open the new "my proof" page
* `user_preferences_account.dart`: added a link to open the new "my proofs" page
  • Loading branch information
monsieurtanuki committed Jun 16, 2024
1 parent 7809854 commit b02f3ac
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 8 deletions.
25 changes: 25 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,27 @@
}
}
},
"prices_proofs_list_length_one_page": "{count,plural, =0{No proof yet} =1{Only one proof} other{All {count} proofs}}",
"@prices_proofs_list_length_one_page": {
"description": "Number of proofs for one-page result",
"placeholders": {
"count": {
"type": "int"
}
}
},
"prices_proofs_list_length_many_pages": "Latest {pageSize} proofs (total: {total})",
"@prices_proofs_list_length_many_pages": {
"description": "Number of proofs for one-page result",
"placeholders": {
"pageSize": {
"type": "int"
},
"total": {
"type": "int"
}
}
},
"prices_users_list_length_many_pages": "Top {pageSize} contributors (total: {total})",
"@prices_users_list_length_many_pages": {
"description": "Number of users for one-page result",
Expand Down Expand Up @@ -1813,6 +1834,10 @@
"@user_search_prices_title": {
"description": "User prices: list tile title"
},
"user_search_proofs_title": "My proofs",
"@user_search_proofs_title": {
"description": "User proofs: list tile title"
},
"user_any_search_prices_title": "Contributor prices",
"@user_any_search_prices_title": {
"description": "User prices (everybody except me): list tile title"
Expand Down
25 changes: 25 additions & 0 deletions packages/smooth_app/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,27 @@
}
}
},
"prices_proofs_list_length_one_page": "{count,plural, =0{Aucune preuve} =1{Une seule preuve} other{Toutes les {count} preuves}}",
"@prices_proofs_list_length_one_page": {
"description": "Number of proofs for one-page result",
"placeholders": {
"count": {
"type": "int"
}
}
},
"prices_proofs_list_length_many_pages": "{pageSize} preuves les plus récentes (total : {total})",
"@prices_proofs_list_length_many_pages": {
"description": "Number of proofs for one-page result",
"placeholders": {
"pageSize": {
"type": "int"
},
"total": {
"type": "int"
}
}
},
"prices_users_list_length_many_pages": "Top {pageSize} contributeurs (total : {total})",
"@prices_users_list_length_many_pages": {
"description": "Number of users for one-page result",
Expand Down Expand Up @@ -1810,6 +1831,10 @@
"@user_search_prices_title": {
"description": "User prices: list tile title"
},
"user_search_proofs_title": "Mes preuves",
"@user_search_proofs_title": {
"description": "User proofs: list tile title"
},
"user_any_search_prices_title": "Prix d'un contributeur",
"@user_any_search_prices_title": {
"description": "User prices (everybody except me): list tile title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:smooth_app/pages/preferences/user_preferences_page.dart';
import 'package:smooth_app/pages/prices/get_prices_model.dart';
import 'package:smooth_app/pages/prices/price_user_button.dart';
import 'package:smooth_app/pages/prices/prices_page.dart';
import 'package:smooth_app/pages/prices/prices_proofs_page.dart';
import 'package:smooth_app/pages/prices/prices_users_page.dart';
import 'package:smooth_app/pages/product/common/product_query_page_helper.dart';
import 'package:smooth_app/pages/user_management/login_page.dart';
Expand Down Expand Up @@ -227,6 +228,15 @@ class UserPreferencesAccount extends AbstractUserPreferences {
CupertinoIcons.money_dollar_circle,
myCount: _getPricesCount(owner: ProductQuery.getWriteUser().userId),
),
_getListTile(
appLocalizations.user_search_proofs_title,
() async => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => const PricesProofsPage(),
),
),
Icons.receipt,
),
_getListTile(
appLocalizations.all_search_prices_latest_title,
() async => Navigator.of(context).push(
Expand Down
17 changes: 9 additions & 8 deletions packages/smooth_app/lib/pages/prices/price_data_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/pages/prices/emoji_helper.dart';
import 'package:smooth_app/pages/prices/get_prices_model.dart';
import 'package:smooth_app/pages/prices/price_button.dart';
import 'package:smooth_app/pages/prices/price_proof_page.dart';
import 'package:smooth_app/pages/prices/price_user_button.dart';
import 'package:smooth_app/pages/product/common/product_query_page_helper.dart';
import 'package:smooth_app/query/product_query.dart';
Expand Down Expand Up @@ -99,13 +99,14 @@ class PriceDataWidget extends StatelessWidget {
if (price.proof?.filePath != null)
PriceButton(
iconData: Icons.image,
onPressed: () async => LaunchUrlHelper.launchURL(
price.proof!
.getFileUrl(
uriProductHelper: ProductQuery.uriProductHelper,
)
.toString(),
),
onPressed: () async => Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) => PriceProofPage(
price.proof!,
),
),
), // PriceProofPage
),
],
);
Expand Down
45 changes: 45 additions & 0 deletions packages/smooth_app/lib/pages/prices/price_proof_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/query/product_query.dart';
import 'package:smooth_app/widgets/smooth_app_bar.dart';
import 'package:smooth_app/widgets/smooth_scaffold.dart';

/// Full page display of a proof.
class PriceProofPage extends StatelessWidget {
const PriceProofPage(
this.proof,
);

final Proof proof;

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final DateFormat dateFormat =
DateFormat.yMd(ProductQuery.getLocaleString()).add_Hms();
return SmoothScaffold(
appBar: SmoothAppBar(
title: Text(appLocalizations.prices_proof_subtitle),
subTitle: Text(dateFormat.format(proof.created)),
actions: <Widget>[
IconButton(
tooltip: appLocalizations.prices_app_button,
icon: const Icon(Icons.open_in_new),
onPressed: () async => LaunchUrlHelper.launchURL(_getUrl()),
),
],
),
body: Image(
image: NetworkImage(_getUrl()),
fit: BoxFit.cover,
),
);
}

String _getUrl() => proof
.getFileUrl(uriProductHelper: ProductQuery.uriProductHelper)
.toString();
}
Loading

0 comments on commit b02f3ac

Please sign in to comment.