Skip to content

Refactor swap min amount: move action to main button#1704

Merged
DRadmir merged 1 commit intomainfrom
refactor-use-min-amount
Feb 16, 2026
Merged

Refactor swap min amount: move action to main button#1704
DRadmir merged 1 commit intomainfrom
refactor-use-min-amount

Conversation

@DRadmir
Copy link
Contributor

@DRadmir DRadmir commented Feb 16, 2026

  • Add useMinAmount case to SwapButtonAction
  • Main button shows "Use Minimum Amount" and becomes active on InputAmountError
  • Remove separate button from error section
  • Update errorInfoAction to only handle NoQuoteAvailable
Simulator Screenshot - iPhone 17 Pro - 2026-02-17 at 01 07 29

@DRadmir DRadmir self-assigned this Feb 16, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @DRadmir, 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 refactors the user experience for handling minimum amount errors in the swap flow. Instead of a secondary button appearing for 'Use Minimum Amount', this functionality is now integrated directly into the main swap button. This change aims to simplify the UI and provide a more intuitive interaction for users when an input amount error is detected, by making the primary action button contextually relevant.

Highlights

  • Refactored 'Use Minimum Amount' Action: The 'Use Minimum Amount' action has been moved from a separate button in the error section to become a primary action on the main swap button.
  • Enhanced SwapButtonAction Enum: A new useMinAmount case was added to the SwapButtonAction enum, allowing the main button to directly handle the application of a minimum amount.
  • Simplified Error Information Handling: The errorInfoAction in SwapSceneViewModel now exclusively handles NoQuoteAvailable errors, streamlining error presentation logic.
  • Updated Button State Logic: The main swap button's text and state logic were updated to dynamically display 'Use Minimum Amount' and become active when an InputAmountError occurs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • Features/Swap/Sources/Scenes/SwapScene.swift
    • Removed the dedicated 'Use Minimum Amount' button from the error display section.
  • Features/Swap/Sources/ViewModels/SwapButtonViewModel.swift
    • Added useMinAmount(minAmount: String, asset: Asset) case to SwapButtonAction enum.
    • Updated buttonText to display 'Use Minimum Amount' when the useMinAmount action is active.
    • Modified buttonAction to prioritize useMinAmount when an InputAmountError is present.
    • Configured buttonState to be .primary(.normal) for the useMinAmount action.
    • Introduced a private useMinAmount computed property to determine if the minimum amount action should be available based on InputAmountError.
  • Features/Swap/Sources/ViewModels/SwapSceneViewModel.swift
    • Refactored errorInfoAction to only provide an action for NoQuoteAvailable errors, removing InputAmountError handling.
    • Removed the errorInfoActionButtonTitle computed property.
    • Added a new case to perform(action:) to handle useMinAmount by calling applyMinAmount.
  • Features/Swap/Tests/SwapTests/SwapSceneViewModelTests.swift
    • Added a test case to verify that buttonViewModel.buttonAction correctly becomes SwapButtonAction.useMinAmount when an InputAmountError occurs.
    • Updated an existing test to trigger the button action via model.buttonViewModel.action() instead of model.errorInfoAction?().
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The refactoring successfully moves the "Use Minimum Amount" action to the main button, which centralizes the primary user action and simplifies the error section. The logic for identifying the minimum amount error and applying it is correctly implemented. However, the priority of this action relative to the balance validation could be improved to ensure a better user experience when multiple issues exist.

}

var buttonAction: SwapButtonAction {
if let useMinAmount { return useMinAmount }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The useMinAmount action currently takes precedence over the balance validation. If a user enters an amount that is both below the swapper's minimum and above their available balance, the button will suggest using the minimum amount. It is generally better to prioritize the insufficientBalance error, as the user cannot proceed with the swap regardless of the swapper's minimum amount if they lack the funds. Consider moving this check after the isAmountValid check.

  - Add useMinAmount case to SwapButtonAction
  - Main button shows "Use Minimum Amount" and becomes active on InputAmountError
  - Remove separate button from error section
  - Update errorInfoAction to only handle NoQuoteAvailable
@DRadmir DRadmir force-pushed the refactor-use-min-amount branch from 57925ba to aa8db7c Compare February 16, 2026 20:21
@DRadmir DRadmir merged commit 691889b into main Feb 16, 2026
1 check passed
@DRadmir DRadmir deleted the refactor-use-min-amount branch February 16, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants