Toggle address display on tap in list item#1771
Conversation
Allow tapping an address list item to toggle showing the (short) address. Adds a showAddress @State and uses it to switch the ListItemImageView subtitle between model.subtitle and model.addressSubtitle. Adds canToggleAddress and addressSubtitle computed properties to the view model to control toggling (only when the account has a name different from the address). Preserves existing context menu and safari sheet behavior; also simplifies the view init formatting.
Summary of ChangesHello, 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 enhances the user experience by allowing users to quickly switch between an account's name and its short address directly within the list item view. This provides more immediate access to address details without navigating away or using context menus, while intelligently restricting the feature to relevant accounts. The change is implemented by introducing state management within the view and extending the view model with properties to control the display logic. Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a feature to toggle address display on tap, which is a good user experience improvement. The implementation is clean, using a new state variable in the view and computed properties in the view model. However, I've identified a potential edge case in the logic for canToggleAddress where an empty string for an account name is not handled, which could lead to unexpected UI behavior. My review includes a suggestion to make this logic more robust.
| public var canToggleAddress: Bool { | ||
| account.name != nil && account.name != account.address | ||
| } |
There was a problem hiding this comment.
The current logic for canToggleAddress doesn't account for account.name being an empty string. If account.name is "", canToggleAddress will evaluate to true, which is likely not the desired behavior as it could allow toggling from an empty subtitle. An empty name should be treated as if there is no name. It's better to explicitly check for a non-empty name to prevent this.
public var canToggleAddress: Bool {
guard let name = account.name, !name.isEmpty else {
return false
}
return name != account.address
}| .url(title: model.addressExplorerText, onOpen: { isPresentingUrl = model.addressExplorerUrl }) | ||
| ] | ||
| ) | ||
| .contentShape(Rectangle()) |
There was a problem hiding this comment.
lets make a custom modiier content shape + ontap? So we can reuse later
Introduce TappableModifier with a View.onTap(_:) extension (uses contentShape + onTapGesture) and replace direct .contentShape/.onTapGesture usage in AddressListItemView with .onTap. Also tighten AddressListItemViewModel.canToggleAddress to treat empty names as non-toggleable and only allow toggling when a non-empty name differs from the address.
Allow tapping an address list item to toggle showing the (short) address. Adds a showAddress @State and uses it to switch the ListItemImageView subtitle between model.subtitle and model.addressSubtitle. Adds canToggleAddress and addressSubtitle computed properties to the view model to control toggling (only when the account has a name different from the address). Preserves existing context menu and safari sheet behavior; also simplifies the view init formatting.
contact


plain address
