Skip to content

Add explorer context actions#1826

Merged
DRadmir merged 7 commits intomainfrom
1809-copy-view-on-explorer-for-addresses
Mar 25, 2026
Merged

Add explorer context actions#1826
DRadmir merged 7 commits intomainfrom
1809-copy-view-on-explorer-for-addresses

Conversation

@DRadmir
Copy link
Contributor

@DRadmir DRadmir commented Mar 24, 2026

Add shared explorer context actions for copy and view in explorer across iOS screens, including NFT token support.

Close: #1809

@DRadmir DRadmir self-assigned this Mar 24, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 introduces a standardized and reusable approach for handling context-sensitive actions related to blockchain explorers within the application. By abstracting the logic for copying values and opening explorer links into dedicated data structures and a SwiftUI view modifier, the changes streamline development, enhance consistency across different screens (including market insights, NFT details, validator selection, and transfer confirmations), and improve the overall user experience when interacting with blockchain-related data.

Highlights

  • Unified Explorer Context Actions: Introduced a shared mechanism for handling 'copy' and 'view in explorer' actions across various iOS screens, centralizing the logic for presenting context menus and Safari sheets.
  • New Data Structures for Context: Added CopyValue enum to represent different types of values that can be copied (plain string, address with chain) and ExplorerContextData struct to encapsulate both the copyable value and the associated explorer link.
  • SwiftUI View Modifier for Explorer Actions: Created a View+ExplorerContext extension with an ExplorerContextModifier to simplify the integration of explorer context menus and Safari sheet presentations directly into SwiftUI views.
  • NFT Token Explorer Support: Extended ExplorerService to include functionality for generating NFT token explorer URLs and integrated this into the CollectibleScene for contract and token ID details.
  • Refactored ViewModels and Scenes: Updated MarketValueViewModel, CollectibleViewModel, ValidatorSelectSceneViewModel, ConfirmTransferSceneViewModel, and TransactionViewModel to leverage the new ExplorerContextData and View+ExplorerContext modifier, reducing boilerplate and improving consistency.
  • Streamlined URL Presentation: Removed individual isPresentingUrl state variables and related logic from several ViewModels and Scenes, as the new explorerContext modifier now manages the presentation of external URLs.

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

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.

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 introduces a standardized way to handle explorer links and copyable values across the application by introducing ExplorerContextData and CopyValue types. This refactoring impacts MarketValueViewModel, CollectibleViewModel, ValidatorSelectSceneViewModel, and ConfirmTransferSceneViewModel, centralizing the logic for displaying and interacting with blockchain explorer links and copy actions. Specifically, ChartScene was updated to use a new Action enum for market items, and CollectibleScene now uses CollectibleInfoRow and explorerContext for NFT details. The ExplorerService was extended with an nftUrl function. Feedback includes a suggestion to use the marketItemView helper in ChartScene for consistency and to enhance the ExplorerContextModifier to support custom onCopy handlers for a more consistent user experience.

switch item.action {
case .explorer(let explorerContext):
SafariNavigationLink(url: explorerContext.explorerLink.url) {
ListItemView(title: item.title, subtitle: item.subtitle)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and to ensure all relevant view model properties are displayed, it's better to use the marketItemView helper function here, similar to the .info and .none cases. This will ensure that properties like titleTag, titleExtra, etc., are rendered if they exist on the item.

Suggested change
ListItemView(title: item.title, subtitle: item.subtitle)
marketItemView(item)

let explorerLink = context.explorerLink
content
.contextMenu([
.copy(value: copyValue.rawValue),
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 current implementation for .copy uses the default behavior, which may show a generic toast message. Other parts of the app provide a custom onCopy handler to show a more specific toast (e.g., showing the value that was copied).

To ensure a consistent user experience, consider adding support for a custom onCopy handler to this modifier. This would involve passing an optional closure to the modifier and using it in the .copy context menu item.

You could update the modifier and extension like this:

public struct ExplorerContextModifier: ViewModifier {
    @State private var isPresentingUrl: URL?

    let context: ExplorerContextData
    let onCopy: ((String) -> Void)?

    public func body(content: Content) -> some View {
        // ...
        .contextMenu([
            .copy(value: copyValue.rawValue, onCopy: onCopy),
            // ...
        ])
    }
}

public extension View {
    func explorerContext(_ context: ExplorerContextData, onCopy: ((String) -> Void)? = nil) -> some View {
        modifier(ExplorerContextModifier(context: context, onCopy: onCopy))
    }
}

DRadmir added 2 commits March 25, 2026 23:08
…-view-on-explorer-for-addresses

# Conflicts:
#	Features/NFT/Sources/ViewModels/CollectibleViewModel.swift
#	core
@DRadmir DRadmir merged commit c014a17 into main Mar 25, 2026
1 of 2 checks passed
@DRadmir DRadmir deleted the 1809-copy-view-on-explorer-for-addresses branch March 25, 2026 18:42
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.

Unified address component with Copy + View on Explorer across all screens

2 participants