-
Notifications
You must be signed in to change notification settings - Fork 14
Refactored AdyenCardComponent for improved readability and structure #491
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
base: main
Are you sure you want to change the base?
Conversation
The AdyenCardComponent has been refactored from a StatelessWidget to a StatefulWidget. This change allows for better state management, particularly for the asynchronous fetching of the SDK version number. The build logic has been streamlined by: - Moving the SDK version number fetching to `initState`. - Introducing dedicated internal widgets (`_CardSessionFlowWidget` and `_CardAdvancedFlowWidget`) to handle the different checkout flows (Session and Advanced). This separation improves code organization and makes the main build method cleaner. - The `_determineInitialHeight` method and its platform-specific helpers remain, but their usage is now within the context of the new stateful widget structure. These changes enhance the component's maintainability and readability without altering its core functionality.
…owWidget The `AdyenCardComponent` now directly returns either `CardSessionComponent` or `CardAdvancedComponent` based on the checkout type, simplifying the widget tree.
The `super.initState()` call was moved before widget-specific initialization in `BaseCardComponent` to ensure the base class is properly initialized first.
The loading widget for the CardComponent has been refactored for better readability and conciseness. The separate `_buildLoadingWidget` method has been removed, and its logic is now inline using a switch expression. This change maintains the existing behavior of showing a `CircularProgressIndicator` on Android and an empty `SizedBox` on other platforms.
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.
Summary of Changes
Hello @Robert-SD, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request focuses on enhancing the internal structure and readability of the AdyenCardComponent and related UI components. The changes aim to improve the maintainability and clarity of the codebase by adopting more idiomatic Flutter patterns for state management and UI rendering, without altering the external behavior or functionality of the payment components.
Highlights
- AdyenCardComponent refactoring: The AdyenCardComponent has been refactored from a StatelessWidget to a StatefulWidget, improving its ability to manage internal state and lifecycle events. This change streamlines the component's logic and enhances maintainability.
- Code simplification: Several helper methods within AdyenCardComponent and CardComponentContainer have been removed, with their logic inlined directly into the build methods or relevant sections. This reduces indirection and makes the code flow more straightforward.
- Improved platform-specific rendering: The logic for determining initial view heights and displaying loading indicators has been simplified using Dart's switch expressions, leading to more concise and readable code for platform-specific UI adjustments.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request refactors the AdyenCardComponent
to a StatefulWidget
for better performance and improves the code structure using modern Dart syntax. While the refactoring is generally well-executed and enhances readability, a critical regression was introduced. The onBinLookup
and onBinValue
callbacks are no longer passed to the underlying card components, which would break functionality for users relying on these callbacks. I've provided a suggestion to fix this issue.
LCOV of commit
|
/gemini review |
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.
Code Review
This pull request significantly improves the AdyenCardComponent
by refactoring it from a StatelessWidget
to a StatefulWidget
. This correctly handles the asynchronous fetching of the SDK version, preventing unnecessary calls on each rebuild and improving performance. The code has also been made more readable and modern by using switch expressions and inlining helper methods. Overall, these are excellent changes that enhance code quality and maintainability. I have added one suggestion to further improve the user experience by displaying a consistent loading indicator.
LCOV of commit
|
|
No description provided.