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

feat: 5207 - new "My proofs" and "Proof" pages #5389

Merged
merged 2 commits into from
Jun 16, 2024
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
29 changes: 29 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,14 @@
"@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_search_proof_title": "My proof",
"@user_search_proof_title": {
"description": "User proof: page title"
},
"user_any_search_prices_title": "Contributor prices",
"@user_any_search_prices_title": {
"description": "User prices (everybody except me): list tile title"
Expand Down
29 changes: 29 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,14 @@
"@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_search_proof_title": "Ma preuve",
"@user_search_proof_title": {
"description": "User proof: page 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.user_search_proof_title),
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
Loading