Skip to content

Add Opacity constants and consolidate hardcoded opacity values#1743

Merged
DRadmir merged 1 commit intomainfrom
refactor/consolidate-opacity
Feb 26, 2026
Merged

Add Opacity constants and consolidate hardcoded opacity values#1743
DRadmir merged 1 commit intomainfrom
refactor/consolidate-opacity

Conversation

@DRadmir
Copy link
Contributor

@DRadmir DRadmir commented Feb 26, 2026

close: #1733

@DRadmir DRadmir self-assigned this Feb 26, 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 significantly refactors the application's UI styling by centralizing opacity definitions. It introduces a dedicated Opacity constant file, replacing scattered hardcoded numerical values with named constants. This change aims to improve the consistency, readability, and maintainability of the UI, making it easier to manage visual styles across the application.

Highlights

  • Standardized Opacity Values: Introduced a new Opacity.swift file to define a comprehensive set of static opacity constants, including both numerical and semantic aliases (e.g., .light, .strong).
  • Refactored Hardcoded Opacities: Replaced numerous hardcoded Double values for opacity across various UI components and views with the newly defined Opacity constants, enhancing consistency and maintainability.
  • Improved Readability and Consistency: The change standardizes how opacity is applied throughout the application, making the codebase easier to read, understand, and modify for future UI adjustments.
  • Property Renaming for Clarity: Renamed the opacity property to viewOpacity within the TagItemViewable protocol and its extension to prevent potential naming conflicts and improve semantic clarity.

🧠 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/InAppNotifications/Sources/ViewModels/InAppNotificationListItemViewModel.swift
    • Updated background opacity for title tags to use .light constant.
  • Features/Onboarding/Sources/ViewModels/TermItemViewModel.swift
    • Updated text style opacity for unconfirmed terms to use .strong constant.
  • Features/Perpetuals/Sources/Types/ChartGridStyle.swift
    • Removed redundant opacity static property.
    • Updated grid color opacity to use .opacity13 constant.
  • Features/Perpetuals/Sources/Views/CandleTooltipView.swift
    • Updated overlay stroke opacity to use .opacity8 constant.
    • Updated shadow color opacity to use .opacity12 constant.
  • Features/Perpetuals/Sources/Views/CandlestickChartView.swift
    • Updated foreground style opacity for rule marks to use .semiStrong constant.
  • Features/Settings/Sources/ChainSettings/ViewModels/LatencyViewModel.swift
    • Updated background color opacity to use .light constant.
  • Features/Settings/Sources/ChainSettings/ViewModels/NodeStatusStateViewModel.swift
    • Updated background color opacities for error and zero latest block number states to use .light constant.
  • Features/Transfer/Sources/Scenes/ReceiveScene.swift
    • Updated shadow color opacity for the QR code background to use .opacity25 constant.
  • Packages/Components/Sources/Buttons/RoundButton.swift
    • Updated button opacity when disabled to use .medium constant.
  • Packages/Components/Sources/NftImageView.swift
    • Updated foreground style opacity for NFT type text to use .strong constant.
  • Packages/Components/Sources/SelectionView.swift
    • Updated background opacity for unselected items to use .extraLight constant.
    • Updated background opacity for selected items to use .opacity20 constant.
  • Packages/Components/Sources/TagsView.swift
    • Updated foreground style opacity to use tag.viewOpacity instead of tag.opacity.
    • Updated background fill opacity to use tag.viewOpacity instead of tag.opacity.
  • Packages/Components/Sources/TextFields/FloatTextField.swift
    • Updated background color opacity for the text field preview to use .extraLight constant.
  • Packages/Components/Sources/Types/TagItemViewable.swift
    • Renamed opacity property to viewOpacity in the protocol and its extension.
  • Packages/PrimitivesComponents/Sources/ViewModels/TransactionStateViewModel.swift
    • Updated background color opacities for confirmed, pending/in-transit, and failed/reverted states to use .light constant.
  • Packages/PrimitivesComponents/Sources/Views/ChartView.swift
    • Updated rule mark foreground style opacity to use .medium constant.
    • Updated radial gradient colors for selected point to use .strong constant.
    • Updated shadow color for selected point to use .semiStrong constant.
    • Updated area gradient stops to use .opacity45, .opacity38, .opacity28, .light, and .faint constants.
  • Packages/PrimitivesComponents/Sources/Views/PulsingDotView.swift
    • Updated shadow color opacities for the pulsing dot to use .strong and .semiMedium constants.
    • Updated stroke color opacity for the pulse ring to use .semiMedium constant.
  • Packages/Style/Sources/Button/StateButtonStyle.swift
    • Updated foreground color opacity for loading state to use .semi constant.
  • Packages/Style/Sources/Opacity.swift
    • Added new file defining Opacity typealias and static constants for various opacity levels.
    • Included semantic aliases for common opacity values (e.g., faint, light, medium, strong).
  • Packages/Style/Sources/Spacing.swift
    • Removed the opacity static property from Sizing.shadow.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for 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

This pull request does an excellent job of introducing a centralized set of opacity constants in Opacity.swift and replacing hardcoded values throughout the codebase. This significantly improves maintainability and consistency. The new constants are well-structured with both numeric and semantic aliases. The refactoring of TagItemViewable.opacity to viewOpacity is also a good improvement to avoid naming collisions. I have one minor suggestion to fully complete the replacement of hardcoded opacity values.


public extension TagItemViewable {
var opacity: CGFloat { isSelected ? 1.0 : 0.5 }
var viewOpacity: CGFloat { isSelected ? 1.0 : 0.5 }
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To fully align with the goal of this PR, the hardcoded opacity value 0.5 should be replaced with the new semantic constant .medium. This will improve consistency, as a similar change was made in RoundButton.swift.

Suggested change
var viewOpacity: CGFloat { isSelected ? 1.0 : 0.5 }
var viewOpacity: CGFloat { isSelected ? 1.0 : .medium }

@DRadmir DRadmir force-pushed the refactor/consolidate-opacity branch from 3173f7f to f6b1530 Compare February 26, 2026 12:22
@DRadmir DRadmir merged commit eb915e3 into main Feb 26, 2026
1 check passed
@DRadmir DRadmir deleted the refactor/consolidate-opacity branch February 26, 2026 15:29
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.

Review and consolidate .opacity()

2 participants