Skip to content

Conversation

gemdev111
Copy link
Contributor

Introduced WalletSceneSheetType to unify and simplify sheet presentation state management in WalletSceneViewModel. Updated WalletNavigationStack to use the new enum for presenting sheets, reducing multiple state variables to a single source of truth and improving code maintainability.

closes #973

Introduced WalletSceneSheetType to unify and simplify sheet presentation state management in WalletSceneViewModel.
Updated WalletNavigationStack to use the new enum for presenting sheets, reducing multiple state variables to a single source of truth and improving code maintainability.
@gemdev111 gemdev111 self-assigned this Jul 28, 2025
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.

Summary of Changes

Hello @gemdev111, 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 significantly refactors the sheet presentation logic within the Wallet scene. By introducing a new WalletSceneSheetType enum, the change unifies how different types of sheets are managed and presented, moving from multiple independent state variables to a single, consolidated source of truth. This architectural improvement aims to simplify the codebase, enhance maintainability, and streamline the UI presentation logic for various wallet-related interactions.

Highlights

  • Unified Sheet Presentation: Introduced a new WalletSceneSheetType enum to centralize and simplify the management of various sheet presentations within the Wallet scene, replacing multiple disparate state variables with a single, unified type.
  • Code Simplification: Consolidated multiple boolean and optional state variables (e.g., isPresentingWallets, isPresentingSelectAssetType, isPresentingInfoSheet, isPresentingUrl, isPresentingTransferData, isPresentingPerpetualRecipientData) in WalletSceneViewModel into a single isPresentingSheet: WalletSceneSheetType? property.
  • UI Logic Streamlining: Refactored WalletNavigationStack to use a single .sheet modifier that leverages a switch statement over the WalletSceneSheetType enum, reducing redundant sheet modifiers and improving the clarity of UI presentation logic.
  • Enhanced Maintainability: Provided Binding extensions for Binding<WalletSceneSheetType?> to allow seamless two-way binding with specific sheet data types, ensuring compatibility with existing UI components and improving overall code maintainability.
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 or fill out our survey to provide feedback.

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

This pull request effectively refactors the sheet presentation logic in WalletSceneViewModel by consolidating multiple state variables into a single WalletSceneSheetType enum. This greatly improves maintainability and clarity.

My review has identified a critical compilation issue related to generating an ID for TransferData, as well as some opportunities to improve the robustness of other sheet IDs and the cross-module visibility of helper properties. I've also suggested using a more type-safe binding helper for presenting the wallets sheet.

case let .selectAssetType(type): "select-asset-type-\(type.id)"
case let .info(type): "info-\(type.id)"
case let .url(url): "url-\(url)"
case let .transferData(data): "transfer-data-\(data.id)"
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The id for the .transferData case is constructed using data.id, but the TransferData type does not have an id property and does not conform to Identifiable. This will result in a compilation error.

Since TransferData conforms to Hashable, you can use data.hashValue to generate a unique identifier. This avoids having to modify the TransferData struct if that's outside the scope of this PR.

Suggested change
case let .transferData(data): "transfer-data-\(data.id)"
case let .transferData(data): "transfer-data-\(data.hashValue)"

case let .info(type): "info-\(type.id)"
case let .url(url): "url-\(url)"
case let .transferData(data): "transfer-data-\(data.id)"
case let .perpetualRecipientData(data): "perpetual-recipient-data-\(data.asset.id.identifier)"
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current id for .perpetualRecipientData only uses the asset's identifier. This may not be unique if sheets for different recipients can be presented for the same asset. The Identifiable conformance on PerpetualRecipientData itself also doesn't include the asset, so data.id would also be insufficient if the asset is a distinguishing factor.

To ensure a unique ID for all properties of data, it's safest to use its hash value, as PerpetualRecipientData is Hashable. This guarantees a unique ID for each distinct PerpetualRecipientData value and makes it consistent with the proposed fix for .transferData.

Suggested change
case let .perpetualRecipientData(data): "perpetual-recipient-data-\(data.asset.id.identifier)"
case let .perpetualRecipientData(data): "perpetual-recipient-data-\(data.hashValue)"

)
}

var wallets: Binding<Bool> {
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 wallets computed property provides a convenient and type-safe Binding<Bool> for the .wallets sheet case. However, it's declared with internal access. To be used from WalletNavigationStack, which appears to be in a different module (Gem), this property needs to be made public.

Suggested change
var wallets: Binding<Bool> {
public var wallets: Binding<Bool> {

case let .url(url):
SFSafariView(url: url)
case .wallets:
WalletsNavigationStack(isPresentingWallets: $model.isPresentingSheet.mappedToBool())
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This code uses a mappedToBool() function which is not defined in the pull request and is likely a generic conversion. It's safer and clearer to use the dedicated wallets binding property you've defined on the Binding<WalletSceneSheetType?> extension. It's specifically designed for this case and provides better type safety.

This change depends on the wallets property being made public, which I've commented on separately.

Suggested change
WalletsNavigationStack(isPresentingWallets: $model.isPresentingSheet.mappedToBool())
WalletsNavigationStack(isPresentingWallets: $model.isPresentingSheet.wallets)

Updated WalletSceneSheetType to use data.id for perpetualRecipientData and made the wallets binding public. Adjusted WalletNavigationStack to use the new wallets binding for presenting WalletsNavigationStack.
@gemdev111 gemdev111 requested a review from gemcoder21 July 28, 2025 15:14
Added a new case for setPriceAlert in WalletSceneSheetType and updated related bindings. Refactored WalletSceneViewModel and WalletNavigationStack to use the unified sheet presentation for price alerts, removing the separate isPresentingSetPriceAlert property and sheet. This streamlines sheet management and improves code maintainability.
@gemdev111 gemdev111 closed this Oct 14, 2025
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.

WalletSceneViewModel updates

1 participant