-
-
Notifications
You must be signed in to change notification settings - Fork 280
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: Make attributes clickable #1654
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9be6cb
feat: Make attributes tapable in the Summary card
M123-dev 2515c1d
fix: Working with Navigator.push
M123-dev 934725c
Imports
M123-dev ba16136
Merge branch 'develop' into make-attributes-clickable
M123-dev 289dbb7
Update new_product_page.dart
M123-dev 49e5733
Update main.dart
M123-dev ed0451d
Update product_knowledge_panels.dart
M123-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...mooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panel_full_loading_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:openfoodfacts/model/KnowledgePanel.dart'; | ||
import 'package:openfoodfacts/model/KnowledgePanels.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:smooth_app/cards/product_cards/knowledge_panels/knowledge_panel_full_page.dart'; | ||
import 'package:smooth_app/data_models/data_provider.dart'; | ||
|
||
class KnowledgePanelFullLoadingPage extends StatelessWidget { | ||
const KnowledgePanelFullLoadingPage( | ||
{required this.panelId, required this.barcode}); | ||
|
||
final String panelId; | ||
final String barcode; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final KnowledgePanels? knowledgePanels = context | ||
.select<DataProvider<Map<String, KnowledgePanels?>>, KnowledgePanels?>( | ||
(DataProvider<Map<String, KnowledgePanels?>> value) => | ||
value.value[barcode]); | ||
|
||
if (knowledgePanels == null) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: | ||
Text(AppLocalizations.of(context)!.loading_dialog_default_title), | ||
), | ||
body: const Center( | ||
child: CircularProgressIndicator(), | ||
), | ||
); | ||
} | ||
|
||
final KnowledgePanel? knowledgePanel = | ||
knowledgePanels.panelIdToPanelMap[panelId]; | ||
|
||
if (knowledgePanel == null) { | ||
Future<void>.delayed(Duration.zero, () { | ||
Navigator.pop(context); | ||
}); | ||
return Container(); | ||
} | ||
Future<void>.delayed(Duration.zero, () { | ||
Navigator.pushReplacement( | ||
context, | ||
MaterialPageRoute<Widget>( | ||
builder: (BuildContext context) => KnowledgePanelFullPage( | ||
panel: knowledgePanel, | ||
allPanels: knowledgePanels, | ||
), | ||
), | ||
); | ||
}); | ||
|
||
return Scaffold( | ||
body: Container(), | ||
); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/smooth_app/lib/cards/product_cards/knowledge_panels/knowledge_panel_full_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:openfoodfacts/model/KnowledgePanel.dart'; | ||
import 'package:openfoodfacts/model/KnowledgePanels.dart'; | ||
import 'package:smooth_app/cards/product_cards/knowledge_panels/knowledge_panel_expanded_card.dart'; | ||
import 'package:smooth_app/generic_lib/design_constants.dart'; | ||
import 'package:smooth_app/generic_lib/widgets/smooth_card.dart'; | ||
import 'package:smooth_app/themes/smooth_theme.dart'; | ||
|
||
class KnowledgePanelFullPage extends StatelessWidget { | ||
const KnowledgePanelFullPage({ | ||
required this.panel, | ||
required this.allPanels, | ||
}); | ||
|
||
final KnowledgePanel panel; | ||
final KnowledgePanels allPanels; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final ThemeData themeData = Theme.of(context); | ||
return Scaffold( | ||
backgroundColor: SmoothTheme.getColor( | ||
themeData.colorScheme, | ||
SmoothTheme.getMaterialColor(context), | ||
ColorDestination.SURFACE_BACKGROUND, | ||
), | ||
appBar: AppBar( | ||
title: Text(panel.titleElement?.title ?? ''), | ||
), | ||
body: SingleChildScrollView( | ||
child: SmoothCard( | ||
padding: const EdgeInsets.all( | ||
SMALL_SPACE, | ||
), | ||
child: KnowledgePanelExpandedCard( | ||
panel: panel, | ||
allPanels: allPanels, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class DataProvider<T> with ChangeNotifier { | ||
DataProvider(this._value); | ||
|
||
T _value; | ||
|
||
T get value => _value; | ||
|
||
void setValue(T newValue) { | ||
_value = newValue; | ||
notifyListeners(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/smooth_app/lib/data_models/user_management_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very surprised that you don't use
LoadingDialog
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that too, but that would have meant that I would have had to distribute the Future through the provider, this seemed to add even more complexity especially when you try to avoid having two calls (when opening the product page and when opening the attributes)