Skip to content

Commit 933bda2

Browse files
author
chetanr25
committed
Remove _fetchUserProfile which is no longer used, added a placeholder to TitleElementType.PERCENTAGE in knowledge_pannel_builder.dart
1 parent 6eea995 commit 933bda2

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
lines changed

packages/smooth_app/lib/knowledge_panel/knowledge_panels_builder.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ class KnowledgePanelsBuilder {
330330
isClickable: isClickable,
331331
),
332332
);
333+
case TitleElementType.PERCENTAGE:
334+
// TODO: Implement percentage case for title element.
335+
/// The case is added to fix type errors but functionality is not implemented yet.
336+
/// TitleElementType.PERCENTAGE was introduced after PR #1086
337+
/// (https://github.com/openfoodfacts/openfoodfacts-dart/pull/1086).
338+
/// Implementation for percentage case still needs to be added.
339+
throw UnimplementedError();
333340
}
334341
}
335342
}

packages/smooth_app/lib/pages/prices/prices_dashboard_page.dart

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
3-
import 'package:http/http.dart' as http;
43
import 'package:openfoodfacts/openfoodfacts.dart';
54
import 'package:smooth_app/helpers/launch_url_helper.dart';
65
import 'package:smooth_app/pages/prices/prices_dashboard_widget.dart';
@@ -12,7 +11,9 @@ import 'package:smooth_app/widgets/smooth_scaffold.dart';
1211
class PricesDashboardPage extends StatelessWidget {
1312
PricesDashboardPage();
1413

15-
late final Future<MaybeError<PriceUser>> _userProfile = _fetchUserProfile();
14+
late final Future<MaybeError<PriceUser>> _userProfile =
15+
OpenPricesAPIClient.getUser(OpenFoodAPIConfiguration.globalUser!.userId,
16+
uriHelper: ProductQuery.uriPricesHelper);
1617

1718
@override
1819
Widget build(BuildContext context) {
@@ -57,26 +58,4 @@ class PricesDashboardPage extends StatelessWidget {
5758
}),
5859
);
5960
}
60-
61-
// TODO(chetanr25): To be implemented in OpenFoodFacts flutter package
62-
static Future<MaybeError<PriceUser>> _fetchUserProfile() async {
63-
final String? userId = OpenFoodAPIConfiguration.globalUser?.userId;
64-
final Uri uri = OpenPricesAPIClient.getUri(
65-
path: '/api/v1/users/$userId',
66-
);
67-
68-
final http.Response response =
69-
await HttpHelper().doGetRequest(uri, uriHelper: uriHelperFoodProd);
70-
try {
71-
if (response.statusCode == 200) {
72-
final dynamic decodedResponse = HttpHelper().jsonDecodeUtf8(response);
73-
return MaybeError<PriceUser>.value(
74-
PriceUser.fromJson(decodedResponse),
75-
);
76-
}
77-
} catch (e) {
78-
//
79-
}
80-
return MaybeError<PriceUser>.responseError(response);
81-
}
8261
}

packages/smooth_app/lib/pages/prices/prices_dashboard_widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class _PricesDashboardWidgetState extends State<PricesDashboardWidget> {
3535
const SizedBox(height: SMALL_SPACE),
3636
_priceProofButton(widget.userProfile, appLocalizations),
3737
FutureBuilder<MaybeError<GetPricesResult?>>(
38-
future: _getUserPrices(),
38+
future: pricesFuture,
3939
builder: (BuildContext context,
4040
AsyncSnapshot<MaybeError<GetPricesResult?>> snapshot) {
4141
if (snapshot.connectionState == ConnectionState.waiting) {

packages/smooth_app/lib/pages/prices/prices_user_profile.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class PricesUserProfile extends StatelessWidget {
1212
Widget build(BuildContext context) {
1313
final AppLocalizations appLocalizations = AppLocalizations.of(context);
1414
return SmoothCard(
15-
child: ListView(
16-
shrinkWrap: true,
15+
child: Column(
1716
children: <Widget>[
1817
ListTile(
1918
leading: const Icon(Icons.person),

0 commit comments

Comments
 (0)