Skip to content

Refactor: Added UACTextButton to Replace TextButton #814

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gaurav-Kushwaha-1225
Copy link
Contributor

Description

Resolves code duplication across the codebase by the repeated use of the TextButton widget with similar UI and structure.

Introduced a custom reusable widget, UACTextButton, for resolving this issue.

Where applicable, all instances of TextButton have been replaced with UACTextButton. This custom widget supports two design variants—primary and secondary—using the isButtonPrimary and isTextPrimary flags to distinguish between positive and negative actions.

Additionally, on the AddOrUpdateAlarm page, I extracted the saveOrUpdateButton into its own widget, as its onPressed logic was extensive.

Proposed Changes

  • Introduced a new reusable widget: UACTextButton
  • Replaced multiple TextButton instances with UACTextButton
  • Added support for primary and secondary button styles using flags
  • Extracted the saveOrUpdateButton from the AddOrUpdateAlarm page into a separate widget

Example:

  1. This code will be for Cancel type buttons. (Green colored ones)
    UACTextButton(
      isButtonPrimary: false,
      isTextPrimary: true,
      text: 'Cancel'.tr,
      onPressed: () {},
    )
  2. This code will be for Save/Ok type buttons. (Grey colored ones)
    UACTextButton(
      isButtonPrimary: true,
      isTextPrimary: false,
      text: 'Save'.tr,
      onPressed: () {},
    )

Fixes #654

Screenshots

photo_2025-04-12_15-24-16 photo_2025-04-12_15-24-15 photo_2025-04-12_15-24-14 (2) photo_2025-04-12_15-24-14
photo_2025-04-12_15-24-13 photo_2025-04-12_15-24-12 photo_2025-04-12_15-24-11 photo_2025-04-12_15-24-10 (2)
photo_2025-04-12_15-24-10 photo_2025-04-12_15-24-08

Checklist

  • Tests have been added or updated to cover the changes
  • Documentation has been updated to reflect the changes
  • Code follows the established coding style guidelines
  • All tests are passing

@Gaurav-Kushwaha-1225
Copy link
Contributor Author

I made sure not to separate the business logic from the UI code, as per the feedback in #670 (review) and #654 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant