Skip to content

Add ListItemField and field initializers#1772

Merged
gemcoder21 merged 2 commits intomainfrom
1732-create-new-model-to-simplify-init-for-fields
Mar 6, 2026
Merged

Add ListItemField and field initializers#1772
gemcoder21 merged 2 commits intomainfrom
1732-create-new-model-to-simplify-init-for-fields

Conversation

@DRadmir
Copy link
Contributor

@DRadmir DRadmir commented Mar 6, 2026

Introduce a new ListItemField type in Components to encapsulate a title and value TextValue. Add convenience initializers ListItemView.init(field:) and GridItemView.init(field:) to accept the new type. Refactor Perpetuals code to use field-based APIs: PerpetualPortfolioScene, PerpetualPortfolioSceneViewModel (unrealizedPnlField, allTimePnlField), CandleTooltipViewModel (openField, closeField, highField, lowField, changeField, volumeField) and CandleTooltipView to use the new fields for cleaner wiring and consistent styling. No functional behavior changes intended.

Close: #1732
Close: #1735

@DRadmir DRadmir self-assigned this Mar 6, 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 standardizes the representation of title-value pairs in UI components by introducing a new ListItemField type. This change simplifies the initialization of ListItemView and GridItemView and streamlines data presentation across various Perpetual features. The refactoring aims to improve code consistency and maintainability without introducing any functional behavior changes.

Highlights

  • New ListItemField Type: Introduced a new ListItemField struct in the Components package to encapsulate a title and value TextValue pair, promoting consistency and reusability for list items.
  • Convenience Initializers: Added new initializers to ListItemView and GridItemView that directly accept the ListItemField type, simplifying their usage.
  • Perpetuals Code Refactoring: Refactored several Perpetual features, including PerpetualPortfolioScene, PerpetualPortfolioSceneViewModel, CandleTooltipViewModel, and CandleTooltipView, to utilize the new ListItemField for displaying data, leading to cleaner wiring and consistent styling.

🧠 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/Perpetuals/Sources/Scenes/PerpetualPortfolioScene.swift
    • Updated ListItemView instances for unrealized and all-time PnL to use the new ListItemField initializer.
  • Features/Perpetuals/Sources/ViewModels/CandleTooltipViewModel.swift
    • Refactored open, close, high, low, change, and volume properties to return ListItemField objects instead of separate title and value TextValues.
  • Features/Perpetuals/Sources/ViewModels/PerpetualPortfolioSceneViewModel.swift
    • Converted unrealizedPnl and allTimePnl properties to return ListItemField objects.
  • Features/Perpetuals/Sources/Views/CandleTooltipView.swift
    • Modified GridItemView instances to use the new ListItemField initializer for displaying candle data.
  • Packages/Components/Sources/Lists/GridItemView.swift
    • Added a new public initializer init(field:valueAlignment:) to accept a ListItemField.
  • Packages/Components/Sources/Lists/ListItemView.swift
    • Added a new public initializer init(field:) to accept a ListItemField.
  • Packages/Components/Sources/Types/ListItemField.swift
    • Introduced a new public struct ListItemField to hold a title and value of type TextValue.
Activity
  • No human activity has been recorded on this pull request yet.
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 pull request successfully introduces the ListItemField abstraction, which streamlines the initialization of ListItemView and GridItemView by encapsulating title and value TextValues. This refactoring improves code clarity and maintainability by reducing boilerplate and promoting a more consistent data structure for list items. The changes are well-contained and align with the stated goal of cleaner wiring and consistent styling.

Introduce a new ListItemField type in Components to encapsulate a title and value TextValue. Add convenience initializers ListItemView.init(field:) and GridItemView.init(field:) to accept the new type. Refactor Perpetuals code to use field-based APIs: PerpetualPortfolioScene, PerpetualPortfolioSceneViewModel (unrealizedPnlField, allTimePnlField), CandleTooltipViewModel (openField, closeField, highField, lowField, changeField, volumeField) and CandleTooltipView to use the new fields for cleaner wiring and consistent styling. No functional behavior changes intended.
@DRadmir DRadmir force-pushed the 1732-create-new-model-to-simplify-init-for-fields branch from fbed86b to ea5db33 Compare March 6, 2026 10:00
@gemcoder21 gemcoder21 merged commit 4653f90 into main Mar 6, 2026
1 check passed
@gemcoder21 gemcoder21 deleted the 1732-create-new-model-to-simplify-init-for-fields branch March 6, 2026 18:53
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.

Consolidate TextValue and List Item view Create new model to simplify init for fields

2 participants