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

Refactoring and update #36

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Refactoring and update #36

wants to merge 24 commits into from

Conversation

FrenkyDema
Copy link
Owner

@FrenkyDema FrenkyDema commented Sep 25, 2024

Refactor and Bug Fixes for Widgets:

Increment/Decrement,
Expandable List,
Custom Action Button,
and List Tile Buttons

Summary

This PR includes refactoring, improvements, and bug fixes for the following files:

  • increment_decrement_widget.dart
  • expandable_list_tile_button.dart
  • custom_action_button.dart
  • list_tile_button.dart

These changes address functional improvements, fix issues related to widget behavior, enhance UI consistency, and ensure better state management across the application.

Changes:

  • increment_decrement_widget.dart:

    • Refactored logic for increment and decrement actions.
    • Improved state management to prevent unnecessary rebuilds.
    • Optimized performance by minimizing widget rebuilds when the quantity changes.
    • Enhanced input validation to handle edge cases gracefully.
  • expandable_list_tile_button.dart:

    • Enhanced the UI for smoother expand/collapse animations.
    • Fixed issues where the button would not expand or collapse under certain conditions.
    • Improved state transitions for better performance and user experience.
    • Refactored code for better readability and maintenance.
  • custom_action_button.dart:

    • Fixed initialization issues with CustomActionButton, especially concerning the ScrollController in a DraggableScrollableSheet.
    • Improved button state management to ensure correct enable/disable behavior.
    • Added support for customizable shapes, padding, and other styling options.
    • Enhanced accessibility by ensuring proper focus and semantics.
  • list_tile_button.dart:

    • Alignment Fixes:
      • Resolved vertical alignment issues in ListTileButton and IconListTileButton.
      • Ensured icons are vertically centered within the buttons.
      • Adjusted leading and trailing widgets for consistent alignment.
    • Interaction Improvements:
      • Moved padding under the InkWell widget to ensure the entire button area is clickable, including padding.
      • Ensured that tap events cover the full button, enhancing user experience.
    • Customization Enhancements:
      • Reintroduced and improved the sizeFactor parameter in IconListTileButton to allow dynamic resizing of icons relative to text.
      • Allowed developers to customize icon sizes easily without affecting alignment.
    • Code Refactoring:
      • Simplified the widget tree to let ListTile manage its own layout for better consistency and alignment.
      • Refactored RoundedContainer to remove unnecessary padding and margins, ensuring compatibility with Material and InkWell.
      • Improved code readability and maintainability by removing redundant code and simplifying widget structures.

Testing:

  • General Testing:

    • Added and updated test cases to cover various functionalities and edge cases.
    • Ensured that all widgets behave correctly with different inputs and states.
  • increment_decrement_widget.dart Tests:

    • Tested increment/decrement functionality with various input values, including boundary conditions.
    • Verified that the widget handles maximum and minimum quantity limits correctly.
  • expandable_list_tile_button.dart Tests:

    • Ensured that the expandable button expands and collapses smoothly.
    • Tested state transitions and verified that the content displays correctly upon expansion.
  • custom_action_button.dart Tests:

    • Verified that custom action buttons initialize correctly with various configurations.
    • Tested button interactions, ensuring that onPressed and onLongPress callbacks function as expected.
  • list_tile_button.dart Tests:

    • Rendering and Interaction:
      • Verified that ListTileButton renders correctly with all combinations of leading, title, subtitle, and trailing widgets.
      • Confirmed that buttons respond to tap events and trigger the appropriate callbacks.
    • Icon Alignment:
      • Tested IconListTileButton with different sizeFactor values to ensure icons resize properly and remain vertically centered.
      • Verified that the icon size adjusts according to the sizeFactor without affecting alignment.
    • Clickable Area:
      • Confirmed that the entire button area, including padding, is clickable.
      • Ensured that moving the padding under InkWell does not affect the visual appearance but improves interaction.

Fixes:

Files Updated:

  • increment_decrement_widget.dart
  • expandable_list_tile_button.dart
  • custom_action_button.dart
  • list_tile_button.dart
  • list_tile_button_test.dart (Updated tests for ListTileButton and related widgets)

@FrenkyDema FrenkyDema linked an issue Sep 25, 2024 that may be closed by this pull request
@github-actions github-actions bot added the lib label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment